]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Removed last known SSD overlaps with provisional fix for flex cables. (E. Cattaruzza)
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoTube.h"
33 #include "TGeoBBox.h"
34 #include "TGeoXtru.h"
35 #include "TGeoTorus.h"
36 #include "TGeoPgon.h"
37 #include "TGeoPcon.h"
38 #include "TRotation.h"
39 #include "AliITSv11GeometrySSD.h"
40 /////////////////////////////////////////////////////////////////////////////////
41 // Names of the Sensitive Volumes of Layer 5 and Layer 6
42 /////////////////////////////////////////////////////////////////////////////////
43 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
45 /////////////////////////////////////////////////////////////////////////////////
46 //Parameters for SSD Geometry
47 /////////////////////////////////////////////////////////////////////////////////
48 // Variable for Vertical Disalignement of Modules
49 /////////////////////////////////////////////////////////////////////////////////
50 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
51 //const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 1.*fgkmm;
52 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment2 = 0.2*fgkmm;
54 /////////////////////////////////////////////////////////////////////////////////
55 // Layer5 (lengths are in mm and angles in degrees)
56 /////////////////////////////////////////////////////////////////////////////////
57 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
58 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
59 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
61 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
62 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
63 /////////////////////////////////////////////////////////////////////////////////
64 // Layer6 (lengths are in mm and angles in degrees)
65 /////////////////////////////////////////////////////////////////////////////////
66 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
67 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
68 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
70 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
71 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
72 /////////////////////////////////////////////////////////////////////////////////
73 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
74 /////////////////////////////////////////////////////////////////////////////////
75 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
76 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
77 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
78 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
83 /////////////////////////////////////////////////////////////////////////////////
84 // Stiffener (lengths are in mm and angles in degrees)
85 /////////////////////////////////////////////////////////////////////////////////
86 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
87 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
88 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
92 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
97 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
100                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
101 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
105                                                                                                           0.25*fgkSSDStiffenerHeight;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
108 /////////////////////////////////////////////////////////////////////////////////
109 // Cooling Block (lengths are in mm and angles in degrees)
110 /////////////////////////////////////////////////////////////////////////////////
111 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
112 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
113 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
114                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
116                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
117 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
118                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
119 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
120                                                                                                                                          1.500*fgkmm;
121 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
122                                                                                                                                          0.300*fgkmm;
123 /////////////////////////////////////////////////////////////////////////////////
124 // SSD Sensor (lengths are in mm and angles in degrees)
125 /////////////////////////////////////////////////////////////////////////////////
126 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
127                                                                                                                  "SSDSensorSensitiveVol";
128 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
129 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
130 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
132                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
135 /////////////////////////////////////////////////////////////////////////////////
136 // Flex (lengths are in mm and angles in degrees)
137 /////////////////////////////////////////////////////////////////////////////////
138 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
139 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
140                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
141                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
142                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
143                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
144                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
145 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
146                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
147 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
148                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
149 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
151 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
152 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
153                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
154 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
155                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
156 /////////////////////////////////////////////////////////////////////////////////
157 // SSD Ladder Cable (lengths are in mm and angles in degrees)
158 /////////////////////////////////////////////////////////////////////////////////
159 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
160 /////////////////////////////////////////////////////////////////////////////////
161 // SSD Module (lengths are in mm and angles in degrees)
162 /////////////////////////////////////////////////////////////////////////////////
163 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
164                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
165 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
166                                                                                                                                         45.600*fgkmm;
167 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
168                                                                                                                                          5.075*fgkmm;
169 /////////////////////////////////////////////////////////////////////////////////
170 // Sensor Support (lengths are in mm and angles in degrees)
171 /////////////////////////////////////////////////////////////////////////////////
172 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
173                                                                                                                                          5.800*fgkmm;
174 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
175                                                                                                                                          2.000*fgkmm;
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
177                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment2, 
178                                                                                                            5.180*fgkmm-fgkSSDModuleVerticalDisalignment2};
179 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
180 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
181 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
182                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
183 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
184                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
185                                                             +  fgkSSDSensorSideSupportThickness[0])
186                                                                 -  fgkSSDSensorSideSupportLength;
187 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
188                                                                                                                                     5.250*fgkmm;
189 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
190                                                                                                                                         1.680*fgkmm;
191 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
192                                                                   = {fgkSSDSensorSideSupportHeight[0]
193                                                                   +  fgkSSDSensorSideSupportThickness[0],
194                                                                          fgkSSDSensorSideSupportHeight[1]
195                                                                   +  fgkSSDSensorSideSupportThickness[1]};
196 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
197                                                                   =  {fgkSSDSensorSideSupportThickness[0],
198                                                                           fgkSSDSensorSideSupportThickness[1]};
199 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
200                                                                                                                                    19.000*fgkmm;
201 /////////////////////////////////////////////////////////////////////////////////
202 // Chip Cables (lengths are in mm and angles in degrees)
203 /////////////////////////////////////////////////////////////////////////////////
204 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
205                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
206 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
207                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
208                                                                   -  (fgkSSDSensorSideSupportHeight[1]
209                                                                   -   fgkSSDSensorSideSupportHeight[0])
210                                                                   -   fgkSSDModuleVerticalDisalignment2 
211                                                                   -   fgkSSDCoolingBlockHoleCenter
212                                                                   -   fgkSSDStiffenerHeight
213                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
214                                                                           fgkSSDModuleCoolingBlockToSensor
215                                                                   -   fgkSSDModuleVerticalDisalignment2 
216                                                                   -   fgkSSDCoolingBlockHoleCenter
217                                                                   -       fgkSSDStiffenerHeight
218                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
219 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
220                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
221 /////////////////////////////////////////////////////////////////////////////////
222 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
223 /////////////////////////////////////////////////////////////////////////////////
224 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
225                                                                                                                                         3.820*fgkmm;
226 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
227 //                                                                                                                                         3.780;
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
229                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
230 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
231                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
232 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
233                                                                                                                                 { 30.00, 90.00};
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
235                                                                                                                                          1.78*fgkmm;
236 /////////////////////////////////////////////////////////////////////////////////
237 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
238 /////////////////////////////////////////////////////////////////////////////////
239 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
240                                                                    = fgkSSDModuleSensorSupportDistance
241                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
242 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
244                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
246                                                                                                                                         1.630*fgkmm;
247 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
249                                                                         = fgkCarbonFiberTriangleLength
250                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
251                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
252                                                                         * TMath::DegToRad());
253 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
254                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
255                                                                         - fgkCarbonFiberSupportWidth)
256                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
257                                                                         - fgkCarbonFiberSupportWidth;
258 /////////////////////////////////////////////////////////////////////////////////
259 // Carbon Fiber Lower Support Parameters (lengths are in mm)
260 /////////////////////////////////////////////////////////////////////////////////
261 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
262                                                                                                                                           =  0.950*fgkmm;
263 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
264                                                                                                                                           =  1.600*fgkmm;
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
266                                                                                                                                           =  0.830*fgkmm;
267 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
268                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
269 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
270                                                                         = fgkCarbonFiberJunctionWidth
271                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
272                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
273 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
274                                                                         = {fgkCarbonFiberLowerSupportWidth
275                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
276                                                                            fgkCarbonFiberLowerSupportWidth
277                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
278                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
279 /////////////////////////////////////////////////////////////////////////////////
280 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
281 /////////////////////////////////////////////////////////////////////////////////
282 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
283                                                            {0.5 * (fgkSSDLay5LadderLength
284                                                                         -  fgkSSDLay5SensorsNumber
285                                                                         *  fgkCarbonFiberJunctionWidth
286                                                                         -  fgkCarbonFiberLowerSupportWidth),
287                                                                 0.5 * (fgkSSDLay5LadderLength
288                                                                         -  fgkSSDLay5SensorsNumber
289                                                                         *  fgkCarbonFiberJunctionWidth
290                                                                         +  fgkCarbonFiberLowerSupportWidth)};
291 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
292                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
293                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
294 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
295                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
296                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
297 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
298                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
299 /////////////////////////////////////////////////////////////////////////////////
300 // Cooling Tube Support (lengths are in mm and angles in degrees)
301 /////////////////////////////////////////////////////////////////////////////////
302 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
303 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
304                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
305 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
309                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
311                                                                                                                                           11.70*fgkmm;
312 /////////////////////////////////////////////////////////////////////////////////
313 // Cooling Tube (lengths are in mm and angles in degrees)
314 /////////////////////////////////////////////////////////////////////////////////
315 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
316 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
317 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
318                                                                                                         fgkCarbonFiberJunctionWidth;
319 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
320                                                                          fgkSSDModuleSensorSupportDistance
321                                                                   +      fgkSSDCoolingBlockLength;
322 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
323 /////////////////////////////////////////////////////////////////////////////////
324 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
325 /////////////////////////////////////////////////////////////////////////////////
326 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
327                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
328 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
329                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
331                                                                                                                                           20.0*fgkmm;
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
333                                                                                                                                                     40.0;
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
335                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
337                                                                                                                                           2.5*fgkmm;
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
339                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
341                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
342 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
343                                                                                                                                           1.0*fgkmm;
344 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
345                                                                                                                                           6.0*fgkmm;
346 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
347                                                                                                                                           4.0*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
349                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
350 /////////////////////////////////////////////////////////////////////////////////
351 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
352 /////////////////////////////////////////////////////////////////////////////////
353 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
356 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
358 /////////////////////////////////////////////////////////////////////////////////
359 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
360 /////////////////////////////////////////////////////////////////////////////////
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
363 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
364                                                                                                   -  fgkSSDMountingBlockHeight[1]
365                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
366                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
367                                                                                                   +  fgkSSDModuleVerticalDisalignment
368                                                                                                   -      fgkMountingBlockSupportDownHeight,
369                                                                                                          fgkSSDLay6RadiusMin
370                                                                                                   -  fgkSSDMountingBlockHeight[1]
371                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
372                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
373                                                                                                   +  fgkSSDModuleVerticalDisalignment
374                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
375 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
376                                                                                                     -  fgkSSDMountingBlockHeight[1]
377                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
378                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
379                                                                                                         +  fgkSSDModuleVerticalDisalignment
380                                                                                                         -  fgkMountingBlockSupportRadius[0],
381                                                                                                            fgkSSDLay6RadiusMax
382                                                                                                     -  fgkSSDMountingBlockHeight[1]
383                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
384                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
385                                                                                                         +  fgkSSDModuleVerticalDisalignment
386                                                                                                         -  fgkMountingBlockSupportRadius[1]};
387 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
390 /////////////////////////////////////////////////////////////////////////////////
391 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
392 /////////////////////////////////////////////////////////////////////////////////
393 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
397                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
399                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
401                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
408 /////////////////////////////////////////////////////////////////////////////////
409 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
410 /////////////////////////////////////////////////////////////////////////////////
411 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
414 /////////////////////////////////////////////////////////////////////////////////
415 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
416 /////////////////////////////////////////////////////////////////////////////////
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
418                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
419 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
422                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
423 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
424                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
425 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
426 /////////////////////////////////////////////////////////////////////////////////
427 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
428 /////////////////////////////////////////////////////////////////////////////////
429 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
430                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
432                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
433                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
434 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
435 /////////////////////////////////////////////////////////////////////////////////
436 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
437 /////////////////////////////////////////////////////////////////////////////////
438 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
439                                                                                                            {62.0*fgkmm,21.87*fgkmm};
440 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
441                                                                                                             {47.0*fgkmm,0.35*fgkmm};
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
443                                                                                                                                           1.0*fgkmm;
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
446                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
448                                                                                                                                          0.15*fgkmm;
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
450                                                                                                                                          19.0*fgkmm;
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
452                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
454                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
456                                                                                                                                           2.1*fgkmm;
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
458                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
459 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
460                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
462                                                                                                                                            19*fgkmm; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
464                                                                                                                                           1.0*fgkmm;
465 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
466                                                                                                                                           3.6*fgkmm;
467 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
468                                                                                                                                          61.0*fgkmm; 
469 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
470                                                                                                                                          5.97*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
473                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
474                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
475 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
476                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
477 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
478                                                                                                                                           1.0*fgkmm; 
479 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
480                                                                                                                                    = 0.15*fgkmm; 
481 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
482                                                                                                                                          20.0*fgkmm;
483 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
488 /////////////////////////////////////////////////////////////////////////////////
489 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
490 /////////////////////////////////////////////////////////////////////////////////
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
500 /////////////////////////////////////////////////////////////////////////////////
501 // SSD Cone Parameters (lengths are in mm and angles in degrees)
502 /////////////////////////////////////////////////////////////////////////////////
503 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
508 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
525 /////////////////////////////////////////////////////////////////////////////////
526 // SSD Cables Parameters (lengths are in mm and angles in degrees)
527 /////////////////////////////////////////////////////////////////////////////////
528 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
533 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
536 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
542 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
544 /////////////////////////////////////////////////////////////////////////////////
545 ClassImp(AliITSv11GeometrySSD)
546 /////////////////////////////////////////////////////////////////////////////////
547 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
548   AliITSv11Geometry(),
549   fSSDChipMedium(),
550   fSSDChipGlueMedium(),
551   fSSDStiffenerMedium(),
552   fSSDStiffenerConnectorMedium(),
553   fSSDStiffener0603CapacitorMedium(),
554   fSSDStiffener1812CapacitorMedium(),
555   fSSDStiffenerHybridWireMedium(),
556   fSSDKaptonFlexMedium(),
557   fSSDAlTraceFlexMedium(),
558   fSSDAlTraceLadderCableMedium(),
559   fSSDKaptonLadderCableMedium(),
560   fSSDKaptonChipCableMedium(),
561   fSSDAlTraceChipCableMedium(),
562   fSSDAlCoolBlockMedium(),
563   fSSDSensorMedium(),
564   fSSDSensorSupportMedium(),
565   fSSDCarbonFiberMedium(),
566   fSSDTubeHolderMedium(),
567   fSSDCoolingTubeWater(),
568   fSSDCoolingTubePhynox(),
569   fSSDSupportRingAl(),
570   fSSDMountingBlockMedium(),
571   fSSDRohaCellCone(),
572   fSSDAir(),
573   fSSDCopper(),
574   fCreateMaterials(kFALSE),
575   fTransformationMatrices(kFALSE),
576   fBasicObjects(kFALSE),
577   fcarbonfiberjunction(),
578   fcoolingtubesupport(),
579   fhybridmatrix(),
580   fssdcoolingblocksystem(),
581   fcoolingblocksystematrix(),
582   fssdstiffenerflex(),
583   fssdendflex(),
584   fendladdercoolingtubesupportmatrix(),
585   fendladdermountingblock(),
586   fendladdermountingblockclip(),
587   fSSDSensor5(),
588   fSSDSensor6(),
589   fSSDLayer5(), 
590   fSSDLayer6(),
591   fMotherVol(),
592   fLay5LadderSupportRing(),
593   fLay6LadderSupportRing(),
594   fgkEndCapSupportSystem(),
595   fSSDCone(),
596   fColorCarbonFiber(4),
597   fColorRyton(5),
598   fColorPhynox(14),
599   fColorSilicon(3),
600   fColorAl(38),
601   fColorKapton(6),
602   fColorPolyhamide(5),
603   fColorStiffener(9),
604   fColorEpoxy(30),
605   fColorWater(7),
606   fColorG10(41)
607 {
608   ////////////////////////
609   // Standard constructor
610   ////////////////////////
611 }
612 /////////////////////////////////////////////////////////////////////////////////
613 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
614   AliITSv11Geometry(s.GetDebug()),
615   fSSDChipMedium(s.fSSDChipMedium),
616   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
617   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
618   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
619   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
620   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
621   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
622   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
623   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
624   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
625   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
626   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
627   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
628   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
629   fSSDSensorMedium(s.fSSDSensorMedium),
630   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
631   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
632   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
633   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
634   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
635   fSSDSupportRingAl(s.fSSDSupportRingAl),
636   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
637   fSSDRohaCellCone(s.fSSDRohaCellCone),
638   fSSDAir(s.fSSDAir),
639   fSSDCopper(s.fSSDCopper),
640   fCreateMaterials(s.fCreateMaterials),
641   fTransformationMatrices(s.fTransformationMatrices),
642   fBasicObjects(s.fBasicObjects),
643   fcarbonfiberjunction(s.fcarbonfiberjunction),
644   fcoolingtubesupport(s.fcoolingtubesupport),
645   fhybridmatrix(s.fhybridmatrix),
646   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
647   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
648   fssdstiffenerflex(s.fssdstiffenerflex),
649   fssdendflex(s.fssdendflex),
650   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
651   fendladdermountingblock(s.fendladdermountingblock),
652   fendladdermountingblockclip(s.fendladdermountingblockclip),
653   fSSDSensor5(s.fSSDSensor5),
654   fSSDSensor6(s.fSSDSensor6),
655   fSSDLayer5(s.fSSDLayer5),     
656   fSSDLayer6(s.fSSDLayer6),
657   fMotherVol(s.fMotherVol),
658   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
659   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
660   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
661   fSSDCone(s.fSSDCone),
662   fColorCarbonFiber(s.fColorCarbonFiber),
663   fColorRyton(s.fColorRyton),
664   fColorPhynox(s.fColorPhynox),
665   fColorSilicon(s.fColorSilicon),
666   fColorAl(s.fColorAl),
667   fColorKapton(s.fColorKapton),
668   fColorPolyhamide(s.fColorPolyhamide),
669   fColorStiffener(s.fColorStiffener),
670   fColorEpoxy(s.fColorEpoxy),
671   fColorWater(s.fColorWater),
672   fColorG10(s.fColorG10)
673 {
674   ////////////////////////
675   // Copy Constructor
676   ////////////////////////
677 }
678 /////////////////////////////////////////////////////////////////////////////////
679 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
680 operator=(const AliITSv11GeometrySSD &s){
681   ////////////////////////
682   // Assignment operator
683   ////////////////////////
684   this->~AliITSv11GeometrySSD();
685   new(this) AliITSv11GeometrySSD(s); 
686   return *this;
687 /*      
688   if(&s == this) return *this;
689   fMotherVol = s.fMotherVol;
690   return *this;
691  */
692 }
693 ///////////////////////////////////////////////////////////////////////////////
694 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
695   ///////////////////////////////////////////////////////////////////////  
696   // Method generating the trasformation matrix for the whole SSD Geometry   
697   ///////////////////////////////////////////////////////////////////////  
698   // Setting some variables for Carbon Fiber Supportmatrix creation
699   //////////////////////////////////////////////////////////////////////
700   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
701                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
702   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
703                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
704                                                                  +      fgkCarbonFiberSupportWidth);
705   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
706                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
707   TGeoRotation* carbonfiberot[3];
708   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
709   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
710   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
711   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
712   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
713                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
714                                                   -  fgkCarbonFiberTriangleLength
715                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
716   ///////////////////////////////////////////
717   //Setting Local Translations and Rotations: 
718   ///////////////////////////////////////////
719   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
720   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
721                                                                          0.5*carbonfibersupportheight,NULL);    
722   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
723                                                                          2.*symmetryplaneposition+transvector[1],
724                                                                          transvector[2], carbonfiberot[2]);
725   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
726   /////////////////////////////////////////////////////////////
727   // Carbon Fiber Support Transformations
728   /////////////////////////////////////////////////////////////
729   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
730   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
731                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
732                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
733                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
734   }             
735   /////////////////////////////////////////////////////////////
736   // Carbon Fiber Junction Transformation
737   /////////////////////////////////////////////////////////////
738   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
739   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
740   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
741   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
742   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
743         localcarbonfiberjunctionmatrix[i] = 
744                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
745         localcarbonfiberjunctionrot[i] = 
746                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
747         localcarbonfiberjunctiontrans[i] = 
748                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
749   }
750   ///////////////////////
751   // Setting Translations
752   ///////////////////////
753   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
754   localcarbonfiberjunctiontrans[1][0] = 
755                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
756   localcarbonfiberjunctiontrans[2][0] = 
757                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
758                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
759                                  fgkCarbonFiberTriangleLength
760                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
761   localcarbonfiberjunctiontrans[0][1] = 
762                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
763   localcarbonfiberjunctiontrans[1][1] = 
764                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
765   localcarbonfiberjunctiontrans[2][1] = 
766                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
767   ////////////////////
768   // Setting Rotations
769   ////////////////////
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
772                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
773   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
774         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
775   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
776   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
777   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
778   ////////////////////////////////////////
779   // Setting Carbon Fiber Junction matrix 
780   ////////////////////////////////////////
781   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
782                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
783                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
784                         localcarbonfiberjunctionmatrix[i][j] = 
785                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
786                                                            *localcarbonfiberjunctionrot[i][j]);
787                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
788          }
789   }
790   /////////////////////////////////////////////////////////////
791   // Carbon Fiber Lower Support Transformations
792   /////////////////////////////////////////////////////////////
793   TGeoTranslation* localcarbonfiberlowersupportrans[2];
794   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
795                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
796                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
797                                                                          0.0);
798   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
799                                                                          fgkCarbonFiberJunctionWidth
800                                                                 -    fgkCarbonFiberLowerSupportWidth
801                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
802                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
803                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
804    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
805    fcarbonfiberlowersupportrans[0] = 
806                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
807    fcarbonfiberlowersupportrans[1] = 
808                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
809   /////////////////////////////////////////////////////////////
810   // SSD Sensor Support Transformations
811   /////////////////////////////////////////////////////////////
812   const Int_t kssdsensorsupportmatrixnumber = 3;
813   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
814   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
815   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
816   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
817         localssdsensorsupportmatrix[i] = 
818                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
819         localssdsensorsupportrot[i] = 
820                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
821         localssdsensorsupportrans[i] = 
822                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
823   }
824   ///////////////////////
825   // Setting Translations
826   ///////////////////////
827   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
828                                                                           0.5*fgkSSDSensorSideSupportWidth,
829                                                                           0.0);
830   localssdsensorsupportrans[1][0] = 
831                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
832   localssdsensorsupportrans[2][0] = 
833                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
834   localssdsensorsupportrans[0][1] = 
835                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
836                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
837                                                                                 0.0);
838   localssdsensorsupportrans[1][1] = 
839                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
840                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
841                                                                     -   fgkSSDModuleSensorSupportDistance,
842                                                                                 0.0);
843   localssdsensorsupportrans[2][1] = 
844                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
845                                                                         -    fgkSSDSensorCenterSupportPosition,
846                                                                                  0.5*fgkSSDSensorCenterSupportWidth
847                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
848                                                                                  fgkSSDSensorCenterSupportThickness[0]);
849   localssdsensorsupportrans[0][2] = 
850                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
851                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
852                                                                                  fgkCarbonFiberJunctionWidth
853                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
854                                                                         +    fgkSSDSensorCenterSupportLength
855                                                                         -    fgkSSDSensorCenterSupportThickness[0])
856                                                                         -    fgkSSDSensorCenterSupportPosition,
857                                                                              0.0);
858   localssdsensorsupportrans[1][2] = 
859                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
860   localssdsensorsupportrans[2][2] = 
861                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
862   ////////////////////
863   // Setting Rotations
864   ////////////////////
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
866                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
867                         localssdsensorsupportrot[i][j] = new TGeoRotation();
868   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
869         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
870         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
871   }
872   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
873   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
874   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
875   ////////////////////////////////////////
876   // SSD Sensor Support matrix 
877   ////////////////////////////////////////
878   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
879                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
880                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
881                         localssdsensorsupportmatrix[i][j] = 
882                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
883                                                            *localssdsensorsupportrot[i][j]);
884                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
885          }
886   }
887   /////////////////////////////////////////////////////////////
888   // SSD Cooling Tube Support Transformations
889   /////////////////////////////////////////////////////////////
890   const Int_t kcoolingtubesupportmatrixnumber = 2;
891   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
892   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
893   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
894   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
895                                                                                                         /fgkCoolingTubeSupportRmax);
896   localcoolingtubesupportrans[0] = 
897                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
898                                                 +  2.*(fgkCoolingTubeSupportLength
899                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
900                                                 +  fgkCarbonFiberTriangleLength
901                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
902   localcoolingtubesupportrans[1] = 
903                         new TGeoTranslation(fgkCarbonFiberJunctionLength
904                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
905                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
906                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
907                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
908                     -  0.5*(fgkCarbonFiberLowerSupportWidth
909                                         +          fgkSSDSensorCenterSupportLength
910                     -      fgkSSDSensorCenterSupportThickness[0])
911                                         +  0.5*fgkSSDSensorLength,
912                                         -  0.5*fgkCoolingTubeSupportHeight);  
913   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
914   localcoolingtubesupportrot[i] = new TGeoRotation();
915   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
916   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
917   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
918         localcoolingtubesupportmatrix[i] = 
919                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
920                                                    *localcoolingtubesupportrot[i]);
921   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
922   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
923                                                                 (*localcoolingtubesupportmatrix[0]));
924   /////////////////////////////////////////////////////////////
925   // End Ladder SSD Cooling Tube Support Transformations
926   /////////////////////////////////////////////////////////////
927   TGeoTranslation** localendladdercooltubetrans[2];
928   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
929   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
930   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
931   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
932                                                                                         -          (fgkCoolingTubeSupportLength
933                                                                                         -               fgkCoolingTubeSupportRmax),
934                                                                                                         fgkEndLadderMountingBlockPosition[0]
935                                                                                         -               fgkendladdercoolingsupportdistance[0]
936                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
937                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
938   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
939                                                                                         -          (fgkCoolingTubeSupportLength
940                                                                                         -               fgkCoolingTubeSupportRmax),
941                                                                                                         fgkEndLadderMountingBlockPosition[0]
942                                                                                         +               fgkendladdercoolingsupportdistance[1]
943                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
944                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
945   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
946                                                                                         -       fgkCoolingTubeSupportRmax)
947                                                                                         +               fgkCarbonFiberTriangleLength
948                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
949                                                                                                 0.0,
950                                                                                                 0.0);
951   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
952                                                                                                         fgkendladdercoolingsupportdistance[0]
953                                                                                         +               fgkendladdercoolingsupportdistance[1],
954                                                                                                         0.0);
955   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
956   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
957                                                                                         +               fgkCarbonFiberJunctionLength
958                                                                                         -               fgkCoolingTubeSupportLength,
959                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
960                                                                                         -       0.5*fgkCoolingTubeSupportWidth
961                                                                                                    -fgkendladdercoolingsupportdistance[2],
962                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
963   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
964                                                                                         +               fgkCoolingTubeSupportLength
965                                                                                         -               fgkCoolingTubeSupportRmax
966                                                                                         -               fgkCarbonFiberJunctionLength,
967                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
968                                                                                         -       0.5*fgkCoolingTubeSupportWidth
969                                                                                         -               fgkendladdercoolingsupportdistance[2],
970                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
971   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
972   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
973   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
974   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
975   (*localcoolingtubesupportrot[1]));
976   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
977   (*localcoolingtubesupportrot[1]));
978   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
979   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
980   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
981   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
982   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
983
984   fendladdercoolingtubesupportmatrix[1][0] =    
985                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
986                                                                                    *(*localcoolingtubesupportrot[1]));
987   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
988   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
989   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
990   /////////////////////////////////////////////////////////////
991   // SSD Cooling Tube Transformations
992   /////////////////////////////////////////////////////////////
993   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
994   localcoolingtuberot->SetAngles(0.,90.,0.);
995   TGeoTranslation** localcoolingtubetrans[4];
996   TVector3** localcoolingtubevect[4];
997   for(Int_t i=0; i<4; i++){
998         localcoolingtubevect[i] = new TVector3*[2];
999         localcoolingtubetrans[i] = new TGeoTranslation*[2];
1000         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
1001   }
1002   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1003                                                   -fgkCarbonFiberTriangleLength),
1004                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1005                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1006                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1007                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1008                                                   +      fgkSSDSensorCenterSupportLength
1009                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1010                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1011                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1012                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1013                                                   -  0.5*fgkCoolingTubeSupportWidth,
1014                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1015   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1016                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1017                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1018                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1019                                                   +  fgkCoolingTubeSupportWidth,
1020                                                   localcoolingtubevect[0][0]->Z());     
1021   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1022                                                          +                               fgkCarbonFiberTriangleLength,
1023                                                                                          localcoolingtubevect[0][0]->Y(),
1024                                                                                          localcoolingtubevect[0][0]->Z());
1025   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1026                                                          +                               fgkCarbonFiberTriangleLength,
1027                                                                                          localcoolingtubevect[0][1]->Y(),
1028                                                                                          localcoolingtubevect[0][1]->Z());
1029   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1030                                                   -     fgkCarbonFiberTriangleLength),
1031                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1032                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1033                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1034                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1035                                                   +      fgkSSDSensorCenterSupportLength
1036                                                   -      fgkSSDSensorCenterSupportThickness[0])
1037                                                   +  fgkSSDModuleStiffenerPosition[1]
1038                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1039                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1040   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1041                                                          +                               fgkCarbonFiberTriangleLength,
1042                                                                                          localcoolingtubevect[2][0]->Y(),
1043                                                                                          localcoolingtubevect[2][0]->Z());      
1044   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1045                                                   -     fgkCarbonFiberTriangleLength),
1046                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1047                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1048                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1049                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1050                                                   +      fgkSSDSensorCenterSupportLength
1051                                                   -      fgkSSDSensorCenterSupportThickness[0])
1052                                                   +      fgkSSDSensorLength
1053                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1054                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1055   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1056                                                   + fgkCarbonFiberTriangleLength,
1057                                                         localcoolingtubevect[3][0]->Y(),
1058                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1059   for(Int_t i=0; i<4; i++) 
1060         for(Int_t j=0; j<2; j++){
1061                 localcoolingtubetrans[i][j] = 
1062                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1063                                                                 localcoolingtubevect[i][j]->Y(),
1064                                                                 localcoolingtubevect[i][j]->Z());
1065                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1066                                                           *                                     (*localcoolingtuberot));
1067         }
1068   /////////////////////////////////////////////////////////////
1069   // SSD End Ladder Cooling Tube Transformations
1070   /////////////////////////////////////////////////////////////
1071   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1072   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1073   TGeoTranslation** localendlladdercoolingtubetrans[2];
1074   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1075   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1076   for(Int_t i=0; i<2; i++)      
1077         for(Int_t j=0; j<(i==0?6:4); j++)       
1078                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1079   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1080                                                                         -        fgkCoolingTubeSupportRmax)
1081                                                                         +        fgkCarbonFiberJunctionLength,
1082                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1083                                                                         -    fgkendladdercoolingsupportdistance[0]),
1084                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1085   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1086                                                                         -        fgkCoolingTubeSupportRmax)
1087                                                                         -        fgkCarbonFiberJunctionLength
1088                                                                         +    fgkCarbonFiberTriangleLength,
1089                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1090                                                                         -    fgkendladdercoolingsupportdistance[0]),
1091                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1092   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1093                                                                         -   fgkCoolingTubeSupportRmax)
1094                                                                         +       fgkCarbonFiberJunctionLength,
1095                                                                            fgkEndLadderMountingBlockPosition[0]
1096                                                                         -   fgkendladdercoolingsupportdistance[0]
1097                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1098                                                   +                             fgkendladdercoolingsupportdistance[1]
1099                                                   +                             fgkCoolingTubeSupportWidth),
1100                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1101   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1102                                                                         -        fgkCoolingTubeSupportRmax)
1103                                                                         -        fgkCarbonFiberJunctionLength
1104                                                                         +    fgkCarbonFiberTriangleLength,
1105                                                                            fgkEndLadderMountingBlockPosition[0]
1106                                                                         -   fgkendladdercoolingsupportdistance[0]
1107                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1108                                                   +                             fgkendladdercoolingsupportdistance[1]
1109                                                   +                             fgkCoolingTubeSupportWidth),
1110                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1111   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1112                                                                         -   fgkCoolingTubeSupportRmax)
1113                                                                         +       fgkCarbonFiberJunctionLength,
1114                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1115                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1116                                                   -                     fgkEndLadderMountingBlockPosition[0]
1117                                                   -                     fgkendladdercoolingsupportdistance[1]           
1118                                                   -                     fgkCoolingTubeSupportWidth),
1119                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1120   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1121                                                                         -        fgkCoolingTubeSupportRmax)
1122                                                                         -        fgkCarbonFiberJunctionLength
1123                                                                         +    fgkCarbonFiberTriangleLength,
1124                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1125                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1126                                                   -                     fgkEndLadderMountingBlockPosition[0]
1127                                                   -                     fgkendladdercoolingsupportdistance[1]           
1128                                                   -                     fgkCoolingTubeSupportWidth),
1129                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1130   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1131                                                                         -   fgkCoolingTubeSupportRmax)
1132                                                                         +       fgkCarbonFiberJunctionLength,
1133                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1134                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1135                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1136                                                         +                 fgkSSDSensorOverlap
1137                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1138                                                         -                 fgkendladdercoolingsupportdistance[2]
1139                                                         -                 fgkEndLadderMountingBlockPosition[1]
1140                                                         -                 fgkCoolingTubeSupportWidth)
1141                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1142                                                         -                 fgkendladdercoolingsupportdistance[2]
1143                                                         -                 fgkCoolingTubeSupportWidth,
1144                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1145   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1146                                                   -      fgkCoolingTubeSupportRmax)
1147                                                   -      fgkCarbonFiberJunctionLength
1148                                                   +    fgkCarbonFiberTriangleLength,
1149                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1150                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1151                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1152                                                         +                 fgkSSDSensorOverlap
1153                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1154                                                         -                 fgkendladdercoolingsupportdistance[2]
1155                                                         -                 fgkEndLadderMountingBlockPosition[1]
1156                                                         -                 fgkCoolingTubeSupportWidth)
1157                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1158                                                         -                 fgkendladdercoolingsupportdistance[2]
1159                                                         -                 fgkCoolingTubeSupportWidth,
1160                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1161   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1162                                                                         -   fgkCoolingTubeSupportRmax)
1163                                                                         +       fgkCarbonFiberJunctionLength,
1164                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1165                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1166                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1167   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1168                                                                         -        fgkCoolingTubeSupportRmax)
1169                                                                         -        fgkCarbonFiberJunctionLength
1170                                                                         +    fgkCarbonFiberTriangleLength,
1171                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1172                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1173                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1174   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1175   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1176   for(Int_t i=0; i<2; i++)
1177         for(Int_t j=0; j<(i==0?6:4); j++){
1178                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1179                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1180         }
1181   /////////////////////////////////////////////////////////////
1182   // SSD Hybrid Components Transformations
1183   /////////////////////////////////////////////////////////////
1184   const Int_t khybridmatrixnumber = 3;
1185   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1186   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1187                                             0.5*fgkSSDStiffenerWidth,
1188                                             0.5*fgkSSDStiffenerHeight);
1189   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1190                                             fgkSSDModuleStiffenerPosition[1],0.0);
1191
1192   localhybridtrans[2] = new TGeoTranslation(
1193                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1194                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1195                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1196                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1197                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1198                       -       fgkSSDSensorCenterSupportThickness[0]),
1199                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1200                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1201                                           -       fgkSSDModuleVerticalDisalignment2)); 
1202   fhybridmatrix = new TGeoHMatrix();
1203   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1204   /////////////////////////////////////////////////////////////
1205   // SSD Cooling Block Transformations
1206   /////////////////////////////////////////////////////////////
1207   const Int_t kcoolingblockmatrixnumber = 4;    
1208   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1209   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1210                             -  fgkCoolingTubeSupportRmin),0.0,
1211                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1212   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1213                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1214                                0.0,fgkSSDStiffenerHeight);
1215   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1216   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1217   fcoolingblocksystematrix = new TGeoHMatrix();
1218   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1219       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1220   /////////////////////////////////////////////////////////////
1221   // SSD Stiffener Flex Transformations
1222   /////////////////////////////////////////////////////////////
1223   const Int_t klocalflexmatrixnumber = 4;
1224   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1225   for(Int_t i=0; i<fgkflexnumber; i++)    
1226       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1227   for(Int_t i=0; i<fgkflexnumber; i++)
1228       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1229             localflexmatrix[i][j] = new TGeoCombiTrans();
1230   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1231                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1232                                                                   -    fgkSSDStiffenerWidth;
1233   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1234                                         +0.5*fgkSSDStiffenerLength,
1235                                          0.5*fgkSSDStiffenerWidth,
1236                                         -0.5*fgkSSDStiffenerHeight
1237                                         -0.5*fgkSSDFlexHeight[0]);
1238   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1239                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1240                                         -0.5*fgkSSDStiffenerWidth,
1241                                         -0.5*fgkSSDStiffenerHeight
1242                                         -0.5*fgkSSDFlexHeight[0]);
1243   TGeoRotation* localflexrot = new TGeoRotation();
1244   localflexrot->SetAngles(180.,0.,0.);    
1245   localflexmatrix[1][0]->SetRotation(localflexrot);
1246   for(Int_t i=0; i<fgkflexnumber; i++)
1247       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1248             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1249   for(Int_t i=0; i<fgkflexnumber; i++){
1250       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1251       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1252             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1253   }
1254   /////////////////////////////////////////////////////////////
1255   // SSD End Flex Transformations
1256   /////////////////////////////////////////////////////////////
1257   TGeoRotation* localendflexrot = new TGeoRotation();
1258   localendflexrot->SetAngles(0.0,90.0,0.0);
1259   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1260   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1261                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1262   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1263                             * TMath::DegToRad()*ssdflexradiusmax
1264                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1265                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
1266   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1267                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1268                             +      fgkSSDFlexLength[2];
1269   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1270                               0.5*fgkSSDFlexWidth[0],
1271                               2.*fgkSSDStiffenerHeight
1272                             + 0.5*fgkSSDFlexHeight[0]);      
1273   localendflexmatrix->SetRotation(localendflexrot);
1274   for(Int_t i=0; i<fgkflexnumber; i++) 
1275       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1276   /////////////////////////////////////////////////////////////
1277   // End Ladder Carbon Fiber Junction
1278   /////////////////////////////////////////////////////////////
1279   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1280   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1281   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1282   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1283       localendladdercarbonfiberjunctionmatrix[i] 
1284             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1285       localendladdercarbonfiberjunctionrot[i] 
1286             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1287       localendladdercarbonfiberjunctiontrans[i] 
1288             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1289       fendladdercarbonfiberjunctionmatrix[i]
1290             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1291   }
1292   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1293       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1294             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1295             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1296       }
1297   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1298       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1299           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1300   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1301       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1302                               0.0,0.0);
1303       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1304                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1305                 *                     SinD(fgkCarbonFiberTriangleAngle),
1306                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1307   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1308   }
1309   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1310   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1311   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1312   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1313       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1314       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1315       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1316       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1317             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1318       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1319             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1320                                *localendladdercarbonfiberjunctionglobalrot[i]);
1321   }
1322   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1323       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1324             localendladdercarbonfiberjunctionmatrix[i][j] = 
1325                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1326                                      *localendladdercarbonfiberjunctionrot[i][j]);
1327            fendladdercarbonfiberjunctionmatrix[i][j] =
1328             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1329             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1330       }  
1331   /////////////////////////////////////////////////////////////
1332   // End Ladder Carbon Fiber Support
1333   /////////////////////////////////////////////////////////////
1334   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1335   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1336       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1337       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1338             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1339       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1340   }
1341   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1342       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1343             fendladdercarbonfibermatrix[i][j] = 
1344             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1345             *(*fcarbonfibersupportmatrix[j]));
1346   /////////////////////////////////////////////////////////////
1347   // End Ladder SSD Mounting Block
1348   /////////////////////////////////////////////////////////////
1349   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1350       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1351   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1352       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1353                                 +        fgkSSDMountingBlockLength[1])
1354                                 +  0.5*fgkCarbonFiberTriangleLength,
1355                                 fgkEndLadderMountingBlockPosition[i],
1356                                 -  fgkSSDMountingBlockHeight[1]
1357                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1358   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1359   endladdermountingblockrot->SetAngles(0.,90.,0.);
1360   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1361         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1362   /////////////////////////////////////////////////////////////
1363   // End Ladder SSD Mounting Block Clip Matrix 
1364   /////////////////////////////////////////////////////////////
1365   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1366         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1367   
1368   TGeoRotation* localendladdercliprot = new TGeoRotation();
1369   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1370   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1371                                                                                   -     fgkSSDMountingBlockLength[1])
1372                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1373   localendladdercliprot->SetAngles(90.,180.,-90.);
1374   TGeoCombiTrans* localendladderclipcombitrans = 
1375                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1376   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1377         for(Int_t j=0; j<2; j++){
1378                 fendladdermountingblockclipmatrix[i][j] = 
1379                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1380                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1381         }
1382   /////////////////////////////////////////////////////////////
1383   // End Ladder Carbon Fiber Lower Support
1384   /////////////////////////////////////////////////////////////
1385   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1386       fendladderlowersupptrans[i] = 
1387             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1388                         +  0.5*fgkSSDMountingBlockWidth),
1389                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1390   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1391                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1392                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1393                                                                          0.0);
1394   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1395  /////////////////////////////////////////////////////////////
1396   // Matrix for positioning Ladder into mother volume
1397   /////////////////////////////////////////////////////////////
1398   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1399   for(Int_t i=0; i<fgkladdernumber; i++) 
1400         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1401   TGeoRotation* localladdermotherrot = new TGeoRotation();
1402   localladdermotherrot->SetAngles(0.,90.,0.);  
1403   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1404   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1405   for(Int_t i=0; i<fgkladdernumber; i++){
1406         localladdermothertrans[i] = new TGeoTranslation(0.,
1407                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1408                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1409                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1410                                                           * fgkCarbonFiberJunctionWidth,0.);
1411         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1412                                                                                                                 *localladdermotherrot);
1413         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1414         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1415   }
1416   /////////////////////////////////////////////////////////////
1417   // Ladder Cables Matrices
1418   /////////////////////////////////////////////////////////////
1419   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1420                                              + fgkSSDFlexHeight[1];  
1421   Double_t ssdladdercabletransx[3];
1422   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1423                                                   *   SinD(2.*fgkSSDFlexAngle)
1424                                                   *       CosD(2.*fgkSSDFlexAngle);
1425   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1426                                                   -     ssdladdercabletransx[0]
1427                                                   /     SinD(2.*fgkSSDFlexAngle))
1428                                                   *     CosD(fgkSSDFlexAngle);                                          
1429   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1430                                                   *       TMath::DegToRad()*ssdflexradiusmax
1431                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1432                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1433                                                   -       fgkSSDLadderCableWidth)
1434                                                   *       CosD(2.*fgkSSDFlexAngle);
1435   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1436                                                   *     TanD(2.*fgkSSDFlexAngle),
1437                                                         ssdladdercabletransx[1]
1438                                                   *     TanD(fgkSSDFlexAngle),
1439                                                         ssdladdercabletransx[2]
1440                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1441   TGeoRotation* localladdercablerot[3]; 
1442   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1443   localladdercablerot[0]->SetAngles(90.,0.,0.);
1444   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1445   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1446                                                  *                        (*localladdercablerot[0]));
1447   ////////////////////////////////////////////
1448   // LocalLadderCableCombiTransMatrix
1449   ////////////////////////////////////////////
1450   const Int_t klocalladdersidecablesnumber = 2;
1451   const Int_t klocalladdercombitransnumber = 5;
1452   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1453   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1454          localladdercablecombitransmatrix[i] = 
1455                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1456   ///////////////////////////////////////////
1457   // Left Side Ladder Cables Transformations
1458   ///////////////////////////////////////////
1459   localladdercablecombitransmatrix[0][0]  =
1460                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1461                                                 0.,0.,NULL);
1462   localladdercablecombitransmatrix[0][1] = 
1463         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1464                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1465                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1466                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1467                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1468                                            + fgkSSDSensorCenterSupportLength
1469                                            - fgkSSDSensorCenterSupportThickness[0]),
1470                                            - (fgkSSDModuleCoolingBlockToSensor
1471                                            + 0.5*fgkCoolingTubeSupportHeight
1472                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1473                                            - fgkSSDChipHeight),NULL);
1474   localladdercablecombitransmatrix[0][2] = 
1475                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1476                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1477   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1478                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1479                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1480                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1481                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1482                                                                                                 new TGeoRotation("",180.,0.,0.));
1483   localladdercablecombitransmatrix[0][4] = 
1484                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1485                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1486                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1487                                                           0.,
1488                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1489                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1490                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1491                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1492   ///////////////////////////////////////////
1493   // Rigth Side Ladder Cables Transformations
1494   ///////////////////////////////////////////
1495   TGeoCombiTrans* localladdercablessdmodulematrix = 
1496         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1497                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1498                                                                          fgkSSDStiffenerWidth,
1499                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1500   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1501    localladdercablecombitransmatrix[1][i] = 
1502                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1503                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1504   ///////////////////////////////////////////
1505   // Setting LadderCableHMatrix
1506   ///////////////////////////////////////////
1507   Int_t beamaxistrans[2][3];
1508   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1509   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1510   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1511   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1512   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1513   beamaxistrans[1][2] = beamaxistrans[1][0];
1514   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1515   TGeoRotation* laddercablerot = new TGeoRotation();
1516   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1517   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1518   Double_t* laddercabletransvector;     
1519   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1520         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1521         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1522   }
1523   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1524         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1525                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1526                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1527                         localladdercablehmatrix[i][j]->MultiplyLeft(
1528                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1529         }
1530                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1531                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1532                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1533                                                                          laddercabletransvector[1]
1534                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1535                                         *                                fgkCarbonFiberJunctionWidth,
1536                                                                          laddercabletransvector[2]);
1537                 laddercablecombitrans->SetRotation(*laddercablerot);
1538                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1539                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1540         }
1541     fladdercablematrix[i][2] = 
1542                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1543                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1544         fladdercablematrix[i][3] = 
1545                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1546                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1547   }
1548   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1549         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1550                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1551   ///////////////////////////////////////////
1552   // Setting Ladder HMatrix
1553   ///////////////////////////////////////////
1554   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1555                                                                                                 fgkSSDLay6SensorsNumber};
1556   for(Int_t i=0; i<fgkladdernumber; i++){
1557         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1558         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1559                 fladdermatrix[i][j] = new TGeoHMatrix();
1560                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1561                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1562                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1563         }
1564   }
1565   ///////////////////////////////////////////
1566   // Setting SSD Sensor Matrix 
1567   ///////////////////////////////////////////
1568   TGeoCombiTrans* localssdsensorcombitrans[2];
1569   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1570   localssdsensorrot->SetAngles(0.,90.,0.);      
1571   TGeoTranslation* localssdsensortrans[2];
1572   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1573   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1574                                           -             (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1575                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1576                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1577                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1578                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1579                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1580                                           -             fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1581                                           +    (fgkSSDSensorSideSupportHeight[1]
1582                                           -             fgkSSDSensorSideSupportHeight[0])
1583                                           +     0.5*fgkSSDModuleVerticalDisalignment2);
1584   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1585                                           -        (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1586                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1587                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1588                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1589                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1590                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1591                                                         -fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1592                                                 +       0.5*fgkSSDModuleVerticalDisalignment2);
1593   for(Int_t i=0; i<2; i++) 
1594         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1595                                                                                                          *localssdsensorrot);   
1596     for(Int_t i=0; i<fgkladdernumber; i++){
1597         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1598         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1599                 switch(i){
1600                         case 0: //Ladder of Layer5  
1601                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1602                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1603                                                                                                 *localssdsensorcombitrans[1])));
1604                         break;
1605                         case 1: //Ladder of Layer6 
1606                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1607                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1608                                                                                                 *localssdsensorcombitrans[0])));
1609                 break;
1610                 }
1611           }
1612   }     
1613   //////////////////////////
1614   // Setting SSD End Ladder  
1615   //////////////////////////
1616   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1617   for(Int_t i=0; i<2; i++){
1618         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1619         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1620         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1621         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1622         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1623         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1624         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1625         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1626    }
1627   /////////////////////////////////////////////////////
1628   // Setting the CombiTransformation to pass ITS center 
1629   /////////////////////////////////////////////////////
1630   Double_t itscentertransz[fgklayernumber];
1631   itscentertransz[0] = fgkSSDLay5LadderLength
1632                                          - fgkLay5CenterITSPosition;
1633   itscentertransz[1] = fgkSSDLay6LadderLength
1634                                          - fgkLay6CenterITSPosition;
1635   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1636                                                    + 0.5*fgkCoolingTubeSupportHeight;
1637   TGeoRotation* itscenterrot[3];
1638   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1639   itscenterrot[0]->SetAngles(90.,180.,-90.);
1640   itscenterrot[1]->SetAngles(0.,90.,0.);
1641   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1642   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1643   for(Int_t i=0; i<fgklayernumber; i++) 
1644         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1645                                                          itssensortransy,
1646                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1647                                                    - itscentertransz[i],itscenterrot[2]);
1648   TGeoRotation** locallayerrot[fgklayernumber];
1649   TGeoTranslation** locallayertrans[fgklayernumber];    
1650   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1651   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1652   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1653                                          - fgkLay5CenterITSPosition);
1654   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1655                                          - fgkLay6CenterITSPosition);
1656   const Int_t kssdlayladdernumber[fgklayernumber] = 
1657                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1658   for(Int_t i=0; i<fgklayernumber; i++){
1659     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1660     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1661         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1662         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1663   }
1664   Double_t layerladderangleposition[fgklayernumber] = 
1665                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1666   Double_t layerradius = 0.;
1667   for(Int_t i=0; i<fgklayernumber; i++){        
1668         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1669                 switch(i){
1670                         case 0: //Ladder of Layer5  
1671                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1672                         break;
1673                         case 1: //Ladder of Layer6 
1674                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1675                 break;
1676                 }
1677                 locallayerrot[i][j] = new TGeoRotation();
1678                 locallayertrans[i][j] = new TGeoTranslation();
1679                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1680                 locallayertrans[i][j]->SetTranslation(layerradius 
1681                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1682                                                             layerradius 
1683                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1684                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1685                                                                          *locallayerrot[i][j]);
1686                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1687                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1688                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1689         }
1690   }
1691   /////////////////////////////////////////////////////////////
1692   // Deallocating memory
1693   /////////////////////////////////////////////////////////////
1694   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1695         delete carbonfiberot[i];
1696         delete localcarbonfibersupportmatrix[i];
1697   }
1698   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1699      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1700        delete localcarbonfiberjunctionmatrix[i][j];
1701            delete localcarbonfiberjunctionrot[i][j];
1702            delete localcarbonfiberjunctiontrans[i][j];
1703            }
1704        delete [] localcarbonfiberjunctionmatrix[i];
1705        delete [] localcarbonfiberjunctionrot[i];
1706        delete [] localcarbonfiberjunctiontrans[i];
1707   }
1708   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1709            delete localcarbonfiberlowersupportrans[i];
1710   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1711      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1712        delete localssdsensorsupportmatrix[i][j];
1713            delete localssdsensorsupportrot[i][j];
1714            delete localssdsensorsupportrans[i][j];
1715            }
1716        delete [] localssdsensorsupportmatrix[i];
1717        delete [] localssdsensorsupportrot[i];
1718        delete [] localssdsensorsupportrans[i];
1719   }
1720   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1721         delete localcoolingtubesupportmatrix[i];
1722         delete localcoolingtubesupportrot[i];
1723         delete localcoolingtubesupportrans[i];
1724   }
1725   for(Int_t i=0; i<4; i++){
1726         for(Int_t j=0; j<2; j++){
1727                 delete localcoolingtubevect[i][j];
1728                 delete localcoolingtubetrans[i][j];
1729         }
1730         delete [] localcoolingtubevect[i];
1731         delete [] localcoolingtubetrans[i];
1732   }
1733  delete endladdermountingblockrot;
1734  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1735  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1736  for(Int_t i=0; i<fgkflexnumber; i++){
1737       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1738             delete localflexmatrix[i][j];
1739       delete [] localflexmatrix[i];
1740  }
1741  delete localendlladdercoolingtuberot;
1742  for(Int_t i=0; i<2; i++){
1743         for(Int_t j=0; j<(i==0?6:4); j++)
1744                 delete localendlladdercoolingtubetrans[i][j];
1745         delete [] localendlladdercoolingtubetrans[i];
1746   }
1747
1748  delete localflexrot;
1749  delete localendflexrot;
1750  delete localendflexmatrix;
1751  for(Int_t i=0; i<fgkladdernumber; i++){ 
1752         delete localladdermothertrans[i];
1753         delete localladdermothercombitrans[i];
1754   }
1755  delete localladdermotherrot;
1756  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1757       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1758             delete localendladdercarbonfiberjunctionmatrix[i][j];
1759             delete localendladdercarbonfiberjunctionrot[i][j];
1760             delete localendladdercarbonfiberjunctiontrans[i][j];
1761       }
1762       delete [] localendladdercarbonfiberjunctionmatrix[i];
1763       delete [] localendladdercarbonfiberjunctionrot[i];
1764       delete [] localendladdercarbonfiberjunctiontrans[i];
1765       delete localendladdercarbonfiberjunctionglobalrot[i];
1766       delete localendladdercarbonfiberjunctionglobaltrans[i];
1767       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1768  }
1769   for(Int_t i=0; i<2; i++){
1770         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1771         delete [] localendladdercooltubetrans[i];
1772   }
1773   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1774       delete localendladdercarbonfibertrans[i];
1775   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1776   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1777         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1778                 delete localladdercablecombitransmatrix[i][j];
1779                 delete []localladdercablecombitransmatrix[i];
1780   }
1781   delete localendladdercliprot;
1782   delete localendladdercliptrans;
1783   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1784         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1785                 delete localladdercablehmatrix[i][j];
1786         delete []localladdercablehmatrix[i];
1787   }
1788   delete laddercablerot;
1789   delete laddercabletrans;
1790   delete laddercablecombitrans;
1791   delete localladdercablessdmodulematrix;
1792   delete localssdsensorrot;     
1793   for(Int_t i=0; i<2; i++){
1794         delete localssdsensortrans[i];
1795         delete localssdsensorcombitrans[i];
1796   }
1797   for(Int_t i=0; i<fgklayernumber; i++){
1798         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1799                 delete locallayerrot[i][j];
1800                 delete locallayertrans[i][j];
1801                 delete locallayercombitrans[i][j];
1802     }
1803         delete [] locallayerrot[i];
1804         delete [] locallayertrans[i];
1805         delete [] locallayercombitrans[i];
1806         delete localbeamaxistrans[i];
1807   }
1808   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1809   for(Int_t i=0; i<fgkladdernumber; i++){
1810         for(Int_t j=0; j<fgkladdernumber; j++)
1811                 delete ladderglobalmatrix[i][j];
1812         delete [] ladderglobalmatrix[i];
1813   }
1814   /////////////////////////////////////////////////////////////
1815   fTransformationMatrices = kTRUE;      
1816 }
1817 ///////////////////////////////////////////////////////////////////////////////
1818 void AliITSv11GeometrySSD::CreateBasicObjects(){
1819   /////////////////////////////////////////////////////////////  
1820   // Method generating the Objects of SSD Geometry    
1821   /////////////////////////////////////////////////////////////
1822   // SSD Sensor
1823   ///////////////////////////////////
1824   SetSSDSensor();
1825   /////////////////////////////////////////////////////////////  
1826   // Carbon Fiber Support    
1827   /////////////////////////////////////////////////////////////  
1828   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1829   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1830       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1831   /////////////////////////////////////////////////////////////
1832   // Carbon Fiber Junction 
1833   /////////////////////////////////////////////////////////////
1834   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1835   /////////////////////////////////////////////////////////////
1836   // Carbon Fiber Lower Support
1837   /////////////////////////////////////////////////////////////
1838   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1839   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1840         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1841   /////////////////////////////
1842   // SSD Sensor Support
1843   /////////////////////////////
1844   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1845                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1846   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1847                                                                          fgkSSDSensorSideSupportThickness[1]};
1848   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1849         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1850                                                                                            fgkSSDSensorSideSupportHeight[i],
1851                                                                                            fgkSSDSensorSideSupportWidth,
1852                                                                                            sidesupporthickness);  
1853         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1854                                                                                            fgkSSDSensorCenterSupportHeight[i],
1855                                                                                            fgkSSDSensorCenterSupportWidth,
1856                                                                                            sidesupporthickness);
1857   }
1858   /////////////////////////////////////////////////////////////
1859   // SSD Cooling Tube Support
1860   /////////////////////////////////////////////////////////////
1861   Int_t edgesnumber = 16;
1862   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1863   /////////////////////////////////////////////////////////////
1864   // SSD Hybrid
1865   /////////////////////////////////////////////////////////////
1866   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1867   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1868         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1869   /////////////////////////////////////////////////////////////
1870   // SSD Cooling Block System
1871   /////////////////////////////////////////////////////////////
1872   fssdcoolingblocksystem = GetCoolingBlockSystem();
1873    /////////////////////////////////////////////////////////////
1874   // SSD Cooling Tube
1875   /////////////////////////////////////////////////////////////
1876   TList* coolingtubelist = GetCoolingTubeList();        
1877   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1878         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1879   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1880         fendladdercoolingtube[i] = 
1881                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1882   /////////////////////////////////////////////////////////////
1883   // SSD Flex  
1884   /////////////////////////////////////////////////////////////
1885   fssdstiffenerflex = GetSSDStiffenerFlex();
1886   fssdendflex = GetSSDEndFlex();
1887   ///////////////////////////////////
1888   // End Ladder Carbon Fiber Junction
1889   ///////////////////////////////////
1890   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1891                                                    fendladdercarbonfiberjunction[i] = 
1892                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1893   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1894     fendladdercarbonfiberjunction[i][0] = 
1895                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1896     fendladdercarbonfiberjunction[i][1] = 
1897                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1898   }
1899   ///////////////////////////////////
1900   // End Ladder Mounting Block
1901   ///////////////////////////////////
1902   fendladdermountingblock = GetSSDMountingBlock();
1903   ///////////////////////////////////
1904   // End Ladder Mounting Block
1905   ///////////////////////////////////
1906   fendladdermountingblockclip = GetMountingBlockClip();
1907   ///////////////////////////////////
1908   // Ladder Support 
1909   ///////////////////////////////////
1910   TList* laddersupportlist = GetMountingBlockSupport(20);
1911   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1912   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1913   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1914   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1915   /////////////////////////////////////////////////////////////
1916   // Deallocating memory
1917   /////////////////////////////////////////////////////////////
1918   delete carbonfibersupportlist;
1919   delete carbonfiberlowersupportlist;
1920   delete ssdhybridcomponentslist;
1921   delete laddersupportlist;
1922   /////////////////////////////////////////////////////////////
1923   fBasicObjects = kTRUE;
1924 }
1925 /////////////////////////////////////////////////////////////////////////////////
1926 void AliITSv11GeometrySSD::SetSSDSensor(){
1927   ////////////////////////////////////////////////////////////////
1928   // Method generating SSD Sensors: it sets the private variables
1929   // fSSDSensor5, fSSDSensor6  
1930   ////////////////////////////////////////////////////////////////
1931   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1932   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1933   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1934                                                 0.5*ssdsensitivewidth,
1935                                                 0.5*fgkSSDSensorHeight,
1936                                                 0.5*ssdsensitivelength);
1937   TGeoVolume* ssdsensorsensitiveLay5 = 
1938         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1939   TGeoVolume* ssdsensorsensitiveLay6 = 
1940         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1941   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1942   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1943   TGeoBBox* ssdsensorinsensitiveshape[2];
1944   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1945                                                 0.5*fgkSSDSensorInsensitiveWidth,
1946                                                 0.5*fgkSSDSensorHeight,
1947                                                 0.5*fgkSSDSensorLength);
1948   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1949                                                 0.5*ssdsensitivewidth,
1950                                                 0.5*fgkSSDSensorHeight,
1951                                                 0.5*fgkSSDSensorInsensitiveWidth);
1952   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1953                                              "SSDSensorInsensitive2"};
1954   TGeoVolume* ssdsensorinsensitive[2];
1955   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1956       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1957                      fSSDSensorMedium);
1958       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1959   }
1960   /////////////////////////////////////////////////////////////
1961   // Virtual Volume containing SSD Sensor  
1962   /////////////////////////////////////////////////////////////
1963   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1964                                                                                              0.5*fgkSSDSensorWidth,
1965                                                                                              0.5*fgkSSDSensorHeight,
1966                                                                                              0.5*fgkSSDSensorLength);
1967   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1968                                                                                  fSSDAir);      
1969   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1970                                                                                  fSSDAir);      
1971   /////////////////////////////////////////////////////////////
1972   for(Int_t i=0; i<4; i++){ 
1973             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1974             ssdsensorinsensitive[1],i<2?1:2,
1975                         new TGeoTranslation(
1976                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1977       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1978                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1979       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1980             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1981             ssdsensorinsensitive[1],i<2?1:2,
1982                         new TGeoTranslation(
1983                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1984       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1985                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1986       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1987   }
1988     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1989     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1990 }
1991 ///////////////////////////////////////////////////////////////////////////////
1992 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1993   /////////////////////////////////////////////////////////////  
1994   // Method generating the Carbon Fiber Support   
1995   /////////////////////////////////////////////////////////////  
1996   const Int_t kvertexnumber = 4;
1997   const Int_t kshapesnumber = 2;
1998   TVector3** vertexposition[kshapesnumber];
1999   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
2000   Double_t carbonfibersupportxaxisEdgeproj = 
2001                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2002         *       TMath::DegToRad());
2003   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
2004                                  /                         fgkCarbonFiberSupportXAxisLength);
2005   /////////////////////
2006   //Vertex Positioning
2007   ////////////////////
2008   vertexposition[0][0] = new TVector3();
2009   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2010                                                                           fgkCarbonFiberSupportYAxisLength);
2011   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2012                                                                           carbonfibersupportxaxisEdgeproj
2013                                            *                      TMath::Tan(theta));
2014   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2015                                            -                      carbonfibersupportxaxisEdgeproj,
2016                                                                           fgkCarbonFiberSupportYAxisLength
2017                                            -                      vertexposition[0][2]->Y());
2018   ////////////////////////////////////////////////////
2019   //Setting the parameters for Isometry Transformation
2020   ////////////////////////////////////////////////////
2021   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2022                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2023                                                                  +      fgkCarbonFiberSupportWidth);
2024   Double_t* param = new Double_t[4]; 
2025   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2026   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2027                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2028                                                           (GetReflection(vertexposition[0][j],param))->Y());
2029   char* carbonfibersupportshapename[kshapesnumber] = 
2030                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2031   char* carbonfibersupportname[kshapesnumber] = 
2032                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2033   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2034   TGeoVolume* carbonfibersupport[kshapesnumber];
2035   TList* carbonfibersupportlist = new TList();
2036   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2037   Double_t carbonfibersupportheight = 
2038           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2039           *TMath::DegToRad());
2040   for(Int_t i = 0; i< kshapesnumber; i++){
2041    carbonfibersupportshape[i] = 
2042                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2043                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2044    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2045                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2046    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2047    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2048    }
2049   /////////////////////////////////////////////////////////////
2050   // Deallocating memory
2051   /////////////////////////////////////////////////////////////
2052   for(Int_t i=0; i< kshapesnumber; i++){
2053      for(Int_t j=0; j< kvertexnumber; j++)
2054            delete vertexposition[i][j];
2055        delete [] vertexposition[i];
2056   }
2057   delete [] param;
2058   /////////////////////////////////////////////////////////////
2059    return carbonfibersupportlist;
2060 }
2061 /////////////////////////////////////////////////////////////////////////////////
2062 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2063   /////////////////////////////////////////////////////////////
2064   // Method generating SSD Carbon Fiber Junction
2065   /////////////////////////////////////////////////////////////
2066   const Int_t kvertexnumber = 6;
2067   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2068   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2069                                                           *  TMath::DegToRad()),-1.,0.};
2070   TVector3* vertex[kvertexnumber];
2071   vertex[0] = new TVector3();
2072   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2073                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2074                         *                         TMath::DegToRad()),
2075                                                   fgkCarbonFiberJunctionEdge[0]
2076                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2077                         *                         TMath::DegToRad()));
2078   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2079                                                    fgkCarbonFiberJunctionEdge[1]);
2080   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2081   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2082   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2083   Double_t xvertexpoints[6], yvertexpoints[6];
2084   for(Int_t i=0; i<kvertexnumber; i++) 
2085           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2086   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2087   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2088   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2089   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2090                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2091   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2092   /////////////////////////////////////////////////////////////
2093   // Deallocating memory
2094   /////////////////////////////////////////////////////////////
2095   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2096   ///////////////////////////////////////////////////////////// 
2097   return carbonfiberjunction;
2098 }
2099 ////////////////////////////////////////////////////////////////////////////////
2100 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2101   /////////////////////////////////////////////////////////////
2102   // Method generating the Carbon Fiber Lower Support   
2103   /////////////////////////////////////////////////////////////  
2104   const Int_t kvertexnumber = 4;
2105   const Int_t kshapesnumber = 2;
2106   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2107                                                                 fgkCarbonFiberLowerSupportWidth};
2108   TVector3** vertexposition[kshapesnumber];
2109   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2110                                                  new TVector3*[kvertexnumber];
2111   //First Shape Vertex Positioning
2112   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2113   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2114                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2115   vertexposition[0][2] = new TVector3();
2116   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2117   //Second Shape Vertex Positioning
2118   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2119                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2120                                  /                              fgkCarbonFiberTriangleLength);
2121   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2122                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2123                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2124   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2125                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2126                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2127   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2128   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2129                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2130   char* carbonfiberlowersupportshapename[kshapesnumber] = 
2131                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2132   char* carbonfiberlowersupportname[kshapesnumber] = 
2133                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2134   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2135   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2136   TList* carbonfiberlowersupportlist = new TList();
2137   for(Int_t i = 0; i< kshapesnumber; i++){ 
2138         carbonfiberlowersupportshape[i] = 
2139                                                                 GetArbShape(vertexposition[i],width,
2140                                                                                         fgkCarbonFiberLowerSupportHeight,
2141                                                                                         carbonfiberlowersupportshapename[i]);
2142     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2143                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2144         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2145     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2146   }
2147   /////////////////////////////////////////////////////////////
2148   // Deallocating memory
2149   /////////////////////////////////////////////////////////////
2150   for(Int_t i=0; i< kshapesnumber; i++){
2151      for(Int_t j=0; j< kvertexnumber; j++)
2152            delete vertexposition[i][j];
2153        delete [] vertexposition[i];
2154   }
2155   /////////////////////////////////////////////////////////////
2156   return carbonfiberlowersupportlist;
2157 }
2158 ///////////////////////////////////////////////////////////////////////////////
2159 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2160                                                                  Double_t width, Double_t* thickness)const{
2161   /////////////////////////////////////////////////////////////
2162   // Method generating the Sensor Support   
2163   /////////////////////////////////////////////////////////////  
2164         const Int_t kvertexnumber = 6;
2165         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2166     TVector3* vertexposition[kvertexnumber];
2167         vertexposition[0] = new TVector3();     
2168         vertexposition[1] = new TVector3(0.0,length);   
2169         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2170         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2171         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2172         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2173         Double_t xvertexpoints[6], yvertexpoints[6];
2174         for(Int_t i=0; i<kvertexnumber; i++) 
2175                 xvertexpoints[i] = vertexposition[i]->X(), 
2176                 yvertexpoints[i] = vertexposition[i]->Y();
2177     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2178     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2179     ssdsensorsupportshape->DefineSection(1,0.5*width);
2180     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2181                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2182   /////////////////////////////////////////////////////////////
2183   // Deallocating memory
2184   /////////////////////////////////////////////////////////////
2185         for (Int_t i=0; i<kvertexnumber; i++)
2186                 delete vertexposition[i];
2187   /////////////////////////////////////////////////////////////
2188     return ssdsensorsupport;
2189 }
2190 ////////////////////////////////////////////////////////////////////////////////
2191 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2192   /////////////////////////////////////////////////////////////
2193   // Method generating the Cooling Tube Support
2194   /////////////////////////////////////////////////////////////
2195   if(nedges%2!=0) nedges--;     
2196   const Int_t kvertexnumber = nedges+5;
2197   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2198                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2199   Double_t angle = 90.+phi;
2200   Double_t psi = 90.-phi;
2201   ///////////////////////////////////////
2202   // Vertex Positioning for TGeoXTru
2203   ///////////////////////////////////////
2204   TVector3** vertexposition = new TVector3*[kvertexnumber];
2205   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2206                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2207   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2208                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2209   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2210                                                                    fgkCoolingTubeSupportRmax);
2211   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2212                                                                    fgkCoolingTubeSupportRmax);
2213   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2214                                                                     vertexposition[1]->Y());
2215   for(Int_t i=0; i<nedges; i++)
2216         vertexposition[i+5] = 
2217                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2218                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2219   ///////////////////////////////////////////////////////////////////////
2220   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2221   ///////////////////////////////////////////////////////////////////////
2222   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2223   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2224   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2225   for(Int_t i=0; i<kvertexnumber; i++){
2226         xvertexpoints[i] = vertexposition[i]->X();
2227         yvertexpoints[i] = vertexposition[i]->Y();
2228   } 
2229   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2230                                                                                         yvertexpoints);
2231   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2232   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2233   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2234                                                                           coolingtubesupportarcshape,
2235                                                                                   fSSDTubeHolderMedium);
2236   coolingtubesupportarc->SetLineColor(fColorG10);
2237   //////////////////////////////////////////////////////////////////////////
2238   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2239   //////////////////////////////////////////////////////////////////////////
2240   TGeoTubeSeg* coolingtubesupportsegshape = 
2241                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2242                                                                                         fgkCoolingTubeSupportRmax,
2243                                                                                         0.5*fgkCoolingTubeSupportWidth,
2244                                                                                         phi,360-phi);
2245   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2246                                                                                         coolingtubesupportsegshape,
2247                                                                                         fSSDTubeHolderMedium);
2248   coolingtubesupportseg->SetLineColor(fColorG10);
2249   //////////////////////////////////////////////////////////////////////////
2250   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2251   //////////////////////////////////////////////////////////////////////////
2252   Double_t* boxorigin = new Double_t[3];
2253   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2254   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2255   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2256                                                                                  0.5*fgkCoolingTubeSupportHeight,
2257                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2258   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2259                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2260   coolingtubesupportbox->SetLineColor(fColorG10);
2261   //////////////////////////////////////////////////////////////////////////
2262   // Cooling Tube for Cooling Tube Support 
2263   //////////////////////////////////////////////////////////////////////////
2264   TGeoXtru* coolingtubearcshape[2];
2265   coolingtubearcshape[0] = new TGeoXtru(2);     
2266   Double_t* xvert = new Double_t[nedges+2];
2267   Double_t* yvert = new Double_t[nedges+2];
2268   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2269   ////////////////////////////////////////
2270   // Positioning the vertices for TGeoXTru
2271   ////////////////////////////////////////
2272   xvert[0] = 0., yvert[0] = 0.;
2273   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2274   for(Int_t i=0; i< nedges; i++)
2275                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2276                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2277   ////////////////////////////////////////
2278   // Defining TGeoXTru PolyGone
2279   ////////////////////////////////////////
2280   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2281   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2282   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2283   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2284                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2285   TGeoVolume* coolingtubearc[2];
2286   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2287                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2288   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2289                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2290   coolingtubearc[0]->SetLineColor(fColorWater);
2291   coolingtubearc[1]->SetLineColor(fColorPhynox);
2292   ////////////////////////////////////////////
2293   // Defining TGeoTubeSeg Part of Cooling Tube
2294   ////////////////////////////////////////////
2295   TGeoTubeSeg* coolingtubesegshape[2];
2296   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2297                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2298   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2299                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2300   TGeoVolume* coolingtubeseg[2];
2301   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2302                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2303   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2304                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2305   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2306   coolingtubeseg[1]->SetLineColor(fColorWater);
2307   /////////////////////////////////////////////////////////////
2308   // Virtual Volume containing Cooling Tube Support  
2309   /////////////////////////////////////////////////////////////
2310   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2311   const Int_t kvirtualvertexnumber = 8;
2312   TVector3* virtualvertex[kvirtualvertexnumber];
2313    ////////////////////////////////////////
2314   // Positioning the vertices for TGeoXTru
2315   ////////////////////////////////////////
2316   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2317   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2318   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2319   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2320   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2321   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2322   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2323   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2324   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2325   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2326         xmothervertex[i] = virtualvertex[i]->X(),
2327         ymothervertex[i] = virtualvertex[i]->Y();
2328   ////////////////////////////////////////
2329   // Defining TGeoXTru PolyGone
2330   ////////////////////////////////////////
2331   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2332                                                                                                                                          ymothervertex);
2333   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2334   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2335   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2336                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2337   ////////////////////////////////////////
2338   // Positioning Volumes in Virtual Volume
2339   ////////////////////////////////////////
2340   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2341   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2342   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2343   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2344   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2345   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2346   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2347   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2348   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2349   /////////////////////////////////////////////////////////////
2350   // Deallocating memory
2351   /////////////////////////////////////////////////////////////
2352   delete [] vertexposition;
2353   delete xvertexpoints;
2354   delete yvertexpoints;
2355   delete xvert;
2356   delete yvert;
2357   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2358         delete virtualvertex[i];
2359   /////////////////////////////////////////////////////////////
2360         return virtualcoolingtubesupport;
2361 }
2362 /////////////////////////////////////////////////////////////////////////////////
2363 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2364   /////////////////////////////////////////////////////////////
2365   // Method generating List containing SSD Hybrid Components   
2366   /////////////////////////////////////////////////////////////
2367   TList* ssdhybridlist = new TList();
2368   const Int_t kssdstiffenernumber = 2;
2369   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2370                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2371                                                                   -    fgkSSDStiffenerWidth;
2372   Double_t ssdchipcablesradius[kssdstiffenernumber];
2373   for(Int_t i=0; i<kssdstiffenernumber; i++)
2374           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2375                                -  fgkSSDChipCablesHeight[0]
2376                                -  fgkSSDChipCablesHeight[1]);
2377   /////////////////////////////////////////////////////////////
2378   // Mother Volumes Containers 
2379   /////////////////////////////////////////////////////////////
2380   const Int_t kmothernumber = 2;
2381   const Int_t kmothervertexnumber = 12;
2382   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2383   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2384   ///////////////////////
2385   // Setting the vertices 
2386   ///////////////////////
2387   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2388   xmothervertex[0][1]  = xmothervertex[0][0]; 
2389   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2390   xmothervertex[0][3]  = xmothervertex[0][2];
2391   xmothervertex[0][4]  = xmothervertex[0][0];
2392   xmothervertex[0][5]  = xmothervertex[0][4];
2393   xmothervertex[0][6]  = -xmothervertex[0][0];
2394   xmothervertex[0][7]  = xmothervertex[0][6];
2395   xmothervertex[0][8]  = -xmothervertex[0][2];
2396   xmothervertex[0][9]  = xmothervertex[0][8];
2397   xmothervertex[0][10] = xmothervertex[0][7];
2398   xmothervertex[0][11] = xmothervertex[0][10];
2399   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2400   for(Int_t i = 0; i<kmothernumber; i++){
2401       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2402                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2403       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2404       ymothervertex[i][2]  = ymothervertex[i][1];
2405       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2406       ymothervertex[i][4]  = ymothervertex[i][3];
2407       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2408       ymothervertex[i][6]  = ymothervertex[i][5];
2409       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2410       ymothervertex[i][8]  = ymothervertex[i][7];
2411       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2412       ymothervertex[i][10] = ymothervertex[i][9];
2413       ymothervertex[i][11] = ymothervertex[i][0];
2414   }
2415   TGeoXtru* ssdhybridmothershape[kmothernumber];
2416 //  TGeoVolume* ssdhybridmother[kmothernumber];
2417   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2418   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2419   for(Int_t i=0; i<kmothernumber; i++){
2420       ssdhybridmothershape[i] = new TGeoXtru(2);
2421       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2422                                           ymothervertex[i]);
2423       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2424                                                -fgkSSDChipCablesHeight[i+2]);
2425       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2426 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2427 //                                          fSSDAir);
2428       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2429    }   
2430   /////////////////////////////////////////////////////////////
2431   // SSD Stiffener   
2432   /////////////////////////////////////////////////////////////
2433   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2434                                              0.5*fgkSSDStiffenerLength,
2435                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2436                                              0.5*fgkSSDStiffenerHeight);
2437   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2438                                             fSSDStiffenerMedium);  
2439   ssdstiffener->SetLineColor(fColorStiffener); 
2440   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2441   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2442       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2443   /////////////////////////////////////////////////////////////
2444   // SSD Chip System    
2445   /////////////////////////////////////////////////////////////
2446   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2447   Double_t ssdchipseparation = fgkSSDSensorLength
2448                              - 2.*fgkSSDModuleStiffenerPosition[1]
2449                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2450                              - 0.5*fgkSSDChipWidth);
2451   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2452                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2453   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2454                                       - 0.5*ssdchipsystemlength,
2455                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2456                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2457 ////////////////////////////
2458 // Capacitor 0603-2200 nF
2459 ///////////////////////////
2460   const Int_t knapacitor0603number = 5;
2461   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2462                                                                                          0.5*fgkSSDCapacitor0603Length,
2463                                                                                          0.5*(fgkSSDCapacitor0603Width),
2464                                                                                          0.5*fgkSSDCapacitor0603Height);
2465   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2466                                              fSSDStiffener0603CapacitorMedium); 
2467   capacitor0603->SetLineColor(fColorAl);
2468   for(Int_t i=0; i<kmothernumber; i++){
2469       for(Int_t j=0; j<kssdstiffenernumber; j++){
2470             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2471             for(Int_t k=1; k<knapacitor0603number+1; k++){
2472                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2473                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2474                                            j*ssdstiffenerseparation
2475                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2476                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2477                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2478             }
2479       } 
2480       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2481       ssdhybridlist->Add(ssdhybridmother[i]);
2482   }    
2483 /////////////////////////////////////////////////////////////
2484 // Mother Volume Containing Capacitor Part 
2485 /////////////////////////////////////////////////////////////
2486   const Int_t kcapacitormothernumber = 8;
2487   Double_t xcapacitorvertex[kcapacitormothernumber];
2488   Double_t ycapacitorvertex[kcapacitormothernumber];  
2489   ///////////////////////
2490   // Setting the vertices 
2491   ///////////////////////
2492   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2493   xcapacitorvertex[1] = xcapacitorvertex[0];   
2494   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2495   xcapacitorvertex[3] = xcapacitorvertex[2];   
2496   xcapacitorvertex[4] = xcapacitorvertex[0];   
2497   xcapacitorvertex[5] = xcapacitorvertex[0];   
2498   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2499   xcapacitorvertex[7] = xcapacitorvertex[6];   
2500   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2501   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2502   ycapacitorvertex[2] = ycapacitorvertex[1];   
2503   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2504   ycapacitorvertex[4] = ycapacitorvertex[3];   
2505   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2506   ycapacitorvertex[6] = ycapacitorvertex[5];   
2507   ycapacitorvertex[7] = ycapacitorvertex[0];   
2508   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2509   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2510                                               ycapacitorvertex);
2511   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2512   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2513 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2514 //                                          fSSDAir);
2515   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2516 ////////////////////////////
2517 // Connector 
2518 ///////////////////////////
2519   const Int_t kssdconnectornumber = 2;
2520   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2521   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2522   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2523                                    +  fgkSSDConnectorAlHeight};  
2524   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2525   TGeoVolume* ssdconnector[kssdconnectornumber];
2526   for(Int_t i=0; i<kssdconnectornumber; i++){
2527       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2528                                           0.5*fgkSSDConnectorWidth,
2529                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2530                            +              i*fgkSSDConnectorNiHeight),
2531                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2532       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2533                                        i==0 ? fSSDAlTraceFlexMedium 
2534                                             : fSSDStiffenerConnectorMedium);      
2535       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2536   }
2537   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2538   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2539                        +  fgkSSDConnectorPosition[0]
2540                        -  fgkSSDConnectorSeparation
2541                        -  1.5*fgkSSDConnectorLength,
2542                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2543                        -  fgkSSDConnectorPosition[1]
2544                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2545   ssdconnectortrans[1] = new TGeoTranslation(
2546                        -  ssdstiffenershape->GetDX()
2547                        +  fgkSSDConnectorPosition[0]
2548                        -  0.5*fgkSSDConnectorLength,
2549                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2550                        -  fgkSSDConnectorPosition[1]
2551                        -  ssdconnectorshape[0]->GetDY(),0.0);
2552   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2553                        -  fgkSSDConnectorPosition[0]
2554                        +  fgkSSDConnectorSeparation
2555                        +  1.5*fgkSSDConnectorLength,
2556                           -(ssdstiffenershape->GetDY()
2557                        -  fgkSSDConnectorPosition[1]
2558                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2559   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2560                        -  fgkSSDConnectorPosition[0]
2561                        +  0.5*fgkSSDConnectorLength,
2562                           -(ssdstiffenershape->GetDY()
2563                        -  fgkSSDConnectorPosition[1]
2564                        -  ssdconnectorshape[0]->GetDY()),0.0);
2565   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2566       for(Int_t j=0; j<kssdconnectornumber; j++)
2567             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2568 ////////////////////////////
2569 // Capacitor 1812-330 nF
2570 /////////////////////////// 
2571   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2572   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2573                                                                                          0.5*fgkSSDCapacitor1812Length,
2574                                                                                          0.5*fgkSSDCapacitor1812Width,
2575                                                                                          0.5*fgkSSDCapacitor1812Height,
2576             ssdcapacitor1812origin);
2577   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2578                                              fSSDStiffener1812CapacitorMedium); 
2579   capacitor1812->SetLineColor(fColorAl);
2580   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2581                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2582                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2583   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2584 ////////////////////////////
2585 //Hybrid Wire
2586 ////////////////////////////
2587   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2588                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2589                                  - fgkSSDConnectorSeparation;
2590   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2591                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2592   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2593                                          + TMath::Power(wirey,2));
2594   Double_t wireangle = TMath::ATan(wirex/wirey);
2595   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2596                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2597   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2598                                              fSSDStiffenerHybridWireMedium); 
2599   hybridwire->SetLineColor(fColorPhynox);
2600   TGeoCombiTrans* hybridwirecombitrans[2];
2601   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2602                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2603                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2604                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2605                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2606                                    ssdstiffenershape->GetDZ()
2607                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2608                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2609   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2610                             0.0,
2611                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2612                             0.0,        
2613                             new TGeoRotation("HybridWireRot2",
2614                           - wireangle*TMath::RadToDeg(),0.,0.));
2615   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2616   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2617   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2618   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2619   ssdhybridlist->Add(ssdhybridcapacitormother);
2620   /////////////////////////////////////////////////////////////
2621   // Deallocating memory
2622   /////////////////////////////////////////////////////////////
2623   delete hybridwirecombitrans[0];
2624   delete hybridwirecombitrans[1];
2625   delete ssdchipsystemlist;
2626   return ssdhybridlist;
2627   /////////////////////////////////////////////////////////////
2628 }
2629 ///////////////////////////////////////////////////////////////////////////////
2630 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2631   /////////////////////////////////////////////////////////////
2632   // SSD Cooling Block System
2633   /////////////////////////////////////////////////////////////
2634   // SSD Cooling Block and Cooling Tube Transformations
2635   /////////////////////////////////////////////////////////////
2636   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2637   localcoolingblockrot->SetAngles(0.,90.,0.);
2638   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2639   TVector3* coolingblocktransvector;
2640   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2641                                                                 + fgkSSDCoolingBlockLength,
2642                                                                   fgkSSDSensorLength
2643                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2644                                                                 - fgkSSDCoolingBlockWidth);
2645   const Int_t kcoolingblocktransnumber = 2;
2646   const Int_t kcoolingblocknumber = 4;
2647   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2648   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2649   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2650   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2651   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2652   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2653                                         0.5*fgkSSDCoolingBlockWidth,
2654                                         fgkSSDCoolingBlockHoleCenter);
2655   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2656   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2657   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2658     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2659       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2660                                              j*coolingblocktransvector->Y(),
2661                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2662                                                     + fgkCoolingTubeRmax));
2663       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2664       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2665     }
2666   }
2667   /////////////////////////////////////////////////////////////
2668   // Virtual Volume containing CoolingBlock System   
2669   /////////////////////////////////////////////////////////////
2670   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2671   const Int_t kmothervertexnumber = 16;  
2672   Double_t xmothervertex[kmothervertexnumber];
2673   Double_t ymothervertex[kmothervertexnumber];
2674   ///////////////////////
2675   // Setting the vertices 
2676   ///////////////////////fgkCoolingTubeSupportRmax
2677   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2678   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2679                                    + fgkSSDCoolingBlockWidth;
2680   xmothervertex[2] = coolingblocktransvector->X()
2681                                    + fgkSSDCoolingBlockLength
2682                                    + 4*coolingtubedistance;
2683   ymothervertex[2] = ymothervertex[1];
2684   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2685   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2686   ymothervertex[4] = ymothervertex[0];
2687   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2688   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2689   ymothervertex[6] = ymothervertex[5]; 
2690   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2691                                    - fgkSSDCoolingBlockWidth; 
2692   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2693   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2694                                    - coolingtubedistance;
2695   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2696   ymothervertex[10] = ymothervertex[9];
2697   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2698   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2699   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2700   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2701   ymothervertex[14] = ymothervertex[13];
2702   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2703   //////////////////////////////////////////////////////////
2704   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2705                                                                         xmothervertex,ymothervertex);
2706   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2707                                                                                            + fgkCoolingTubeRmax));
2708   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2709                                                                                            + fgkCoolingTubeRmax));
2710   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2711 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2712 //                                                        coolingsystemothershape,fSSDAir);
2713   /////////////////////////////////////////////////////////////
2714   // SSD Cooling Tube Part 
2715   /////////////////////////////////////////////////////////////
2716   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2717   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2718                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2719   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2720                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2721   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2722   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2723                                                                         fSSDCoolingTubePhynox);
2724   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2725                                                                         fSSDCoolingTubeWater);
2726   coolingtube[0]->SetLineColor(fColorPhynox);
2727   coolingtube[1]->SetLineColor(fColorWater);
2728   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2729   /////////////////////////////////////////////////////////////
2730   // Adding Cooling block to mother volume
2731   /////////////////////////////////////////////////////////////
2732    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2733         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2734         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2735         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2736   }
2737   /////////////////////////////////////////////////////////////
2738   // Deallocating memory
2739   /////////////////////////////////////////////////////////////
2740         delete coolingblocktransvector;
2741         delete localcoolingblockrot;
2742         delete localcoolingtubetrans;
2743         delete localcoolingtuberot;
2744   /////////////////////////////////////////////////////////////
2745   // Checking overlaps  
2746   /////////////////////////////////////////////////////////////
2747         //coolingsystemother->CheckOverlaps(0.01);
2748   /////////////////////////////////////////////////////////////
2749         return coolingsystemother;
2750 }
2751 /////////////////////////////////////////////////////////////////////////////////
2752 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2753   /////////////////////////////////////////////////////////////
2754   // SSD Flex
2755   /////////////////////////////////////////////////////////////
2756   const Int_t kssdflexlayernumber = 2;
2757   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2758   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2759   const Int_t kmothervertexnumber = 17; 
2760   Double_t xmothervertex[kmothervertexnumber];
2761   Double_t ymothervertex[kmothervertexnumber];
2762   /////////////////////////////////////////////
2763   // Auxiliary variables for vertex positioning
2764   /////////////////////////////////////////////
2765   const Int_t kssdflexboxnumber = 5;
2766   Double_t ssdflexboxlength[kssdflexboxnumber];
2767   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2768                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2769                                           *     fgkSSDChipSeparationLength
2770                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2771                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2772   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2773   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2774                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2775   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2776   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2777                                           -     ssdflexboxlength[1];
2778   Double_t ssdflexboxwidth[kssdflexboxnumber];
2779   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2780   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2781   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2782   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2783   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2784   ///////////////////////
2785   // Setting the vertices 
2786   ///////////////////////
2787   xmothervertex[0]  = 0.0;
2788   xmothervertex[1]  = xmothervertex[0];
2789   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2790   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2791                                         + ssdflexboxlength[4];
2792   xmothervertex[4]  = xmothervertex[3];
2793   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2794   xmothervertex[6]  = xmothervertex[5];
2795   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2796   xmothervertex[8]  = xmothervertex[7];
2797   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2798   xmothervertex[10] = xmothervertex[9]; 
2799   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2800   xmothervertex[12] = xmothervertex[11];
2801   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2802   xmothervertex[14] = xmothervertex[13];
2803   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2804   xmothervertex[16] = xmothervertex[15];
2805   ymothervertex[0]  = 0.0;
2806   ymothervertex[1]  = fgkSSDFlexWidth[1];
2807   ymothervertex[2]  = fgkSSDFlexWidth[0];
2808   ymothervertex[3]  = ymothervertex[2];
2809   ymothervertex[4]  = ymothervertex[0];
2810   ymothervertex[5]  = ymothervertex[4];
2811   ymothervertex[6]  = ssdflexboxwidth[2];
2812   ymothervertex[7]  = ymothervertex[6];
2813   ymothervertex[8]  = ymothervertex[0];
2814   ymothervertex[9]  = ymothervertex[8];
2815   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2816   ymothervertex[11] = ymothervertex[10];
2817   ymothervertex[12] = ymothervertex[0];
2818   ymothervertex[13] = ymothervertex[12];
2819   ymothervertex[14] = ymothervertex[7];
2820   ymothervertex[15] = ymothervertex[14];
2821   ymothervertex[16] = ymothervertex[0];
2822   /////////////////////////////////////////////////////////////
2823   // First Mother Volume containing SSDFlex
2824   /////////////////////////////////////////////////////////////
2825   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2826   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2827                                                                     ymothervertex);
2828   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2829   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2830   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2831 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2832 //                                                                                       fSSDAir);
2833   /////////////////////////////////////////////////////////////
2834   // SSDFlex Layer Shapes
2835   /////////////////////////////////////////////////////////////
2836   for(Int_t i=0; i<kssdflexlayernumber; i++){
2837         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2838                                                                    ymothervertex);
2839     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2840         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2841   }
2842   /////////////////////////////////////
2843   // Setting Layers into Mother Volume
2844   /////////////////////////////////////
2845   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2846   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2847                                                                                                  fSSDKaptonFlexMedium};
2848   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2849                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2850   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2851   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2852   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2853         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2854                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2855                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2856         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2857     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2858                                          +                                         fgkSSDFlexHeight[1])); 
2859     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2860   }
2861   return ssdflexmother;
2862 }
2863 /////////////////////////////////////////////////////////////////////////////////
2864 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2865   /////////////////////////////////////////////////////////////
2866   // Method generating SSD End Flex   
2867   /////////////////////////////////////////
2868   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2869                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2870   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2871                                                 * TMath::DegToRad()*ssdflexradiusmax
2872                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2873                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2874   const Int_t knedges = 20;  
2875   const Int_t karcnumber = 2;
2876   TVector3* vertexposition[karcnumber*(knedges+1)];
2877   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2878   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2879   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2880   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2881                                                                                  - 90.0*TMath::DegToRad()};
2882   TVector3* referencetrans[karcnumber];
2883   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2884                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2885                                                                    radius[0]);
2886   referencetrans[1] = new TVector3(referencetrans[0]->X()
2887                                         +              fgkSSDFlexLength[2],
2888      -              fgkSSDStiffenerHeight);
2889 for(Int_t i=0; i<karcnumber; i++){
2890         for(Int_t j=0; j<knedges+1; j++){
2891                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2892                                                                                                radius[i]*SinD(angle[i]));
2893                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2894         }       
2895   }
2896   ///////////////////////
2897   // Setting the vertices 
2898   ///////////////////////
2899   const Int_t kendflexlayernumber = 4;
2900   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2901   TVector3** vertex[kendflexlayernumber];
2902   for(Int_t i=0; i<kendflexlayernumber; i++) 
2903                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2904   TVector3* transvector[kendflexlayernumber+1];
2905   TVector3* deltatransvector = new TVector3();  
2906   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2907   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2908                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2909   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2910         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2911                                         *                 CosD(fgkSSDFlexAngle),
2912                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2913                                         *         SinD(fgkSSDFlexAngle),0.0);   
2914         *transvector[i] = *transvector[i-1]+*deltatransvector;
2915   }
2916   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2917   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2918   for(Int_t i=0; i<karcnumber; i++){
2919         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2920                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2921                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2922                                               /radius[i];
2923         }
2924   }
2925   for(Int_t i=0; i<kendflexlayernumber; i++){
2926         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2927         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2928         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2929                 if(j<(knedges+1)){
2930                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2931                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2932                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2933                         *vertex[i][j+2] += *referencetrans[0];
2934                         vertex[i][4*(knedges+1)-j+1] = 
2935                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2936                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2937                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2938                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2939                 }
2940                 else{
2941                 
2942                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2943                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2944                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2945                         *vertex[i][j+2] += *referencetrans[1];
2946                         vertex[i][4*(knedges+1)-j+1] = 
2947                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2948                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2949                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2950                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2951            }
2952         }
2953   }
2954   /////////////////////////////////////////////////////////////
2955   // First Mother Volume containing SSDEndFlex
2956   /////////////////////////////////////////////////////////////
2957   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2958   Double_t xmothervertex[kendflexvertexnumber];
2959   Double_t ymothervertex[kendflexvertexnumber];
2960   xmothervertex[0] = vertex[0][0]->X(); 
2961   ymothervertex[0] = vertex[0][0]->Y();
2962   for(Int_t i=1; i<kendflexvertexnumber; i++){
2963         if(i<2*(knedges+1)+2){
2964                 xmothervertex[i] = vertex[3][i]->X();
2965                 ymothervertex[i] = vertex[3][i]->Y();
2966         }
2967         else{
2968                 xmothervertex[i] = vertex[0][i]->X();
2969                 ymothervertex[i] = vertex[0][i]->Y();
2970         }
2971   }
2972   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2973                                                                            xmothervertex,ymothervertex);
2974   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2975   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2976   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2977                                                                  ssdendflexmothershape,fSSDAir);        
2978   //////////////////////////////////////
2979   // End Flex TGeoXtru Layer Definition 
2980   //////////////////////////////////////
2981   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2982   TGeoVolume* ssdendflex[kendflexlayernumber];
2983   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2984   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2985   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2986   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2987   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2988                                                                                                         fSSDKaptonFlexMedium};
2989   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2990                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2991   for(Int_t i=0; i<kendflexlayernumber; i++){
2992         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2993                 xvertex[i][j] = vertex[i][j]->X();
2994                 yvertex[i][j] = vertex[i][j]->Y();
2995         }
2996   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2997   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2998   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2999   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
3000                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
3001   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
3002   ssdendflexmother->AddNode(ssdendflex[i],1);
3003   }
3004   /////////////////////////////////////////////////////////////
3005   // Deallocating memory
3006   /////////////////////////////////////////////////////////////
3007   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3008   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3009   for(Int_t i=0; i<kendflexlayernumber; i++){
3010         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3011         delete [] vertex[i];
3012   }
3013   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3014   delete deltatransvector;
3015   /////////////////////////////////////////////////////////////
3016   //ssdendflexmother->CheckOverlaps(0.01);
3017   return ssdendflexmother;
3018 }
3019 ///////////////////////////////////////////////////////////////////////////////
3020 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3021   /////////////////////////////////////////////////////////////
3022   // Method generating the Mounting Block
3023   /////////////////////////////////////////////////////////////  
3024   const Int_t kvertexnumber = 8;
3025   Double_t xvertex[kvertexnumber];
3026   Double_t yvertex[kvertexnumber];
3027   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3028   xvertex[1] = xvertex[0];
3029   xvertex[2] = -xvertex[0];
3030   xvertex[3] = xvertex[2];
3031   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3032                          -                                 fgkSSDMountingBlockLength[2]);
3033   xvertex[5] = xvertex[4];
3034   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3035                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3036                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3037   xvertex[7] = xvertex[6];
3038   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3039                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3040                          -  fgkSSDModuleVerticalDisalignment;
3041   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3042   yvertex[2] = yvertex[1]; 
3043   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3044   yvertex[4] = yvertex[3];
3045   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3046                          - fgkSSDMountingBlockHeight[0];
3047   yvertex[6] = yvertex[5];
3048   yvertex[7] = yvertex[0];
3049   ///////////////////////////////////////////////////////////////////////
3050   // TGeoXTru Volume definition for Mounting Block Part
3051   ///////////////////////////////////////////////////////////////////////
3052   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3053   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3054   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3055   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3056   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3057                                                                           ssdmountingblockshape,
3058                                                                                   fSSDMountingBlockMedium);
3059   ssdmountingblock->SetLineColor(fColorG10);
3060   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3061   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3062   TGeoRotation* mountingblockrot = new TGeoRotation();
3063   mountingblockrot->SetAngles(90.,180.,-90.);
3064   mountingblockcombitrans->SetRotation(*mountingblockrot);
3065   /////////////////////////////////////////////////////////////
3066   // Generating the Mounting Block Screw Vertices 
3067   /////////////////////////////////////////////////////////////  
3068   const Int_t kscrewvertexnumber = 15;
3069   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3070                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3071                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3072                                  * TMath::RadToDeg();
3073   Double_t phi0 = 90.+alpha;
3074   Double_t phi = 270.-2*alpha;
3075   Double_t deltaphi = phi/kscrewvertexnumber;   
3076   TVector3* screwvertex[kscrewvertexnumber+1];
3077   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3078         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3079                                    *CosD(phi0+i*deltaphi),
3080                                    fgkSSDMountingBlockScrewHoleRadius[0]
3081                                    *SinD(phi0+i*deltaphi));
3082   Double_t xscrewvertex[kscrewvertexnumber+6];
3083   Double_t yscrewvertex[kscrewvertexnumber+6];
3084   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3085   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3086                                   -               fgkSSDMountingBlockScrewHoleEdge);
3087   xscrewvertex[1] = xscrewvertex[0];
3088   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3089   xscrewvertex[2] = screwvertex[0]->X();
3090   yscrewvertex[2] = yscrewvertex[1];
3091   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3092         xscrewvertex[i+3] = screwvertex[i]->X();        
3093         yscrewvertex[i+3] = screwvertex[i]->Y();        
3094   } 
3095   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3096   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3097   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3098   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3099   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3100   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3101   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3102   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3103                                                         +                                  fgkSSDMountingBlockHeight[2]);
3104   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3105                                                                                 ssdmountingblockscrewshape,
3106                                                                                             fSSDMountingBlockMedium);
3107   ssdmountingblockscrew->SetLineColor(fColorG10);
3108   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3109   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3110   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3111                                                                         -                                yscrewvertex[1],
3112                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3113                                                                         -                                fgkSSDMountingBlockHeight[2]
3114                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3115                                                                         +                                fgkSSDMountingBlockHeight[2]
3116                                                                         -                                yvertex[0]));
3117   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3118                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3119                                                                                                                  yscrewvertex[1]
3120                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3121                                                                                                          +fgkSSDMountingBlockHeight[2]
3122                                                                                                          -yvertex[0]));
3123   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3124                                                                                                           yscrewvertex[1],
3125                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3126                                                                         +                                 fgkSSDMountingBlockHeight[2]
3127                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3128                                                                         +                                 fgkSSDMountingBlockHeight[2]
3129                                                                         -                                 yvertex[0]));
3130   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3131                                                                                                          yscrewvertex[1],
3132                                                                         -                                yscrewvertex[1]
3133                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3134                                                                         +                                fgkSSDMountingBlockHeight[2]
3135                                                                         -                                yvertex[0]));
3136   TGeoRotation* ssdmountingblockscrewrot[4];
3137   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3138         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3139     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3140     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3141   for(Int_t i=1; i<4; i++) 
3142         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3143   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3144   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3145   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3146   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3147                                                          +                                xvertex[0],yscrewvertex[1]
3148                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3149                                                          +                                fgkSSDMountingBlockHeight[2]
3150                                                          -                                yvertex[0]),0.);      
3151   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3152   for(Int_t i=0; i<4; i++){
3153         ssdmountingblockscrewmatrix[i] = 
3154                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3155         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3156   }
3157   ///////////////////////////////////////////////////////////////////////
3158   // TGeoXtru for Mother Volume 
3159   ///////////////////////////////////////////////////////////////////////
3160   const Int_t kvertexmothernumber = 12;
3161   Double_t xmothervertex[kvertexmothernumber];
3162   Double_t ymothervertex[kvertexmothernumber];
3163   for(Int_t i=0; i<6; i++){
3164         xmothervertex[i] = xvertex[i];
3165         ymothervertex[i] = yvertex[i];
3166   } 
3167   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3168   ymothervertex[6]  = ymothervertex[5];
3169   xmothervertex[7]  = xmothervertex[6];
3170   ymothervertex[7]  = ymothervertex[4];
3171   xmothervertex[8]  = xmothervertex[7]
3172                                         + 0.5*(fgkSSDMountingBlockLength[1]
3173                                         -          fgkSSDMountingBlockLength[2]);
3174   ymothervertex[8]  = ymothervertex[4];
3175   xmothervertex[9]  = xmothervertex[8];
3176   ymothervertex[9]  = ymothervertex[2];
3177   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3178   ymothervertex[10] = ymothervertex[1];
3179   xmothervertex[11] = xmothervertex[10];
3180   ymothervertex[11] = ymothervertex[0];  
3181   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3182   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3183   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3184   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3185   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3186                                                                           ssdmountingblockmothershape,
3187                                                                                   fSSDAir);
3188   /////////////////////////////////////////////////////////////
3189   // Placing the Volumes into Mother Volume 
3190   /////////////////////////////////////////////////////////////
3191   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3192   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3193   for(Int_t i=0; i<4; i++) 
3194         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3195                                                                         ssdmountingblockscrewmatrix[i]);
3196   /////////////////////////////////////////////////////////////
3197   // Deallocating memory
3198   /////////////////////////////////////////////////////////////
3199   delete mountingblockrot;
3200   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3201   delete ssdmountingblockglobalrot; 
3202   delete ssdmountingblockglobaltrans; 
3203   /////////////////////////////////////////////////////////////
3204   return ssdmountingblockmother;
3205 }
3206 ///////////////////////////////////////////////////////////////////////////////
3207  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3208   /////////////////////////////////////////////////////////////
3209   // Method generating the Mounting Block Clip 
3210   /////////////////////////////////////////////////////////////  
3211   const Int_t kmothervertexnumber = 10;
3212   Double_t xmothervertex[kmothervertexnumber];
3213   Double_t ymothervertex[kmothervertexnumber];
3214   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3215                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3216   xmothervertex[1] = xmothervertex[0];
3217   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3218                                    - fgkMountingBlockClibScrewRadius);
3219   xmothervertex[3] = xmothervertex[2]; 
3220   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3221   xmothervertex[5] = xmothervertex[4]; 
3222   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3223   xmothervertex[7] = xmothervertex[6]; 
3224   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3225   xmothervertex[9] = xmothervertex[8]; 
3226   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3227                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3228                                    - fgkSSDModuleVerticalDisalignment;
3229   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3230   ymothervertex[2] = ymothervertex[1];
3231   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3232                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3233                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3234   ymothervertex[4] = ymothervertex[3];
3235   ymothervertex[5] = ymothervertex[2];
3236   ymothervertex[6] = ymothervertex[5];
3237   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3238   ymothervertex[8] = ymothervertex[7];
3239   ymothervertex[9] = ymothervertex[0];
3240   ///////////////////////////////////////////////////////////////////////
3241   // TGeoXTru Volume definition for Mounting Block Clip Part
3242   ///////////////////////////////////////////////////////////////////////
3243   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3244   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3245   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3246   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3247   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3248                                                                           ssdmountingblockclipshape,fSSDAir);
3249   ssdmountingblockclip->SetLineColor(4);
3250   ///////////////////////////////////////////////////////////////////////
3251   // TGeoXTru Volume definition for Clip 
3252   ///////////////////////////////////////////////////////////////////////
3253   const Int_t kclipvertexnumber = 6;
3254   Double_t xclipvertex[kclipvertexnumber];
3255   Double_t yclipvertex[kclipvertexnumber];
3256   xclipvertex[0] = xmothervertex[0];
3257   xclipvertex[1] = xclipvertex[0];
3258   xclipvertex[2] = xmothervertex[6];
3259   xclipvertex[3] = xclipvertex[2];
3260   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3261   xclipvertex[5] = xclipvertex[4];
3262   yclipvertex[0] = ymothervertex[0];
3263   yclipvertex[1] = ymothervertex[1];
3264   yclipvertex[2] = yclipvertex[1];
3265   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3266   yclipvertex[4] = yclipvertex[3];
3267   yclipvertex[5] = yclipvertex[0];
3268   TGeoXtru* clipshape = new TGeoXtru(2);
3269   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3270   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3271   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3272                                                          +   fgkMountingBlockClibWidth);
3273   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3274   clip->SetLineColor(18);
3275   ///////////////////////////////////////////////////////////////////////
3276   // Ladder Support Piece  
3277   ///////////////////////////////////////////////////////////////////////
3278   const Int_t ksupportvertexnumber = 4;
3279   Double_t xsupportvertex[ksupportvertexnumber];
3280   Double_t ysupportvertex[ksupportvertexnumber];
3281   xsupportvertex[0] = xclipvertex[5];
3282   xsupportvertex[1] = xsupportvertex[0];
3283   xsupportvertex[2] = xmothervertex[9];
3284   xsupportvertex[3] = xsupportvertex[2];
3285   ysupportvertex[0] = yclipvertex[0];
3286   ysupportvertex[1] = yclipvertex[3];
3287   ysupportvertex[2] = ysupportvertex[1];
3288   ysupportvertex[3] = ysupportvertex[0];
3289   TGeoXtru* supportshape = new TGeoXtru(2);
3290   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3291   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3292   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3293   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3294   support->SetLineColor(9);
3295   ///////////////////////////////////////////////////////////////////////
3296   // TGeoXTru Volume definition for Screw   
3297   ///////////////////////////////////////////////////////////////////////
3298   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3299                                                 0.5*fgkMountingBlockClibScrewRadius};
3300   Int_t edgesnumber[2] = {50,6};
3301   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3302                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3303   TGeoXtru* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3304   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3305   clipscrew->SetLineColor(12);
3306   TGeoRotation* screwrot = new TGeoRotation();
3307   screwrot->SetAngles(0.,90.,0.);
3308   TGeoTranslation* screwtrans = new TGeoTranslation();
3309   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3310                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3311                                                          0.5*fgkSSDMountingBlockWidth+
3312                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3313   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3314   ///////////////////////////////////////////////////////////////////////
3315   // Placing the Volumes
3316   ///////////////////////////////////////////////////////////////////////
3317   ssdmountingblockclip->AddNode(clip,1);
3318   ssdmountingblockclip->AddNode(support,1);
3319   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3320   /////////////////////////////////////////////////////////////
3321   // Deallocating memory
3322   /////////////////////////////////////////////////////////////  
3323   delete screwtrans;
3324   delete screwrot;
3325   /////////////////////////////////////////////////////////////
3326   return ssdmountingblockclip;
3327 }
3328 ///////////////////////////////////////////////////////////////////////////////
3329 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3330   /////////////////////////////////////////////////////////////
3331   // Method generating the Cooling Tube 
3332   /////////////////////////////////////////////////////////////  
3333    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3334    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3335                                                                                                 new     TGeoTube*[2];
3336    // Ladder Cooling Tubes
3337    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3338                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3339                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth));
3340    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3341                                                                                  coolingtubeshape[0][0]->GetDz());
3342    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3343                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3344                                                   -                                       fgkSSDSensorOverlap));
3345    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3346                                                                                  coolingtubeshape[1][0]->GetDz());
3347    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3348                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]));
3349    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3350                                                                                  coolingtubeshape[2][0]->GetDz());
3351    // End Ladder Cooling Tubes  
3352    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3353    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3354    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3355    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3356                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3357                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3358    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3359                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3360    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3361                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3362                                                   +                     fgkendladdercoolingsupportdistance[1]
3363                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3364    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3365                                                                         endladdercoolingtubeshape[1][0]->GetDz());
3366    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3367                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3368                                                   -                     fgkEndLadderMountingBlockPosition[0]
3369                                                   -                     fgkendladdercoolingsupportdistance[1]           
3370                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3371    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3372                                                                         endladdercoolingtubeshape[2][0]->GetDz());
3373    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3374                                                           0.50 * (fgkMountingBlockToSensorSupport
3375                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3376                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3377                                                         +                 fgkSSDSensorOverlap
3378                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3379                                                         -                 fgkendladdercoolingsupportdistance[2]
3380                                                         -                 fgkEndLadderMountingBlockPosition[1]
3381                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3382    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3383                                                                         endladdercoolingtubeshape[3][0]->GetDz());
3384    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3385                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3386    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3387                                                                         endladdercoolingtubeshape[4][0]->GetDz());
3388    // Ladder Cooling Tubes
3389    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3390    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3391                                                                                          new TGeoVolume*[2];
3392    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3393                                                                           fSSDCoolingTubePhynox);
3394    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3395                                                                           fSSDCoolingTubeWater);
3396    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3397                                                                           fSSDCoolingTubePhynox);
3398    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3399                                                                           fSSDCoolingTubeWater);
3400    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3401                                                                           fSSDCoolingTubePhynox);
3402    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3403                                                                           fSSDCoolingTubeWater);
3404    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3405         coolingtube[i][0]->SetLineColor(fColorPhynox);
3406         coolingtube[i][1]->SetLineColor(fColorWater);
3407    }
3408    // End Ladder Cooling Tubes  
3409    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3410    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3411    endladdercoolingtube[i] = new TGeoVolume*[2];
3412    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3413                                                                 endladdercoolingtubeshape[0][0],
3414                                                                 fSSDCoolingTubePhynox);
3415    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3416                                                                 endladdercoolingtubeshape[0][1],
3417                                                                 fSSDCoolingTubeWater);
3418    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3419                                                                 endladdercoolingtubeshape[1][0],
3420                                                                 fSSDCoolingTubePhynox);
3421    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3422                                                                 endladdercoolingtubeshape[1][1],
3423                                                                 fSSDCoolingTubeWater);
3424    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3425                                                                 endladdercoolingtubeshape[2][0],
3426                                                                 fSSDCoolingTubePhynox);
3427    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3428                                                                 endladdercoolingtubeshape[2][1],
3429                                                                 fSSDCoolingTubeWater);
3430    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3431                                                                 endladdercoolingtubeshape[3][0],
3432                                                                 fSSDCoolingTubePhynox);
3433    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3434                                                                 endladdercoolingtubeshape[3][1],
3435                                                                 fSSDCoolingTubeWater);
3436    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3437                                                                 endladdercoolingtubeshape[4][0],
3438                                                                 fSSDCoolingTubePhynox);
3439    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3440                                                                 endladdercoolingtubeshape[4][1],
3441                                                                 fSSDCoolingTubeWater);
3442    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3443                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3444                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3445    }
3446   /////////////////////////////////////////////////////////////
3447   // Virtual Volume containing Cooling Tubes
3448   /////////////////////////////////////////////////////////////
3449   // Ladder Cooling Tubes
3450   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3451   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3452   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3453                                                                                         coolingtubeshape[i][0]->GetRmax(),
3454                                                                                         coolingtubeshape[i][0]->GetDz());
3455   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3456   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3457                                                                           fSSDAir);
3458   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3459                                                                           fSSDAir);
3460   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3461                                                                           fSSDAir);
3462   // End Ladder Cooling Tubes
3463   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3464   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3465   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3466                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3467                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3468   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3469   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3470                                                                           endladdervirtualcoolingtubeshape[0],
3471                                                                           fSSDAir);
3472   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3473                                                                           endladdervirtualcoolingtubeshape[1],
3474                                                                           fSSDAir);
3475   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3476                                                                           endladdervirtualcoolingtubeshape[2],
3477                                                                           fSSDAir);
3478   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3479                                                                           endladdervirtualcoolingtubeshape[3],
3480                                                                           fSSDAir);
3481   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3482                                                                           endladdervirtualcoolingtubeshape[4],
3483                                                                           fSSDAir);
3484   TList* coolingtubelist = new TList();
3485   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3486         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3487         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3488     coolingtubelist->Add(virtualcoolingtube[i]);
3489   }
3490         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3491         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3492     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3493         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3494         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3495     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3496         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3497         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3498     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3499         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3500         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3501     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3502         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3503         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3504     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3505   return coolingtubelist;
3506 }
3507 ///////////////////////////////////////////////////////////////////////////////
3508 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3509   /////////////////////////////////////////////////////////////
3510   // Method generating SSD Cooling Block    
3511   /////////////////////////////////////////////////////////////
3512   const Int_t kvertexnumber = 8;
3513   ///////////////////////////////////////
3514   // Vertex Positioning for TGeoXTru
3515   ///////////////////////////////////////
3516   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3517   vertexposition[0] = new TVector3(0.0,0.0);
3518   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3519   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3520                                           vertexposition[1]->Y());
3521   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3522                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3523   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3524   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3525                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3526   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3527                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3528                                         - fgkSSDCoolingBlockHoleLength[0]
3529                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3530                                           fgkSSDCoolingBlockHeight[0]
3531                                         - fgkSSDCoolingBlockHoleRadius[1],
3532                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3533   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3534                                         - fgkSSDCoolingBlockHoleLength[0]),
3535                                           vertexposition[6]->Y());
3536   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3537                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3538   Double_t phi = 180.-alpha;
3539   Double_t psi = 180.+2.*alpha;
3540   Double_t deltapsi = psi/nedges;
3541   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3542   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3543                                                   fgkSSDCoolingBlockHoleCenter);
3544   for(Int_t i=0; i<nedges+1; i++){
3545         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3546                                                                                                radius*SinD(phi+i*deltapsi));
3547    *vertexposition[kvertexnumber+i] += (*transvector);
3548   }
3549   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3550   for(Int_t i=0; i<kvertexnumber; i++)
3551     vertexposition[kvertexnumber+nedges+1+i] = 
3552                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3553   ///////////////////////////////////////////////////////////////////////
3554   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3555   ///////////////////////////////////////////////////////////////////////
3556   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3557   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3558   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3559   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3560         xvertexpoints[i] = vertexposition[i]->X();
3561         yvertexpoints[i] = vertexposition[i]->Y();
3562   } 
3563   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3564                                                                                         yvertexpoints);
3565   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3566   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3567   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3568                                                                           ssdcoolingblockshape,
3569                                                                                   fSSDAlCoolBlockMedium);
3570   ssdcoolingblock->SetLineColor(fColorAl);
3571   /////////////////////////////////////////////////////////////
3572   // Deallocating memory
3573   /////////////////////////////////////////////////////////////
3574   delete [] vertexposition;
3575   delete xvertexpoints;
3576   delete yvertexpoints;
3577   /////////////////////////////////////////////////////////////
3578   return ssdcoolingblock;
3579 }
3580 /////////////////////////////////////////////////////////////////////////////////
3581 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3582   ///////////////////////////////////////////////////////
3583   const Int_t kssdchipcablesnumber    = 2;
3584   const Int_t kssdchipcableslaynumber = 2;
3585   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3586   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3587   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3588   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3589                                                  -  fgkSSDChipCablesHeight[0]
3590                                                  -  fgkSSDChipCablesHeight[1]);
3591   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3592   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3593   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3594                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3595                                                           - ssdchipcablesradius[0]
3596                                                           - fgkSSDChipCablesWidth[1]
3597                                                           - fgkSSDChipCablesWidth[2]);
3598   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3599                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3600                                                           +      fgkSSDChipCablesHeight[1]
3601                                                           +      fgkSSDSensorHeight);
3602   ///////////////////////////////////////////////////////
3603   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3604   ///////////////////////////////////////////////////////
3605   TVector3** vertexposition[kssdchipcableslaynumber];
3606   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3607                                                                                                   new TVector3*[4*(nedges+1)+4];
3608   Double_t ratio[4];
3609   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3610   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3611                    /  ssdchipcablesradius[0]; 
3612   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3613                    /  ssdchipcablesradius[0];
3614   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3615                    +  fgkSSDChipCablesHeight[1])
3616                    /  ssdchipcablesradius[0];
3617   Double_t phi = 180.;
3618   Double_t deltaphi = 180./nedges;
3619   Double_t angle = 0.0;
3620   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3621   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3622   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3623         xvertexpoints[i] = new Double_t[kvertexnumber];
3624         yvertexpoints[i] = new Double_t[kvertexnumber];
3625   }  
3626   TVector3* vertex = new TVector3();
3627   TVector3* transvector[kssdchipcableslaynumber];
3628   transvector[0] = new TVector3(fgkSSDChipWidth,
3629                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3630   transvector[1] = new TVector3();
3631   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3632   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3633   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3634                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3635                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3636   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3637         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3638         transvector[1]->SetY(ssdchipcablesradius[0]
3639                                  +               fgkSSDChipCablesHeight[0]
3640                                  +               fgkSSDChipCablesHeight[1]);  
3641         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3642                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3643                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3644                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3645                                                          - i*fgkSSDChipCablesHeight[0]);
3646                 vertexposition[i][2*(nedges+1)+2] = 
3647                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3648                                 +                                fgkSSDChipCablesWidth[1]
3649                                 +                                fgkSSDChipCablesWidth[2],
3650                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3651                                 +                                fgkSSDChipCablesHeight[1]));
3652         vertexposition[i][2*(nedges+1)+3] = 
3653                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3654                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3655                                 -                                fgkSSDChipCablesHeight[i]);
3656             for(Int_t j=0; j<nedges+1; j++){            
3657                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3658                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3659                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3660                         vertexposition[0][(nedges+1)*i+j+2] = 
3661                                                 new TVector3(*vertex+*transvector[i]);
3662                         vertexposition[1][(nedges+1)*i+j+2] = 
3663                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3664                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3665                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3666                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3667                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3668                                                 new TVector3(vertex->X()*ratio[2*i+1]
3669                                                         +                        transvector[i]->X(),
3670                                                                                  vertex->Y()*ratio[2*i+1]
3671                                                         +                transvector[i]->Y());
3672                 }
3673         }
3674         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3675                 for(Int_t j=0; j<kvertexnumber; j++){   
3676                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3677                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3678                 }
3679                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3680                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3681                                                                                 xvertexpoints[i],yvertexpoints[i]);
3682                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3683                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3684                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3685                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3686                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3687                                                           (kssdchipcablesnumber*k+i)%2==0?
3688                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3689                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3690         }
3691         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3692                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3693   }
3694   /////////////////////////////////////////////////////////////
3695   // Mother Volume definition 
3696   /////////////////////////////////////////////////////////////
3697   Double_t ssdchipseparation = fgkSSDSensorLength
3698                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3699                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3700                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3701   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3702   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3703                                                           +fgkSSDChipCablesWidth[1]
3704                                                           +fgkSSDChipCablesWidth[2]);
3705   Double_t dy = fgkSSDChipCablesLength[1];
3706   Double_t dz = SSDChipCablesHeigth;
3707   TGeoBBox* ssdchipcablesmotherbox = new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3708   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3709 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3710 //                        ssdchipcablesmotherbox,fSSDAir);
3711   /////////////////////////////////////////////////////////////
3712   // Rotation and Translation Definition for positioning 
3713   /////////////////////////////////////////////////////////////
3714   TGeoRotation* ssdchipcablesrot[5];
3715   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3716   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3717   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3718   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3719   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3720   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3721                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3722   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3723   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3724   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3725   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3726   /////////////////////////////////////////////////////////////
3727   // Deallocating memory
3728   /////////////////////////////////////////////////////////////
3729   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3730         delete [] xvertexpoints[i];
3731         delete [] yvertexpoints[i];
3732   }
3733   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3734   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3735   delete vertex; 
3736   delete ssdchipcablesrot[0];
3737   delete ssdchipcablesrot[1];
3738   delete ssdchipcablesrot[3];
3739   /////////////////////////////////////////////////////////////
3740   return ssdchipcablesmother;
3741 }
3742 ///////////////////////////////////////////////////////////////////////////////
3743 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3744   /////////////////////////////////////////////////////////////
3745   // SSD Chip Assembly
3746   /////////////////////////////////////////////////////////////
3747   TGeoVolume* ssdchipassembly = GetSSDChips();
3748   TList* ssdchipsystemlist = new TList();
3749 //  const Int_t knedges = 20;
3750   const Int_t knedges = 5;
3751   const Int_t kchipsystemnumber = 2;
3752   /////////////////////////////////////////////////////////////
3753   // Mother Volume containing SSDChipSystem
3754   /////////////////////////////////////////////////////////////
3755   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3756   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3757   const Int_t kmothervertexnumber = 12;  
3758   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3759   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3760   Double_t ssdchipcablesradius[kchipsystemnumber];
3761   Double_t ssdchipseparation = fgkSSDSensorLength
3762                              - 2.*fgkSSDModuleStiffenerPosition[1]
3763                              - 2.*(fgkSSDStiffenerWidth
3764                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3765   for(Int_t i=0; i<kchipsystemnumber; i++)
3766         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3767                                                    -  fgkSSDChipCablesHeight[0]
3768                                                    -  fgkSSDChipCablesHeight[1]);
3769   ///////////////////////
3770   // Setting the vertices 
3771   ///////////////////////
3772   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3773   xmothervertex[0][1]  = xmothervertex[0][0];  
3774   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3775                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3776   xmothervertex[0][3]  = xmothervertex[0][2];  
3777   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3778   xmothervertex[0][5]  = xmothervertex[0][4];  
3779   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3780   xmothervertex[0][7]  = xmothervertex[0][6]; 
3781   xmothervertex[0][8]  = 0.0;  
3782   xmothervertex[0][9]  = xmothervertex[0][8];  
3783   xmothervertex[0][10] = xmothervertex[0][4];  
3784   xmothervertex[0][11] = xmothervertex[0][10];  
3785   for(Int_t i=0; i<kmothervertexnumber; i++) 
3786         xmothervertex[1][i] = xmothervertex[0][i]; 
3787   for(Int_t i=0; i<kchipsystemnumber; i++){
3788         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3789                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3790         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3791         ymothervertex[i][2]  = ymothervertex[i][1];
3792         ymothervertex[i][3]  = ymothervertex[i][0];
3793         ymothervertex[i][4]  = ymothervertex[i][0];
3794         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3795         ymothervertex[i][6]  = ymothervertex[i][5];
3796         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3797         ymothervertex[i][8]  = ymothervertex[i][7];
3798         ymothervertex[i][9]  = ymothervertex[i][5];
3799         ymothervertex[i][10] = ymothervertex[i][5];
3800         ymothervertex[i][11] = ymothervertex[i][4];
3801   }
3802   //////////////////////////////////////////////////////////
3803 //  TGeoVolume* chipsystemother[kchipsystemnumber];
3804   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3805   const char* chipsytemothername[kchipsystemnumber] = 
3806                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3807   for(Int_t i=0; i<kchipsystemnumber; i++){
3808     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3809                                                                         xmothervertex[i],ymothervertex[i]);
3810     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3811                                                                                   -0.5*fgkSSDChipHeight);
3812     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3813 //    chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3814 //                                                        chipsystemothershape[i],fSSDAir);
3815     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3816   }
3817   /////////////////////////////////////////////////////////////
3818   // SSD Chip Cables
3819   /////////////////////////////////////////////////////////////
3820   TGeoVolume* ssdchipcables[kchipsystemnumber];
3821   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3822   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3823   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3824   //////////////////
3825   for(Int_t i=0; i<kchipsystemnumber; i++){
3826                 ssdchipcables[i] = 
3827                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3828                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3829                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3830                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3831   }
3832   for(Int_t i=0; i<kchipsystemnumber; i++){
3833         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3834                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3835                 ssdchipcablesrot[i][j] = new TGeoRotation();
3836                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3837                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3838                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3839                                                   +                fgkSSDChipSeparationLength),
3840                                                                                         0.5*fgkSSDChipWidth,
3841                                                   -                                     0.5*fgkSSDChipHeight
3842                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3843                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3844                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3845                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3846         }
3847         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3848         ssdchipsystemlist->Add(chipsystemother[i]);     
3849   }
3850   /////////////////////////////////////////////////////////////
3851   // Deallocating memory
3852   /////////////////////////////////////////////////////////////
3853   for(Int_t i=0; i<kchipsystemnumber; i++){
3854         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3855                 delete ssdchipcablesrot[i][j];
3856                 delete ssdchipcablestrans[i][j];
3857         }
3858         delete ssdchipcablesrot[i];
3859         delete ssdchipcablestrans[i];
3860   }
3861   /////////////////////////////////////////////////////////////
3862   return ssdchipsystemlist;
3863 }
3864 ///////////////////////////////////////////////////////////////////////////////
3865 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3866   /////////////////////////////////////////////////////////////
3867   // SSD Chip Assembly Generation    
3868   /////////////////////////////////////////////////////////////
3869   const Int_t kssdchiprownumber = 2;
3870   TGeoBBox* ssdchipcompshape[2];
3871   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3872                                                                                 0.5*fgkSSDChipLength,
3873                                                                                 0.5*fgkSSDChipWidth,
3874                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3875   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3876                                                                                 0.5*fgkSSDChipLength,
3877                                                                                 0.5*fgkSSDChipWidth,
3878                                                                                 0.5*fgkSSDChipGlueHeight);
3879   TGeoVolume* ssdchipcomp[2];
3880   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3881   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3882                                                                   fSSDChipGlueMedium);
3883   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3884   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3885   TGeoTranslation* ssdchipcomptrans[2];
3886   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3887   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3888   /////////////////////////////////////////////////////////////
3889   // Virtual Volume containing SSDChip   
3890   /////////////////////////////////////////////////////////////
3891   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3892                                                                                                                  0.5*fgkSSDChipWidth,
3893                                                                                                                  0.5*fgkSSDChipHeight);
3894   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3895   /////////////////////////////////////////////////////////////
3896   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3897   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3898                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3899                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3900                                    -  0.5*fgkSSDChipWidth)};
3901   /////////////////////////////////////////////////////////////
3902   // Virtual Volume containing SSDChipAssembly   
3903   /////////////////////////////////////////////////////////////
3904   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3905   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3906   Double_t xmothervertex[kssdmothervertexnumber];
3907   Double_t ymothervertex[kssdmothervertexnumber];
3908   ///////////////////////
3909   // Setting the vertices 
3910   ///////////////////////
3911   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3912   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3913                                    - ymothervertex[0];
3914   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3915   ymothervertex[2] = ymothervertex[1];
3916   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3917   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3918   ymothervertex[4] = ymothervertex[0];
3919   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3920   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3921                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3922   ymothervertex[6] = ymothervertex[5];
3923   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3924                                    - fgkSSDChipWidth;
3925   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3926   ymothervertex[8] = ymothervertex[7];
3927   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3928   ymothervertex[9] = ymothervertex[6];
3929   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3930   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3931   //////////////////////////////////////////////////////////
3932   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3933                                                                         xmothervertex,ymothervertex);
3934   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3935   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3936 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3937 //                                                        ssdchipmothershape,fSSDAir);
3938   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3939    /////////////////////////////////////////////////////////////
3940   for(Int_t i=0; i<kssdchiprownumber; i++)
3941     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3942                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3943                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3944   return ssdchipmother;
3945 }
3946 /////////////////////////////////////////////////////////////////////////////////
3947 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3948   /////////////////////////////////////////////////////////////
3949   // Method returning a List containing pointers to Ladder Cable Volumes    
3950   /////////////////////////////////////////////////////////////
3951   const Int_t kladdercablesegmentnumber = 2;
3952   /////////////////////////////////////////
3953   // LadderSegmentBBox Volume
3954   /////////////////////////////////////////
3955   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3956   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3957                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3958   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3959                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3960                                                                            0.5*fgkSSDFlexWidth[0],
3961                                                                            0.5*fgkSSDLadderCableWidth,
3962                                                                            0.5*fgkSSDFlexHeight[i]); 
3963   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3964                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3965   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3966   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3967                         laddercablesegmentbbox[i] =
3968                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3969                                                                                  laddercablesegmentbboxshape[i],
3970                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3971             fSSDKaptonLadderCableMedium));
3972                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3973                                                                                                                    fColorPolyhamide);
3974   }
3975   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3976   laddercablesegmentbboxtrans[0] = 
3977                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3978                                                                                            0.5*fgkSSDFlexWidth[0],
3979                                                                                            0.5*fgkSSDLadderCableWidth,
3980                                                                                            0.5*fgkSSDFlexHeight[0]);
3981   laddercablesegmentbboxtrans[1] = 
3982                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3983                                                                                            0.5*fgkSSDFlexWidth[0],
3984                                                                                            0.5*fgkSSDLadderCableWidth,
3985                                                                                            fgkSSDFlexHeight[0]
3986                                                                                            +0.5*fgkSSDFlexHeight[1]);
3987   TGeoVolume* laddercablesegmentbboxassembly = 
3988                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3989   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3990                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3991                                                                                             laddercablesegmentbboxtrans[i]);
3992 /////////////////////////////////////////
3993 // LadderSegmentArb8 Volume
3994 /////////////////////////////////////////
3995   const Int_t kvertexnumber = 4;
3996   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3997   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3998                                                                                                   new TVector3*[kvertexnumber];
3999 //Shape Vertex Positioning
4000   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4001         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
4002         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
4003                                                                                                                   i*fgkSSDFlexHeight[0]);
4004         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
4005                                                                                    +                         fgkSSDFlexHeight[1]
4006                                                                                    +                      i*fgkSSDFlexHeight[0]);
4007         laddercablesegmentvertexposition[i][3] = 
4008                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
4009                                                                                 laddercablesegmentvertexposition[i][2]->Y());
4010   }
4011   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
4012                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
4013   char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
4014                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
4015   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
4016   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
4017                                         GetArbShape(laddercablesegmentvertexposition[i],
4018                                                                 laddercablesegmentwidth[i],
4019                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4020                                                                 laddercablesegmentarbshapename[i]);
4021   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4022                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4023   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4024   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4025                          laddercablesegmentarb[i] =
4026                                                    new TGeoVolume(laddercablesegmentarbname[i],
4027                                                                                   laddercablesegmentarbshape[i],
4028                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4029             fSSDKaptonLadderCableMedium)); 
4030                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4031                                                                                                                    fColorPolyhamide);
4032 }
4033   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4034   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4035                                                                                                  90.,90,-90.);   
4036   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4037                                                                                                   0.,90.,0.);    
4038   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4039                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4040                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4041                                                          + fgkSSDFlexWidth[0],0.,0.,
4042                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4043                                                      *(*laddercablesegmentarbrot[0])));
4044   TGeoVolume* laddercablesegmentarbassembly = 
4045                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4046   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4047   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4048                                                                                    laddercablesegmentarbcombitrans);
4049 /////////////////////////////////////////
4050 // End Ladder Cable Volume
4051 /////////////////////////////////////////
4052   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4053   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4054                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4055   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4056                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4057                                                                            0.5*ssdendladdercablelength,
4058                                                                            0.5*fgkSSDLadderCableWidth,
4059                                                                            0.5*fgkSSDFlexHeight[i]);
4060   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4061                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4062   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4063   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4064                         ladderendcablesegmentbbox[i] =
4065                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4066                                                                                  ladderendcablesegmentbboxshape[i],
4067                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4068             fSSDKaptonLadderCableMedium));
4069                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4070                                                                                                                    fColorPolyhamide);
4071   }
4072   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4073   ladderendcablesegmentbboxtrans[0] = 
4074                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4075                                                                                            0.5*ssdendladdercablelength,
4076                                                                                            0.5*fgkSSDLadderCableWidth,
4077                                                                                            0.5*fgkSSDFlexHeight[0]);
4078   ladderendcablesegmentbboxtrans[1] = 
4079                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4080                                                                                            0.5*ssdendladdercablelength,
4081                                                                                            0.5*fgkSSDLadderCableWidth,
4082                                                                                            fgkSSDFlexHeight[0]
4083                                                                                            +0.5*fgkSSDFlexHeight[1]);
4084   TGeoVolume* ladderendcablesegmentbboxassembly = 
4085                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4086   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4087                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4088                                                                                             ladderendcablesegmentbboxtrans[i]);
4089 /////////////////////////////////////////
4090   TList* laddercablesegmentlist = new TList();
4091   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4092   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4093   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4094   return laddercablesegmentlist;
4095   }
4096 /////////////////////////////////////////////////////////////////////////////////
4097 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4098   /////////////////////////////////////////////////////////////
4099   // Method generating Ladder Cable Volumes Assemblies    
4100   /////////////////////////////////////////////////////////////
4101   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4102   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4103   for(Int_t i=0; i<n; i++){
4104          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4105                                                         i*(fgkCarbonFiberJunctionWidth),
4106                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4107                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4108     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4109         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4110   }
4111   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4112                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4113                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4114                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4115   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4116   return laddercable;
4117 }
4118 /////////////////////////////////////////////////////////////////////////////////
4119 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4120   /////////////////////////////////////////////////////////////
4121   // Method generating Ladder Cable Volumes Assembly   
4122   /////////////////////////////////////////////////////////////
4123   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4124   char laddercabletransname[30];
4125   for(Int_t i=0; i<n; i++){ 
4126         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4127     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4128         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4129   }
4130   return laddercableassembly;
4131 }
4132 /////////////////////////////////////////////////////////////////////////////////
4133 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4134   /////////////////////////////////////////////////////////////
4135   // Method generating Ladder Cable List Assemblies  
4136   /////////////////////////////////////////////////////////////  
4137   const Int_t kladdercableassemblynumber = 2;
4138   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4139   TGeoVolume* ladderCable[kladdercableassemblynumber];
4140   char laddercableassemblyname[30];
4141   TList* laddercableassemblylist = new TList();
4142   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4143         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4144         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4145         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4146                                          new TGeoCombiTrans((n-1)
4147                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4148                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4149                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4150         laddercableassemblylist->Add(ladderCable[i]);
4151 }
4152   return laddercableassemblylist;
4153 }
4154 ///////////////////////////////////////////////////////////////////////////////
4155 void AliITSv11GeometrySSD::SetLadderSegment(){
4156   /////////////////////////////////////////////////////////////
4157   // Method Generating Ladder Segment Array
4158   /////////////////////////////////////////////////////////////
4159   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4160   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4161   if(!fCreateMaterials) CreateMaterials();
4162   if(!fTransformationMatrices) CreateTransformationMatrices();
4163   if(!fBasicObjects) CreateBasicObjects();
4164   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4165   // Placing Carbon Fiber Support       
4166         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4167                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4168                                                                                         fcarbonfibersupportmatrix[j]);  
4169                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4170                                                                                         fcarbonfibersupportmatrix[j]);
4171   }
4172   // Placing Carbon Fiber Junction
4173     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4174         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4175                                                                    fcarbonfiberjunctionmatrix[j]);
4176   // Placing Carbon Fiber Lower Support
4177         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4178                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4179                                                            fcarbonfiberlowersupportrans[j]);    
4180   // Placing SSD Sensor Support
4181     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4182         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4183                                                                      fssdsensorsupport[1][i],
4184                                                            j+1,fssdsensorsupportmatrix[j]);
4185   // Placing SSD Cooling Tube Support 
4186         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4187                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4188                                                                    fcoolingtubesupportmatrix[j]);
4189   // Placing SSD Cooling Tube  
4190         for(Int_t j=0; j<2; j++)
4191                 for(Int_t k=0; k<2; k++){
4192                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4193                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4194                 }
4195   // Placing SSD Hybrid
4196     switch(i){
4197         case 0: 
4198                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4199                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4200                 break;
4201     case 1:
4202                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4203                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4204                 break;
4205         }
4206         // Placing Cooling Block System
4207     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4208         // Placing SSD Flex
4209         for(Int_t j=0; j<fgkflexnumber; j++){
4210       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4211       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4212         }
4213    }
4214 }
4215 ///////////////////////////////////////////////////////////////////////////////
4216 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4217   /////////////////////////////////////////////////////////////
4218   // Method Generating End Ladder
4219   /////////////////////////////////////////////////////////////
4220   // End Ladder Carbon Fiber Junction 
4221   /////////////////////////////////////////////////////////////
4222   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4223   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4224   if(!fCreateMaterials) CreateMaterials();
4225   if(!fTransformationMatrices) CreateTransformationMatrices();
4226   if(!fBasicObjects) CreateBasicObjects();
4227   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4228         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4229                 fendladdersegment[i]->AddNode(j==2 ? 
4230                                                         fendladdercarbonfiberjunction[i][1] : 
4231                                                         fendladdercarbonfiberjunction[i][0],
4232                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4233   }
4234   /////////////////////////////////////////////////////////////
4235   // End Ladder Carbon Fiber Support 
4236   /////////////////////////////////////////////////////////////
4237   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4238       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4239                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4240                   fendladdercarbonfibermatrix[i][j]);   
4241           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4242                   fendladdercarbonfibermatrix[i][j]);   
4243       }
4244   /////////////////////////////////////////////////////////////
4245   // End Ladder Mounting Block
4246   /////////////////////////////////////////////////////////////
4247   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4248        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4249                                      fendladdermountingblockcombitrans[i]);
4250   /////////////////////////////////////////////////////////////
4251   // End Ladder Mounting Block Clip
4252   /////////////////////////////////////////////////////////////
4253   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4254         for(Int_t j=0; j<2; j++)
4255                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4256                                               fendladdermountingblockclipmatrix[i][j]);
4257   /////////////////////////////////////////////////////////////
4258   // End Ladder Lower Supports
4259   /////////////////////////////////////////////////////////////
4260   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4261                                 fendladderlowersupptrans[0]);
4262   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4263                                 fendladderlowersupptrans[1]);
4264   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4265                                 fendladderlowersupptrans[2]);
4266   /////////////////////////////////////////////////////////////
4267   // End Ladder Cooling Tube Support
4268   /////////////////////////////////////////////////////////////
4269   for(Int_t i=0; i<2; i++) 
4270         for(Int_t j=0; j<(i==0?4:2); j++)   
4271                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4272                                               fendladdercoolingtubesupportmatrix[i][j]);
4273   /////////////////////////////////////////////////////////////
4274   // End Ladder Cooling Tube Support
4275   /////////////////////////////////////////////////////////////
4276 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4277 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4278   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4279   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4280   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4281   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4282   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4283   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4284   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4285   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4286 }
4287 ///////////////////////////////////////////////////////////////////////////////
4288 void AliITSv11GeometrySSD::SetLadder(){
4289   /////////////////////////////////////////////////////////////
4290   // Method Generating Ladder of Layer 5 and 6
4291   /////////////////////////////////////////////////////////////  
4292   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4293                                                                                                 fgkSSDLay6SensorsNumber};
4294   /////////////////////////////////////////////////////////////////////////////                                         
4295   /// Generating Ladder Mother Volume Containing Ladder 
4296   /////////////////////////////////////////////////////////////////////////////          
4297   TGeoXtru* laddershape[fgkladdernumber];       
4298   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4299   const Int_t kmothervertexnumber = 8;  
4300   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4301   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4302   ///////////////////////
4303   // Setting the vertices 
4304   ///////////////////////
4305   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4306                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4307   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4308   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
4309                                           -  fgkSSDModuleVerticalDisalignment;
4310   xmothervertex[0][1] = xmothervertex[0][0];
4311   ymothervertex[0][1] = 0.0;
4312   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4313                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4314   ymothervertex[0][2] = ymothervertex[0][1];
4315   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4316   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4317   xmothervertex[0][4] = -xmothervertex[0][3];
4318   ymothervertex[0][4] = ymothervertex[0][3];
4319   xmothervertex[0][5] = -xmothervertex[0][2];
4320   ymothervertex[0][5] = ymothervertex[0][2];
4321   xmothervertex[0][6] = -xmothervertex[0][1];
4322   ymothervertex[0][6] = ymothervertex[0][1];
4323   xmothervertex[0][7] = -xmothervertex[0][0];
4324   ymothervertex[0][7] = ymothervertex[0][0];
4325   for(Int_t i=0; i<kmothervertexnumber; i++){
4326         xmothervertex[1][i] = xmothervertex[0][i];
4327         ymothervertex[1][i] = ymothervertex[0][i];
4328   }
4329   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4330   for(Int_t i=0; i<fgkladdernumber; i++){
4331         laddershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
4332                                                                     ymothervertex[i]);
4333     laddershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4334     laddershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4335                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4336     fladder[i] = new TGeoVolume(laddername[i],laddershape[i],fSSDAir);
4337         fladder[i]->SetLineColor(4);
4338  }
4339 ///////////////////////////////////////////////////////////////////////////
4340  if(!fCreateMaterials) CreateMaterials();
4341  if(!fTransformationMatrices) CreateTransformationMatrices();
4342  if(!fBasicObjects) CreateBasicObjects();
4343  SetLadderSegment(); 
4344  SetEndLadderSegment();
4345   for(Int_t i=0; i<fgkladdernumber; i++){
4346         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4347         //////////////////////////                                              
4348         /// Placing Ladder Segment
4349         //////////////////////////              
4350                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4351                                                                      fladdersegment[i==0 ? 1 : 0],
4352                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4353         //////////////////////////                                              
4354         /// Placing SSD Sensor
4355         //////////////////////////              
4356         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4357                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4358                                                         fssdsensormatrix[i][j]);
4359         }
4360         ///////////////////////////////                                         
4361         /// Placing End Ladder Segment
4362         ///////////////////////////////         
4363     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4364         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4365    }
4366 /////////////////////////////////////////////////////////////////////////////                                           
4367 /// Placing Ladder Cables
4368 /////////////////////////////////////////////////////////////////////////////           
4369   Int_t sidecablenumber[2][2];
4370   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4371   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4372   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4373   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4374   Double_t carbonfibertomoduleposition[3];
4375   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4376   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4377                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4378          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4379          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4380          -            fgkSSDSensorCenterSupportThickness[0]);
4381   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4382                                                                  +   0.5*fgkCoolingTubeSupportHeight
4383          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4384   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4385   Double_t ssdendladdercablelength[4];
4386   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4387                                                          + fgkSSDSensorLength
4388                                                          - fgkSSDModuleStiffenerPosition[1]
4389                                                          - fgkSSDStiffenerWidth 
4390                                                          - fgkSSDFlexWidth[0]
4391                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4392   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4393                                                          + fgkSSDModuleStiffenerPosition[1]
4394                                                          + fgkSSDStiffenerWidth
4395                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4396   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4397                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4398                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4399                                                          - kendladdercablecorrection;
4400   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4401                                                          + carbonfibertomoduleposition[1]
4402                                                          - fgkSSDModuleStiffenerPosition[1]
4403                                                          - fgkSSDStiffenerWidth)
4404                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4405   TList* laddercableassemblylist[4];
4406   const Int_t kendladdercablesnumber = 4;
4407   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4408         for(Int_t j=0; j<kendladdercablesnumber; j++){
4409                 laddercableassemblylist[j] = 
4410                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4411                                                                    ssdendladdercablelength[j]);
4412 //          fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4413 //                                                                      j<2?1:2,fladdercablematrix[i][j]);
4414   }
4415 }
4416 ////////////////////////////////////////////////////////////////////////////////
4417 void AliITSv11GeometrySSD::SetLayer(){
4418 ////////////////////////////////////////////////////////////////////////////////
4419   // Creating Ladder of Layer 5 and Layer 6
4420   /////////////////////////////////////////////////////////////
4421   if(!fCreateMaterials) CreateMaterials();
4422   if(!fTransformationMatrices) CreateTransformationMatrices();
4423   if(!fBasicObjects) CreateBasicObjects();
4424   SetLadder(); // Generating the ladder of Layer5 and Layer6
4425   const Int_t kssdlayladdernumber[fgklayernumber] = 
4426                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4427   /////////////////////////////////////////////////////////////
4428   // Generating mother volumes for Layer5 and Layer6
4429   /////////////////////////////////////////////////////////////
4430   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4431   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4432   Int_t *ladderindex[fgklayernumber];
4433   Int_t index[fgklayernumber] = {8,9};
4434   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4435   for(Int_t i=0; i<fgklayernumber; i++) 
4436         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4437                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4438                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4439                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4440                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4441         }
4442   /////////////////////////////////////////////////////////////
4443   // Deallocating memory
4444   /////////////////////////////////////////////////////////////
4445   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4446 }
4447 ////////////////////////////////////////////////////////////////////////////////
4448 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4449   /////////////////////////////////////////////////////////////
4450   // Insert the layer 5 in the mother volume. 
4451   /////////////////////////////////////////////////////////////
4452   if (! moth) {
4453     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4454     return;
4455   };
4456   if(!fSSDLayer5) SetLayer();
4457   fMotherVol = moth;
4458   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4459                                                                                 + fgkLay5CenterITSPosition);
4460   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4461  }
4462 ////////////////////////////////////////////////////////////////////////////////
4463 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4464   /////////////////////////////////////////////////////////////
4465   // Insert the layer 6 in the mother volume. 
4466   /////////////////////////////////////////////////////////////
4467   if (! moth) {
4468     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4469     return;
4470   };
4471   if(!fSSDLayer6) SetLayer();
4472   fMotherVol = moth;
4473   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4474                                                                                 + fgkLay6CenterITSPosition);
4475   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4476  }
4477  ////////////////////////////////////////////////////////////////////////////////
4478  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4479   /////////////////////////////////////////////////////////////
4480   // Method generating the Arc structure of Ladder Support 
4481   /////////////////////////////////////////////////////////////
4482   const Int_t kssdlayladdernumber[fgklayernumber] = 
4483                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4484   Double_t mountingsupportedge[fgklayernumber];
4485   Double_t mountingblockratio[fgklayernumber];
4486   Double_t theta[fgklayernumber];
4487   Double_t phi[fgklayernumber];
4488   Double_t psi0[fgklayernumber];
4489   Double_t deltapsi[fgklayernumber];
4490   TVector3* mountingsupportedgevector[fgklayernumber];
4491   for(Int_t i=0; i<fgklayernumber; i++){
4492         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4493     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4494                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4495                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4496                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4497                                                           / kssdlayladdernumber[i])));
4498     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4499     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4500         mountingsupportedgevector[i] = new TVector3();
4501     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4502         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4503                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4504                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4505     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4506     deltapsi[i] = (theta[i]+phi[i])/nedges;
4507   }
4508   TVector3** vertex[fgklayernumber];
4509   TList* vertexlist[fgklayernumber];
4510   Int_t indexedge[fgklayernumber] = {0,0};
4511   for(Int_t i=0; i<fgklayernumber; i++){
4512         vertex[i] = new TVector3*[nedges+1];
4513         vertexlist[i] = new TList();
4514   } 
4515   for(Int_t i=0; i<fgklayernumber; i++){
4516         for(Int_t j=0; j<nedges+1; j++){
4517                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4518                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4519                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4520                 vertexlist[i]->Add(vertex[i][j]);
4521         }
4522         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4523   }
4524   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4525   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4526   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4527   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4528   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4529   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4530   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4531   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4532   for(Int_t i=0; i<fgklayernumber; i++){
4533     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4534     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4535     xcentervertex[i] = new Double_t[indexedge[i]+3];
4536     ycentervertex[i] = new Double_t[indexedge[i]+3];
4537         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4538         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4539         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4540         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4541         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4542                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4543                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4544                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4545                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4546                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4547                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4548                 if(j<indexedge[i]+1){
4549                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4550                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4551                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4552                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4553                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4554                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4555                 }
4556         }
4557         xsidevertex[i][1] = xsidevertex[i][0]; 
4558         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4559         xsidevertex[i][2] = xsidevertex[i][3]; 
4560         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4561         xcentervertex[i][1] = xcentervertex[i][0]; 
4562         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4563         xcentervertex[i][2] = xcentervertex[i][3]; 
4564         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4565         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4566         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4567         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4568         ycenterlowervertex[i][0] = ysidevertex[i][0];
4569         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4570         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4571   }
4572   /////////////////////////////////////////////////////////////
4573   // Building the Arc Structure of Ladder Supports 
4574   /////////////////////////////////////////////////////////////
4575   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4576   TGeoXtru* centermountingsupportshape[fgklayernumber];
4577   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4578   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4579   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4580   TGeoVolume* centermountingblocksupport[fgklayernumber];
4581   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4582   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4583   char sidemountingblockname[40];
4584   char centermountingblockname[40];
4585   char sideladdersupportpiecename[40];
4586   char centerladdersupportpiecename[40];
4587   for(Int_t i=0; i<fgklayernumber; i++){ 
4588         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4589         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4590         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4591         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4592         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4593     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4594                                                                                                 xsidevertex[i],ysidevertex[i]);
4595     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4596                                                                                                          -fgkMountingBlockSupportWidth[0]);
4597     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4598     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4599                                                                           sidemountingblocksupportshape[i],
4600                                                                                   fSSDAlCoolBlockMedium);
4601         sidemountingblocksupport[i]->SetLineColor(9);
4602         centermountingsupportshape[i] = new TGeoXtru(2);
4603     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4604                                                                                                 xcentervertex[i],ycentervertex[i]);
4605         centermountingsupportshape[i]->DefineSection(0,0.);
4606     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4607                                                                                                   -fgkMountingBlockSupportWidth[0]);
4608     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4609                                                                           centermountingsupportshape[i],
4610                                                                                   fSSDAlCoolBlockMedium);
4611         centermountingblocksupport[i]->SetLineColor(9);
4612         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4613     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4614                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4615         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4616                                                                                                          -fgkMountingBlockSupportWidth[0]);
4617     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4618     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4619                                                                           sideladdersupportpieceshape[i],
4620                                                                                   fSSDCarbonFiberMedium);
4621         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4622         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4623     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4624                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4625         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4626     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4627                                                                                                   -fgkMountingBlockSupportWidth[0]);
4628     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4629                                                                           centerladdersupportpieceshape[i],
4630                                                                                   fSSDCarbonFiberMedium);
4631         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4632   }
4633   /////////////////////////////////////////////////////////////
4634   // Building the Up Structure of Ladder Supports 
4635   /////////////////////////////////////////////////////////////
4636   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4637   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4638   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4639   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4640   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4641   //////////////////////////////////////////////////////////
4642   // Setting the volume for TGeoXtru Mounting Block Piece  
4643   //////////////////////////////////////////////////////////
4644   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4645   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4646   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4647   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4648   TGeoVolume* mountingblockpieceup[fgklayernumber];
4649   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4650   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4651   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4652   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4653   char mountingblockpiecedownname[34];
4654   char mountingblockpieceupname[34];
4655   for(Int_t i=0; i<fgklayernumber; i++){
4656     ///////////////////////////
4657     // Mounting Block Down Vertex
4658     ///////////////////////////
4659         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4660     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4661         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4662         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4663                                                                                 + fgkMountingBlockSupportDownHeight;
4664         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4665         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4666                                                                                 + fgkSSDMountingBlockHeight[1]
4667                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4668                                                                                 - fgkSSDModuleCoolingBlockToSensor
4669                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4670         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4671         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4672         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4673         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4674         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4675         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4676         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4677         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4678                                                                                 + fgkSSDMountingBlockHeight[2]
4679                                                                                 - fgkSSDMountingBlockHeight[0];
4680         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4681         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4682         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4683         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4684         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4685                                                                                                          mountingblockpiecedownyvertex[i]);
4686         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4687         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4688         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4689                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4690         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4691     ///////////////////////////
4692     // Mounting Block Up Vertex
4693     ///////////////////////////
4694         mountingblockpieceupshape[i] = new TGeoXtru(2);
4695         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4696         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4697         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4698                                                                                 + fgkMountingBlockSupportUpHeight[i];
4699         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4700         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4701                                                                                 + fgkSSDMountingBlockHeight[1]
4702                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4703                                                                                 - fgkSSDModuleCoolingBlockToSensor
4704                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4705         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4706         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4707         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4708         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4709         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4710         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4711         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4712         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4713                                                                                 + fgkSSDMountingBlockHeight[2]
4714                                                                                 - fgkSSDMountingBlockHeight[0];
4715         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4716         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4717         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4718         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4719         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4720                                                                                                          mountingblockpieceupyvertex[i]);
4721         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4722         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4723         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4724                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4725         mountingblockpieceup[i]->SetLineColor(fColorG10);
4726  }
4727   ///////////////////////////////////////////////////////////////////
4728   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4729   ///////////////////////////////////////////////////////////////////
4730   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4731   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4732   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4733   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4734   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4735   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4736   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4737   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4738   char mountingblocksupportrapezoidowname[40];
4739   char mountingblocksupportrapezoidupname[40];
4740   Double_t scalefactor = 3./4.;
4741   for(Int_t i=0; i<fgklayernumber; i++){
4742   ////////////////////////////////////////////
4743   // Mounting Block Support Down Trapezoid Vertex 
4744   ////////////////////////////////////////////
4745         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4746         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4747                                                                                                  - mountingsupportedge[i];
4748         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4749         mountingblocksupportrapezoidownxvertex[i][1] = 
4750                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4751         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4752                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4753                                                                                              - mountingblockpiecedownyvertex[i][0]);
4754         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4755         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4756         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4757         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4758         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4759         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4760         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4761                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4762         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4763                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4764         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4765         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4766         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4767                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4768         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4769   ////////////////////////////////////////////
4770   // Mounting Block Support Up Trapezoid Vertex 
4771   ////////////////////////////////////////////
4772         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4773         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4774                                                                                                  - mountingsupportedge[i];
4775         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4776         mountingblocksupportrapezoidupxvertex[i][1] = 
4777                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4778         mountingblocksupportrapezoidupyvertex[i][1] = 
4779                                                                                                mountingblockpieceupyvertex[i][0]
4780                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4781                                                                                              - mountingblockpieceupyvertex[i][0]);
4782         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4783         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4784         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4785         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4786         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4787         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4788         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4789                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4790         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4791                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4792         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4793         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4794         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4795                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4796         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4797   }
4798   ///////////////////////////////////////////////////////////////////
4799   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4800   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4801   Double_t boxoriginup[fgklayernumber][2][3];
4802   Double_t boxorigindown[fgklayernumber][2][3];
4803   char mountingblocksupportboxdownname[34];
4804   char mountingblocksupportboxupname[34];
4805   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4806   mountingblocksupportrot->SetAngles(90.,180.,-90);
4807   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4808   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4809   TGeoHMatrix* laddersupportmatrix[2];
4810   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4811   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4812   /////////////////////////////////////////////////////////////
4813   // Creating Mother Volume for Containment
4814   /////////////////////////////////////////////////////////////
4815   Double_t *xmothervertex[fgklayernumber];
4816   Double_t *ymothervertex[fgklayernumber];
4817   for(Int_t i=0; i<fgklayernumber; i++){
4818         xmothervertex[i] = new Double_t[8];
4819         ymothervertex[i] = new Double_t[8];
4820   }  
4821   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4822   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4823   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4824 //  TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4825   TGeoVolumeAssembly* upmotherladdersupport[fgklayernumber];   
4826   char upmotheladdersupportname[30];
4827   char downmotheladdersupportname[30];
4828   for(Int_t i=0; i<fgklayernumber; i++){
4829         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4830                                                     -  mountingsupportedge[i];
4831         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4832         xmothervertex[i][1] = xmothervertex[i][0];
4833         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4834                                                         + fgkMountingBlockSupportWidth[0];
4835         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4836         ymothervertex[i][2] = ymothervertex[i][1];
4837         xmothervertex[i][3] = xmothervertex[i][2];
4838         ymothervertex[i][3] = -ymothervertex[i][0];
4839         xmothervertex[i][4] = -xmothervertex[i][0];
4840         ymothervertex[i][4] = ymothervertex[i][3];
4841         xmothervertex[i][5] = xmothervertex[i][4];
4842         ymothervertex[i][5] = -ymothervertex[i][1];
4843         xmothervertex[i][6] = -xmothervertex[i][2];
4844         ymothervertex[i][6] = ymothervertex[i][5];
4845         xmothervertex[i][7] = xmothervertex[i][6];
4846         ymothervertex[i][7] = ymothervertex[i][0];
4847         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4848         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4849     downmotherladdersupportshape[i] = new TGeoXtru(2);
4850         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4851         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4852     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4853                                                                    +                       fgkMountingBlockSupportDownHeight
4854                                                                    +                       fgkSSDMountingBlockHeight[1]
4855                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4856                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4857                                                                    -                       2.*fgkSSDModuleVerticalDisalignment);
4858     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4859                                                                           downmotherladdersupportshape[i],fSSDAir);
4860     upmotherladdersupportshape[i] = new TGeoXtru(2);
4861         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4862         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4863     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4864                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4865                                                                    +                       fgkSSDMountingBlockHeight[1]
4866                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4867                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4868                                                                    -               2.*fgkSSDModuleVerticalDisalignment);
4869         upmotherladdersupport[i] = new TGeoVolumeAssembly(upmotheladdersupportname);
4870 //    upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4871 //                                                                                        upmotherladdersupportshape[i],fSSDAir);
4872   }
4873   for(Int_t i=0; i<fgklayernumber; i++){
4874         /////////////////////////
4875         // Setting the box origin
4876         /////////////////////////
4877         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4878         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4879                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4880         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4881                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4882   
4883         boxorigindown[i][1][0] = 0.0;
4884         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4885         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4886                                                    -      fgkMountingBlockSupportWidth[0]);
4887                                                    
4888         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4889         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4890                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4891         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4892                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4893   
4894         boxoriginup[i][1][0] = 0.0;
4895         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4896                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4897         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4898                                                  - fgkMountingBlockSupportWidth[0]);
4899   
4900         /////////////////////////
4901     // Setting the boxes    
4902         /////////////////////////
4903         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4904                                                                                  +  fgkSSDMountingBlockLength[0]),
4905                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4906                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4907                                                                                         boxorigindown[i][0]);
4908     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4909                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4910                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4911                                                                                  -  fgkMountingBlockSupportWidth[0]),
4912                                                                                         boxorigindown[i][1]);
4913                                                                                         
4914         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4915                                                                                  +  fgkSSDMountingBlockLength[0]),
4916                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4917                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4918                                                                                         boxoriginup[i][0]);
4919                                                                                         
4920         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4921                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4922                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4923                                                                      -  fgkMountingBlockSupportWidth[0]),
4924                                                                                         boxoriginup[i][1]);
4925         ///////////////////////////////////////
4926     // Adding the Volumes to Mother Volume    
4927         ///////////////////////////////////////
4928         for(Int_t j=0; j<2; j++){
4929                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4930                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4931                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4932                                                                                   mountingblocksupportboxdownshape[i][j],
4933                                                                                   fSSDCarbonFiberMedium);
4934                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4935                                                                                   mountingblocksupportboxupshape[i][j],
4936                                                                                   fSSDCarbonFiberMedium);
4937                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4938                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4939                 for(Int_t k=0; k<2; k++){
4940                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4941 //                      upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4942                 }
4943         }
4944         for(Int_t k=0; k<2; k++){
4945                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4946                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4947                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4948                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4949             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4950                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4951                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4952 //              upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4953 //              upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4954 //              upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4955 //              upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4956 //              upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4957         }
4958   }
4959   TList* laddersupportlist = new TList();
4960   laddersupportlist->Add(downmotherladdersupport[0]); 
4961   laddersupportlist->Add(upmotherladdersupport[0]); 
4962   laddersupportlist->Add(downmotherladdersupport[1]); 
4963   laddersupportlist->Add(upmotherladdersupport[1]); 
4964   /////////////////////////////////////////////////////////////
4965   // Deallocating memory
4966   /////////////////////////////////////////////////////////////
4967   for(Int_t i=0; i<fgklayernumber; i++){
4968         for(Int_t j=0; j<nedges+1; j++)
4969                 delete vertex[i][j];
4970         delete mountingsupportedgevector[i];
4971         delete [] vertex[i];
4972         delete vertexlist[i];
4973         delete [] xsidevertex[i];
4974         delete [] ysidevertex[i];
4975         delete [] xcentervertex[i];
4976         delete [] ycentervertex[i];
4977         delete [] xsidelowervertex[i];
4978         delete [] ysidelowervertex[i];
4979         delete [] xcenterlowervertex[i];
4980         delete [] ycenterlowervertex[i];
4981   }
4982   delete xsidevertex;
4983   delete ysidevertex;
4984   delete xcentervertex;
4985   delete ycentervertex;
4986   delete xsidelowervertex;
4987   delete ysidelowervertex;
4988   delete xcenterlowervertex;
4989   delete ycenterlowervertex;
4990   delete globalrefladdersupportrot;
4991   delete mountingblocksupportrot;
4992   /////////////////////
4993   return laddersupportlist;     
4994 }
4995  ////////////////////////////////////////////////////////////////////////////////
4996 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4997 //////////////////////////////////////////
4998 // Method Generating Ladder Support Ring
4999 //////////////////////////////////////////
5000   if(!fCreateMaterials) CreateMaterials();
5001   if(!fTransformationMatrices) CreateTransformationMatrices();
5002   if(!fBasicObjects) CreateBasicObjects();
5003   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5004   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5005     const Int_t kssdlayladdernumber[fgklayernumber] = 
5006                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5007   Double_t mountingsupportedge[fgklayernumber];
5008   Double_t mountingblockratio[fgklayernumber];
5009   Double_t theta[fgklayernumber];
5010   Double_t phi[fgklayernumber];
5011   for(Int_t i=0; i<fgklayernumber; i++){
5012         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5013     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5014                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
5015                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5016                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5017                                                           / kssdlayladdernumber[i])));
5018     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5019                          / fgkMountingBlockSupportRadius[i]);
5020     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5021   }
5022   TGeoRotation* globalrot = new TGeoRotation();
5023   globalrot->SetAngles(0.,-90.,0.); 
5024   TGeoRotation** laddersupportrot[fgklayernumber];
5025   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5026   for(Int_t i=0; i<fgklayernumber; i++){                
5027         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5028         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5029         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5030                 laddersupportrot[i][j] = new TGeoRotation();
5031                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5032                 switch(i){
5033                         case 0: //Ladder of Layer5  
5034                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5035                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5036                                                                             laddersupportmatrix[i][j]); 
5037                         break;
5038                         case 1: //Ladder of Layer6 
5039                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5040                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5041                                                                               laddersupportmatrix[i][j]); 
5042                         break;
5043                 }
5044     }
5045   }
5046   /////////////////////////////////////////////////////////////
5047   // Creating Lower Ladder Support 
5048   /////////////////////////////////////////////////////////////
5049   TVector3** ringsupportvertex[fgklayernumber];         
5050   Double_t angle = 360./nedges;
5051   for(Int_t i=0; i<fgklayernumber; i++){
5052     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5053         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5054                                                         *                          TMath::Cos(theta[i]));
5055         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5056                                                         -                          mountingsupportedge[i],
5057                                                                                    ringsupportvertex[i][0]->Y());
5058         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5059                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5060     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5061         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5062            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5063            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5064            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5065            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5066         }
5067         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5068     for(Int_t j=0; j<nedges+1; j++){
5069                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5070                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5071                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5072         }
5073   }
5074   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5075   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5076   for(Int_t i=0; i<fgklayernumber; i++){
5077         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5078         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5079         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5080                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5081                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5082         }
5083   }
5084 ////////////////////////////////////////////////////////////////////////////////
5085 // Start Corrections 13/06/08
5086 ////////////////////////////////////////////////////////////////////////////////
5087   char lowerladderpconsupportname[30];
5088   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5089   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5090   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5091   Double_t lowerladderpconradiusmax[fgklayernumber];
5092   Double_t lowerladderpconradiusmin[fgklayernumber];
5093   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5094   lowerladdersupportrot->SetAngles(90.,180.,-90);
5095   for(Int_t i=0; i<fgklayernumber; i++){
5096         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5097                                                                 *                          TMath::Cos(theta[i]);
5098     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5099   } 
5100   for(Int_t i=0; i<fgklayernumber; i++){
5101 ///////////////////////////  Modified Version ?///////////////////
5102     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5103         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5104                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5105                                                          lowerladderpconradiusmax[i]);
5106         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5107         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5108     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5109         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5110         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5111  }
5112 ////////////////////////////////////////////////////////////////////////////////
5113 // End Corrections 13/06/08
5114 ////////////////////////////////////////////////////////////////////////////////
5115   /*char lowerladdersupportname[30];
5116   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5117   TGeoVolume* lowerladdersupport[fgklayernumber];
5118   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5119   lowerladdersupportrot->SetAngles(90.,180.,-90);
5120   for(Int_t i=0; i<fgklayernumber; i++){
5121         lowerladdersupportshape[i] = new TGeoXtru(2);
5122         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5123                                                                                           xmothervertex[i],ymothervertex[i]);
5124         lowerladdersupportshape[i]->DefineSection(0,0.);
5125     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5126         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5127     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5128                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5129         lowerladdersupport[i]->SetLineColor(fColorAl);
5130         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5131         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5132   }*/
5133   /////////////////////////////////////////////////////////////
5134   // Deallocating memory
5135   /////////////////////////////////////////////////////////////
5136   for(Int_t i=0; i<fgklayernumber; i++){
5137         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5138                 delete ringsupportvertex[i][j];
5139         delete [] ringsupportvertex[i];
5140   }
5141   for(Int_t i=0; i<fgklayernumber; i++){
5142         delete [] xmothervertex[i];
5143         delete [] ymothervertex[i];
5144   }
5145   delete xmothervertex;
5146   delete ymothervertex; 
5147   delete globalrot;
5148   for(Int_t i=0; i<fgklayernumber; i++){
5149         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5150                 delete laddersupportrot[i][j];
5151         delete [] laddersupportrot[i];
5152   }
5153  }  
5154  ////////////////////////////////////////////////////////////////////////////////
5155  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5156   /////////////////////////////////////////////////////////////
5157   // Method generating Endcap CoverPlate
5158   /////////////////////////////////////////////////////////////
5159   // Holes Definition 
5160   ///////////////////
5161   Int_t nendcapcoverplateholedges = 30;
5162   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5163   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5164                                                           0.5*fgkEndCapCoverPlateThickness};
5165   TGeoXtru* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5166                                                                                                               nendcapcoverplateholedges,holesection);
5167   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5168                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5169   endcapcoverplatesmallhole->SetLineColor(6);
5170   TGeoXtru* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5171                                                                                                               nendcapcoverplateholedges,holesection);
5172   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5173                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5174   endcapcoverplatebighole->SetLineColor(6);
5175   //////////////////////////
5176   // Screw Piece Definition 
5177   //////////////////////////
5178   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5179   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5180                                                                                                       CosD(0.5*smallscrewangle),
5181                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5182   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5183                                                                                                 endcapsmallscrewpieceshape,
5184                                                                                                 fSSDCoolingTubePhynox);
5185   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5186   ///////////////////
5187   // Box Definition 
5188   ///////////////////
5189   TGeoBBox* endcapcoverplateboxshape[4];
5190   TGeoVolume* endcapcoverplatebox[4];
5191   Double_t boxorigin[5][3];
5192   boxorigin[0][0] = 0.;
5193   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5194   boxorigin[0][2] = 0.;
5195
5196   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5197   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5198   boxorigin[1][2] = 0.;
5199
5200   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5201                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5202   boxorigin[2][1] = boxorigin[1][1];
5203   boxorigin[2][2] = 0.;
5204
5205   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5206                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5207   boxorigin[3][1] = boxorigin[1][1];
5208   boxorigin[3][2] = 0.;
5209
5210   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5211                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5212                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5213                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5214
5215   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5216                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5217                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5218                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5219                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5220
5221   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5222                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5223                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5224                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5225                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5226
5227   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5228                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5229                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5230                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5231                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5232   
5233   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5234                                                                            fSSDAlCoolBlockMedium);
5235   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5236                                                                            fSSDAlCoolBlockMedium);
5237   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5238                                                                            fSSDAlCoolBlockMedium);
5239   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5240                                                                            fSSDAlCoolBlockMedium);
5241   endcapcoverplatebox[0]->SetLineColor(6);
5242   endcapcoverplatebox[1]->SetLineColor(6);
5243   endcapcoverplatebox[2]->SetLineColor(6);
5244   endcapcoverplatebox[3]->SetLineColor(6);
5245   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5246   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5247                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5248                                                                                         0.5*fgkEndCapCoverPlateThickness,
5249                                                                                         endcapfillingboxorigin);
5250   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5251                                                                            fSSDAlCoolBlockMedium);
5252   endcapfillingbox->SetLineColor(6);
5253   ////////////////////////////
5254   // Contour Xtru Definition 
5255   ////////////////////////////
5256   const Int_t kcontourvertexnumber = 10;
5257   Double_t xcontourvertex[kcontourvertexnumber];
5258   Double_t ycontourvertex[kcontourvertexnumber];
5259   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5260   xcontourvertex[1] = xcontourvertex[0];
5261   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5262   xcontourvertex[3] = xcontourvertex[2];
5263   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5264   xcontourvertex[5] = xcontourvertex[4];
5265   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5266   xcontourvertex[7] = xcontourvertex[6];
5267   xcontourvertex[8] = xcontourvertex[4];
5268   xcontourvertex[9] = xcontourvertex[8];
5269   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5270                                         - (kendcapcoverplatesmallholenumber[1]-1)
5271                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5272   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5273                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5274   ycontourvertex[2] = ycontourvertex[1];
5275   ycontourvertex[3] = ycontourvertex[0];
5276   ycontourvertex[4] = ycontourvertex[3];
5277   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5278   ycontourvertex[6] = ycontourvertex[5];
5279   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5280                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5281                                         + fgkEndCapCoverPlateSmallHoleRadius;
5282   ycontourvertex[8] = ycontourvertex[7];
5283   ycontourvertex[9] = ycontourvertex[0];
5284   TGeoXtru* contourshape = new TGeoXtru(2);
5285   contourshape->DefinePolygon(kcontourvertexnumber,xcontourvertex,ycontourvertex);  
5286   contourshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5287   contourshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5288   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5289                                                                            fSSDAlCoolBlockMedium);
5290   contour->SetLineColor(6);
5291   /////////////////////////////
5292   // Hole Contour Xtru Definition 
5293   ////////////////////////////
5294   const Int_t kholecontourvertexnumber = 10;
5295   Double_t xholecontourvertex[2][kcontourvertexnumber];
5296   Double_t yholecontourvertex[2][kcontourvertexnumber];
5297   xholecontourvertex[0][0] = xcontourvertex[0];
5298   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5299   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5300   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5301   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5302                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5303                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5304   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5305   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5306                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5307   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5308   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5309   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5310   
5311   yholecontourvertex[0][0] = ycontourvertex[1];
5312   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5313   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5314   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5315   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5316   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5317                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5318   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5319   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5320   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5321   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5322
5323   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5324   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5325   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5326   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5327   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5328                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5329                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5330   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5331   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5332                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5333   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5334   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5335   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5336   
5337   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5338                                                    - fgkEndCapCoverPlateWidth[0]);
5339   yholecontourvertex[1][1] = ycontourvertex[0];
5340   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5341   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5342   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5343   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5344                                                    - fgkEndCapCoverPlateWidth[0]
5345                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5346   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5347   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5348   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5349   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5350
5351   TGeoXtru* holecontourshape[2];
5352   holecontourshape[0] = new TGeoXtru(2);
5353   holecontourshape[0]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[0],
5354                                                                   yholecontourvertex[0]);  
5355   holecontourshape[0]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5356   holecontourshape[0]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5357
5358   holecontourshape[1] = new TGeoXtru(2);
5359   holecontourshape[1]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[1],
5360                                                                   yholecontourvertex[1]);  
5361   holecontourshape[1]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5362   holecontourshape[1]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5363
5364   TGeoVolume* holecontour[2];
5365   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",holecontourshape[0],
5366                                                                   fSSDAlCoolBlockMedium);
5367   holecontour[0]->SetLineColor(6);
5368   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",holecontourshape[1],
5369                                                                   fSSDAlCoolBlockMedium);
5370   holecontour[1]->SetLineColor(6);
5371   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5372                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5373   TGeoTranslation*  bigholetrans[3];
5374   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5375                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5376   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5377                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5378                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5379   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5380                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5381   /////////////////////////////////
5382   // Mother Volume Xtru Definition 
5383   /////////////////////////////////
5384   const Int_t kmothervertexnumber = 12;
5385   Double_t xmothervertex[kmothervertexnumber];  
5386   Double_t ymothervertex[kmothervertexnumber];  
5387   xmothervertex[0]  = xcontourvertex[0];
5388   xmothervertex[1]  = xmothervertex[0];
5389   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5390   xmothervertex[3]  = xmothervertex[2];
5391   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5392   xmothervertex[5]  = xmothervertex[4];
5393   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5394   xmothervertex[7]  = xmothervertex[6];
5395   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5396                                         + fgkEndCapCoverPlateLength[2]; 
5397   xmothervertex[9]  = xmothervertex[8];
5398   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5399   xmothervertex[11] = xmothervertex[10];
5400   
5401   ymothervertex[0]  = ycontourvertex[0];
5402   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5403   ymothervertex[2]  = ymothervertex[1];
5404   ymothervertex[3]  = ycontourvertex[1];
5405   ymothervertex[4]  = ymothervertex[3];
5406   ymothervertex[5]  = ymothervertex[1];
5407   ymothervertex[6]  = ymothervertex[5];
5408   ymothervertex[7]  = ymothervertex[0];
5409   ymothervertex[8]  = ymothervertex[7];
5410   ymothervertex[9]  = ymothervertex[8]
5411                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5412   ymothervertex[10] = ymothervertex[9];
5413   ymothervertex[11] = ymothervertex[8];
5414   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5415   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5416   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5417   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5418   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5419   ////////////////////////////////////////
5420   // Adding Nodes
5421   ////////////////////////////////////////
5422 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5423   TGeoTranslation*** endcapcoverplatesmallholetrans;
5424   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5425   Double_t transx[4] = {0,
5426                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5427                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5428                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5429                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5430                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5431   Int_t index = 0;
5432   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5433         endcapcoverplatesmallholetrans[i] = 
5434                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5435     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5436                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5437             endcapcoverplatesmallholetrans[i][j] = 
5438                 new TGeoTranslation(transx[i],
5439                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5440             if(index!=10){ 
5441                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5442                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5443                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5444                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5445                 }
5446                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5447                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5448                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5449     }
5450   }
5451   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5452   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5453   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5454   mothercoverplate->AddNode(endcapfillingbox,1);
5455   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5456   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5457   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5458   mothercoverplate->AddNode(holecontour[0],1);
5459   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5460   mothercoverplate->AddNode(holecontour[1],1);  
5461   mothercoverplate->AddNode(contour,1);
5462   /////////////////////////////////
5463   return mothercoverplate;      
5464  }
5465  ////////////////////////////////////////////////////////////////////////////////
5466  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5467   /////////////////////////////////////////////////////////////
5468   // Getting EndCap Cooling Tube 
5469   /////////////////////////////////////////////////////////////
5470   TGeoTorus* endcapcoolingtubetorushape[5];
5471   TGeoVolume* endcapcoolingtubetorus[5];
5472   TGeoTube* endcapcoolingtubeshape[4];
5473   TGeoVolume* endcapcoolingtube[4];
5474   char endcapcoolingtubetorusname[30];
5475   char endcapcoolingtubename[30];
5476   TGeoTorus* endcapcoolingwatertubetorushape[5];
5477   TGeoVolume* endcapcoolingwatertubetorus[5];
5478   TGeoTube* endcapcoolingwatertubeshape[4];
5479   TGeoVolume* endcapcoolingwatertube[4];
5480   char endcapcoolingwatertubetorusname[30];
5481   char endcapcoolingwatertubename[30];
5482   for(Int_t i=0; i<5; i++){
5483         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5484         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5485         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5486         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5487         if(i==3){
5488                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5489                                                                                 fgkEndCapCoolingTubeRadiusMin,
5490                                                                                 fgkEndCapCoolingTubeRadiusMax,
5491                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5492                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5493                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5494                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5495     }
5496         else{
5497                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5498                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5499                                                                            fgkEndCapCoolingTubeRadiusMin,
5500                                                                            fgkEndCapCoolingTubeRadiusMax,
5501                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5502                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5503                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5504                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5505                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5506         }
5507         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5508                                                                                            endcapcoolingtubetorushape[i],
5509                                                                                            fSSDCoolingTubePhynox);
5510         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5511                                                                                                         endcapcoolingwatertubetorushape[i],
5512                                                                                                         fSSDCoolingTubeWater);
5513     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5514     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5515     if(i<4){
5516                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5517                                                                   fgkEndCapCoolingTubeRadiusMax,
5518                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5519                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5520                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5521         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5522                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5523         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5524                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5525                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5526                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5527         }
5528   }
5529   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5530   /////////////////////////////////////////
5531   // Transformation for Volume Positioning 
5532   /////////////////////////////////////////
5533   TGeoCombiTrans* coolingtubecombitrans[6];
5534   TGeoRotation* coolingtuberot[8];
5535   TGeoTranslation* coolingtubetrans[6];
5536   TGeoHMatrix* coolingtubematrix[4];
5537   TGeoCombiTrans* torustubecombitrans[4];
5538   TGeoRotation* torustuberot[7];
5539   TGeoTranslation* torustubetrans[4];
5540   TGeoHMatrix* torustubematrix[5];
5541   TGeoCombiTrans* coolingwatertubecombitrans[6];
5542   TGeoRotation* coolingwatertuberot[8];
5543   TGeoTranslation* coolingwatertubetrans[6];
5544   TGeoHMatrix* coolingwatertubematrix[4];
5545   TGeoCombiTrans* toruswatertubecombitrans[4];
5546   TGeoRotation* toruswatertuberot[7];
5547   TGeoTranslation* toruswatertubetrans[4];
5548   TGeoHMatrix* toruswatertubematrix[5];
5549   for(Int_t i=0; i<8; i++){
5550     if(i<6){
5551          coolingtubetrans[i] = new TGeoTranslation();
5552          coolingwatertubetrans[i] = new TGeoTranslation();
5553     }
5554     if(i<8){
5555          coolingtuberot[i] = new TGeoRotation();
5556          coolingwatertuberot[i] = new TGeoRotation();
5557     }
5558     if(i<4){
5559          torustubetrans[i] = new TGeoTranslation();
5560          toruswatertubetrans[i] = new TGeoTranslation();
5561     }
5562     if(i<7){
5563          torustuberot[i] = new TGeoRotation();
5564          toruswatertuberot[i] = new TGeoRotation();
5565         }
5566   }
5567   /////////////////////////////////////////
5568   // Transformation for Inox Volume Positioning 
5569   /////////////////////////////////////////
5570   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5571                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5572   coolingtuberot[0]->SetAngles(0.,90.,0.);
5573   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5574                                                                                                 *coolingtuberot[0]);
5575                                                                                                 
5576   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5577   coolingtuberot[1]->SetAngles(0.,90.,0.);
5578   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5579                                                                                                 *coolingtuberot[1]);
5580
5581   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5582                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5583                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5584                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5585                                                                           0.);
5586   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5587   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5588                                                                                                 *coolingtuberot[2]);
5589
5590   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5591                                            *                             (*coolingtubecombitrans[1]));
5592
5593   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5594                                                                          endcapcoolingtubeshape[1]->GetDz());
5595   torustuberot[0]->SetAngles(0.,90.,0.); 
5596   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5597
5598   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5599
5600   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5601                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5602   coolingtuberot[3]->SetAngles(0.,90.,0.);
5603   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5604                                                                                                 *coolingtuberot[3]);
5605   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5606   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5607   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5608   
5609   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5610                                                                         endcapcoolingtubeshape[2]->GetDz());
5611   torustuberot[1]->SetAngles(0.,90.,0.); 
5612   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5613   torustuberot[2]->SetAngles(180.,0.,0.); 
5614   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5615   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5616
5617   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5618                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5619   torustuberot[3]->SetAngles(0.,90.,0.); 
5620   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5621   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5622   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5623   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5624
5625   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5626                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5627   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5628   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5629                                                                                                 *coolingtuberot[5]);
5630   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5631   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5632   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5633   
5634   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5635                                                                         endcapcoolingtubeshape[0]->GetDz());
5636   torustuberot[5]->SetAngles(0.,90.,0.); 
5637   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5638   torustuberot[6]->SetAngles(-90.,0.,0.); 
5639   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5640   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5641   
5642   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5643                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5644   coolingtuberot[6]->SetAngles(0.,90.,0.);
5645   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5646                                                                                                 *coolingtuberot[6]);
5647   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5648   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5649   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5650     /////////////////////////////////////////
5651   // Transformation for Water Volume Positioning 
5652   /////////////////////////////////////////
5653   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5654                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5655   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5656   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5657                                                                                                      *coolingwatertuberot[0]);
5658
5659   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5660   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5661   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5662                                                                                                      *coolingwatertuberot[1]);
5663
5664   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5665                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5666                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5667                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5668                                                                               0.);
5669   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5670   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5671                                                                                                     *coolingwatertuberot[2]);
5672
5673   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5674                                            *                                 (*coolingwatertubecombitrans[1]));
5675                                            
5676   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5677                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5678   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5679   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5680                                                                                                    *toruswatertuberot[0]);
5681
5682   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5683                                                   *                                     (*toruswatertubecombitrans[0]));
5684
5685   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5686                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5687   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5688   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5689                                                                                                      *coolingwatertuberot[3]);
5690   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5691   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5692                                                         *                                 (*coolingwatertubecombitrans[3]));
5693   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5694
5695   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5696                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5697   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5698   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5699                                                                                                    *toruswatertuberot[1]);
5700   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5701   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5702                                                   *                 (*toruswatertubecombitrans[1]));
5703   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5704   
5705   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5706                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5707   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5708   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5709                                                                                                    *toruswatertuberot[3]);
5710   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5711   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5712                                                   *                                     (*toruswatertubecombitrans[2]));
5713   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5714
5715   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5716                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5717   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5718   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5719                                                                                                      *coolingwatertuberot[5]);
5720   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5721   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5722                                                         *                                 (*coolingwatertubecombitrans[4]));
5723   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5724   
5725   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5726                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5727   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5728   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5729                                                                                                    *toruswatertuberot[5]);
5730   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5731   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5732                                                   *                 (*toruswatertubecombitrans[3]));
5733   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5734   
5735   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5736                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5737   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5738   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5739                                                                                                      *coolingwatertuberot[6]);
5740   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5741   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5742                                                         *                                 (*coolingwatertubecombitrans[5]));
5743   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5744   /////////////////////////////////////////
5745   // Positioning Volumes
5746   /////////////////////////////////////////
5747   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5748   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5749   
5750   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5751   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5752
5753   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5754   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5755  
5756   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5757   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5758
5759   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5760   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5761
5762   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5763   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5764
5765   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5766   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5767
5768   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5769   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5770   
5771   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5772   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5773  
5774   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5775   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5776   /////////////////////////////////////////////////////////////
5777   // Deallocating memory
5778   /////////////////////////////////////////////////////////////
5779   for(Int_t i=0; i<8; i++){
5780     if(i<6){
5781          delete coolingtubetrans[i];
5782          delete coolingwatertubetrans[i];
5783          if(i!=0){
5784           delete coolingtubecombitrans[i];
5785           delete coolingwatertubecombitrans[i];
5786          }
5787         }
5788     if(i<8){
5789           delete coolingtuberot[i];
5790           delete coolingwatertuberot[i];
5791     }
5792     if(i<4){
5793                 delete torustubetrans[i];
5794                 delete toruswatertubetrans[i];
5795                 delete torustubecombitrans[i];
5796                 delete toruswatertubecombitrans[i];
5797         } 
5798     if(i<7){
5799          delete torustuberot[i];
5800          delete toruswatertuberot[i];
5801         }
5802   }
5803   /////////////////////////////////////////////////////////////
5804   return endcapcoolingtubemother;
5805  }
5806  ////////////////////////////////////////////////////////////////////////////////
5807  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5808   /////////////////////////////////////////////////////////////
5809   // Getting EndCap Cover Side 
5810   /////////////////////////////////////////////////////////////
5811   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5812   const Int_t kvertexnumber = 15; 
5813   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5814   xvertex[0]  = 0.0;
5815   xvertex[1]  = xvertex[0];
5816   xvertex[2]  = fgkEndCapSideCoverLength[0];
5817   xvertex[3]  = fgkEndCapSideCoverLength[1];
5818   xvertex[4]  = xvertex[3];
5819   xvertex[5]  = fgkEndCapSideCoverLength[2];
5820   xvertex[6]  = xvertex[5];
5821   xvertex[7]  = xvertex[2];
5822   xvertex[8]  = xvertex[7];
5823   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5824   xvertex[10] = xvertex[9];
5825   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5826                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5827                           * fgkEndCapSideCoverLength[4];
5828   xvertex[12] = xvertex[11];
5829   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5830                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5831                           * fgkEndCapSideCoverLength[4];
5832   xvertex[14] = xvertex[13];
5833   yvertex[0]  = 0.0;
5834   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5835   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5836   yvertex[3]  = yvertex[2];
5837   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5838   yvertex[5]  = yvertex[4];
5839   yvertex[6]  = yvertex[0];
5840   yvertex[7]  = yvertex[6];
5841   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5842   yvertex[9]  = yvertex[8];
5843   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5844   yvertex[11] = yvertex[10];
5845   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5846   yvertex[13] = yvertex[12];
5847   yvertex[14] = yvertex[6];
5848   TGeoXtru* endcapsidecovershape = new TGeoXtru(2);
5849   endcapsidecovershape->DefinePolygon(kvertexnumber,xvertex,yvertex); 
5850   endcapsidecovershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5851   endcapsidecovershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5852   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5853                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5854   endcapsidecover->SetLineColor(fColorPhynox);
5855   ////////////////////////////////////////////
5856   // Defininition of Mother Volume
5857   ////////////////////////////////////////////
5858   const Int_t kmothervertexnumber = 7;
5859   Double_t xmothervertex[kmothervertexnumber]; 
5860   Double_t ymothervertex[kmothervertexnumber]; 
5861   for(Int_t i=0; i<kmothervertexnumber; i++){
5862         xmothervertex[i] = xvertex[i];
5863         ymothervertex[i] = yvertex[i];
5864   }
5865   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5866   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5867   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5868   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5869   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5870                                                                 endcapsidecovermothershape,fSSDAir);
5871   ////////////////////////////////////////////
5872   endcapsidecovermother->AddNode(endcapsidecover,1);
5873   TGeoBBox* endcapsidecoverboxshape[4];
5874   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5875                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5876                                                                0.5*fgkEndCapSideCoverLength[4],
5877                                                                    0.5*fgkEndCapSideCoverThickness); 
5878   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5879                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5880                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5881                                                          -     fgkEndCapSideCoverLength[4]),
5882                                                                    0.5*fgkEndCapSideCoverThickness); 
5883   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5884                                                                0.5*fgkEndCapSideCoverLength[4],
5885                                                                    0.5*fgkEndCapSideCoverThickness); 
5886   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5887                                                                0.5*fgkEndCapSideCoverWidth[5],
5888                                                                    0.5*fgkEndCapSideCoverThickness); 
5889   TGeoVolume* endcapsidecoverbox[4];
5890   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5891   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5892   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5893   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5894   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5895 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5896   TGeoTranslation** endcapsidecoverboxtrans;
5897   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5898   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5899                                                          +                                         fgkEndCapSideCoverLength[0],
5900                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5901                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5902   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5903                                                          +                     xvertex[11],
5904                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5905                                                          +                     yvertex[12],0.);
5906   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5907                                                          +                     xvertex[11],
5908                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5909                                                          +                     yvertex[12]
5910                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5911                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5912   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5913   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5914   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5915   for(Int_t i=0; i<2; i++)
5916         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5917                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5918                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5919                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5920                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5921                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5922                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5923                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5924         }
5925   for(Int_t i=0; i<2; i++)
5926         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5927                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5928                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5929                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5930                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5931                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5932                                                         +fgkEndCapSideCoverLength[4]),0.0);
5933                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5934                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5935                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5936                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5937         }
5938         return endcapsidecovermother;
5939  } 
5940  ////////////////////////////////////////////////////////////////////////////////
5941  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5942  ////////////////////////////////////////////////////////////////////////////////
5943  // Method returning Interface Card A, Interface Card B, Supply Card 
5944  ////////////////////////////////////////////////////////////////////////////////
5945  /////////////////////
5946  // Supply Card
5947  /////////////////////
5948  // Electronic Board Back Al Plane
5949  const Int_t kelectboardbackvertexnumber = 8;
5950  Double_t xelectboardback[kelectboardbackvertexnumber];
5951  Double_t yelectboardback[kelectboardbackvertexnumber];
5952  xelectboardback[0] = 0.0;
5953  xelectboardback[1] = xelectboardback[0];
5954  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5955  xelectboardback[3] = xelectboardback[2];
5956  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5957  xelectboardback[5] = xelectboardback[4];
5958  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5959  xelectboardback[7] = xelectboardback[6];
5960  
5961  yelectboardback[0] = 0.0;
5962  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5963  yelectboardback[2] = yelectboardback[1];
5964  yelectboardback[3] = yelectboardback[0];
5965  yelectboardback[4] = yelectboardback[3];
5966  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5967  yelectboardback[6] = yelectboardback[5];
5968  yelectboardback[7] = yelectboardback[4];
5969  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5970  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5971                                                                         xelectboardback,yelectboardback); 
5972  electboardbackshape->DefineSection(0,0.0);
5973  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5974  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5975                                                                                          electboardbackshape,fSSDSupportRingAl);
5976  electboardback->SetLineColor(fColorAl);
5977  // Electronic Board Kapton Layer
5978  const Int_t kelectlayervertexnumber = 8;
5979  Double_t xelectlayer[kelectlayervertexnumber];
5980  Double_t yelectlayer[kelectlayervertexnumber];
5981  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5982  xelectlayer[1] = xelectlayer[0];
5983  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5984  xelectlayer[3] = xelectlayer[2];
5985  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5986      
5987  yelectlayer[0] = 0.0;
5988  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5989  yelectlayer[2] = yelectlayer[1];
5990  yelectlayer[3] = yelectlayer[0];
5991  yelectlayer[4] = yelectlayer[3];
5992  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5993  yelectlayer[6] = yelectlayer[5];
5994  yelectlayer[7] = yelectlayer[4];
5995  TGeoXtru* electlayershape = new TGeoXtru(2);
5996  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5997  electlayershape->DefineSection(0,0.0);
5998  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5999  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6000                                                                                          electlayershape,fSSDKaptonFlexMedium);
6001  electlayer->SetLineColor(fColorKapton);
6002  // JMD Connector Female
6003  const Int_t kjmdconnectorvertexnumber = 6;
6004  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6005  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6006  xjmdconnectorvertex[0] = 0.0; 
6007  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6008  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6009  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6010  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6011  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6012
6013  yjmdconnectorvertex[0] = 0.0; 
6014  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6015  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6016  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6017  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6018  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6019  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6020  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6021                                                                   yjmdconnectorvertex); 
6022  jmdconnectorshape->DefineSection(0,0.0);
6023  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6024  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6025                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6026  jmdconnector->SetLineColor(fColorG10);
6027  // Top Cable Connector
6028  const Int_t kcableconnectorvertexnumber = 8;
6029  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6030  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6031  xconnectorvertex[0] = 0.0;
6032  xconnectorvertex[1] = xconnectorvertex[0];
6033  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6034  xconnectorvertex[3] = xconnectorvertex[2];
6035  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6036                                          - fgkEndCapCardCableConnectorLength[2];
6037  xconnectorvertex[5] = xconnectorvertex[4];
6038  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6039  xconnectorvertex[7] = xconnectorvertex[6];
6040
6041  yconnectorvertex[0] = 0.0;
6042  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6043  yconnectorvertex[2] = yconnectorvertex[1];
6044  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6045  yconnectorvertex[4] = yconnectorvertex[3];
6046  yconnectorvertex[5] = yconnectorvertex[1];
6047  yconnectorvertex[6] = yconnectorvertex[5];
6048  yconnectorvertex[7] = yconnectorvertex[0];
6049  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6050  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6051                                                                     yconnectorvertex); 
6052  cableconnectorshape->DefineSection(0,0.0);
6053  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6054  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6055                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6056  cableconnector->SetLineColor(fColorG10);
6057  // Strip Connection
6058  TGeoBBox* endcapstripconnectionshape = 
6059                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6060                                                                                          0.5*fgkEndCapStripConnectionThickness,
6061                                                                                          0.5*fgkEndCapStripConnectionWidth);
6062  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6063                                                                                                         endcapstripconnectionshape,
6064                                                                                                         fSSDSupportRingAl);
6065  endcapstripconnection->SetLineColor(fColorAl);
6066  // Interface Card B
6067  const Int_t kcardBvertexnumber = 12; 
6068  Double_t xcardBvertexnumber[kcardBvertexnumber];
6069  Double_t ycardBvertexnumber[kcardBvertexnumber];
6070
6071  xcardBvertexnumber[0]  = 0.0;
6072  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6073  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6074  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6075  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6076  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6077  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6078  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6079  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6080  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6081  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6082  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6083  
6084  ycardBvertexnumber[0]  = 0.0;
6085  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6086  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6087  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6088  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6089  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6090  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6091  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6092  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6093  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6094  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6095  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6096
6097  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6098  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6099  interfacecardBshape->DefineSection(0,0.);
6100  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6101  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6102                                                                                          fSSDMountingBlockMedium);
6103  interfacecardB->SetLineColor(46);
6104  // Interface Card B Electronic Board
6105  const Int_t kelectboardcardBvertexnumber = 14; 
6106  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6107  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6108
6109  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6110  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6111  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6112  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6113  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6114  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6115  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6116  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6117  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6118  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6119  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6120  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6121  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6122  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6123
6124  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6125  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6126  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6127  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6128  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6129  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6130  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6131  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6132  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6133  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6134  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6135  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6136  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6137  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6138
6139  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6140  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6141                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6142  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6143  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6144                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6145  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6146                                                                                           fSSDSupportRingAl);
6147  electboardcardB->SetLineColor(fColorAl);
6148  // Generating Stiffener 2
6149  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6150                                                                                            0.5*fgkEndCapStiffenerThickness,
6151                                                                                            0.5*fgkEndCapStiffenerLength);
6152  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6153  endcapstiffener->SetLineColor(fColorAl);   
6154  // Generating Mother Interface Card B Container
6155  const Int_t kinterfacecardBmothervertexnumber = 10;
6156  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6157  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6158
6159  xinterfacecardBmothervertex[0] = 0.0;
6160  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6161  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6162                                                                 + fgkEndCapInterfaceCardBThickness;
6163  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6164  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6165                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6166  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6167  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6168  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6169  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6170                                                                 + fgkEndCapCardJMDConnectorLength[0];
6171  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6172
6173  yinterfacecardBmothervertex[0] = 0.0;
6174  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6175                                                                 + fgkEndCapInterfaceCardBWidth[1]
6176                                                                 + fgkEndCapInterfaceCardBWidth[2];
6177  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6178  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6179  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6180  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6181  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6182  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6183                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6184                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6185  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6186  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6187  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6188  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6189                                                                                   xinterfacecardBmothervertex,
6190                                                                                   yinterfacecardBmothervertex);
6191  interfacecardBmothershape->DefineSection(0,-1.e-15);
6192  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6193  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6194                                                                                                    interfacecardBmothershape,fSSDAir);
6195  electboardcardB->SetLineColor(fColorAl);
6196  // Positioning Volumes Mother Interface Card B Container 
6197  TGeoRotation* interfacecardBrot = new TGeoRotation();
6198  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6199  interfacecardBrot->SetAngles(90.,-90.,-90.);
6200  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6201  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6202  TGeoRotation* electboardcardBrot = new TGeoRotation();
6203  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6204  electboardcardBrot->SetAngles(90.,90.,-90.);
6205  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6206  TGeoCombiTrans* electboardcardBcombitrans = 
6207                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6208  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6209  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6210  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6211  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6212  TGeoTranslation* jmdconnectorcardBtrans[3];
6213  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6214  for(Int_t i=0; i<3; i++){
6215    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6216                                                          + fgkEndCapCardJMDConnectorLength[0], 
6217                                                            fgkEndCapCardElectBoardLayerWidth[1],
6218                                                            0.5*fgkEndCapCardJMDConnectorThickness
6219                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6220                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6221                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6222    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6223                                                                                                            *jmdconnectorcardBrot);
6224    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6225  }
6226  // Mother Supply Card Container 
6227  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6228  // Interface Card Container
6229  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6230  // Placing Volumes in Mother Supply Card Container
6231  // JMD Connector Positioning
6232  TGeoTranslation* jmdconnectortrans[2];
6233  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6234  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6235                                                                                         fgkEndCapCardElectBoardBackLength[0]
6236                                           -                                             fgkEndCapCardJMDConnectorThickness
6237                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6238  TGeoRotation* jmdconnectorot = new TGeoRotation();
6239  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6240                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6241                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6242                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6243                                                                       fgkEndCapCardJMDConnectorThickness
6244                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6245  jmdconnectorot->SetAngles(90.,180.,-90);
6246  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6247                                                                                 * jmdconnectorot);
6248  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6249  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6250  // Top Cable Connector Placing
6251  TGeoRotation* cableconnectorot[2];
6252  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6253  TGeoTranslation* cableconnectortrans[3];
6254  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6255  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6256  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6257  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6258  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6259                                                                                                                            *cableconnectorot[0]);
6260  TGeoHMatrix* cableconnectormatrix[2];
6261  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6262                                                         new TGeoHMatrix((*cableconnectorot[1])
6263                                                                                    *(*cableconnectorcombitrans));
6264  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6265                                            -                               fgkEndCapCardCableConnectorThickness,
6266                                                                                 fgkEndCapCardCableConnectorLength[0]
6267                                            +                            fgkEndCapCardCableConnectorToLayer);
6268  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6269                                            -                2.*fgkEndCapCardCableConnectorThickness
6270                                            -                            fgkEndCapCardCableConnectorDistance,
6271                                                                                 fgkEndCapCardCableConnectorLength[0]
6272                                            +                            fgkEndCapCardCableConnectorToLayer);
6273  for(Int_t i=0; i<2; i++){
6274         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6275     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6276  }
6277  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6278  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6279  electboardbackrot->SetAngles(90.,-90.,-90.);
6280  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6281                                                         +                fgkEndCapCardJMDConnectorLength[0]
6282                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6283  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6284                                                                                                                            *electboardbackrot);
6285  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6286  // Electronic Board Kapton Layer Positioning
6287  TGeoRotation* electlayerrot = new TGeoRotation();
6288  TGeoTranslation* electlayertrans[2];
6289  TGeoCombiTrans* electlayercombitrans[2];
6290  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6291  electlayerrot->SetAngles(90.,-90.,-90.);
6292  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6293                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6294  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6295                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6296                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6297  for(Int_t i=0; i<2; i++){
6298         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6299         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6300  }
6301  // Placing Volumes in Mother Interface Card Container
6302  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6303  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6304  for(Int_t i=0; i<2; i++){
6305         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6306  }
6307  /////////////////////////////////////////////////////////////
6308  // Generation of Card Interface Container
6309  /////////////////////////////////////////////////////////////
6310  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6311                                                   - fgkEndCapCardJMDConnectorLength[0]
6312                                                   - fgkEndCapInterfaceCardBThickness
6313                                                   - 9.*fgkEndCapStripConnectionThickness
6314                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6315  const Int_t kcardinterfacecontainervertexnumber = 14;
6316  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6317  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6318  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6319                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6320  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6321  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6322                                                                    + fgkEndCapStripConnectionThickness
6323                                                                    - fgkEndCapCardElectBoardLayerThickness
6324                                                                    - fgkEndCapCardCableConnectorWidth[0];
6325  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6326  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6327  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6328  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6329                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6330  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6331  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6332                                                                    + fgkEndCapInterfaceCardBThickness;
6333  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6334  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6335                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6336  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6337  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6338                                    - fgkEndCapInterfaceElectBoardCardBThickness
6339                                                                    + fgkEndCapCardJMDConnectorLength[0]
6340                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6341  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6342
6343  ycardinterfacecontainervertex[0]  = 0.;
6344  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6345                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6346                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6347  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6348  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6349                                                                    - fgkEndCapStripConnectionWidth;
6350  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6351  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6352  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6353  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6354                                                                    + fgkEndCapInterfaceCardBWidth[1]
6355                                                                    + fgkEndCapInterfaceCardBWidth[2];
6356  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6357  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6358  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6359  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6360  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6361  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6362  
6363  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6364  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6365                                                                                   xcardinterfacecontainervertex,
6366                                                                                   ycardinterfacecontainervertex);
6367  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6368                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6369  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6370                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6371  TGeoVolume** cardinterfacecontainer;
6372  cardinterfacecontainer = new TGeoVolume*[4];
6373  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6374                                                                                         interfacecardmothershape,fSSDAir); 
6375  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6376                                                                                         interfacecardmothershape,fSSDAir); 
6377  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6378                                                                                         interfacecardmothershape,fSSDAir); 
6379  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6380                                                                                         interfacecardmothershape,fSSDAir); 
6381  /////////////////////////////////
6382  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6383  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6384  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6385  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6386  /////////////////////////////////
6387  TGeoRotation* endcapstripconnectionrot[2];
6388  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6389  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6390  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6391  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6392                                                                         *                                 (*endcapstripconnectionrot[0]));
6393  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6394  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6395                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6396                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6397                                                                                         -endcapstripconnectionshape->GetDZ(),
6398                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6399  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6400  TGeoTranslation* cardinterfacetrans[9];
6401  TGeoHMatrix* cardinterfacematrix[9]; 
6402  for(Int_t i=0; i<7; i++){ 
6403         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6404                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6405                                                                                                 0.0,0.0);  
6406         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6407                                                    *                             (*endcapstripconnectionmatrix));
6408  }
6409  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6410                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6411                                                                                                 0.0,0.0);  
6412  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6413                                                 *                                 (*endcapstripconnectionmatrix));
6414  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6415                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6416                                                                                                 0.0,0.0);  
6417  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6418                                                 *                                 (*endcapstripconnectionmatrix));
6419
6420  for(Int_t i=0; i<4; i++){
6421         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6422                                                                            cardinterfacematrix[7]);                             
6423         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6424                                                                            cardinterfacematrix[8]);                             
6425  }
6426  TGeoTranslation* mothersupplycardtrans = 
6427                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6428                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6429                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6430  TGeoHMatrix* mothersupplycardmatrix[7];
6431  Int_t index[4] = {1,1,1,1};
6432  for(Int_t i=0; i<7; i++){
6433         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6434                                                         *                                 (*mothersupplycardtrans));
6435         for(Int_t j=0; j<4; j++){
6436                 switch(j){
6437                         case 0: //Layer5 EndCap Left Side  
6438                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6439                                                                                                    cardinterfacematrix[i]);                             
6440                                 if(i!=0){
6441                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6442                                                                                                            mothersupplycardmatrix[i]);                  
6443                                         index[j]++;
6444
6445                                 }
6446                         break;
6447                         case 1: //Layer5 EndCap Rigth Side  
6448                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6449                                                                                                    cardinterfacematrix[i]);                     
6450                                 if(i>0&&i<6){
6451                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6452                                                                                                            mothersupplycardmatrix[i]);                  
6453                                         index[j]++;
6454                                 }
6455                         break;
6456                         case 2: //Layer6 EndCap Left Side  
6457                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6458                                                                                                    cardinterfacematrix[i]);                             
6459                                 if(i!=6){
6460                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6461                                                                                                            mothersupplycardmatrix[i]);                  
6462                                         index[j]++;
6463                                 }
6464                         break;
6465                         case 3: //Layer6 EndCap Right Side  
6466                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6467                                                                                                    cardinterfacematrix[i]);                             
6468                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6469                                                                                                    mothersupplycardmatrix[i]);                  
6470                                 index[j]++;
6471                         break;
6472                 }
6473         }
6474  }
6475  // Positioning Interface 
6476  TGeoTranslation* motherinterfacecardtrans = 
6477                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6478                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6479                                                          -fgkEndCapCardElectBoardLayerThickness
6480                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6481  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6482                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6483  // Positioning Interface Card B 
6484  TGeoTranslation* interfacecardBmothertrans = 
6485                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6486                                                                                 + 2.*fgkEndCapStripConnectionThickness
6487                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6488                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6489                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6490  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6491                                                                                                                          interfacecardBmothertrans);
6492  // Positioning Stiffener 
6493  TGeoTranslation* endcapstiffenertrans = 
6494                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6495                                                                            +    2.0*fgkEndCapStripConnectionThickness
6496                                                                            +    fgkEndCapInterfaceCardBThickness
6497                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6498                                                                            +    stiffenertransx
6499                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6500                                                                                         endcapstiffenershape->GetDZ()
6501                                                                            -    0.5*(fgkEndCapStiffenerLength
6502                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6503  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6504  /////////////////////////////////////////////////////////////
6505  // Deallocating memory
6506  /////////////////////////////////////////////////////////////
6507  delete interfacecardBrot;
6508  delete interfacecardBtrans;
6509  delete electboardcardBtrans;
6510  delete electboardcardBrot; 
6511  delete jmdconnectorcardBrot;
6512  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6513  delete jmdconnectorot;
6514  delete jmdconnectortrans[1];
6515  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6516  delete cableconnectorcombitrans;
6517  delete electboardbacktrans;
6518  delete electboardbackrot;
6519  delete electlayerrot;
6520  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6521  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6522  delete mothersupplycardtrans;
6523  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6524  /////////////////////////////////////////////////////////////
6525  return cardinterfacecontainer;
6526  }
6527  ////////////////////////////////////////////////////////////////////////////////
6528  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6529   /////////////////////////////////////////////////////////////
6530   // Method returning EndCap Mother Volume
6531   /////////////////////////////////////////////////////////////
6532   const Int_t kendcapcoverplatesmallholenumber = 9;
6533   Double_t endcapmotherorigin[3];
6534   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6535                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6536                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6537   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6538                                           -                      fgkEndCapCoverPlateWidth[2]
6539                                           -       (kendcapcoverplatesmallholenumber-1)
6540                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6541                                           +  0.5*(fgkEndCapSideCoverLength[2]
6542                                           +               fgkEndCapCoverPlateWidth[1]
6543                                           -       fgkEndCapCoverPlateWidth[0])
6544                                           -      (fgkEndCapCoverPlateWidth[1]
6545                                           -       fgkEndCapCoverPlateWidth[0]);
6546   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6547                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6548                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6549                                                 +      fgkEndCapSideCoverWidth[1]
6550                                                 +      fgkEndCapSideCoverThickness
6551                                                 +      fgkEndCapKaptonFoilThickness);
6552   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6553                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6554                                                           +              2.0* fgkEndCapSideCoverThickness),
6555                                                                          0.5* (fgkEndCapSideCoverLength[2]
6556                                                           +                    fgkEndCapCoverPlateWidth[1]
6557                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6558                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6559                                                       +                                    fgkEndCapSideCoverWidth[1]
6560                                                           +                                       fgkEndCapSideCoverThickness
6561                                                       +                                   fgkEndCapKaptonFoilThickness),
6562                                                                                          endcapmotherorigin);
6563   TGeoVolume** endcapassembly;  
6564   endcapassembly = new TGeoVolume*[4];
6565   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6566                                                                                         endcapmothershape,fSSDAir); 
6567   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6568                                                                                         endcapmothershape,fSSDAir); 
6569   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6570                                                                                         endcapmothershape,fSSDAir); 
6571   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6572                                                                                         endcapmothershape,fSSDAir); 
6573  /////////////////////////////////
6574  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6575  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6576  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6577  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6578  /////////////////////////////////
6579   /////////////////////////////////////////////////////
6580   // Placing Endcap Cover Plate
6581   /////////////////////////////////////////////////////
6582   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6583   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6584   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6585   TGeoCombiTrans* endcapcoverplatecombitrans = 
6586                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6587                                                                                          endcapcoverplaterot);
6588   TGeoTranslation* endcapcoverplatetrans = 
6589                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6590   TGeoHMatrix* endcapcoverplatematrix = 
6591                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6592                                                                           *       (*endcapcoverplatecombitrans));
6593   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6594   /////////////////////////////////////////////////////
6595   // Placing Endcap Side Cover
6596   /////////////////////////////////////////////////////
6597   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6598   TGeoRotation* endcapsidecoverot[2];
6599   TGeoCombiTrans* endcapsidecovercombitrans[3];
6600   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6601   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6602   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6603                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6604                                                                                         - fgkEndCapCoverPlateWidth[2]
6605                                                                                     - (kendcapcoverplatesmallholenumber-1)
6606                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6607                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6608                                                                                         + fgkEndCapSideCoverLength[2],
6609                                                                                           0.5*(fgkEndCapSideCoverThickness
6610                                                                                         + fgkEndCapCoverPlateThickness)
6611                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6612                                                                                           endcapsidecoverot[0]);
6613   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6614   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6615                                                                                                         0.5*fgkEndCapCoverPlateThickness
6616                                                                                                         -fgkEndCapSideCoverWidth[1],
6617                                                                                                         endcapsidecoverot[1]);
6618   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6619                                                                                                         +fgkEndCapCoverPlateLength[3]
6620                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6621                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6622                                                                                                         0.5*fgkEndCapCoverPlateThickness
6623                                                                                                         -fgkEndCapSideCoverWidth[1],
6624                                                                                                         endcapsidecoverot[1]);
6625   TGeoHMatrix* endcapsidecovermatrix[2];
6626   for(Int_t i=0; i<2; i++){
6627    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6628                                                         *                                 (*endcapsidecovercombitrans[0]));
6629         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6630                                                                                                                 endcapsidecovermatrix[i]);
6631   }
6632   /////////////////////////////////////////////////////
6633   // Placing Endcap Cooling Tube
6634   /////////////////////////////////////////////////////
6635   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6636   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6637   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6638   TGeoCombiTrans* endcapccolingtubecombitrans 
6639                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6640                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6641                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6642                                                 - fgkEndCapCoolingTubeToCoverSide,
6643                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6644                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6645   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6646                                                                                                           endcapccolingtubecombitrans);
6647   /////////////////////////////////////////////////////
6648   // Placing Screws 
6649   /////////////////////////////////////////////////////
6650   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6651                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6652   Int_t screwcoverplatedgesnumber[2] = {20,20};
6653   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6654                                                                                 fgkEndCapCoverPlateThickness
6655                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6656   TGeoXtru* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6657                                                                                                  screwcoverplatedgesnumber,
6658                                                                                                  screwcoverplatesection);
6659   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6660                                                                                            screwcoverplateshape,
6661                                                                                            fSSDCoolingTubePhynox); 
6662   screwcoverplate->SetLineColor(12);
6663   Double_t transx[4] = {0,
6664                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6665                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6666                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6667                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6668                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6669   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6670 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6671   TGeoTranslation*** endcapcoverplatescrewtrans;
6672   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6673   Int_t index = 0;
6674   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6675         endcapcoverplatescrewtrans[i] = 
6676                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6677     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6678                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6679         if(index==1||index==9||index==28||index==36){
6680                         endcapcoverplatescrewtrans[i][j] = 
6681                                 new TGeoTranslation(transx[i],
6682                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6683                                                                         fgkEndCapSideCoverThickness);
6684                 }
6685                 else{
6686                         endcapcoverplatescrewtrans[i][j] = 
6687                                 new TGeoTranslation(transx[i],
6688                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6689                                                                         0.);
6690                 }
6691             if(index!=19) 
6692                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6693                                                                                           endcapcoverplatescrewtrans[i][j]);
6694         }
6695   }
6696   /////////////////////////////////////////////////////
6697   // Placing Cover Plate Clips 
6698   /////////////////////////////////////////////////////
6699   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6700                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6701                                                                                                          0.5*fgkEndCapSideCoverThickness);
6702   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6703                                                                                                         endcapcoverplateclipshape,
6704                                                                                                         fSSDCoolingTubePhynox);
6705   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6706                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6707                                                                                                          0.5*fgkEndCapSideCoverThickness);
6708   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6709                                                                                                         endcapcoverplatedownclipshape,
6710                                                                                                         fSSDCoolingTubePhynox);
6711   TGeoTranslation* endcapcoverplatecliptrans[4];
6712   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6713                                                            -                     fgkEndCapCoverPlateLength[0]
6714                                                            -                     fgkEndCapSideCoverThickness,
6715                                                                                                          0.0,
6716                                                                                                  0.5*(fgkEndCapSideCoverThickness
6717                                                            +                                              fgkEndCapCoverPlateThickness));
6718   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6719                                                            -                     fgkEndCapCoverPlateLength[0]
6720                                                            -                     fgkEndCapSideCoverThickness,
6721                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6722                                                            *                                     fgkEndCapSideCoverWidth[5],
6723                                                                                                  0.5*(fgkEndCapSideCoverThickness
6724                                                            +                                              fgkEndCapCoverPlateThickness));
6725   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6726                                                            -                     fgkEndCapCoverPlateLength[0]
6727                                                            +                                     fgkEndCapCoverPlateLength[1]
6728                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6729                                                            -                                     fgkEndCapCoverPlateClipLength
6730                                                            +                                 fgkEndCapSideCoverThickness,
6731                                                                                                          0.0,
6732                                                                                                  0.5*(fgkEndCapSideCoverThickness
6733                                                            +                                              fgkEndCapCoverPlateThickness));
6734   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6735                                                            -                     fgkEndCapCoverPlateLength[0]
6736                                                            +                                     fgkEndCapCoverPlateLength[1]
6737                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6738                                                            -                                     fgkEndCapCoverPlateClipLength
6739                                                            +                                 fgkEndCapSideCoverThickness,
6740                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6741                                                            *                                     fgkEndCapSideCoverWidth[5],
6742                                                                                                  0.5*(fgkEndCapSideCoverThickness
6743                                                            +                                              fgkEndCapCoverPlateThickness));
6744   endcapcoverplateclip->SetLineColor(fColorPhynox);
6745   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6746   for(Int_t i=0; i<4; i++) 
6747         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6748                                                                                                    endcapcoverplatecliptrans[i]);  
6749   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6750   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6751                                                                    -                     fgkEndCapCoverPlateLength[0]
6752                                                                    -                     fgkEndCapSideCoverThickness,
6753                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6754                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6755                                                                                                         0.5*(fgkEndCapSideCoverThickness
6756                                                                +                                         fgkEndCapCoverPlateThickness)
6757                                                                    -                     fgkEndCapSideCoverWidth[1]
6758                                                                    -                                     fgkEndCapSideCoverThickness);
6759   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6760                                                                    -                     fgkEndCapCoverPlateLength[0]
6761                                                                    -                     fgkEndCapSideCoverThickness,
6762                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6763                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6764                                                                    +                            fgkEndCapSideCoverLength[2]
6765                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6766                                                                                                         0.5*(fgkEndCapSideCoverThickness
6767                                                                +                                         fgkEndCapCoverPlateThickness)
6768                                                                    -                     fgkEndCapSideCoverWidth[1]
6769                                                                    -                                     fgkEndCapSideCoverThickness);
6770   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6771                                                                    -                     fgkEndCapCoverPlateLength[0]
6772                                                                    +                     fgkEndCapSideCoverThickness
6773                                                                    +                     fgkEndCapCoverPlateLength[1]
6774                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6775                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6776                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6777                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6778                                                                                                         0.5*(fgkEndCapSideCoverThickness
6779                                                                +                                         fgkEndCapCoverPlateThickness)
6780                                                                    -                     fgkEndCapSideCoverWidth[1]
6781                                                                    -                                     fgkEndCapSideCoverThickness);
6782   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6783                                                                    -                     fgkEndCapCoverPlateLength[0]
6784                                                                    +                     fgkEndCapSideCoverThickness
6785                                                                    +                     fgkEndCapCoverPlateLength[1]
6786                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6787                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6788                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6789                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6790                                                                    +                                 fgkEndCapSideCoverLength[2]
6791                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6792                                                                                                         0.5*(fgkEndCapSideCoverThickness
6793                                                                +                                         fgkEndCapCoverPlateThickness)
6794                                                                    -                     fgkEndCapSideCoverWidth[1]
6795                                                                    -                                     fgkEndCapSideCoverThickness);
6796   for(Int_t i=0; i<4; i++)
6797         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6798                                                                                                    endcapcoverplatedowncliptrans[i]);
6799   /////////////////////////////////////////////////////
6800   // Placing Kapton Foil
6801   /////////////////////////////////////////////////////
6802   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6803                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6804                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6805   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6806                                                                                                 endcapkaptonfoilshape,
6807                                                                                                 fSSDKaptonFlexMedium);
6808   endcapkaptonfoil->SetLineColor(8);
6809   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6810                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6811                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6812                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6813                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6814                                                                              -                     fgkEndCapSideCoverWidth[1]
6815                                                                                  -                     fgkEndCapSideCoverThickness);
6816   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6817   /////////////////////////////////////////////////////////////
6818   // Placing Electronic Tubes
6819   /////////////////////////////////////////////////////////////
6820   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6821                                                                              - fgkEndCapInterfaceCardBThickness
6822                                                                              - 9.*fgkEndCapStripConnectionThickness
6823                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6824                                                                                fgkEndCapKaptonFoilWidth
6825                                                                              - fgkEndCapInterfaceCardBThickness
6826                                                                              - 9.*fgkEndCapStripConnectionThickness
6827                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6828                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6829   TGeoVolume* endcapeffectivecables[2];
6830   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6831                                                                                          fgkEndCapEffectiveCableRadiusMax,
6832                                                                                          endcapeffectivecableswidth[0],
6833                                                                                          10,"EndCapEffectiveCables1"); 
6834   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6835                                                                                          fgkEndCapEffectiveCableRadiusMax,
6836                                                                                          endcapeffectivecableswidth[1],
6837                                                                                          25,"EndCapEffectiveCables2"); 
6838   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6839   TGeoTranslation* endcapeffectivecablestrans[2];
6840   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6841                                           -                                                        0.5*endcapeffectivecableswidth[0]
6842                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6843                                           -                                                               fgkEndCapCoverPlateWidth[2]
6844                                           -                                             (kendcapcoverplatesmallholenumber-1)
6845                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6846                                           +                                             fgkEndCapSideCoverLength[2],
6847                                           -                     0.5*fgkEndCapCoverPlateThickness
6848                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6849                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6850                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6851   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6852                                           -                                                        0.5*endcapeffectivecableswidth[1]
6853                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6854                                           -                                                               fgkEndCapCoverPlateWidth[2]
6855                                           -                                             (kendcapcoverplatesmallholenumber-1)
6856                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6857                                           +                                         fgkEndCapSideCoverLength[2],
6858                                           -                     0.5*fgkEndCapCoverPlateThickness
6859                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6860                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6861                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6862   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6863   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6864   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6865                                                                                                                    *endcapeffectivecablesrot);
6866   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6867                                                                                                                    *endcapeffectivecablesrot);
6868 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6869 //                                                                                                        endcapeffectivecablescombitrans[0]);
6870   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6871                                                                                                           endcapeffectivecablescombitrans[1]);
6872   /////////////////////////////////////////////////////////////
6873   // Placing End Cap Cards
6874   /////////////////////////////////////////////////////////////
6875   TGeoVolume** endcapcards = GetEndCapCards();
6876   TGeoRotation* endcapcardsrot[2];
6877   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6878   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6879   TGeoTranslation* endcapcardstrans[2]; 
6880   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6881                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6882   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6883   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6884   TGeoHMatrix* endcapcardsmatrix[2];
6885   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6886   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6887                                                   - fgkEndCapCardJMDConnectorLength[0]
6888                                                   - fgkEndCapInterfaceCardBThickness
6889                                                   - 9.*fgkEndCapStripConnectionThickness
6890                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6891   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6892                                           -                                             fgkEndCapCoverPlateLength[0]
6893                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6894                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6895                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6896                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6897                                           -                                                               fgkEndCapInterfaceCardBThickness
6898                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6899                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6900                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6901                                           -                                                               fgkEndCapCoverPlateWidth[2]
6902                                           -                                             (kendcapcoverplatesmallholenumber-1)
6903                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6904                                           +                     fgkEndCapKaptonFoilWidth,
6905                                                                                           0.5*fgkEndCapCoverPlateThickness
6906                                           -                                                     fgkEndCapSideCoverWidth[1]);
6907   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6908   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6909    /////////////////////////////////////////////////////////////
6910   // Deallocating memory
6911   /////////////////////////////////////////////////////////////
6912   delete endcapcoverplaterot;
6913   delete endcapcoverplatecombitrans;
6914   delete endcapcoverplatetrans;
6915   for(Int_t i=0; i<3; i++){
6916    delete endcapsidecovercombitrans[i];
6917    if(i<2) delete endcapsidecoverot[i]; 
6918   }
6919   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6920   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6921   delete endcapcardsmatrix[0];
6922   return endcapassembly;
6923  } 
6924  ////////////////////////////////////////////////////////////////////////////////
6925  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6926                                                                                                                         Double_t radiusmax, 
6927                                                                                                                         Double_t width, 
6928                                                                                                                         Int_t ncables,
6929                                                                                                                         char* volname){
6930   /////////////////////////////////////////////////////////////
6931   // Generating EndCap High Voltage Tubes 
6932   /////////////////////////////////////////////////////////////
6933   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6934   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
6935                                                            +             TMath::Power(radiusmax,2.)
6936                                -             TMath::Power(radiusmin,2.));
6937   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6938   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6939                                                                                                    effectiveouteradius,0.5*width);
6940   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6941                                                                                                 effectiveinnertubeshape,
6942                                                                                                 fSSDStiffenerConnectorMedium);
6943   effectiveinnertube->SetLineColor(41);
6944   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6945                                                                                                 effectiveoutertubeshape,
6946                                                                                                 fSSDKaptonChipCableMedium);
6947   effectiveoutertube->SetLineColor(39);
6948   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6949   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6950   effectivemothertube->AddNode(effectiveinnertube,1);
6951   effectivemothertube->AddNode(effectiveoutertube,1);
6952   return effectivemothertube;
6953  } 
6954  ////////////////////////////////////////////////////////////////////////////////
6955  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6956   /////////////////////////////////////////////////////////////
6957   // Generating EndCap Support Layer 5 and Layer 6 
6958   /////////////////////////////////////////////////////////////
6959   const Int_t knedges = 5;
6960   ///////////////////////////////////////////////
6961   // Setting the vertices for TGeoXtru Up Volume
6962   ///////////////////////////////////////////////
6963   const Int_t klayernumber = 2;
6964   Double_t xupvertex[klayernumber][knedges+3];
6965   Double_t yupvertex[klayernumber][knedges+3];
6966   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6967   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6968   Double_t middlepsi[klayernumber] = {0.0,0.0};
6969   for(Int_t i=0; i<klayernumber; i++){
6970         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6971         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6972         xupvertex[i][2] = -xupvertex[i][1];
6973         xupvertex[i][3] = -xupvertex[i][0];
6974
6975         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6976         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6977         yupvertex[i][2] =  yupvertex[i][1];
6978         yupvertex[i][3] =  yupvertex[i][0];
6979         
6980     middledgeangle[i] = upedgeangle[i]/knedges;
6981     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6982     for(Int_t j=1; j<knedges; j++){
6983                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6984                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6985         }
6986   }
6987   ////////////////////////////////////
6988   // Generating Up TGeoXtru
6989   ////////////////////////////////////
6990   TGeoXtru* upendcapsupportshape[klayernumber];
6991   TGeoVolume* upendcapsupport[klayernumber]; 
6992   char upendcapsupportname[30]; 
6993   for(Int_t i=0; i<klayernumber; i++){
6994    upendcapsupportshape[i] = new TGeoXtru(2);
6995    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
6996    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6997    upendcapsupportshape[i]->DefineSection(0,0.);
6998    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6999    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7000                                                                         fSSDSupportRingAl);
7001    upendcapsupport[i]->SetLineColor(5);
7002   }
7003   ///////////////////////////////////////////////
7004   // Setting the vertices for TGeoXtru Down Volume
7005   ///////////////////////////////////////////////
7006   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7007   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7008   for(Int_t i=0; i<klayernumber; i++){
7009         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7010         xdownvertex[i][1] =  xupvertex[i][0];
7011         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7012         ydownvertex[i][1] =  yupvertex[i][0];
7013         for(Int_t j=0; j<knedges; j++){
7014                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7015                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7016         } 
7017         for(Int_t j=0; j<knedges; j++){
7018                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7019                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7020                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7021                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7022         }
7023   }
7024   ////////////////////////////////////
7025   // Generating Down TGeoXtru
7026   ////////////////////////////////////  
7027   TGeoXtru* downendcapsupportshape[klayernumber];
7028   TGeoVolume* downendcapsupport[klayernumber]; 
7029   char downendcapsupportname[30]; 
7030   for(Int_t i=0; i<klayernumber; i++){
7031         downendcapsupportshape[i] = new TGeoXtru(2);
7032     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7033         downendcapsupportshape[i] = new TGeoXtru(2);
7034         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7035     if(i==0){
7036                 downendcapsupportshape[i]->DefineSection(0,0.);
7037                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7038     }
7039         else{
7040                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7041                                                                  -                 fgkEndCapSupportLowWidth[i]);
7042                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7043         }
7044     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7045                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7046         downendcapsupport[i]->SetLineColor(5);
7047   }
7048   ///////////////////////////////////////////////
7049   // Setting TGeoPgon Volume
7050   ///////////////////////////////////////////////
7051   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7052                                                                                                    fgkSSDLay6LadderNumber};
7053   TGeoPgon* endcapsupportmothershape[klayernumber];
7054   TGeoVolume** endcapsupportmother;
7055   endcapsupportmother = new TGeoVolume*[klayernumber];
7056   char endcapsupportmothername[30];
7057   for(Int_t i=0; i<klayernumber; i++){
7058         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7059     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7060         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7061     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7062                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7063     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7064                                                                                         fSSDAir);       
7065   }
7066   ////////////////////////////////////
7067   TGeoRotation** endcapsupportrot[klayernumber];
7068   for(Int_t i=0; i<2; i++){
7069         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7070         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7071            endcapsupportrot[i][j] = new TGeoRotation();
7072            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7073        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7074        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7075         }
7076   }
7077   return endcapsupportmother;
7078  } 
7079  ////////////////////////////////////////////////////////////////////////////////
7080  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7081   /////////////////////////////////////////////////////////////
7082   // Setting End Cap Support Layer 5 and 6. 
7083   /////////////////////////////////////////////////////////////
7084   const Int_t kendcapcoverplatesmallholenumber = 9;
7085   const Int_t klayernumber = 2;
7086   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7087                                                                                                    fgkSSDLay6LadderNumber};
7088   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7089                                                                                 360.0/kssdlayladdernumber[1]};
7090   TGeoVolume** endcapsupport = EndCapSupport();
7091   TGeoVolume** endcapassembly = GetEndCapAssembly();
7092   TGeoPgon* endcapsupportshape[klayernumber];
7093   Double_t* radiusmin[klayernumber];
7094   Double_t* radiusmax[klayernumber];
7095   for(Int_t i=0; i<klayernumber; i++){
7096     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7097         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7098         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7099   }  
7100   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7101   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7102                                                                           endcapassemblyshape->GetDY(),
7103                                                                           endcapassemblyshape->GetDZ()};
7104   ///////////////////////////////////////////////
7105   // Setting TGeoPgon Volume for Mother Container
7106   ///////////////////////////////////////////////
7107   TGeoPgon* endcapsupportsystemshape[klayernumber];
7108   char endcapsupportsystemothername[30];
7109   for(Int_t i=0; i<klayernumber; i++){
7110         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7111     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7112         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7113                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7114                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7115                                                                                            +2.*endcapassemblycenter[2])
7116                                                                                            /CosD(0.5*upedgeangle[i]));  
7117     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7118                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7119                                                                                              - fgkEndCapCoverPlateWidth[0]),
7120                                                                                            *radiusmin[i],
7121                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7122                                                                                            +2.*endcapassemblycenter[2])
7123                                                                                            /CosD(0.5*upedgeangle[i]));
7124   }
7125   fgkEndCapSupportSystem = new TGeoVolume*[4];
7126   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7127                                                                           endcapsupportsystemshape[0],fSSDAir); 
7128   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7129                                                                           endcapsupportsystemshape[0],fSSDAir); 
7130   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7131                                                                           endcapsupportsystemshape[1],fSSDAir); 
7132   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7133                                                                           endcapsupportsystemshape[1],fSSDAir); 
7134   ///////////////////////////////////////////////
7135   TGeoTranslation* endcapassemblytrans[klayernumber];
7136   for(Int_t i=0; i<klayernumber; i++)
7137         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7138                                                                            -  fgkEndCapSideCoverThickness
7139                                                                            +  endcapassemblycenter[0],
7140                                                                            -  0.5*fgkEndCapCoverPlateThickness
7141                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7142                                                                            +  2.0*endcapassemblycenter[2]
7143                                                                            +  0.5*fgkEndCapSupportLength[i]
7144                                                                            /  TanD(0.5*upedgeangle[i]),
7145                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7146                                                                            -  fgkEndCapCoverPlateWidth[2]
7147                                                                            - (kendcapcoverplatesmallholenumber-1)
7148                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7149   TGeoRotation** endcapassemblyrot[klayernumber];
7150   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7151   for(Int_t i=0; i<klayernumber; i++){
7152    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7153    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7154    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7155    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7156    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7157    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7158    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7159    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7160         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7161         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7162    }
7163   }
7164   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7165                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7166   for(Int_t i=0; i<2*klayernumber; i++){
7167         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7168                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7169                                                                                                                                            endcapassemblymatrix[1][j+2]);
7170         }
7171         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7172   }
7173    /////////////////////////////////////////////////////////////
7174   // Deallocating memory
7175   /////////////////////////////////////////////////////////////
7176   for(Int_t i=0; i<klayernumber; i++){
7177         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7178                 delete endcapassemblyrot[i][j];
7179         }
7180         delete endcapassemblyrot[i];
7181         delete endcapassemblymatrix[i][0];
7182         delete endcapassemblymatrix[i][1];
7183   }
7184   /////////////////////////////////////////////////////////////
7185   }
7186   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7187   /////////////////////////////////////////////////////////////
7188   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7189   /////////////////////////////////////////////////////////////
7190   if (! moth) {
7191     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7192     return;
7193   };
7194   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7195   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7196   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7197                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7198                                                                            +            fgkEndCapSupportCenterLay5Position
7199                                                                            -            fgkEndCapSideCoverLength[2]);
7200   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7201                                                                                                 fgkEndCapSideCoverLength[2]
7202                                                                            -        fgkEndCapSupportCenterLay5Position
7203                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7204   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7205   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7206   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7207         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7208   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7209   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7210    /////////////////////////////////////////////////////////////
7211   // Deallocating memory
7212   /////////////////////////////////////////////////////////////
7213   delete endcapsupportsystemrot;
7214   delete endcapsupportsystemITSCentertrans[1];
7215  }
7216   /////////////////////////////////////////////////////////////
7217   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7218   /////////////////////////////////////////////////////////////
7219   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7220   /////////////////////////////////////////////////////////////
7221   if (! moth) {
7222     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7223     return;
7224   };
7225   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7226   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7227   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7228                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7229                                                                            +            fgkEndCapSupportCenterLay6Position
7230                                                                            -            fgkEndCapSideCoverLength[2]);
7231   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7232                                                                                                 fgkEndCapSideCoverLength[2]
7233                                                                            -        fgkEndCapSupportCenterLay6Position
7234                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7235   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7236   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7237   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7238         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7239   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7240   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7241    /////////////////////////////////////////////////////////////
7242   // Deallocating memory
7243   /////////////////////////////////////////////////////////////
7244   delete endcapsupportsystemrot;
7245   delete endcapsupportsystemITSCentertrans[1];
7246  }
7247  ////////////////////////////////////////////////////////////////////////////////
7248  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7249   /////////////////////////////////////////////////////////////
7250   // Setting Ladder Support of Layer 5. 
7251   /////////////////////////////////////////////////////////////
7252   if (! moth) {
7253     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7254     return;
7255   };
7256   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7257   fMotherVol = moth;
7258   TGeoTranslation* centerITSRingSupportLay5trans[2];
7259   for(Int_t i=0; i<2; i++){
7260         centerITSRingSupportLay5trans[i] = 
7261                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7262     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7263   }
7264  }
7265  ////////////////////////////////////////////////////////////////////////////////
7266  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7267   /////////////////////////////////////////////////////////////
7268   // Setting Ladder Support of Layer 6. 
7269   /////////////////////////////////////////////////////////////
7270   if (! moth) {
7271     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7272     return;
7273   };
7274   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7275   fMotherVol = moth;
7276   TGeoTranslation* centerITSRingSupportLay6trans[2];
7277   for(Int_t i=0; i<2; i++){
7278         centerITSRingSupportLay6trans[i] = 
7279                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7280     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7281   }
7282  }
7283  ////////////////////////////////////////////////////////////////////////////////
7284  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7285   /////////////////////////////////////////////////////////////
7286   // Setting Ladder Support of Layer 6. 
7287   /////////////////////////////////////////////////////////////
7288   if (! moth) {
7289     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7290     return;
7291   };
7292   if(!fSSDCone) SetSSDCone();
7293   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7294                                                                 +                                         fgkSSDCentralAL3SupportLength);
7295     moth->AddNode(fSSDCone,1,ssdconetrans);
7296 }
7297  ////////////////////////////////////////////////////////////////////////////////
7298  void AliITSv11GeometrySSD::SetSSDCone(){
7299   /////////////////////////////////////////////////////////////
7300   // Method generating SSDCone 
7301   /////////////////////////////////////////////////////////////
7302   if(!fCreateMaterials) CreateMaterials();
7303   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7304   Double_t ssdpconesectionradiusmax[16];
7305   Double_t ssdpconesectionradiusmin[16];
7306   Double_t ssdpconezsection[16];
7307   TGeoPcon* ssdpconelittleholeshape[8];
7308   TGeoVolume* ssdpconelittlehole[8];
7309   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7310   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7311   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7312                                                       / SinD(fgkSSDPConeAngle)
7313                                                           + ssdpconesectionradiusmin[0];
7314   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7315                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7316                                                           / SinD(fgkSSDPConeAngle);
7317   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7318   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7319                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7320   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7321   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7322                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7323   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7324   ssdpconelittlehole[0]->SetLineColor(4);
7325   /////////////////////////////////////////////////////////////
7326   ssdpconezsection[2] = ssdpconezsection[1];  
7327   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7328   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7329   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7330                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7331                                                           / SinD(fgkSSDPConeAngle);
7332   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7333                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7334   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7335                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7336   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7337                                                                    * TMath::RadToDeg();
7338   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7339                                                                                                           60.-ssdpconelittleholeangle,2);    
7340   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7341                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7342   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7343   ssdpconelittlehole[1]->SetLineColor(4);
7344   TGeoRotation* ssdconelittleholerot[6];
7345   for(Int_t i=0; i<6; i++){
7346         ssdconelittleholerot[i] = new TGeoRotation();
7347     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7348   }
7349   /////////////////////////////////////////////////////////////
7350   ssdpconezsection[4] = ssdpconezsection[3];  
7351   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7352   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7353   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7354                                                           * CosD(fgkSSDPConeAngle)
7355                                                           / SinD(fgkSSDPConeAngle);
7356   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7357   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7358                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7359   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7360   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7361                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7362   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7363   ssdpconelittlehole[2]->SetLineColor(4);
7364   ///////////////////////////////////////////////////
7365   ssdpconezsection[6] = ssdpconezsection[5];  
7366   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7367   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7368   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7369                                                           -ssdpconezsection[0]
7370                                                           * CosD(fgkSSDPConeAngle)
7371                                                           / SinD(fgkSSDPConeAngle);
7372   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7373   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7374                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7375   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7376                                                                    * TMath::RadToDeg();
7377   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7378                                                                                                           45.-ssdpconemiddleholeangle,2);    
7379   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7380                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7381   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7382   ssdpconelittlehole[3]->SetLineColor(4);
7383   TGeoRotation* ssdconemiddleholerot[8];
7384   for(Int_t i=0; i<8; i++){
7385         ssdconemiddleholerot[i] = new TGeoRotation();
7386     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7387   }
7388   /////////////////////////////////////////////////////////////
7389   ssdpconezsection[8] = ssdpconezsection[7];  
7390   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7391   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7392   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7393                                                           * CosD(fgkSSDPConeAngle)
7394                                                           / SinD(fgkSSDPConeAngle);
7395   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7396   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7397                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7398   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7399   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7400                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7401   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7402   ssdpconelittlehole[4]->SetLineColor(4);
7403   /////////////////////////////////////////////////////////////
7404   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7405   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7406                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7407                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7408                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7409                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7410   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7411   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7412                                                                                  * TMath::RadToDeg();
7413   ssdpconezsection[10] = ssdpconezsection[9];
7414   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7415   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7416   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7417                                                           * CosD(fgkSSDPConeAngle)
7418                                                           / SinD(fgkSSDPConeAngle);
7419   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7420   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7421                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7422   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7423                                                                                         ssdpconetrapezoidsectionangle,2);    
7424   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7425                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7426   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7427   ssdpconelittlehole[5]->SetLineColor(4);
7428   TGeoRotation* ssdconeupradiusrot[8];
7429   for(Int_t i=0; i<8; i++){
7430         ssdconeupradiusrot[i] = new TGeoRotation();
7431     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7432   }
7433   /////////////////////////////////////////////////////////////
7434   ssdpconezsection[12] = ssdpconezsection[11];
7435   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7436   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7437   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7438   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7439   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7440   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7441   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7442                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7443   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7444   ssdpconelittlehole[6]->SetLineColor(4);
7445   /////////////////////////////////////////////////////////////
7446   ssdpconezsection[14] = 0.0;
7447   ssdpconezsection[15] = ssdpconezsection[0];
7448   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7449   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7450   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7451   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7452   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7453   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7454                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7455   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7456   ssdpconelittlehole[7]->SetLineColor(4);
7457   /////////////////////////////////////////////////////////////
7458   TGeoTube* ssdtubeconeshape[2];
7459   TGeoVolume* ssdtubecone[2];
7460   TGeoTranslation* ssdtubeconetrans[2];
7461   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7462                                                                            fgkSSDPConeExternalRadius,
7463                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7464   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7465                                                                            0.5*ssdpconezsection[0]); 
7466   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7467   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7468   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7469                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7470                                           + ssdpconezsection[13]);
7471   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7472   ssdtubecone[0]->SetLineColor(4);
7473   ssdtubecone[1]->SetLineColor(4);
7474   /////////////////////////////////////////////////////////////
7475   // Mother Volume Container
7476   /////////////////////////////////////////////////////////////
7477   Double_t ssdconemotherradiusmin[8];
7478   Double_t ssdconemotherradiusmax[8];
7479   Double_t ssdconemothersection[8]; 
7480   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7481   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7482   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7483   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7484   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7485   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7486   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7487   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7488   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7489   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7490   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7491   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7492   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7493   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7494   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7495   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7496   ssdconemothersection[0] = 0.0;
7497   ssdconemothersection[1] = ssdpconezsection[0];
7498   ssdconemothersection[2] = ssdpconezsection[0];
7499   ssdconemothersection[3] = ssdpconezsection[11];
7500   ssdconemothersection[4] = ssdpconezsection[11];
7501   ssdconemothersection[5] = ssdpconezsection[13];
7502   ssdconemothersection[6] = ssdpconezsection[13];
7503   ssdconemothersection[7] = fgkSSDPConeLength;
7504   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7505   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7506                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7507   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7508   /////////////////////////////////////////////////////////////
7509   //Placing the Volumes into Mother 
7510   /////////////////////////////////////////////////////////////
7511   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7512   for(Int_t i=0; i<6; i++){
7513         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7514   }
7515   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7516   for(Int_t i=0; i<8; i++){
7517     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7518   }
7519   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7520   for(Int_t i=0; i<8; i++){
7521     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7522   }
7523   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7524   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7525   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7526   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7527   /////////////////////////////////////////////////////////////
7528   // ITS General Support
7529   /////////////////////////////////////////////////////////////
7530   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7531                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7532   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7533   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7534                                                                              - fgkSSDCentralAL3SupportLength);
7535   ssdcentralsupport->SetLineColor(4);
7536   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7537   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7538                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7539   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7540   TGeoTranslation* ssdcentralal3supportrans[3]; 
7541   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7542   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7543                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7544   ssdcentralal3support->SetLineColor(4);
7545   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7546   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7547   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7548   Double_t ssdpconcentralradiusmin[2];
7549   Double_t ssdpconcentralradiusmax[2];
7550   Double_t ssdpconcentralsection[2];
7551   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7552   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7553   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7554   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7555   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7556   ssdpconcentralsection[1] = 0.;
7557   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7558                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7559   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7560   ssdpconcentralal3->SetLineColor(4);
7561   fSSDCone->AddNode(ssdpconcentralal3,1);
7562   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7563   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7564   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7565                                                                 -2.*fgkSSDCentralAL3SupportLength);
7566   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7567                                                                                                                      *ssdcentralal3supportrot);
7568   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7569   TGeoRotation* ssdconemotherot = new TGeoRotation();
7570   ssdconemotherot->SetAngles(90.,180.,-90.);
7571   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7572                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7573   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7574   fSSDCone->AddNode(ssdconemother,1);
7575   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7576   /////////////////////////////////////////////////////////////
7577   // Deallocating memory
7578   /////////////////////////////////////////////////////////////
7579   delete ssdcentralal3supportrot;
7580   delete ssdcentralal3supportrans[2];
7581   delete ssdconemotherot;
7582   delete ssdconemothertrans;
7583   /////////////////////////////////////////////////////////////
7584  }
7585  ////////////////////////////////////////////////////////////////////////////////
7586  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7587   /////////////////////////////////////////////////////////////
7588   // Setting SSD Cables
7589   /////////////////////////////////////////////////////////////
7590   if (! moth) {
7591     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7592     return;
7593   };
7594   TGeoVolume* ssdcables = SetSSDCables();
7595   moth->AddNode(ssdcables,1);
7596 }
7597  ////////////////////////////////////////////////////////////////////////////////
7598  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7599   /////////////////////////////////////////////////////////////
7600   // Method generating SSDCables
7601   /////////////////////////////////////////////////////////////
7602   // SSD Layer 5 Cables
7603   //////////////////////////////////////////////////////////////////////////////////////////////////
7604   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7605   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7606   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7607   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7608   //////////////////////////////////////////////////////////////////////////////////////////////////
7609   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7610   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7611                                                                             -  fgkSSDLowerPConeRadius)
7612                                                                             * TanD(fgkSSDPConeAngle);
7613   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7614                                                                               + fgkEndCapSupportCenterLay5Position
7615                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7616   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7617                                                                            - ssdcableslay5startconedistance; 
7618   ssdcablelay5rightsidelength *= ssdcablesfactor;
7619   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7620   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7621                                                                                                 ssdcableslay5rightsideradiusmax,
7622                                                                                                 0.5*ssdcablelay5rightsidelength); 
7623   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7624                                                                                                          ssdcablelay5rightubeshape,
7625                                                                                                          fSSDCopper);
7626   ssdcablelay5righttube->SetLineColor(9);
7627   TGeoTranslation* ssdcablelay5rightrans = 
7628                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7629                                                                                  +              fgkEndCapSupportCenterLay5Position
7630                                                                                  +      0.5*ssdcablelay5rightsidelength);
7631   ////////////////////////////////////
7632   //  Double_t cablescapacity[20];
7633   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7634   ////////////////////////////////////
7635   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7636   ////////////////////////////////////
7637   // TGeoPCone Volumes
7638   ///////////////////////////////////
7639   TGeoPcon* ssdcableslay5pconshape[3];
7640   TGeoVolume* ssdcableslay5pcon[3]; 
7641   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7642   Double_t ssdcableslay5pconzsection[6];
7643   Double_t ssdcableslay5pconrmin[6];
7644   Double_t ssdcableslay5pconrmax[6];
7645   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7646   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7647   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7648   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7649   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7650                                                            + fgkEndCapSupportCenterLay5Position
7651                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7652   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7653                                                            + fgkSSDCentralAL3SupportLength
7654                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7655                                                            * TanD(fgkSSDPConeAngle);      
7656   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7657                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7658   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7659                                                            ssdcableslay5pconshape[0],fSSDCopper);
7660   ssdcableslay5pcon[0]->SetLineColor(9);
7661   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7662 ////////////////////////////////////
7663 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7664 ////////////////////////////////////
7665   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7666   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7667                                                            + fgkSSDCentralAL3SupportLength
7668                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7669                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7670   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7671                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7672                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7673   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7674                                                                                    ssdcableangle,2);   
7675   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7676   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7677   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7678                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7679   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7680   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7681   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7682                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7683   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7684   ssdcableslay5pcon[1]->SetLineColor(9);
7685   ////////////////////////////////////
7686   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7687                                                                                    ssdcableangle,2);   
7688   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7689   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7690   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7691   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7692   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7693   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7694                                                            * TanD(fgkSSDPConeAngle)
7695                                                            + 0.5*fgkSSDCentralSupportLength
7696                                                            + fgkSSDCentralAL3SupportLength;
7697   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7698   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7699                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7700   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7701   ssdcableslay5pcon[2]->SetLineColor(9);
7702 ////////////////////////////////////
7703   TGeoRotation* ssdcableslay5pconrot[4];        
7704   for(Int_t i=0; i<4; i++){
7705    ssdcableslay5pconrot[i] = new TGeoRotation();
7706    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7707    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7708    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7709   }
7710   ////////////////////////////////////
7711   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7712   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7713   ////////////////////////////////////
7714   // Positioning Left SSD Cables Part
7715   ////////////////////////////////////
7716   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7717                                                                                                         - 0.5*ssdcablelay5rightsidelength
7718                                                                                                         - fgkEndCapSupportCenterLay5Position
7719                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7720   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7721   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7722   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7723   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7724   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7725   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7726         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7727         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7728     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7729   }
7730   ////////////////////////////////////
7731   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7732   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7733   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7734   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7735   /////////////////////////////////////////////////////////////
7736   // Water Tubes Layer 5
7737   /////////////////////////
7738   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7739                                                                                      ssdcableslay5rightsideradiusmax
7740                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7741                                                                                      0.5*ssdcablelay5rightsidelength); 
7742   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7743                                                                                                          ssdcablelay5rightubewatershape,
7744                                                                                                          fSSDCoolingTubeWater);
7745   ssdcablelay5rightwatertube->SetLineColor(7);
7746   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7747   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7748   ////////////////////////////////////
7749   // TGeoPCone Water Volumes Layer 
7750   ///////////////////////////////////
7751   TGeoPcon* ssdcableslay5pconwatershape[3];
7752   TGeoVolume* ssdcableslay5pconwater[3]; 
7753   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7754   Double_t ssdcableslay5pconwaterzsection[6];
7755   Double_t ssdcableslay5pcwateronrmin[6];
7756   Double_t ssdcableslay5pconwaterrmax[6];
7757   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7758   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7759                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7760   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7761   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7762                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7763   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7764   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7765   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7766                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7767   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7768                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7769   ssdcableslay5pconwater[0]->SetLineColor(7);
7770   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7771   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7772 ////////////////////////////////////
7773   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7774   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7775   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7776                                                                                                 ssdcableangle,2);   
7777   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7778   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7779                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7780   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7781   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7782                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7783   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7784                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7785   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7786                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7787   ssdcableslay5pconwater[1]->SetLineColor(7);
7788 ////////////////////////////////////
7789   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7790                                                                                                 ssdcableangle,2);   
7791   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7792   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7793                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7794   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7795   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7796                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7797   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7798   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7799   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7800                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7801   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7802                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7803   ssdcableslay5pconwater[2]->SetLineColor(7);
7804 ////////////////////////////////////
7805   TGeoRotation* ssdcableslay5pconwaterot[4];    
7806   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7807   for(Int_t i=0; i<4; i++){
7808    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7809    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7810    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7811         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7812         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7813         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7814         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7815         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7816   }
7817   /////////////////////////
7818   // SSD Layer 6 Cables
7819   /////////////////////////
7820   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7821   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7822   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7823   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7824                                                                                                 ssdcableslay6rightsideradiusmax,
7825                                                                                                 0.5*ssdcablelay6rightsidelength); 
7826   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7827                                                                                                          ssdcablelay6rightubeshape,
7828                                                                                                          fSSDCopper);
7829   ssdcablelay6righttube->SetLineColor(9);
7830   TGeoTranslation* ssdcablelay6rightrans = 
7831                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7832                                                                                  +              fgkEndCapSupportCenterLay6Position
7833                                                                                  +      0.5*ssdcablelay6rightsidelength);
7834   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7835                                                                                                         - 0.5*ssdcablelay6rightsidelength
7836                                                                                                         - fgkEndCapSupportCenterLay6Position
7837                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7838   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7839   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7840   ////////////////////////////////////
7841   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7842   ////////////////////////////////////
7843   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7844                                                                                    ssdcableangle,2);   
7845   TGeoVolume* ssdcableslay6pcon;
7846   Double_t ssdcableslay6pconrmin[2];
7847   Double_t ssdcableslay6pconrmax[2];
7848   Double_t ssdcableslay6pconzsection[2];
7849   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7850   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7851   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7852   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7853   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7854                                                            + fgkEndCapSupportCenterLay6Position
7855                                                            + ssdcablelay6rightsidelength;
7856   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7857   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7858                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7859   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7860                                                            ssdcableslay6pconshape,fSSDCopper);
7861   ssdcableslay6pcon->SetLineColor(9);
7862   for(Int_t i=0; i<4; i++){
7863    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7864    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7865   }
7866   ////////////////////////////////////
7867   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7868   /////////////////////////
7869   // Water Tubes Layer 6
7870   /////////////////////////
7871   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7872                                                                                                                   ssdcableslay6rightsideradiusmax
7873                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7874                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7875   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7876                                                                                                          ssdcablelay6righwatertubeshape,
7877                                                                                                          fSSDCoolingTubeWater);
7878   ssdcablelay6rightwatertube->SetLineColor(7);
7879   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7880   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7881   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7882                                                                                    ssdcableangle,2);   
7883   TGeoVolume* ssdcableslay6waterpcon;
7884   Double_t ssdcableslay6waterpconrmin[2];
7885   Double_t ssdcableslay6waterpconrmax[2];
7886   Double_t ssdcableslay6waterpconzsection[2];
7887   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7888   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7889                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7890   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7891   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7892   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7893                                                            + fgkEndCapSupportCenterLay6Position
7894                                                            + ssdcablelay6rightsidelength;
7895   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7896   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7897                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7898   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7899                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7900   ssdcableslay6waterpcon->SetLineColor(7);
7901   TGeoRotation* ssdcableslay6pconwaterot[4];    
7902   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7903   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7904   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7905   for(Int_t i=0; i<4; i++){
7906    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7907    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7908    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7909                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7910    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7911    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7912   }
7913   ////////////////////////////////////////
7914   // From ITS Ring to Patch Panel3-RB26
7915   ////////////////////////////////////////
7916   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7917   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7918   Double_t ssdcablepatchpanel3RB26zsection[2];
7919   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
7920   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7921                                                                           + fgkSSDCablesLay5RightSideHeight
7922                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7923   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7924   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7925                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7926                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7927   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7928                                                                                  + fgkSSDCentralAL3SupportLength
7929                                                                                  + fgkSSDPConeZLength[0];
7930   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7931   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7932                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7933                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7934   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7935                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7936   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7937                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7938   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7939   TGeoRotation* ssdcablepatchpanel3B26rot[3];
7940   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7941   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7942   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7943                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7944   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7945   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7946                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7947   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7948   ////////////////////////////////////
7949   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7950   ////////////////////////////////////////
7951   //  ITS Ring Cables RB26 Part
7952   ////////////////////////////////////////
7953   Double_t ssdcableitsring3BB26pconzsection[2];
7954   Double_t ssdcableitsring3BB26pconrmin[2];
7955   Double_t ssdcableitsring3BB26pconrmax[2];
7956   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7957                                                                           + fgkSSDCentralAL3SupportLength
7958                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7959   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7960   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
7961   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7962                                                                   + fgkSSDCablesLay5RightSideHeight
7963                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7964   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7965   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7966   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7967   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7968                                                                    -              0.5*ssdcableangle,ssdcableangle
7969                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7970                                                                    -                             fgkSSDCableAngle),2);
7971   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7972                                                                    -              0.5*ssdcableangle,ssdcableangle
7973                                                                    +                      3.0*fgkSSDCableAngle
7974                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7975   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7976                                                                    -              0.5*ssdcableangle,ssdcableangle
7977                                                                    -                      fgkSSDCableAngle
7978                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7979   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7980                                                                    -              0.5*ssdcableangle,ssdcableangle
7981                                                                    +                      3.0*fgkSSDCableAngle
7982                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7983   for(Int_t i=0;i<4;i++)
7984         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7985                                                          ssdcableitsring3BB26pconrmin[j],
7986                                                          ssdcableitsring3BB26pconrmax[j]); 
7987   TGeoVolume* ssdcableitsring3BB26pcon[4];
7988   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7989                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7990   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7991                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7992   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7993                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7994   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7995                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7996   for(Int_t i=0;i<4;i++){
7997         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7998         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7999 }
8000   ////////////////////////////////////
8001   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8002   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8003   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8004   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8005   ////////////////////////////////////////
8006   // From ITS Ring to Patch Panel2-RB24
8007   ////////////////////////////////////////
8008   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8009   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8010   Double_t ssdcablepatchpanel3RB24zsection[2];
8011   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8012   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8013   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8014   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8015                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8016                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8017                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8018   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8019                                                                          -  fgkSSDCentralAL3SupportLength
8020                                                                          -  fgkSSDPConeZLength[0];
8021   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8022   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8023                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8024                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8025   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8026                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8027   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8028                                                                                                 ssdcablepatchpanel3RB24pconshape,
8029                                                                                                 fSSDCopper);
8030   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8031   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8032   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8033   ssdcablepatchpanel3B24rot[0]->SetAngles(0.0,0.0,0.0);
8034   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8035                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8036   ssdcablepatchpanel3B24rot[2]->SetAngles(180.0,0.0,0.0);
8037   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8038                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8039   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8040   ////////////////////////////////////
8041   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8042   ////////////////////////////////////////
8043   //  ITS Ring Cables RB24 Part
8044   ////////////////////////////////////////
8045   Double_t ssdcableitsring3BB24pconzsection[2];
8046   Double_t ssdcableitsring3BB24pconrmin[2];
8047   Double_t ssdcableitsring3BB24pconrmax[2];
8048   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8049   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8050   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8051   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8052                                                                   + fgkSSDCablesLay5RightSideHeight
8053                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8054   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8055   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8056   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8057   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8058                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8059                                                                    -                             fgkSSDCableAngle),2);
8060   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8061                                                                      ssdcableangle-fgkSSDCableAngle
8062                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8063   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8064                                                                    -                      fgkSSDCableAngle
8065                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8066   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8067                                                                                                   ssdcableangle-fgkSSDCableAngle
8068                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8069   for(Int_t i=0;i<4;i++)
8070         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8071                                                          ssdcableitsring3BB24pconrmin[j],
8072                                                          ssdcableitsring3BB24pconrmax[j]); 
8073   TGeoVolume* ssdcableitsring3BB24pcon[4];
8074   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8075                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8076   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8077                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8078   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8079                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8080   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8081                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8082   for(Int_t i=0;i<4;i++){
8083         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8084         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8085 }
8086   ////////////////////////////////////
8087   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8088   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8089   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8090   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8091   ////////////////////////////////////
8092   // Volumes for Material Budget 
8093   ////////////////////////////////////
8094   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8095                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8096                                                                                                          ssdcableslay6rightsideradiusmax
8097                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8098                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8099   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8100                                                                                                          ssdcablelay6materialbudgetubeshape,
8101                                                                                                          fSSDCopper);
8102   ssdcablelay6materialbudgetube->SetLineColor(9);
8103   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8104   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8105
8106   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8107                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8108   TGeoVolume* ssdcablelay6materialbudgetpcon;
8109   Double_t ssdcablelay6materialbudgetpconrmin[2];
8110   Double_t ssdcablelay6materialbudgetpconrmax[2];
8111   Double_t ssdcablelay6materialbudgetpconzsection[2];
8112   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8113                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8114   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8115                                                                                 + fgkSSDCableMaterialBudgetHeight;
8116   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8117   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8118   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8119                                                                                         + fgkEndCapSupportCenterLay6Position
8120                                                                                         + ssdcablelay6rightsidelength;
8121   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8122   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8123                                                   ssdcablelay6materialbudgetpconzsection[i],
8124                                                   ssdcablelay6materialbudgetpconrmin[i],
8125                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8126   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8127                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8128   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8129   for(Int_t i=0; i<4; i++){
8130    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8131    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8132   }
8133 ////////////////////////////////////
8134  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8135   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8136   Double_t ssdcablesvolume = 0.0;
8137   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8138   std::cout << ssdcablesvolume << std::endl;*/
8139   return ssdcablesmother;
8140  }
8141  ////////////////////////////////////////////////////////////////////////////////
8142 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8143                                                                         Double_t height, char* shapename, Int_t isign) const{
8144   /////////////////////////////////////////////////////////////
8145   // Method generating an Arb shape 
8146   /////////////////////////////////////////////////////////////
8147   const Int_t kvertexnumber = 8;
8148   const Int_t ktransvectnumber = 2;
8149   TVector3* vertex[kvertexnumber];
8150   TVector3* transvector[2];
8151   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8152   /////////////////////////////////////////////////////////////
8153   //Setting the vertices for TGeoArb8
8154   /////////////////////////////////////////////////////////////
8155   vertex[0] = new TVector3(*vertexpos[0]);
8156   vertex[1] = new TVector3(*vertexpos[1]);
8157   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8158   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8159   vertex[4] = new TVector3(*vertexpos[2]);
8160   vertex[5] = new TVector3(*vertexpos[3]);
8161   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8162   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8163   /////////////////////////////////////////////////////////////
8164   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8165   for(Int_t i = 0; i<kvertexnumber;i++) 
8166                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8167   /////////////////////////////////////////////////////////////
8168   // Deallocating memory
8169   /////////////////////////////////////////////////////////////
8170   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8171   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8172   /////////////////////////////////////////////////////////////
8173   return arbshape;
8174
8175 ///////////////////////////////////////////////////////////////////////////////
8176 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8177                                                                 Double_t rmax, Int_t nedges, Double_t height){
8178   /////////////////////////////////////////////////////////////
8179   // Method generating Arc shape 
8180   /////////////////////////////////////////////////////////////
8181         const Int_t kvertexnumber = 2*nedges+2;
8182         TGeoXtru* arcshape = new TGeoXtru(2);   
8183         TVector3** vertexposition[2];
8184         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8185         Double_t angle = 0.;
8186     for(Int_t i=0; i<nedges+1; i++){ 
8187                 angle = 90.+0.5*phi-i*(phi/nedges);
8188                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8189                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8190         }
8191         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8192         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8193         for(Int_t i=0; i<kvertexnumber; i++){ 
8194                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8195                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8196                 }
8197                 else if(i>=1&&i<nedges+2)
8198                 {
8199                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8200                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8201                 }
8202         else
8203                 {
8204                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8205                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8206                 }
8207     }
8208   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8209   arcshape->DefineSection(0,-0.5*height);
8210   arcshape->DefineSection(1,0.5*height);
8211   /////////////////////////////////////////////////////////////
8212   // Deallocating memory
8213   /////////////////////////////////////////////////////////////
8214   for(Int_t i=0; i<2; i++){
8215         for(Int_t j=0; j<nedges+1; j++)
8216                 delete vertexposition[i][j];
8217         delete [] vertexposition[i];
8218   }
8219   delete [] xvertexpoints;
8220   delete [] yvertexpoints;
8221   /////////////////////////////////////////////////////////////
8222         return arcshape;
8223 }
8224 ////////////////////////////////////////////////////////////////////////////////
8225 TGeoXtru* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8226   ///////////////////////////////////////////////////////////////////////
8227   // Method Generating the Screw Shape  
8228   // radius[0]: outer radius
8229   // radius[1]: inner radius
8230   // edgesnumber[0]: outer number of edges
8231   // edgesnumber[1]: inner number of edges
8232   // section[0]: lower section position
8233   // section[1]: higher section position
8234   ///////////////////////////////////////////////////////////////////////
8235   Double_t outradius = radius[0];
8236   Double_t inradius = radius[1];
8237   Int_t outvertexnumber = edgesnumber[0];
8238   Int_t invertexnumber = edgesnumber[1];
8239   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8240   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8241   for(Int_t i=0; i<outvertexnumber+1; i++){
8242         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8243         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8244   }
8245   for(Int_t i=0; i<invertexnumber+1; i++){
8246         xscrewvertex[outvertexnumber+i+1] = inradius*CosD(90.-i*360./invertexnumber);
8247         yscrewvertex[outvertexnumber+i+1] = inradius*SinD(90.-i*360./invertexnumber);
8248   }
8249   TGeoXtru* screwshape = new TGeoXtru(2);
8250   screwshape->DefinePolygon(outvertexnumber+invertexnumber+2,xscrewvertex,yscrewvertex);
8251   screwshape->DefineSection(0,section[0]);
8252   screwshape->DefineSection(1,section[1]);
8253   delete [] xscrewvertex;
8254   delete [] yscrewvertex;
8255   return screwshape;
8256 }
8257 ////////////////////////////////////////////////////////////////////////////////
8258 TGeoXtru* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8259   ///////////////////////////////////////////////////////////////////////
8260   // Method Generating the Hole Shape  
8261   // radius of the Hole
8262   // nedges: number of edges to approximate the circle
8263   ///////////////////////////////////////////////////////////////////////
8264   Int_t vertexnumber = nedges+6;
8265   Double_t* xholevertex = new Double_t[vertexnumber];
8266   Double_t* yholevertex = new Double_t[vertexnumber];
8267   xholevertex[0] = radius;
8268   xholevertex[1] = xholevertex[0];
8269   xholevertex[2] = -xholevertex[1];
8270   xholevertex[3] = xholevertex[2];
8271   xholevertex[4] = xholevertex[0];
8272   yholevertex[0] = 0.;
8273   yholevertex[1] = -radius;
8274   yholevertex[2] = yholevertex[1];
8275   yholevertex[3] = -yholevertex[1];
8276   yholevertex[4] = yholevertex[3];
8277   for(Int_t i=0; i<nedges+1; i++){
8278         xholevertex[i+5] = radius*CosD(i*360./nedges);
8279         yholevertex[i+5] = radius*SinD(i*360./nedges);
8280   }
8281   TGeoXtru* holeshape = new TGeoXtru(2);
8282   holeshape->DefinePolygon(vertexnumber,xholevertex,yholevertex);
8283   holeshape->DefineSection(0,section[0]);
8284   holeshape->DefineSection(1,section[1]);
8285   delete [] xholevertex;
8286   delete [] yholevertex;
8287   return holeshape;
8288 }
8289 ////////////////////////////////////////////////////////////////////////////////
8290 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8291   /////////////////////////////////////////////////////////////
8292   // Given an axis specified by param, it gives the reflection of the point
8293   // respect to the axis
8294   /////////////////////////////////////////////////////////////
8295   TVector3* n = new TVector3(param[0],param[1],param[2]);
8296   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8297   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8298   /////////////////////////////////////////////////////////////
8299   // Deallocating memory
8300   /////////////////////////////////////////////////////////////
8301   delete n;
8302   /////////////////////////////////////////////////////////////
8303   return reflectedvector;
8304 }
8305 ////////////////////////////////////////////////////////////////////////////////
8306 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8307                                                        Double_t dx,
8308                                                        Double_t dy,
8309                                                        Double_t dz) const{
8310   /////////////////////////////////////////////////////////////
8311   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8312   /////////////////////////////////////////////////////////////
8313   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8314   const Double_t *vect = hmatrix->GetTranslation();
8315   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8316   hmatrix->SetTranslation(newvect);
8317   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8318   delete hmatrix;
8319   return matrix;
8320 }
8321 ////////////////////////////////////////////////////////////////////////////////
8322 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8323   /////////////////////////////////////////////////////////////
8324   // Method returning the Medium type 
8325   /////////////////////////////////////////////////////////////
8326   char ch[30];
8327   sprintf(ch, "ITS_%s",mediumName);
8328   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8329   if (! medium)
8330     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8331   return medium;
8332 }
8333 ////////////////////////////////////////////////////////////////////////////////
8334 void AliITSv11GeometrySSD::CreateMaterials(){
8335 ///////////////////////////////////
8336 // This part has to be modified
8337 ///////////////////////////////////
8338   ///////////////////////////////////
8339   // Silicon for Sensor
8340   /////////////////////////////////// 
8341   fSSDSensorMedium = GetMedium("SI$");
8342   ///////////////////////////////////
8343   // Silicon Mixture for Sensor
8344   /////////////////////////////////// 
8345   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8346   fSSDChipGlueMedium = GetMedium("EPOXY$");
8347   ///////////////////////////////////
8348   // Stiffener Components Materials
8349   /////////////////////////////////// 
8350   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8351   ///////////////////////////  
8352   // Stiffener Connectors 
8353   ///////////////////////////  
8354   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8355   ////////////////////////////////  
8356   // Stiffener 0603-1812 Capacitor
8357   ////////////////////////////////  
8358   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8359   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8360   ///////////////////////////  
8361   // Stiffener Hybrid Wire 
8362   ///////////////////////////  
8363   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8364   ///////////////////////////  
8365   // Al for Cooling Block
8366   ///////////////////////////  
8367   fSSDAlCoolBlockMedium = GetMedium("AL$");
8368   //////////////////////////////////////////////////////  
8369   // Kapton and Al for Chip Cable Flex and Ladder Cables
8370   //////////////////////////////////////////////////////  
8371   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8372   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8373   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8374   fSSDAlTraceFlexMedium = GetMedium("AL$");
8375   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8376   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8377   /////////////////////////////////////////////////////////////////  
8378   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8379   //////////////////////////////////////////////////////////////////  
8380   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8381   /////////////////////////////////////////////////////////////////  
8382   // G10 for Detector Leg, TubeHolder
8383   //////////////////////////////////////////////////////////////////  
8384   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8385   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8386   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8387   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8388   /////////////////////////////////////////////////////////////////  
8389   // Water and Phynox for Cooling Tube
8390   //////////////////////////////////////////////////////////////////  
8391   fSSDCoolingTubeWater = GetMedium("WATER$");
8392   fSSDCoolingTubePhynox = GetMedium("INOX$");
8393   /////////////////////////////////////////////////////////////////////
8394   // Material for Support Rings
8395   /////////////////////////////////////////////////////////////////////
8396   fSSDSupportRingAl = GetMedium("AL$");
8397   fSSDRohaCellCone = GetMedium("ROHACELL$");
8398   /////////////////////////////////////////////////////////////////////
8399   fSSDAir = GetMedium("SDD AIR$");
8400   fSSDCopper = GetMedium("COPPER$");
8401   fCreateMaterials = kTRUE;
8402 }
8403 /////////////////////////////////////////////////////////////////////
8404