]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Correction of the Z position of Q2 quadrupole from Chiara Oppedisano
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41 /////////////////////////////////////////////////////////////////////////////////
42 // Names of the Sensitive Volumes of Layer 5 and Layer 6
43 /////////////////////////////////////////////////////////////////////////////////
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
45 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
46 /////////////////////////////////////////////////////////////////////////////////
47 //Parameters for SSD Geometry
48 /////////////////////////////////////////////////////////////////////////////////
49 // Variable for Vertical Disalignement of Modules
50 /////////////////////////////////////////////////////////////////////////////////
51 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
52 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
54 /////////////////////////////////////////////////////////////////////////////////
55 // Layer5 (lengths are in mm and angles in degrees)
56 /////////////////////////////////////////////////////////////////////////////////
57 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
58 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
59 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
61 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
62 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
63 /////////////////////////////////////////////////////////////////////////////////
64 // Layer6 (lengths are in mm and angles in degrees)
65 /////////////////////////////////////////////////////////////////////////////////
66 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
67 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
68 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
70 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
71 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
72 /////////////////////////////////////////////////////////////////////////////////
73 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
74 /////////////////////////////////////////////////////////////////////////////////
75 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
76 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
77 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
78 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
83 /////////////////////////////////////////////////////////////////////////////////
84 // Stiffener (lengths are in mm and angles in degrees)
85 /////////////////////////////////////////////////////////////////////////////////
86 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
87 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
88 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
92 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
97 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
100                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
101 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
105                                                                                                           0.25*fgkSSDStiffenerHeight;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
108 /////////////////////////////////////////////////////////////////////////////////
109 // Cooling Block (lengths are in mm and angles in degrees)
110 /////////////////////////////////////////////////////////////////////////////////
111 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
112 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
113 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
114                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
116                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
117 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
118                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
119 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
120                                                                                                                                          1.500*fgkmm;
121 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
122                                                                                                                                          0.300*fgkmm;
123 /////////////////////////////////////////////////////////////////////////////////
124 // SSD Sensor (lengths are in mm and angles in degrees)
125 /////////////////////////////////////////////////////////////////////////////////
126 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
127                                                                                                                  "SSDSensorSensitiveVol";
128 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
129 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
130 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
132                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
135 /////////////////////////////////////////////////////////////////////////////////
136 // Flex (lengths are in mm and angles in degrees)
137 /////////////////////////////////////////////////////////////////////////////////
138 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
139 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
140                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
141                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
142                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
143                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
144                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
145 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
146                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
147 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
148                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
149 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
151 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
152 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
153                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
154 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
155                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
156 /////////////////////////////////////////////////////////////////////////////////
157 // SSD Ladder Cable (lengths are in mm and angles in degrees)
158 /////////////////////////////////////////////////////////////////////////////////
159 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
160 /////////////////////////////////////////////////////////////////////////////////
161 // SSD Module (lengths are in mm and angles in degrees)
162 /////////////////////////////////////////////////////////////////////////////////
163 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
164                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
165 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
166                                                                                                                                         45.600*fgkmm;
167 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
168                                                                                                                                          5.075*fgkmm;
169 /////////////////////////////////////////////////////////////////////////////////
170 // Sensor Support (lengths are in mm and angles in degrees)
171 /////////////////////////////////////////////////////////////////////////////////
172 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
173                                                                                                                                          5.800*fgkmm;
174 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
175                                                                                                                                          2.000*fgkmm;
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
177                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
178                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
179 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
180 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
181 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
182                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
183 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
184                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
185                                                             +  fgkSSDSensorSideSupportThickness[0])
186                                                                 -  fgkSSDSensorSideSupportLength;
187 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
188                                                                                                                                     5.250*fgkmm;
189 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
190                                                                                                                                         1.680*fgkmm;
191 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
192                                                                   = {fgkSSDSensorSideSupportHeight[0]
193                                                                   +  fgkSSDSensorSideSupportThickness[0],
194                                                                          fgkSSDSensorSideSupportHeight[1]
195                                                                   +  fgkSSDSensorSideSupportThickness[1]};
196 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
197                                                                   =  {fgkSSDSensorSideSupportThickness[0],
198                                                                           fgkSSDSensorSideSupportThickness[1]};
199 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
200                                                                                                                                    19.000*fgkmm;
201 /////////////////////////////////////////////////////////////////////////////////
202 // Chip Cables (lengths are in mm and angles in degrees)
203 /////////////////////////////////////////////////////////////////////////////////
204 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
205                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
206 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
207                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
208                                                                   -  (fgkSSDSensorSideSupportHeight[1]
209                                                                   -   fgkSSDSensorSideSupportHeight[0])
210                                                                   -   fgkSSDModuleVerticalDisalignment
211                                                                   -   fgkSSDCoolingBlockHoleCenter
212                                                                   -   fgkSSDStiffenerHeight
213                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
214                                                                           fgkSSDModuleCoolingBlockToSensor
215                                                                   -   fgkSSDModuleVerticalDisalignment  
216                                                                   -   fgkSSDCoolingBlockHoleCenter
217                                                                   -       fgkSSDStiffenerHeight
218                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
219 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
220                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
221 /////////////////////////////////////////////////////////////////////////////////
222 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
223 /////////////////////////////////////////////////////////////////////////////////
224 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
225                                                                                                                                         3.820*fgkmm;
226 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
227 //                                                                                                                                         3.780;
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
229                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
230 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
231                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
232 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
233                                                                                                                                 { 30.00, 90.00};
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
235                                                                                                                                          1.78*fgkmm;
236 /////////////////////////////////////////////////////////////////////////////////
237 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
238 /////////////////////////////////////////////////////////////////////////////////
239 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
240                                                                    = fgkSSDModuleSensorSupportDistance
241                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
242 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
244                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
246                                                                                                                                         1.630*fgkmm;
247 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
249                                                                         = fgkCarbonFiberTriangleLength
250                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
251                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
252                                                                         * TMath::DegToRad());
253 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
254                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
255                                                                         - fgkCarbonFiberSupportWidth)
256                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
257                                                                         - fgkCarbonFiberSupportWidth;
258 /////////////////////////////////////////////////////////////////////////////////
259 // Carbon Fiber Lower Support Parameters (lengths are in mm)
260 /////////////////////////////////////////////////////////////////////////////////
261 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
262 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
263                                                                                                                                           =  0.950*fgkmm;
264 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
265                                                                                                                                           =  1.600*fgkmm;
266 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
267                                                                                                                                           =  0.830*fgkmm;
268 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
269                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
270 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
271                                                                         = fgkCarbonFiberJunctionWidth
272                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
273                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
274 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
275                                                                         = {fgkCarbonFiberLowerSupportWidth
276                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
277                                                                            fgkCarbonFiberLowerSupportWidth
278                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
279                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
280 /////////////////////////////////////////////////////////////////////////////////
281 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
282 /////////////////////////////////////////////////////////////////////////////////
283 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
284                                                            {0.5 * (fgkSSDLay5LadderLength
285                                                                         -  fgkSSDLay5SensorsNumber
286                                                                         *  fgkCarbonFiberJunctionWidth
287                                                                         -  fgkCarbonFiberLowerSupportWidth),
288                                                                 0.5 * (fgkSSDLay5LadderLength
289                                                                         -  fgkSSDLay5SensorsNumber
290                                                                         *  fgkCarbonFiberJunctionWidth
291                                                                         +  fgkCarbonFiberLowerSupportWidth)};
292 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
293                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
294                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
295 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
296                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
297                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
298 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
299                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
300 /////////////////////////////////////////////////////////////////////////////////
301 // Cooling Tube Support (lengths are in mm and angles in degrees)
302 /////////////////////////////////////////////////////////////////////////////////
303 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
304 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
305                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
310                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
312                                                                                                                                           11.70*fgkmm;
313 /////////////////////////////////////////////////////////////////////////////////
314 // Cooling Tube (lengths are in mm and angles in degrees)
315 /////////////////////////////////////////////////////////////////////////////////
316 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
317 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
318 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
319                                                                                                         fgkCarbonFiberJunctionWidth;
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
321                                                                          fgkSSDModuleSensorSupportDistance
322                                                                   +      fgkSSDCoolingBlockLength;
323 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
324 /////////////////////////////////////////////////////////////////////////////////
325 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
326 /////////////////////////////////////////////////////////////////////////////////
327 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
328                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
329 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
330                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
331 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
332                                                                                                                                           20.0*fgkmm;
333 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
334                                                                                                                                                     40.0;
335 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
336                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
337 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
338                                                                                                                                           2.5*fgkmm;
339 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
340                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
341 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
342                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
343 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
344                                                                                                                                           1.0*fgkmm;
345 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
346                                                                                                                                           6.0*fgkmm;
347 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
348                                                                                                                                           4.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
350                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
351 /////////////////////////////////////////////////////////////////////////////////
352 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
353 /////////////////////////////////////////////////////////////////////////////////
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
356 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
359 /////////////////////////////////////////////////////////////////////////////////
360 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
361 /////////////////////////////////////////////////////////////////////////////////
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
363 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
364 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
365                                                                                                   -  fgkSSDMountingBlockHeight[1]
366                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
367                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
368                                                                                                   -      fgkMountingBlockSupportDownHeight,
369                                                                                                          fgkSSDLay6RadiusMin
370                                                                                                   -  fgkSSDMountingBlockHeight[1]
371                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
372                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
373                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
374 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
375                                                                                                     -  fgkSSDMountingBlockHeight[1]
376                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
377                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
378                                                                                                         -  fgkMountingBlockSupportRadius[0],
379                                                                                                            fgkSSDLay6RadiusMax
380                                                                                                     -  fgkSSDMountingBlockHeight[1]
381                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
382                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
383                                                                                                         -  fgkMountingBlockSupportRadius[1]};
384 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
385 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
386 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
387 /////////////////////////////////////////////////////////////////////////////////
388 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
389 /////////////////////////////////////////////////////////////////////////////////
390 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
391 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
392 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
393 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
394                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
396                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
398                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
401 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
405 /////////////////////////////////////////////////////////////////////////////////
406 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
407 /////////////////////////////////////////////////////////////////////////////////
408 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
409 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
410 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
411 /////////////////////////////////////////////////////////////////////////////////
412 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
413 /////////////////////////////////////////////////////////////////////////////////
414 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
415                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
416 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
418 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
419                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
421                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
423 /////////////////////////////////////////////////////////////////////////////////
424 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
425 /////////////////////////////////////////////////////////////////////////////////
426 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
427                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
428 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
429                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
430                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
432 /////////////////////////////////////////////////////////////////////////////////
433 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
434 /////////////////////////////////////////////////////////////////////////////////
435 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
436                                                                                                            {62.0*fgkmm,21.87*fgkmm};
437 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
438                                                                                                             {47.0*fgkmm,0.35*fgkmm};
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
440                                                                                                                                           1.0*fgkmm;
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
443                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
445                                                                                                                                          0.15*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
447                                                                                                                                          19.0*fgkmm;
448 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
449                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
450 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
451                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
452 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
453                                                                                                                                           2.1*fgkmm;
454 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
455                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
456 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
457                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
458 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
459                                                                                                                                            19*fgkmm; 
460 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
461                                                                                                                                           1.0*fgkmm;
462 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
463                                                                                                                                           3.6*fgkmm;
464 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
465                                                                                                                                          61.0*fgkmm; 
466 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
467                                                                                                                                          5.97*fgkmm; 
468 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
469 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
470                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
471                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
472 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
473                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
474 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
475                                                                                                                                           1.0*fgkmm; 
476 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
477                                                                                                                                    = 0.15*fgkmm; 
478 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
479                                                                                                                                          20.0*fgkmm;
480 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
481 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
482 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
483 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
484 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
485 /////////////////////////////////////////////////////////////////////////////////
486 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
487 /////////////////////////////////////////////////////////////////////////////////
488 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
489 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
490 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
497 /////////////////////////////////////////////////////////////////////////////////
498 // SSD Cone Parameters (lengths are in mm and angles in degrees)
499 /////////////////////////////////////////////////////////////////////////////////
500 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
501 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
502 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
503 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
505 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
519 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
522 /////////////////////////////////////////////////////////////////////////////////
523 // SSD Cables Parameters (lengths are in mm and angles in degrees)
524 /////////////////////////////////////////////////////////////////////////////////
525 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
526 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
527 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
528 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
529 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
533 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
534 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
535 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
536 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
539 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
540 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
541 /////////////////////////////////////////////////////////////////////////////////
542 ClassImp(AliITSv11GeometrySSD)
543 /////////////////////////////////////////////////////////////////////////////////
544 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
545   AliITSv11Geometry(),
546   fSSDChipMedium(),
547   fSSDChipGlueMedium(),
548   fSSDStiffenerMedium(),
549   fSSDStiffenerConnectorMedium(),
550   fSSDStiffener0603CapacitorMedium(),
551   fSSDStiffener1812CapacitorMedium(),
552   fSSDStiffenerHybridWireMedium(),
553   fSSDKaptonFlexMedium(),
554   fSSDAlTraceFlexMedium(),
555   fSSDAlTraceLadderCableMedium(),
556   fSSDKaptonLadderCableMedium(),
557   fSSDKaptonChipCableMedium(),
558   fSSDAlTraceChipCableMedium(),
559   fSSDAlCoolBlockMedium(),
560   fSSDSensorMedium(),
561   fSSDSensorSupportMedium(),
562   fSSDCarbonFiberMedium(),
563   fSSDTubeHolderMedium(),
564   fSSDCoolingTubeWater(),
565   fSSDCoolingTubePhynox(),
566   fSSDSupportRingAl(),
567   fSSDMountingBlockMedium(),
568   fSSDRohaCellCone(),
569   fSSDAir(),
570   fSSDCopper(),
571   fCreateMaterials(kFALSE),
572   fTransformationMatrices(kFALSE),
573   fBasicObjects(kFALSE),
574   fcarbonfiberjunction(),
575   fcoolingtubesupport(),
576   fhybridmatrix(),
577   fssdcoolingblocksystem(),
578   fcoolingblocksystematrix(),
579   fssdstiffenerflex(),
580   fssdendflex(),
581   fendladdercoolingtubesupportmatrix(),
582   fendladdermountingblock(),
583   fendladdermountingblockclip(),
584   fSSDSensor5(),
585   fSSDSensor6(),
586   fSSDLayer5(), 
587   fSSDLayer6(),
588   fMotherVol(),
589   fLay5LadderSupportRing(),
590   fLay6LadderSupportRing(),
591   fgkEndCapSupportSystem(),
592   fSSDCone(),
593   fColorCarbonFiber(4),
594   fColorRyton(5),
595   fColorPhynox(14),
596   fColorSilicon(3),
597   fColorAl(38),
598   fColorKapton(6),
599   fColorPolyhamide(5),
600   fColorStiffener(9),
601   fColorEpoxy(30),
602   fColorWater(7),
603   fColorG10(41)
604 {
605   ////////////////////////
606   // Standard constructor
607   ////////////////////////
608 }
609 /////////////////////////////////////////////////////////////////////////////////
610 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
611   AliITSv11Geometry(s.GetDebug()),
612   fSSDChipMedium(s.fSSDChipMedium),
613   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
614   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
615   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
616   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
617   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
618   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
619   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
620   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
621   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
622   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
623   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
624   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
625   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
626   fSSDSensorMedium(s.fSSDSensorMedium),
627   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
628   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
629   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
630   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
631   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
632   fSSDSupportRingAl(s.fSSDSupportRingAl),
633   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
634   fSSDRohaCellCone(s.fSSDRohaCellCone),
635   fSSDAir(s.fSSDAir),
636   fSSDCopper(s.fSSDCopper),
637   fCreateMaterials(s.fCreateMaterials),
638   fTransformationMatrices(s.fTransformationMatrices),
639   fBasicObjects(s.fBasicObjects),
640   fcarbonfiberjunction(s.fcarbonfiberjunction),
641   fcoolingtubesupport(s.fcoolingtubesupport),
642   fhybridmatrix(s.fhybridmatrix),
643   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
644   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
645   fssdstiffenerflex(s.fssdstiffenerflex),
646   fssdendflex(s.fssdendflex),
647   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
648   fendladdermountingblock(s.fendladdermountingblock),
649   fendladdermountingblockclip(s.fendladdermountingblockclip),
650   fSSDSensor5(s.fSSDSensor5),
651   fSSDSensor6(s.fSSDSensor6),
652   fSSDLayer5(s.fSSDLayer5),     
653   fSSDLayer6(s.fSSDLayer6),
654   fMotherVol(s.fMotherVol),
655   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
656   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
657   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
658   fSSDCone(s.fSSDCone),
659   fColorCarbonFiber(s.fColorCarbonFiber),
660   fColorRyton(s.fColorRyton),
661   fColorPhynox(s.fColorPhynox),
662   fColorSilicon(s.fColorSilicon),
663   fColorAl(s.fColorAl),
664   fColorKapton(s.fColorKapton),
665   fColorPolyhamide(s.fColorPolyhamide),
666   fColorStiffener(s.fColorStiffener),
667   fColorEpoxy(s.fColorEpoxy),
668   fColorWater(s.fColorWater),
669   fColorG10(s.fColorG10)
670 {
671   ////////////////////////
672   // Copy Constructor
673   ////////////////////////
674 }
675 /////////////////////////////////////////////////////////////////////////////////
676 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
677 operator=(const AliITSv11GeometrySSD &s){
678   ////////////////////////
679   // Assignment operator
680   ////////////////////////
681   this->~AliITSv11GeometrySSD();
682   new(this) AliITSv11GeometrySSD(s); 
683   return *this;
684 /*      
685   if(&s == this) return *this;
686   fMotherVol = s.fMotherVol;
687   return *this;
688  */
689 }
690 ///////////////////////////////////////////////////////////////////////////////
691 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
692   ///////////////////////////////////////////////////////////////////////  
693   // Method generating the trasformation matrix for the whole SSD Geometry   
694   ///////////////////////////////////////////////////////////////////////  
695   // Setting some variables for Carbon Fiber Supportmatrix creation
696   //////////////////////////////////////////////////////////////////////
697   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
698                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
699   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
700                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
701                                                                  +      fgkCarbonFiberSupportWidth);
702   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
703                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
704   TGeoRotation* carbonfiberot[3];
705   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
706   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
707   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
708   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
709   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
710                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
711                                                   -  fgkCarbonFiberTriangleLength
712                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
713   ///////////////////////////////////////////
714   //Setting Local Translations and Rotations: 
715   ///////////////////////////////////////////
716   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
717   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
718                                                                          0.5*carbonfibersupportheight,NULL);    
719   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
720                                                                          2.*symmetryplaneposition+transvector[1],
721                                                                          transvector[2], carbonfiberot[2]);
722   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
723   /////////////////////////////////////////////////////////////
724   // Carbon Fiber Support Transformations
725   /////////////////////////////////////////////////////////////
726   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
727   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
728                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
729                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
730                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
731   }             
732   /////////////////////////////////////////////////////////////
733   // Carbon Fiber Junction Transformation
734   /////////////////////////////////////////////////////////////
735   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
736   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
737   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
738   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
739   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
740         localcarbonfiberjunctionmatrix[i] = 
741                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
742         localcarbonfiberjunctionrot[i] = 
743                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
744         localcarbonfiberjunctiontrans[i] = 
745                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
746   }
747   ///////////////////////
748   // Setting Translations
749   ///////////////////////
750   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
751   localcarbonfiberjunctiontrans[1][0] = 
752                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
753   localcarbonfiberjunctiontrans[2][0] = 
754                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
755                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
756                                  fgkCarbonFiberTriangleLength
757                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
758   localcarbonfiberjunctiontrans[0][1] = 
759                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
760   localcarbonfiberjunctiontrans[1][1] = 
761                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
762   localcarbonfiberjunctiontrans[2][1] = 
763                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
764   ////////////////////
765   // Setting Rotations
766   ////////////////////
767   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
768                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
769                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
772   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
773   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
774   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
775   ////////////////////////////////////////
776   // Setting Carbon Fiber Junction matrix 
777   ////////////////////////////////////////
778   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
779                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
780                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
781                         localcarbonfiberjunctionmatrix[i][j] = 
782                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
783                                                            *localcarbonfiberjunctionrot[i][j]);
784                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
785          }
786   }
787   /////////////////////////////////////////////////////////////
788   // Carbon Fiber Lower Support Transformations
789   /////////////////////////////////////////////////////////////
790   TGeoTranslation* localcarbonfiberlowersupportrans[2];
791   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
792                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
793                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
794                                                                          0.0);
795   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
796                                                                          fgkCarbonFiberJunctionWidth
797                                                                 -    fgkCarbonFiberLowerSupportWidth
798                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
799                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
800                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
801    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
802    fcarbonfiberlowersupportrans[0] = 
803                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
804    fcarbonfiberlowersupportrans[1] = 
805                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
806   /////////////////////////////////////////////////////////////
807   // SSD Sensor Support Transformations
808   /////////////////////////////////////////////////////////////
809   const Int_t kssdsensorsupportmatrixnumber = 3;
810   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
811   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
812   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
813   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
814         localssdsensorsupportmatrix[i] = 
815                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
816         localssdsensorsupportrot[i] = 
817                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
818         localssdsensorsupportrans[i] = 
819                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
820   }
821   ///////////////////////
822   // Setting Translations
823   ///////////////////////
824   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
825                                                                           0.5*fgkSSDSensorSideSupportWidth,
826                                                                           0.0);
827   localssdsensorsupportrans[1][0] = 
828                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
829   localssdsensorsupportrans[2][0] = 
830                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
831   localssdsensorsupportrans[0][1] = 
832                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
833                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
834                                                                                 0.0);
835   localssdsensorsupportrans[1][1] = 
836                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
837                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
838                                                                     -   fgkSSDModuleSensorSupportDistance,
839                                                                                 0.0);
840   localssdsensorsupportrans[2][1] = 
841                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
842                                                                         -    fgkSSDSensorCenterSupportPosition,
843                                                                                  0.5*fgkSSDSensorCenterSupportWidth
844                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
845                                                                                  fgkSSDSensorCenterSupportThickness[0]);
846   localssdsensorsupportrans[0][2] = 
847                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
848                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
849                                                                                  fgkCarbonFiberJunctionWidth
850                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
851                                                                         +    fgkSSDSensorCenterSupportLength
852                                                                         -    fgkSSDSensorCenterSupportThickness[0])
853                                                                         -    fgkSSDSensorCenterSupportPosition,
854                                                                              0.0);
855   localssdsensorsupportrans[1][2] = 
856                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
857   localssdsensorsupportrans[2][2] = 
858                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
859   ////////////////////
860   // Setting Rotations
861   ////////////////////
862   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
863                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
864                         localssdsensorsupportrot[i][j] = new TGeoRotation();
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
866         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
867         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
868   }
869   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
870   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
871   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
872   ////////////////////////////////////////
873   // SSD Sensor Support matrix 
874   ////////////////////////////////////////
875   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
876                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
877                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
878                         localssdsensorsupportmatrix[i][j] = 
879                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
880                                                            *localssdsensorsupportrot[i][j]);
881                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
882          }
883   }
884   /////////////////////////////////////////////////////////////
885   // SSD Cooling Tube Support Transformations
886   /////////////////////////////////////////////////////////////
887   const Int_t kcoolingtubesupportmatrixnumber = 2;
888   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
889   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
890   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
891   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
892                                                                                                         /fgkCoolingTubeSupportRmax);
893   localcoolingtubesupportrans[0] = 
894                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
895                                                 +  2.*(fgkCoolingTubeSupportLength
896                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
897                                                 +  fgkCarbonFiberTriangleLength
898                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
899   localcoolingtubesupportrans[1] = 
900                         new TGeoTranslation(fgkCarbonFiberJunctionLength
901                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
902                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
903                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
904                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
905                     -  0.5*(fgkCarbonFiberLowerSupportWidth
906                                         +          fgkSSDSensorCenterSupportLength
907                     -      fgkSSDSensorCenterSupportThickness[0])
908                                         +  0.5*fgkSSDSensorLength,
909                                         -  0.5*fgkCoolingTubeSupportHeight);  
910   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
911   localcoolingtubesupportrot[i] = new TGeoRotation();
912   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
913   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
914   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
915         localcoolingtubesupportmatrix[i] = 
916                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
917                                                    *localcoolingtubesupportrot[i]);
918   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
919   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
920                                                                 (*localcoolingtubesupportmatrix[0]));
921   /////////////////////////////////////////////////////////////
922   // End Ladder SSD Cooling Tube Support Transformations
923   /////////////////////////////////////////////////////////////
924   TGeoTranslation** localendladdercooltubetrans[2];
925   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
926   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
927   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
928   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
929                                                                                         -          (fgkCoolingTubeSupportLength
930                                                                                         -               fgkCoolingTubeSupportRmax),
931                                                                                                         fgkEndLadderMountingBlockPosition[0]
932                                                                                         -               fgkendladdercoolingsupportdistance[0]
933                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
934                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
935   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
936                                                                                         -          (fgkCoolingTubeSupportLength
937                                                                                         -               fgkCoolingTubeSupportRmax),
938                                                                                                         fgkEndLadderMountingBlockPosition[0]
939                                                                                         +               fgkendladdercoolingsupportdistance[1]
940                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
941                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
942   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
943                                                                                         -       fgkCoolingTubeSupportRmax)
944                                                                                         +               fgkCarbonFiberTriangleLength
945                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
946                                                                                                 0.0,
947                                                                                                 0.0);
948   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
949                                                                                                         fgkendladdercoolingsupportdistance[0]
950                                                                                         +               fgkendladdercoolingsupportdistance[1],
951                                                                                                         0.0);
952   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
953   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
954                                                                                         +               fgkCarbonFiberJunctionLength
955                                                                                         -               fgkCoolingTubeSupportLength,
956                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
957                                                                                         -       0.5*fgkCoolingTubeSupportWidth
958                                                                                                    -fgkendladdercoolingsupportdistance[2],
959                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
960   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
961                                                                                         +               fgkCoolingTubeSupportLength
962                                                                                         -               fgkCoolingTubeSupportRmax
963                                                                                         -               fgkCarbonFiberJunctionLength,
964                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
965                                                                                         -       0.5*fgkCoolingTubeSupportWidth
966                                                                                         -               fgkendladdercoolingsupportdistance[2],
967                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
968   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
969   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
970   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
971   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
972   (*localcoolingtubesupportrot[1]));
973   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
974   (*localcoolingtubesupportrot[1]));
975   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
976   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
977   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
978   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
979   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
980
981   fendladdercoolingtubesupportmatrix[1][0] =    
982                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
983                                                                                    *(*localcoolingtubesupportrot[1]));
984   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
985   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
986   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
987   /////////////////////////////////////////////////////////////
988   // SSD Cooling Tube Transformations
989   /////////////////////////////////////////////////////////////
990   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
991   localcoolingtuberot->SetAngles(0.,90.,0.);
992   TGeoTranslation** localcoolingtubetrans[4];
993   TVector3** localcoolingtubevect[4];
994   for(Int_t i=0; i<4; i++){
995         localcoolingtubevect[i] = new TVector3*[2];
996         localcoolingtubetrans[i] = new TGeoTranslation*[2];
997         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
998   }
999   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1000                                                   -fgkCarbonFiberTriangleLength),
1001                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1002                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1003                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1004                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1005                                                   +      fgkSSDSensorCenterSupportLength
1006                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1007                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1008                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1009                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1010                                                   -  0.5*fgkCoolingTubeSupportWidth,
1011                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1012   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1013                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1014                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1015                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1016                                                   +  fgkCoolingTubeSupportWidth,
1017                                                   localcoolingtubevect[0][0]->Z());     
1018   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1019                                                          +                               fgkCarbonFiberTriangleLength,
1020                                                                                          localcoolingtubevect[0][0]->Y(),
1021                                                                                          localcoolingtubevect[0][0]->Z());
1022   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1023                                                          +                               fgkCarbonFiberTriangleLength,
1024                                                                                          localcoolingtubevect[0][1]->Y(),
1025                                                                                          localcoolingtubevect[0][1]->Z());
1026   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1027                                                   -     fgkCarbonFiberTriangleLength),
1028                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1029                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1030                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1031                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1032                                                   +      fgkSSDSensorCenterSupportLength
1033                                                   -      fgkSSDSensorCenterSupportThickness[0])
1034                                                   +  fgkSSDModuleStiffenerPosition[1]
1035                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1036                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1037   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1038                                                          +                               fgkCarbonFiberTriangleLength,
1039                                                                                          localcoolingtubevect[2][0]->Y(),
1040                                                                                          localcoolingtubevect[2][0]->Z());      
1041   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1042                                                   -     fgkCarbonFiberTriangleLength),
1043                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1044                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1045                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1046                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1047                                                   +      fgkSSDSensorCenterSupportLength
1048                                                   -      fgkSSDSensorCenterSupportThickness[0])
1049                                                   +      fgkSSDSensorLength
1050                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1051                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1052   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1053                                                   + fgkCarbonFiberTriangleLength,
1054                                                         localcoolingtubevect[3][0]->Y(),
1055                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1056   for(Int_t i=0; i<4; i++) 
1057         for(Int_t j=0; j<2; j++){
1058                 localcoolingtubetrans[i][j] = 
1059                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1060                                                                 localcoolingtubevect[i][j]->Y(),
1061                                                                 localcoolingtubevect[i][j]->Z());
1062                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1063                                                           *                                     (*localcoolingtuberot));
1064         }
1065   /////////////////////////////////////////////////////////////
1066   // SSD End Ladder Cooling Tube Transformations
1067   /////////////////////////////////////////////////////////////
1068   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1069   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1070   TGeoTranslation** localendlladdercoolingtubetrans[2];
1071   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1072   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1073   for(Int_t i=0; i<2; i++)      
1074         for(Int_t j=0; j<(i==0?6:4); j++)       
1075                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1076   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1077                                                                         -        fgkCoolingTubeSupportRmax)
1078                                                                         +        fgkCarbonFiberJunctionLength,
1079                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1080                                                                         -    fgkendladdercoolingsupportdistance[0]),
1081                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1082   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1083                                                                         -        fgkCoolingTubeSupportRmax)
1084                                                                         -        fgkCarbonFiberJunctionLength
1085                                                                         +    fgkCarbonFiberTriangleLength,
1086                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1087                                                                         -    fgkendladdercoolingsupportdistance[0]),
1088                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1089   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1090                                                                         -   fgkCoolingTubeSupportRmax)
1091                                                                         +       fgkCarbonFiberJunctionLength,
1092                                                                            fgkEndLadderMountingBlockPosition[0]
1093                                                                         -   fgkendladdercoolingsupportdistance[0]
1094                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1095                                                   +                             fgkendladdercoolingsupportdistance[1]
1096                                                   +                             fgkCoolingTubeSupportWidth),
1097                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1098   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1099                                                                         -        fgkCoolingTubeSupportRmax)
1100                                                                         -        fgkCarbonFiberJunctionLength
1101                                                                         +    fgkCarbonFiberTriangleLength,
1102                                                                            fgkEndLadderMountingBlockPosition[0]
1103                                                                         -   fgkendladdercoolingsupportdistance[0]
1104                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1105                                                   +                             fgkendladdercoolingsupportdistance[1]
1106                                                   +                             fgkCoolingTubeSupportWidth),
1107                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1108   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1109                                                                         -   fgkCoolingTubeSupportRmax)
1110                                                                         +       fgkCarbonFiberJunctionLength,
1111                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1112                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1113                                                   -                     fgkEndLadderMountingBlockPosition[0]
1114                                                   -                     fgkendladdercoolingsupportdistance[1]           
1115                                                   -                     fgkCoolingTubeSupportWidth),
1116                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1117   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1118                                                                         -        fgkCoolingTubeSupportRmax)
1119                                                                         -        fgkCarbonFiberJunctionLength
1120                                                                         +    fgkCarbonFiberTriangleLength,
1121                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1122                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1123                                                   -                     fgkEndLadderMountingBlockPosition[0]
1124                                                   -                     fgkendladdercoolingsupportdistance[1]           
1125                                                   -                     fgkCoolingTubeSupportWidth),
1126                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1127   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1128                                                                         -   fgkCoolingTubeSupportRmax)
1129                                                                         +       fgkCarbonFiberJunctionLength,
1130                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1131                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1132                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1133                                                         +                 fgkSSDSensorOverlap
1134                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1135                                                         -                 fgkendladdercoolingsupportdistance[2]
1136                                                         -                 fgkEndLadderMountingBlockPosition[1]
1137                                                         -                 fgkCoolingTubeSupportWidth)
1138                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1139                                                         -                 fgkendladdercoolingsupportdistance[2]
1140                                                         -                 fgkCoolingTubeSupportWidth,
1141                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1142   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1143                                                   -      fgkCoolingTubeSupportRmax)
1144                                                   -      fgkCarbonFiberJunctionLength
1145                                                   +    fgkCarbonFiberTriangleLength,
1146                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1147                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1148                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1149                                                         +                 fgkSSDSensorOverlap
1150                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1151                                                         -                 fgkendladdercoolingsupportdistance[2]
1152                                                         -                 fgkEndLadderMountingBlockPosition[1]
1153                                                         -                 fgkCoolingTubeSupportWidth)
1154                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1155                                                         -                 fgkendladdercoolingsupportdistance[2]
1156                                                         -                 fgkCoolingTubeSupportWidth,
1157                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1158   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1159                                                                         -   fgkCoolingTubeSupportRmax)
1160                                                                         +       fgkCarbonFiberJunctionLength,
1161                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1162                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1163                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1164   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1165                                                                         -        fgkCoolingTubeSupportRmax)
1166                                                                         -        fgkCarbonFiberJunctionLength
1167                                                                         +    fgkCarbonFiberTriangleLength,
1168                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1169                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1170                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1171   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1172   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1173   for(Int_t i=0; i<2; i++)
1174         for(Int_t j=0; j<(i==0?6:4); j++){
1175                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1176                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1177         }
1178   /////////////////////////////////////////////////////////////
1179   // SSD Hybrid Components Transformations
1180   /////////////////////////////////////////////////////////////
1181   const Int_t khybridmatrixnumber = 3;
1182   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1183   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1184                                             0.5*fgkSSDStiffenerWidth,
1185                                             0.5*fgkSSDStiffenerHeight);
1186   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1187                                             fgkSSDModuleStiffenerPosition[1],0.0);
1188
1189   localhybridtrans[2] = new TGeoTranslation(
1190                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1191                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1192                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1193                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1194                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1195                       -       fgkSSDSensorCenterSupportThickness[0]),
1196                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1197                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1198                                           -       fgkSSDModuleVerticalDisalignment)); 
1199   fhybridmatrix = new TGeoHMatrix();
1200   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1201   /////////////////////////////////////////////////////////////
1202   // SSD Cooling Block Transformations
1203   /////////////////////////////////////////////////////////////
1204   const Int_t kcoolingblockmatrixnumber = 4;    
1205   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1206   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1207                             -  fgkCoolingTubeSupportRmin),0.0,
1208                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1209   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1210                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1211                                0.0,fgkSSDStiffenerHeight);
1212   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1213   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1214   fcoolingblocksystematrix = new TGeoHMatrix();
1215   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1216       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1217   /////////////////////////////////////////////////////////////
1218   // SSD Stiffener Flex Transformations
1219   /////////////////////////////////////////////////////////////
1220   const Int_t klocalflexmatrixnumber = 4;
1221   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1222   for(Int_t i=0; i<fgkflexnumber; i++)    
1223       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1224   for(Int_t i=0; i<fgkflexnumber; i++)
1225       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1226             localflexmatrix[i][j] = new TGeoCombiTrans();
1227   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1228                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1229                                                                   -    fgkSSDStiffenerWidth;
1230   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1231                                         +0.5*fgkSSDStiffenerLength,
1232                                          0.5*fgkSSDStiffenerWidth,
1233                                         -0.5*fgkSSDStiffenerHeight
1234                                         -0.5*fgkSSDFlexHeight[0]);
1235   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1236                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1237                                         -0.5*fgkSSDStiffenerWidth,
1238                                         -0.5*fgkSSDStiffenerHeight
1239                                         -0.5*fgkSSDFlexHeight[0]);
1240   TGeoRotation* localflexrot = new TGeoRotation();
1241   localflexrot->SetAngles(180.,0.,0.);    
1242   localflexmatrix[1][0]->SetRotation(localflexrot);
1243   for(Int_t i=0; i<fgkflexnumber; i++)
1244       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1245             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1246   for(Int_t i=0; i<fgkflexnumber; i++){
1247       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1248       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1249             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1250   }
1251   /////////////////////////////////////////////////////////////
1252   // SSD End Flex Transformations
1253   /////////////////////////////////////////////////////////////
1254   TGeoRotation* localendflexrot = new TGeoRotation();
1255   localendflexrot->SetAngles(0.0,90.0,0.0);
1256   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1257   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1258                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1259   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1260                             * TMath::DegToRad()*ssdflexradiusmax
1261                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1262                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1263                                                                                    - 0.1*fgkSSDFlexFullLength;
1264   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1265                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1266                             +      fgkSSDFlexLength[2];
1267   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1268                               0.5*fgkSSDFlexWidth[0],
1269                               2.*fgkSSDStiffenerHeight
1270                             + 0.5*fgkSSDFlexHeight[0]);      
1271   localendflexmatrix->SetRotation(localendflexrot);
1272   for(Int_t i=0; i<fgkflexnumber; i++) 
1273       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1274   /////////////////////////////////////////////////////////////
1275   // End Ladder Carbon Fiber Junction
1276   /////////////////////////////////////////////////////////////
1277   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1278   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1279   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1280   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1281       localendladdercarbonfiberjunctionmatrix[i] 
1282             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1283       localendladdercarbonfiberjunctionrot[i] 
1284             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1285       localendladdercarbonfiberjunctiontrans[i] 
1286             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1287       fendladdercarbonfiberjunctionmatrix[i]
1288             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1289   }
1290   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1291       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1292             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1293             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1294       }
1295   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1296       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1297           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1298   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1299       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1300                               0.0,0.0);
1301       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1302                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1303                 *                     SinD(fgkCarbonFiberTriangleAngle),
1304                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1305   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1306   }
1307   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1308   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1309   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1310   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1311       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1312       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1313       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1314       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1315             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1316       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1317             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1318                                *localendladdercarbonfiberjunctionglobalrot[i]);
1319   }
1320   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1321       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1322             localendladdercarbonfiberjunctionmatrix[i][j] = 
1323                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1324                                      *localendladdercarbonfiberjunctionrot[i][j]);
1325            fendladdercarbonfiberjunctionmatrix[i][j] =
1326             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1327             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1328       }  
1329   /////////////////////////////////////////////////////////////
1330   // End Ladder Carbon Fiber Support
1331   /////////////////////////////////////////////////////////////
1332   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1333   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1334       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1335       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1336             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1337       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1338   }
1339   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1340       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1341             fendladdercarbonfibermatrix[i][j] = 
1342             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1343             *(*fcarbonfibersupportmatrix[j]));
1344   /////////////////////////////////////////////////////////////
1345   // End Ladder SSD Mounting Block
1346   /////////////////////////////////////////////////////////////
1347   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1348       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1349   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1350       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1351                                 +        fgkSSDMountingBlockLength[1])
1352                                 +  0.5*fgkCarbonFiberTriangleLength,
1353                                 fgkEndLadderMountingBlockPosition[i],
1354                                 -  fgkSSDMountingBlockHeight[1]
1355                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1356   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1357   endladdermountingblockrot->SetAngles(0.,90.,0.);
1358   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1359         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1360   /////////////////////////////////////////////////////////////
1361   // End Ladder SSD Mounting Block Clip Matrix 
1362   /////////////////////////////////////////////////////////////
1363   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1364         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1365   
1366   TGeoRotation* localendladdercliprot = new TGeoRotation();
1367   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1368   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1369                                                                                   -     fgkSSDMountingBlockLength[1])
1370                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1371   localendladdercliprot->SetAngles(90.,180.,-90.);
1372   TGeoCombiTrans* localendladderclipcombitrans = 
1373                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1374   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1375         for(Int_t j=0; j<2; j++){
1376                 fendladdermountingblockclipmatrix[i][j] = 
1377                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1378                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1379         }
1380   /////////////////////////////////////////////////////////////
1381   // End Ladder Carbon Fiber Lower Support
1382   /////////////////////////////////////////////////////////////
1383   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1384       fendladderlowersupptrans[i] = 
1385             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1386                         +  0.5*fgkSSDMountingBlockWidth),
1387                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1388   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1389                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1390                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1391                                                                          0.0);
1392   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1393  /////////////////////////////////////////////////////////////
1394   // Matrix for positioning Ladder into mother volume
1395   /////////////////////////////////////////////////////////////
1396   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1397   for(Int_t i=0; i<fgkladdernumber; i++) 
1398         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1399   TGeoRotation* localladdermotherrot = new TGeoRotation();
1400   localladdermotherrot->SetAngles(0.,90.,0.);  
1401   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1402   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1403   for(Int_t i=0; i<fgkladdernumber; i++){
1404         localladdermothertrans[i] = new TGeoTranslation(0.,
1405                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1406                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1407                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1408                                                           * fgkCarbonFiberJunctionWidth,0.);
1409         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1410                                                                                                                 *localladdermotherrot);
1411         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1412         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1413   }
1414   /////////////////////////////////////////////////////////////
1415   // Ladder Cables Matrices
1416   /////////////////////////////////////////////////////////////
1417   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1418                                              + fgkSSDFlexHeight[1];  
1419   Double_t ssdladdercabletransx[3];
1420   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1421                                                   *   SinD(2.*fgkSSDFlexAngle)
1422                                                   *       CosD(2.*fgkSSDFlexAngle);
1423   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1424                                                   -     ssdladdercabletransx[0]
1425                                                   /     SinD(2.*fgkSSDFlexAngle))
1426                                                   *     CosD(fgkSSDFlexAngle);                                          
1427   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1428                                                   *       TMath::DegToRad()*ssdflexradiusmax
1429                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1430                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1431                                                   -       fgkSSDLadderCableWidth)
1432                                                   *       CosD(2.*fgkSSDFlexAngle);
1433   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1434                                                   *     TanD(2.*fgkSSDFlexAngle),
1435                                                         ssdladdercabletransx[1]
1436                                                   *     TanD(fgkSSDFlexAngle),
1437                                                         ssdladdercabletransx[2]
1438                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1439   TGeoRotation* localladdercablerot[3]; 
1440   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1441   localladdercablerot[0]->SetAngles(90.,0.,0.);
1442   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1443   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1444                                                  *                        (*localladdercablerot[0]));
1445   ////////////////////////////////////////////
1446   // LocalLadderCableCombiTransMatrix
1447   ////////////////////////////////////////////
1448   const Int_t klocalladdersidecablesnumber = 2;
1449   const Int_t klocalladdercombitransnumber = 5;
1450   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1451   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1452          localladdercablecombitransmatrix[i] = 
1453                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1454   ///////////////////////////////////////////
1455   // Left Side Ladder Cables Transformations
1456   ///////////////////////////////////////////
1457   localladdercablecombitransmatrix[0][0]  =
1458                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1459                                                 0.,0.,NULL);
1460   localladdercablecombitransmatrix[0][1] = 
1461         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1462                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1463                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1464                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1465                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1466                                            + fgkSSDSensorCenterSupportLength
1467                                            - fgkSSDSensorCenterSupportThickness[0]),
1468                                            - (fgkSSDModuleCoolingBlockToSensor
1469                                            + 0.5*fgkCoolingTubeSupportHeight
1470                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1471                                            - fgkSSDChipHeight),NULL);
1472   localladdercablecombitransmatrix[0][2] = 
1473                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1474                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1475   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1476                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1477                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1478                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1479                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1480                                                                                                 new TGeoRotation("",180.,0.,0.));
1481   localladdercablecombitransmatrix[0][4] = 
1482                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1483                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1484                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1485                                                           0.,
1486                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1487                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1488                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1489                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1490   ///////////////////////////////////////////
1491   // Rigth Side Ladder Cables Transformations
1492   ///////////////////////////////////////////
1493   TGeoCombiTrans* localladdercablessdmodulematrix = 
1494         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1495                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1496                                                                          fgkSSDStiffenerWidth,
1497                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1498   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1499    localladdercablecombitransmatrix[1][i] = 
1500                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1501                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1502   ///////////////////////////////////////////
1503   // Setting LadderCableHMatrix
1504   ///////////////////////////////////////////
1505   Int_t beamaxistrans[2][3];
1506   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1507   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1508   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1509   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1510   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1511   beamaxistrans[1][2] = beamaxistrans[1][0];
1512   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1513   TGeoRotation* laddercablerot = new TGeoRotation();
1514   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1515   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1516   Double_t* laddercabletransvector;     
1517   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1518         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1519         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1520   }
1521   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1522         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1523                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1524                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1525                         localladdercablehmatrix[i][j]->MultiplyLeft(
1526                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1527         }
1528                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1529                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1530                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1531                                                                          laddercabletransvector[1]
1532                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1533                                         *                                fgkCarbonFiberJunctionWidth,
1534                                                                          laddercabletransvector[2]);
1535                 laddercablecombitrans->SetRotation(*laddercablerot);
1536                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1537                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1538         }
1539     fladdercablematrix[i][2] = 
1540                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1541                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1542         fladdercablematrix[i][3] = 
1543                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1544                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1545   }
1546   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1547         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1548                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1549   ///////////////////////////////////////////
1550   // Setting Ladder HMatrix
1551   ///////////////////////////////////////////
1552   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1553                                                                                                 fgkSSDLay6SensorsNumber};
1554   for(Int_t i=0; i<fgkladdernumber; i++){
1555         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1556         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1557                 fladdermatrix[i][j] = new TGeoHMatrix();
1558                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1559                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1560                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1561         }
1562   }
1563   ///////////////////////////////////////////
1564   // Setting SSD Sensor Matrix 
1565   ///////////////////////////////////////////
1566   TGeoCombiTrans* localssdsensorcombitrans[2];
1567   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1568   localssdsensorrot->SetAngles(0.,90.,0.);      
1569   TGeoTranslation* localssdsensortrans[2];
1570   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1571   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1572                                          fgkCarbonFiberJunctionWidth 
1573                                          - fgkCarbonFiberLowerSupportWidth 
1574                                          - fgkLowerSupportToSensorZ,
1575                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1576                                           -             fgkSSDModuleCoolingBlockToSensor
1577                                           +    (fgkSSDSensorSideSupportHeight[1]
1578                                           -             fgkSSDSensorSideSupportHeight[0]));
1579   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1580                                          fgkCarbonFiberJunctionWidth 
1581                                          - fgkCarbonFiberLowerSupportWidth 
1582                                          - fgkLowerSupportToSensorZ,
1583                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1584                                                         -fgkSSDModuleCoolingBlockToSensor);
1585   for(Int_t i=0; i<2; i++) 
1586         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1587                                                                                                          *localssdsensorrot);   
1588     for(Int_t i=0; i<fgkladdernumber; i++){
1589         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1590         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1591                 switch(i){
1592                         case 0: //Ladder of Layer5  
1593                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1594                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1595                                                                                                 *localssdsensorcombitrans[1])));
1596                         break;
1597                         case 1: //Ladder of Layer6 
1598                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1599                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1600                                                                                                 *localssdsensorcombitrans[0])));
1601                 break;
1602                 }
1603           }
1604   }     
1605   //////////////////////////
1606   // Setting SSD End Ladder  
1607   //////////////////////////
1608   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1609   for(Int_t i=0; i<2; i++){
1610         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1611         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1612         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1613         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1614         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1615         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1616         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1617         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1618    }
1619   /////////////////////////////////////////////////////
1620   // Setting the CombiTransformation to pass ITS center 
1621   /////////////////////////////////////////////////////
1622   Double_t itscentertransz[fgklayernumber];
1623   itscentertransz[0] = fgkSSDLay5LadderLength
1624                                          - fgkLay5CenterITSPosition;
1625   itscentertransz[1] = fgkSSDLay6LadderLength
1626                                          - fgkLay6CenterITSPosition;
1627   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1628                                                    + 0.5*fgkCoolingTubeSupportHeight;
1629   TGeoRotation* itscenterrot[3];
1630   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1631   itscenterrot[0]->SetAngles(90.,180.,-90.);
1632   itscenterrot[1]->SetAngles(0.,90.,0.);
1633   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1634   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1635   for(Int_t i=0; i<fgklayernumber; i++) 
1636         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1637                                                          itssensortransy,
1638                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1639                                                    - itscentertransz[i],itscenterrot[2]);
1640   TGeoRotation** locallayerrot[fgklayernumber];
1641   TGeoTranslation** locallayertrans[fgklayernumber];    
1642   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1643   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1644   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1645                                          - fgkLay5CenterITSPosition);
1646   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1647                                          - fgkLay6CenterITSPosition);
1648   const Int_t kssdlayladdernumber[fgklayernumber] = 
1649                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1650   for(Int_t i=0; i<fgklayernumber; i++){
1651     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1652     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1653         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1654         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1655   }
1656   Double_t layerladderangleposition[fgklayernumber] = 
1657                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1658   Double_t layerradius = 0.;
1659   for(Int_t i=0; i<fgklayernumber; i++){        
1660         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1661                 switch(i){
1662                         case 0: //Ladder of Layer5  
1663                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1664                         break;
1665                         case 1: //Ladder of Layer6 
1666                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1667                 break;
1668                 }
1669                 locallayerrot[i][j] = new TGeoRotation();
1670                 locallayertrans[i][j] = new TGeoTranslation();
1671                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1672                 locallayertrans[i][j]->SetTranslation(layerradius 
1673                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1674                                                             layerradius 
1675                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1676                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1677                                                                          *locallayerrot[i][j]);
1678                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1679                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1680                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1681         }
1682   }
1683   /////////////////////////////////////////////////////////////
1684   // Deallocating memory
1685   /////////////////////////////////////////////////////////////
1686   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1687         delete carbonfiberot[i];
1688         delete localcarbonfibersupportmatrix[i];
1689   }
1690   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1691      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1692        delete localcarbonfiberjunctionmatrix[i][j];
1693            delete localcarbonfiberjunctionrot[i][j];
1694            delete localcarbonfiberjunctiontrans[i][j];
1695            }
1696        delete [] localcarbonfiberjunctionmatrix[i];
1697        delete [] localcarbonfiberjunctionrot[i];
1698        delete [] localcarbonfiberjunctiontrans[i];
1699   }
1700   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1701            delete localcarbonfiberlowersupportrans[i];
1702   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1703      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1704        delete localssdsensorsupportmatrix[i][j];
1705            delete localssdsensorsupportrot[i][j];
1706            delete localssdsensorsupportrans[i][j];
1707            }
1708        delete [] localssdsensorsupportmatrix[i];
1709        delete [] localssdsensorsupportrot[i];
1710        delete [] localssdsensorsupportrans[i];
1711   }
1712   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1713         delete localcoolingtubesupportmatrix[i];
1714         delete localcoolingtubesupportrot[i];
1715         delete localcoolingtubesupportrans[i];
1716   }
1717   for(Int_t i=0; i<4; i++){
1718         for(Int_t j=0; j<2; j++){
1719                 delete localcoolingtubevect[i][j];
1720                 delete localcoolingtubetrans[i][j];
1721         }
1722         delete [] localcoolingtubevect[i];
1723         delete [] localcoolingtubetrans[i];
1724   }
1725  delete endladdermountingblockrot;
1726  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1727  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1728  for(Int_t i=0; i<fgkflexnumber; i++){
1729       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1730             delete localflexmatrix[i][j];
1731       delete [] localflexmatrix[i];
1732  }
1733  delete localendlladdercoolingtuberot;
1734  for(Int_t i=0; i<2; i++){
1735         for(Int_t j=0; j<(i==0?6:4); j++)
1736                 delete localendlladdercoolingtubetrans[i][j];
1737         delete [] localendlladdercoolingtubetrans[i];
1738   }
1739
1740  delete localflexrot;
1741  delete localendflexrot;
1742  delete localendflexmatrix;
1743  for(Int_t i=0; i<fgkladdernumber; i++){ 
1744         delete localladdermothertrans[i];
1745         delete localladdermothercombitrans[i];
1746   }
1747  delete localladdermotherrot;
1748  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1749       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1750             delete localendladdercarbonfiberjunctionmatrix[i][j];
1751             delete localendladdercarbonfiberjunctionrot[i][j];
1752             delete localendladdercarbonfiberjunctiontrans[i][j];
1753       }
1754       delete [] localendladdercarbonfiberjunctionmatrix[i];
1755       delete [] localendladdercarbonfiberjunctionrot[i];
1756       delete [] localendladdercarbonfiberjunctiontrans[i];
1757       delete localendladdercarbonfiberjunctionglobalrot[i];
1758       delete localendladdercarbonfiberjunctionglobaltrans[i];
1759       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1760  }
1761   for(Int_t i=0; i<2; i++){
1762         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1763         delete [] localendladdercooltubetrans[i];
1764   }
1765   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1766       delete localendladdercarbonfibertrans[i];
1767   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1768   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1769         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1770                 delete localladdercablecombitransmatrix[i][j];
1771                 delete []localladdercablecombitransmatrix[i];
1772   }
1773   delete localendladdercliprot;
1774   delete localendladdercliptrans;
1775   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1776         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1777                 delete localladdercablehmatrix[i][j];
1778         delete []localladdercablehmatrix[i];
1779   }
1780   delete laddercablerot;
1781   delete laddercabletrans;
1782   delete laddercablecombitrans;
1783   delete localladdercablessdmodulematrix;
1784   delete localssdsensorrot;     
1785   for(Int_t i=0; i<2; i++){
1786         delete localssdsensortrans[i];
1787         delete localssdsensorcombitrans[i];
1788   }
1789   for(Int_t i=0; i<fgklayernumber; i++){
1790         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1791                 delete locallayerrot[i][j];
1792                 delete locallayertrans[i][j];
1793                 delete locallayercombitrans[i][j];
1794     }
1795         delete [] locallayerrot[i];
1796         delete [] locallayertrans[i];
1797         delete [] locallayercombitrans[i];
1798         delete localbeamaxistrans[i];
1799   }
1800   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1801   for(Int_t i=0; i<fgkladdernumber; i++){
1802         for(Int_t j=0; j<fgkladdernumber; j++)
1803                 delete ladderglobalmatrix[i][j];
1804         delete [] ladderglobalmatrix[i];
1805   }
1806   /////////////////////////////////////////////////////////////
1807   fTransformationMatrices = kTRUE;      
1808 }
1809 ///////////////////////////////////////////////////////////////////////////////
1810 void AliITSv11GeometrySSD::CreateBasicObjects(){
1811   /////////////////////////////////////////////////////////////  
1812   // Method generating the Objects of SSD Geometry    
1813   /////////////////////////////////////////////////////////////
1814   // SSD Sensor
1815   ///////////////////////////////////
1816   SetSSDSensor();
1817   /////////////////////////////////////////////////////////////  
1818   // Carbon Fiber Support    
1819   /////////////////////////////////////////////////////////////  
1820   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1821   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1822       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1823   /////////////////////////////////////////////////////////////
1824   // Carbon Fiber Junction 
1825   /////////////////////////////////////////////////////////////
1826   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1827   /////////////////////////////////////////////////////////////
1828   // Carbon Fiber Lower Support
1829   /////////////////////////////////////////////////////////////
1830   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1831   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1832         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1833   /////////////////////////////
1834   // SSD Sensor Support
1835   /////////////////////////////
1836   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1837                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1838   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1839                                                                          fgkSSDSensorSideSupportThickness[1]};
1840   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1841         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1842                                                                                            fgkSSDSensorSideSupportHeight[i],
1843                                                                                            fgkSSDSensorSideSupportWidth,
1844                                                                                            sidesupporthickness);  
1845         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1846                                                                                            fgkSSDSensorCenterSupportHeight[i],
1847                                                                                            fgkSSDSensorCenterSupportWidth,
1848                                                                                            sidesupporthickness);
1849   }
1850   /////////////////////////////////////////////////////////////
1851   // SSD Cooling Tube Support
1852   /////////////////////////////////////////////////////////////
1853   Int_t edgesnumber = 16;
1854   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1855   /////////////////////////////////////////////////////////////
1856   // SSD Hybrid
1857   /////////////////////////////////////////////////////////////
1858   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1859   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1860         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1861   /////////////////////////////////////////////////////////////
1862   // SSD Cooling Block System
1863   /////////////////////////////////////////////////////////////
1864   fssdcoolingblocksystem = GetCoolingBlockSystem();
1865    /////////////////////////////////////////////////////////////
1866   // SSD Cooling Tube
1867   /////////////////////////////////////////////////////////////
1868   TList* coolingtubelist = GetCoolingTubeList();        
1869   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1870         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1871   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1872         fendladdercoolingtube[i] = 
1873                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1874   /////////////////////////////////////////////////////////////
1875   // SSD Flex  
1876   /////////////////////////////////////////////////////////////
1877   fssdstiffenerflex = GetSSDStiffenerFlex();
1878   fssdendflex = GetSSDEndFlex();
1879   ///////////////////////////////////
1880   // End Ladder Carbon Fiber Junction
1881   ///////////////////////////////////
1882   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1883                                                    fendladdercarbonfiberjunction[i] = 
1884                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1885   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1886     fendladdercarbonfiberjunction[i][0] = 
1887                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1888     fendladdercarbonfiberjunction[i][1] = 
1889                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1890   }
1891   ///////////////////////////////////
1892   // End Ladder Mounting Block
1893   ///////////////////////////////////
1894   fendladdermountingblock = GetSSDMountingBlock();
1895   ///////////////////////////////////
1896   // End Ladder Mounting Block
1897   ///////////////////////////////////
1898   fendladdermountingblockclip = GetMountingBlockClip();
1899   ///////////////////////////////////
1900   // Ladder Support 
1901   ///////////////////////////////////
1902   TList* laddersupportlist = GetMountingBlockSupport(20);
1903   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1904   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1905   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1906   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1907   /////////////////////////////////////////////////////////////
1908   // Deallocating memory
1909   /////////////////////////////////////////////////////////////
1910   delete carbonfibersupportlist;
1911   delete carbonfiberlowersupportlist;
1912   delete ssdhybridcomponentslist;
1913   delete laddersupportlist;
1914   /////////////////////////////////////////////////////////////
1915   fBasicObjects = kTRUE;
1916 }
1917 /////////////////////////////////////////////////////////////////////////////////
1918 void AliITSv11GeometrySSD::SetSSDSensor(){
1919   ////////////////////////////////////////////////////////////////
1920   // Method generating SSD Sensors: it sets the private variables
1921   // fSSDSensor5, fSSDSensor6  
1922   ////////////////////////////////////////////////////////////////
1923   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1924   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1925   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1926                                                 0.5*ssdsensitivewidth,
1927                                                 0.5*fgkSSDSensorHeight,
1928                                                 0.5*ssdsensitivelength);
1929   TGeoVolume* ssdsensorsensitiveLay5 = 
1930         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1931   TGeoVolume* ssdsensorsensitiveLay6 = 
1932         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1933   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1934   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1935   TGeoBBox* ssdsensorinsensitiveshape[2];
1936   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1937                                                 0.5*fgkSSDSensorInsensitiveWidth,
1938                                                 0.5*fgkSSDSensorHeight,
1939                                                 0.5*fgkSSDSensorLength);
1940   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1941                                                 0.5*ssdsensitivewidth,
1942                                                 0.5*fgkSSDSensorHeight,
1943                                                 0.5*fgkSSDSensorInsensitiveWidth);
1944   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1945                                              "SSDSensorInsensitive2"};
1946   TGeoVolume* ssdsensorinsensitive[2];
1947   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1948       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1949                      fSSDSensorMedium);
1950       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1951   }
1952   /////////////////////////////////////////////////////////////
1953   // Virtual Volume containing SSD Sensor  
1954   /////////////////////////////////////////////////////////////
1955   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1956                                                                                              0.5*fgkSSDSensorWidth,
1957                                                                                              0.5*fgkSSDSensorHeight,
1958                                                                                              0.5*fgkSSDSensorLength);
1959   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1960                                                                                  fSSDAir);      
1961   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1962                                                                                  fSSDAir);      
1963   /////////////////////////////////////////////////////////////
1964   for(Int_t i=0; i<4; i++){ 
1965             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1966             ssdsensorinsensitive[1],i<2?1:2,
1967                         new TGeoTranslation(
1968                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1969       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1970                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1971       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1972             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1973             ssdsensorinsensitive[1],i<2?1:2,
1974                         new TGeoTranslation(
1975                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1976       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1977                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1978       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1979   }
1980     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1981     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1982 }
1983 ///////////////////////////////////////////////////////////////////////////////
1984 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1985   /////////////////////////////////////////////////////////////  
1986   // Method generating the Carbon Fiber Support   
1987   /////////////////////////////////////////////////////////////  
1988   const Int_t kvertexnumber = 4;
1989   const Int_t kshapesnumber = 2;
1990   TVector3** vertexposition[kshapesnumber];
1991   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1992   Double_t carbonfibersupportxaxisEdgeproj = 
1993                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1994         *       TMath::DegToRad());
1995   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1996                                  /                         fgkCarbonFiberSupportXAxisLength);
1997   /////////////////////
1998   //Vertex Positioning
1999   ////////////////////
2000   vertexposition[0][0] = new TVector3();
2001   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2002                                                                           fgkCarbonFiberSupportYAxisLength);
2003   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2004                                                                           carbonfibersupportxaxisEdgeproj
2005                                            *                      TMath::Tan(theta));
2006   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2007                                            -                      carbonfibersupportxaxisEdgeproj,
2008                                                                           fgkCarbonFiberSupportYAxisLength
2009                                            -                      vertexposition[0][2]->Y());
2010   ////////////////////////////////////////////////////
2011   //Setting the parameters for Isometry Transformation
2012   ////////////////////////////////////////////////////
2013   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2014                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2015                                                                  +      fgkCarbonFiberSupportWidth);
2016   Double_t* param = new Double_t[4]; 
2017   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2018   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2019                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2020                                                           (GetReflection(vertexposition[0][j],param))->Y());
2021   const char* carbonfibersupportshapename[kshapesnumber] = 
2022                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2023   const char* carbonfibersupportname[kshapesnumber] = 
2024                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2025   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2026   TGeoVolume* carbonfibersupport[kshapesnumber];
2027   TList* carbonfibersupportlist = new TList();
2028   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2029   Double_t carbonfibersupportheight = 
2030           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2031           *TMath::DegToRad());
2032   for(Int_t i = 0; i< kshapesnumber; i++){
2033    carbonfibersupportshape[i] = 
2034                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2035                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2036    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2037                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2038    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2039    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2040    }
2041   /////////////////////////////////////////////////////////////
2042   // Deallocating memory
2043   /////////////////////////////////////////////////////////////
2044   for(Int_t i=0; i< kshapesnumber; i++){
2045      for(Int_t j=0; j< kvertexnumber; j++)
2046            delete vertexposition[i][j];
2047        delete [] vertexposition[i];
2048   }
2049   delete [] param;
2050   /////////////////////////////////////////////////////////////
2051    return carbonfibersupportlist;
2052 }
2053 /////////////////////////////////////////////////////////////////////////////////
2054 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2055   /////////////////////////////////////////////////////////////
2056   // Method generating SSD Carbon Fiber Junction
2057   /////////////////////////////////////////////////////////////
2058   const Int_t kvertexnumber = 6;
2059   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2060   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2061                                             *  TMath::DegToRad()),-1.,0.,0.};
2062   TVector3* vertex[kvertexnumber];
2063   vertex[0] = new TVector3();
2064   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2065                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2066                         *                         TMath::DegToRad()),
2067                                                   fgkCarbonFiberJunctionEdge[0]
2068                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2069                         *                         TMath::DegToRad()));
2070   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2071                                                    fgkCarbonFiberJunctionEdge[1]);
2072   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2073   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2074   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2075   Double_t xvertexpoints[6], yvertexpoints[6];
2076   for(Int_t i=0; i<kvertexnumber; i++) 
2077           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2078   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2079   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2080   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2081   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2082                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2083   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2084   /////////////////////////////////////////////////////////////
2085   // Deallocating memory
2086   /////////////////////////////////////////////////////////////
2087   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2088   ///////////////////////////////////////////////////////////// 
2089   return carbonfiberjunction;
2090 }
2091 ////////////////////////////////////////////////////////////////////////////////
2092 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2093   /////////////////////////////////////////////////////////////
2094   // Method generating the Carbon Fiber Lower Support   
2095   /////////////////////////////////////////////////////////////  
2096   const Int_t kvertexnumber = 4;
2097   const Int_t kshapesnumber = 2;
2098   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2099                                                                 fgkCarbonFiberLowerSupportWidth};
2100   TVector3** vertexposition[kshapesnumber];
2101   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2102                                                  new TVector3*[kvertexnumber];
2103   //First Shape Vertex Positioning
2104   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2105   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2106                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2107   vertexposition[0][2] = new TVector3();
2108   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2109   //Second Shape Vertex Positioning
2110   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2111                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2112                                  /                              fgkCarbonFiberTriangleLength);
2113   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2114                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2115                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2116   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2117                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2118                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2119   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2120   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2121                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2122   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
2123                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2124   const char* carbonfiberlowersupportname[kshapesnumber] = 
2125                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2126   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2127   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2128   TList* carbonfiberlowersupportlist = new TList();
2129   for(Int_t i = 0; i< kshapesnumber; i++){ 
2130         carbonfiberlowersupportshape[i] = 
2131                                                                 GetArbShape(vertexposition[i],width,
2132                                                                                         fgkCarbonFiberLowerSupportHeight,
2133                                                                                         carbonfiberlowersupportshapename[i]);
2134     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2135                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2136         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2137     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2138   }
2139   /////////////////////////////////////////////////////////////
2140   // Deallocating memory
2141   /////////////////////////////////////////////////////////////
2142   for(Int_t i=0; i< kshapesnumber; i++){
2143      for(Int_t j=0; j< kvertexnumber; j++)
2144            delete vertexposition[i][j];
2145        delete [] vertexposition[i];
2146   }
2147   /////////////////////////////////////////////////////////////
2148   return carbonfiberlowersupportlist;
2149 }
2150 ///////////////////////////////////////////////////////////////////////////////
2151 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2152                                                                  Double_t width, Double_t* thickness)const{
2153   /////////////////////////////////////////////////////////////
2154   // Method generating the Sensor Support   
2155   /////////////////////////////////////////////////////////////  
2156         const Int_t kvertexnumber = 6;
2157         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2158     TVector3* vertexposition[kvertexnumber];
2159         vertexposition[0] = new TVector3();     
2160         vertexposition[1] = new TVector3(0.0,length);   
2161         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2162         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2163         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2164         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2165         Double_t xvertexpoints[6], yvertexpoints[6];
2166         for(Int_t i=0; i<kvertexnumber; i++) 
2167                 xvertexpoints[i] = vertexposition[i]->X(), 
2168                 yvertexpoints[i] = vertexposition[i]->Y();
2169     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2170     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2171     ssdsensorsupportshape->DefineSection(1,0.5*width);
2172     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2173                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2174   /////////////////////////////////////////////////////////////
2175   // Deallocating memory
2176   /////////////////////////////////////////////////////////////
2177         for (Int_t i=0; i<kvertexnumber; i++)
2178                 delete vertexposition[i];
2179   /////////////////////////////////////////////////////////////
2180     return ssdsensorsupport;
2181 }
2182 ////////////////////////////////////////////////////////////////////////////////
2183 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2184   /////////////////////////////////////////////////////////////
2185   // Method generating the Cooling Tube Support
2186   /////////////////////////////////////////////////////////////
2187   if(nedges%2!=0) nedges--;     
2188   const Int_t kvertexnumber = nedges+5;
2189   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2190                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2191   Double_t angle = 90.+phi;
2192   Double_t psi = 90.-phi;
2193   ///////////////////////////////////////
2194   // Vertex Positioning for TGeoXTru
2195   ///////////////////////////////////////
2196   TVector3** vertexposition = new TVector3*[kvertexnumber];
2197   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2198                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2199   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2200                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2201   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2202                                                                    fgkCoolingTubeSupportRmax);
2203   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2204                                                                    fgkCoolingTubeSupportRmax);
2205   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2206                                                                     vertexposition[1]->Y());
2207   for(Int_t i=0; i<nedges; i++)
2208         vertexposition[i+5] = 
2209                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2210                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2211   ///////////////////////////////////////////////////////////////////////
2212   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2213   ///////////////////////////////////////////////////////////////////////
2214   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2215   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2216   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2217   for(Int_t i=0; i<kvertexnumber; i++){
2218         xvertexpoints[i] = vertexposition[i]->X();
2219         yvertexpoints[i] = vertexposition[i]->Y();
2220   } 
2221   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2222                                                                                         yvertexpoints);
2223   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2224   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2225   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2226                                                                           coolingtubesupportarcshape,
2227                                                                                   fSSDTubeHolderMedium);
2228   coolingtubesupportarc->SetLineColor(fColorG10);
2229   //////////////////////////////////////////////////////////////////////////
2230   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2231   //////////////////////////////////////////////////////////////////////////
2232   TGeoTubeSeg* coolingtubesupportsegshape = 
2233                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2234                                                                                         fgkCoolingTubeSupportRmax,
2235                                                                                         0.5*fgkCoolingTubeSupportWidth,
2236                                                                                         phi,360-phi);
2237   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2238                                                                                         coolingtubesupportsegshape,
2239                                                                                         fSSDTubeHolderMedium);
2240   coolingtubesupportseg->SetLineColor(fColorG10);
2241   //////////////////////////////////////////////////////////////////////////
2242   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2243   //////////////////////////////////////////////////////////////////////////
2244   Double_t* boxorigin = new Double_t[3];
2245   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2246   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2247   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2248                                                                                  0.5*fgkCoolingTubeSupportHeight,
2249                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2250   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2251                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2252   coolingtubesupportbox->SetLineColor(fColorG10);
2253   //////////////////////////////////////////////////////////////////////////
2254   // Cooling Tube for Cooling Tube Support 
2255   //////////////////////////////////////////////////////////////////////////
2256   TGeoXtru* coolingtubearcshape[2];
2257   coolingtubearcshape[0] = new TGeoXtru(2);     
2258   Double_t* xvert = new Double_t[nedges+2];
2259   Double_t* yvert = new Double_t[nedges+2];
2260   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2261   ////////////////////////////////////////
2262   // Positioning the vertices for TGeoXTru
2263   ////////////////////////////////////////
2264   xvert[0] = 0., yvert[0] = 0.;
2265   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2266   for(Int_t i=0; i< nedges; i++)
2267                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2268                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2269   ////////////////////////////////////////
2270   // Defining TGeoXTru PolyGone
2271   ////////////////////////////////////////
2272   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2273   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2274   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2275   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2276                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2277   TGeoVolume* coolingtubearc[2];
2278   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2279                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2280   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2281                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2282   coolingtubearc[0]->SetLineColor(fColorWater);
2283   coolingtubearc[1]->SetLineColor(fColorPhynox);
2284   ////////////////////////////////////////////
2285   // Defining TGeoTubeSeg Part of Cooling Tube
2286   ////////////////////////////////////////////
2287   TGeoTubeSeg* coolingtubesegshape[2];
2288   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2289                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2290   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2291                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2292   TGeoVolume* coolingtubeseg[2];
2293   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2294                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2295   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2296                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2297   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2298   coolingtubeseg[1]->SetLineColor(fColorWater);
2299   /////////////////////////////////////////////////////////////
2300   // Virtual Volume containing Cooling Tube Support  
2301   /////////////////////////////////////////////////////////////
2302   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2303   const Int_t kvirtualvertexnumber = 8;
2304   TVector3* virtualvertex[kvirtualvertexnumber];
2305    ////////////////////////////////////////
2306   // Positioning the vertices for TGeoXTru
2307   ////////////////////////////////////////
2308   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2309   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2310   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2311   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2312   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2313   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2314   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2315   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2316   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2317   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2318         xmothervertex[i] = virtualvertex[i]->X(),
2319         ymothervertex[i] = virtualvertex[i]->Y();
2320   ////////////////////////////////////////
2321   // Defining TGeoXTru PolyGone
2322   ////////////////////////////////////////
2323   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2324                                                                                                                                          ymothervertex);
2325   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2326   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2327   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2328                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2329   ////////////////////////////////////////
2330   // Positioning Volumes in Virtual Volume
2331   ////////////////////////////////////////
2332   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2333   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2334   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2335   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2336   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2337   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2338   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2339   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2340   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2341   /////////////////////////////////////////////////////////////
2342   // Deallocating memory
2343   /////////////////////////////////////////////////////////////
2344   delete [] vertexposition;
2345   delete [] xvertexpoints;
2346   delete [] yvertexpoints;
2347   delete [] xvert;
2348   delete [] yvert;
2349   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2350         delete virtualvertex[i];
2351   /////////////////////////////////////////////////////////////
2352         return virtualcoolingtubesupport;
2353 }
2354 /////////////////////////////////////////////////////////////////////////////////
2355 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2356   /////////////////////////////////////////////////////////////
2357   // Method generating List containing SSD Hybrid Components   
2358   /////////////////////////////////////////////////////////////
2359   TList* ssdhybridlist = new TList();
2360   const Int_t kssdstiffenernumber = 2;
2361   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2362                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2363                                                                   -    fgkSSDStiffenerWidth;
2364   Double_t ssdchipcablesradius[kssdstiffenernumber];
2365   for(Int_t i=0; i<kssdstiffenernumber; i++)
2366           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2367                                -  fgkSSDChipCablesHeight[0]
2368                                -  fgkSSDChipCablesHeight[1]);
2369   /////////////////////////////////////////////////////////////
2370   // Mother Volumes Containers 
2371   /////////////////////////////////////////////////////////////
2372   const Int_t kmothernumber = 2;
2373   const Int_t kmothervertexnumber = 12;
2374   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2375   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2376   ///////////////////////
2377   // Setting the vertices 
2378   ///////////////////////
2379   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2380   xmothervertex[0][1]  = xmothervertex[0][0]; 
2381   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2382   xmothervertex[0][3]  = xmothervertex[0][2];
2383   xmothervertex[0][4]  = xmothervertex[0][0];
2384   xmothervertex[0][5]  = xmothervertex[0][4];
2385   xmothervertex[0][6]  = -xmothervertex[0][0];
2386   xmothervertex[0][7]  = xmothervertex[0][6];
2387   xmothervertex[0][8]  = -xmothervertex[0][2];
2388   xmothervertex[0][9]  = xmothervertex[0][8];
2389   xmothervertex[0][10] = xmothervertex[0][7];
2390   xmothervertex[0][11] = xmothervertex[0][10];
2391   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2392   for(Int_t i = 0; i<kmothernumber; i++){
2393       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2394                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2395       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2396       ymothervertex[i][2]  = ymothervertex[i][1];
2397       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2398       ymothervertex[i][4]  = ymothervertex[i][3];
2399       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2400       ymothervertex[i][6]  = ymothervertex[i][5];
2401       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2402       ymothervertex[i][8]  = ymothervertex[i][7];
2403       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2404       ymothervertex[i][10] = ymothervertex[i][9];
2405       ymothervertex[i][11] = ymothervertex[i][0];
2406   }
2407   TGeoXtru* ssdhybridmothershape[kmothernumber];
2408 //  TGeoVolume* ssdhybridmother[kmothernumber];
2409   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2410   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2411   for(Int_t i=0; i<kmothernumber; i++){
2412       ssdhybridmothershape[i] = new TGeoXtru(2);
2413       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2414                                           ymothervertex[i]);
2415       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2416                                                -fgkSSDChipCablesHeight[i+2]);
2417       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2418 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2419 //                                          fSSDAir);
2420       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2421    }   
2422   /////////////////////////////////////////////////////////////
2423   // SSD Stiffener   
2424   /////////////////////////////////////////////////////////////
2425   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2426                                              0.5*fgkSSDStiffenerLength,
2427                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2428                                              0.5*fgkSSDStiffenerHeight);
2429   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2430                                             fSSDStiffenerMedium);  
2431   ssdstiffener->SetLineColor(fColorStiffener); 
2432   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2433   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2434       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2435   /////////////////////////////////////////////////////////////
2436   // SSD Chip System    
2437   /////////////////////////////////////////////////////////////
2438   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2439   Double_t ssdchipseparation = fgkSSDSensorLength
2440                              - 2.*fgkSSDModuleStiffenerPosition[1]
2441                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2442                              - 0.5*fgkSSDChipWidth);
2443   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2444                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2445   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2446                                       - 0.5*ssdchipsystemlength,
2447                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2448                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2449 ////////////////////////////
2450 // Capacitor 0603-2200 nF
2451 ///////////////////////////
2452   const Int_t knapacitor0603number = 5;
2453   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2454                                                                                          0.5*fgkSSDCapacitor0603Length,
2455                                                                                          0.5*(fgkSSDCapacitor0603Width),
2456                                                                                          0.5*fgkSSDCapacitor0603Height);
2457   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2458                                              fSSDStiffener0603CapacitorMedium); 
2459   capacitor0603->SetLineColor(fColorAl);
2460   for(Int_t i=0; i<kmothernumber; i++){
2461       for(Int_t j=0; j<kssdstiffenernumber; j++){
2462             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2463             for(Int_t k=1; k<knapacitor0603number+1; k++){
2464                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2465                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2466                                            j*ssdstiffenerseparation
2467                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2468                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2469                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2470             }
2471       } 
2472       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2473       ssdhybridlist->Add(ssdhybridmother[i]);
2474   }    
2475 /////////////////////////////////////////////////////////////
2476 // Mother Volume Containing Capacitor Part 
2477 /////////////////////////////////////////////////////////////
2478   const Int_t kcapacitormothernumber = 8;
2479   Double_t xcapacitorvertex[kcapacitormothernumber];
2480   Double_t ycapacitorvertex[kcapacitormothernumber];  
2481   ///////////////////////
2482   // Setting the vertices 
2483   ///////////////////////
2484   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2485   xcapacitorvertex[1] = xcapacitorvertex[0];   
2486   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2487   xcapacitorvertex[3] = xcapacitorvertex[2];   
2488   xcapacitorvertex[4] = xcapacitorvertex[0];   
2489   xcapacitorvertex[5] = xcapacitorvertex[0];   
2490   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2491   xcapacitorvertex[7] = xcapacitorvertex[6];   
2492   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2493   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2494   ycapacitorvertex[2] = ycapacitorvertex[1];   
2495   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2496   ycapacitorvertex[4] = ycapacitorvertex[3];   
2497   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2498   ycapacitorvertex[6] = ycapacitorvertex[5];   
2499   ycapacitorvertex[7] = ycapacitorvertex[0];   
2500   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2501   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2502                                               ycapacitorvertex);
2503   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2504   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2505 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2506 //                                          fSSDAir);
2507   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2508 ////////////////////////////
2509 // Connector 
2510 ///////////////////////////
2511   const Int_t kssdconnectornumber = 2;
2512   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2513   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2514   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2515                                    +  fgkSSDConnectorAlHeight};  
2516   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2517   TGeoVolume* ssdconnector[kssdconnectornumber];
2518   for(Int_t i=0; i<kssdconnectornumber; i++){
2519       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2520                                           0.5*fgkSSDConnectorWidth,
2521                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2522                            +              i*fgkSSDConnectorNiHeight),
2523                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2524       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2525                                        i==0 ? fSSDAlTraceFlexMedium 
2526                                             : fSSDStiffenerConnectorMedium);      
2527       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2528   }
2529   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2530   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2531                        +  fgkSSDConnectorPosition[0]
2532                        -  fgkSSDConnectorSeparation
2533                        -  1.5*fgkSSDConnectorLength,
2534                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2535                        -  fgkSSDConnectorPosition[1]
2536                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2537   ssdconnectortrans[1] = new TGeoTranslation(
2538                        -  ssdstiffenershape->GetDX()
2539                        +  fgkSSDConnectorPosition[0]
2540                        -  0.5*fgkSSDConnectorLength,
2541                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2542                        -  fgkSSDConnectorPosition[1]
2543                        -  ssdconnectorshape[0]->GetDY(),0.0);
2544   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2545                        -  fgkSSDConnectorPosition[0]
2546                        +  fgkSSDConnectorSeparation
2547                        +  1.5*fgkSSDConnectorLength,
2548                           -(ssdstiffenershape->GetDY()
2549                        -  fgkSSDConnectorPosition[1]
2550                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2551   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2552                        -  fgkSSDConnectorPosition[0]
2553                        +  0.5*fgkSSDConnectorLength,
2554                           -(ssdstiffenershape->GetDY()
2555                        -  fgkSSDConnectorPosition[1]
2556                        -  ssdconnectorshape[0]->GetDY()),0.0);
2557   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2558       for(Int_t j=0; j<kssdconnectornumber; j++)
2559             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2560 ////////////////////////////
2561 // Capacitor 1812-330 nF
2562 /////////////////////////// 
2563   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2564   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2565                                                                                          0.5*fgkSSDCapacitor1812Length,
2566                                                                                          0.5*fgkSSDCapacitor1812Width,
2567                                                                                          0.5*fgkSSDCapacitor1812Height,
2568             ssdcapacitor1812origin);
2569   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2570                                              fSSDStiffener1812CapacitorMedium); 
2571   capacitor1812->SetLineColor(fColorAl);
2572   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2573                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2574                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2575   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2576 ////////////////////////////
2577 //Hybrid Wire
2578 ////////////////////////////
2579   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2580                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2581                                  - fgkSSDConnectorSeparation;
2582   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2583                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2584   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2585
2586   Double_t wireangle = TMath::ATan(wirex/wirey);
2587   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2588                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2589   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2590                                              fSSDStiffenerHybridWireMedium); 
2591   hybridwire->SetLineColor(fColorPhynox);
2592   TGeoCombiTrans* hybridwirecombitrans[2];
2593   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2594                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2595                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2596                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2597                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2598                                    ssdstiffenershape->GetDZ()
2599                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2600                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2601   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2602                             0.0,
2603                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2604                             0.0,        
2605                             new TGeoRotation("HybridWireRot2",
2606                           - wireangle*TMath::RadToDeg(),0.,0.));
2607   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2608   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2609   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2610   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2611   ssdhybridlist->Add(ssdhybridcapacitormother);
2612   /////////////////////////////////////////////////////////////
2613   // Deallocating memory
2614   /////////////////////////////////////////////////////////////
2615   delete hybridwirecombitrans[0];
2616   delete hybridwirecombitrans[1];
2617   delete ssdchipsystemlist;
2618   return ssdhybridlist;
2619   /////////////////////////////////////////////////////////////
2620 }
2621 ///////////////////////////////////////////////////////////////////////////////
2622 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2623   /////////////////////////////////////////////////////////////
2624   // SSD Cooling Block System
2625   /////////////////////////////////////////////////////////////
2626   // SSD Cooling Block and Cooling Tube Transformations
2627   /////////////////////////////////////////////////////////////
2628   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2629   localcoolingblockrot->SetAngles(0.,90.,0.);
2630   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2631   TVector3* coolingblocktransvector;
2632   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2633                                                                 + fgkSSDCoolingBlockLength,
2634                                                                   fgkSSDSensorLength
2635                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2636                                                                 - fgkSSDCoolingBlockWidth);
2637   const Int_t kcoolingblocktransnumber = 2;
2638   const Int_t kcoolingblocknumber = 4;
2639   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2640   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2641   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2642   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2643   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2644   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2645                                         0.5*fgkSSDCoolingBlockWidth,
2646                                         fgkSSDCoolingBlockHoleCenter);
2647   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2648   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2649   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2650     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2651       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2652                                              j*coolingblocktransvector->Y(),
2653                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2654                                                     + fgkCoolingTubeRmax));
2655       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2656       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2657     }
2658   }
2659   /////////////////////////////////////////////////////////////
2660   // Virtual Volume containing CoolingBlock System   
2661   /////////////////////////////////////////////////////////////
2662   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2663   const Int_t kmothervertexnumber = 16;  
2664   Double_t xmothervertex[kmothervertexnumber];
2665   Double_t ymothervertex[kmothervertexnumber];
2666   ///////////////////////
2667   // Setting the vertices 
2668   ///////////////////////fgkCoolingTubeSupportRmax
2669   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2670   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2671                                    + fgkSSDCoolingBlockWidth;
2672   xmothervertex[2] = coolingblocktransvector->X()
2673                                    + fgkSSDCoolingBlockLength
2674                                    + 4*coolingtubedistance;
2675   ymothervertex[2] = ymothervertex[1];
2676   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2677   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2678   ymothervertex[4] = ymothervertex[0];
2679   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2680   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2681   ymothervertex[6] = ymothervertex[5]; 
2682   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2683                                    - fgkSSDCoolingBlockWidth; 
2684   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2685   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2686                                    - coolingtubedistance;
2687   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2688   ymothervertex[10] = ymothervertex[9];
2689   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2690   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2691   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2692   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2693   ymothervertex[14] = ymothervertex[13];
2694   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2695   //////////////////////////////////////////////////////////
2696   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2697                                                                         xmothervertex,ymothervertex);
2698   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2699                                                                                            + fgkCoolingTubeRmax));
2700   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2701                                                                                            + fgkCoolingTubeRmax));
2702   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2703 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2704 //                                                        coolingsystemothershape,fSSDAir);
2705   /////////////////////////////////////////////////////////////
2706   // SSD Cooling Tube Part 
2707   /////////////////////////////////////////////////////////////
2708   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2709   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2710                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2711   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2712                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2713   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2714   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2715                                                                         fSSDCoolingTubePhynox);
2716   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2717                                                                         fSSDCoolingTubeWater);
2718   coolingtube[0]->SetLineColor(fColorPhynox);
2719   coolingtube[1]->SetLineColor(fColorWater);
2720   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2721   /////////////////////////////////////////////////////////////
2722   // Adding Cooling block to mother volume
2723   /////////////////////////////////////////////////////////////
2724    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2725         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2726         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2727         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2728   }
2729   /////////////////////////////////////////////////////////////
2730   // Deallocating memory
2731   /////////////////////////////////////////////////////////////
2732         delete coolingblocktransvector;
2733         delete localcoolingblockrot;
2734         delete localcoolingtubetrans;
2735         delete localcoolingtuberot;
2736   /////////////////////////////////////////////////////////////
2737   // Checking overlaps  
2738   /////////////////////////////////////////////////////////////
2739         //coolingsystemother->CheckOverlaps(0.01);
2740   /////////////////////////////////////////////////////////////
2741         return coolingsystemother;
2742 }
2743 /////////////////////////////////////////////////////////////////////////////////
2744 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2745   /////////////////////////////////////////////////////////////
2746   // SSD Flex
2747   /////////////////////////////////////////////////////////////
2748   const Int_t kssdflexlayernumber = 2;
2749   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2750   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2751   const Int_t kmothervertexnumber = 17; 
2752   Double_t xmothervertex[kmothervertexnumber];
2753   Double_t ymothervertex[kmothervertexnumber];
2754   /////////////////////////////////////////////
2755   // Auxiliary variables for vertex positioning
2756   /////////////////////////////////////////////
2757   const Int_t kssdflexboxnumber = 5;
2758   Double_t ssdflexboxlength[kssdflexboxnumber];
2759   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2760                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2761                                           *     fgkSSDChipSeparationLength
2762                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2763                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2764   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2765   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2766                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2767   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2768   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2769                                           -     ssdflexboxlength[1];
2770   Double_t ssdflexboxwidth[kssdflexboxnumber];
2771   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2772   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2773   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2774   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2775   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2776   ///////////////////////
2777   // Setting the vertices 
2778   ///////////////////////
2779   xmothervertex[0]  = 0.0;
2780   xmothervertex[1]  = xmothervertex[0];
2781   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2782   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2783                                         + ssdflexboxlength[4];
2784   xmothervertex[4]  = xmothervertex[3];
2785   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2786   xmothervertex[6]  = xmothervertex[5];
2787   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2788   xmothervertex[8]  = xmothervertex[7];
2789   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2790   xmothervertex[10] = xmothervertex[9]; 
2791   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2792   xmothervertex[12] = xmothervertex[11];
2793   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2794   xmothervertex[14] = xmothervertex[13];
2795   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2796   xmothervertex[16] = xmothervertex[15];
2797   ymothervertex[0]  = 0.0;
2798   ymothervertex[1]  = fgkSSDFlexWidth[1];
2799   ymothervertex[2]  = fgkSSDFlexWidth[0];
2800   ymothervertex[3]  = ymothervertex[2];
2801   ymothervertex[4]  = ymothervertex[0];
2802   ymothervertex[5]  = ymothervertex[4];
2803   ymothervertex[6]  = ssdflexboxwidth[2];
2804   ymothervertex[7]  = ymothervertex[6];
2805   ymothervertex[8]  = ymothervertex[0];
2806   ymothervertex[9]  = ymothervertex[8];
2807   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2808   ymothervertex[11] = ymothervertex[10];
2809   ymothervertex[12] = ymothervertex[0];
2810   ymothervertex[13] = ymothervertex[12];
2811   ymothervertex[14] = ymothervertex[7];
2812   ymothervertex[15] = ymothervertex[14];
2813   ymothervertex[16] = ymothervertex[0];
2814   /////////////////////////////////////////////////////////////
2815   // First Mother Volume containing SSDFlex
2816   /////////////////////////////////////////////////////////////
2817   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2818   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2819                                                                     ymothervertex);
2820   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2821   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2822   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2823 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2824 //                                                                                       fSSDAir);
2825   /////////////////////////////////////////////////////////////
2826   // SSDFlex Layer Shapes
2827   /////////////////////////////////////////////////////////////
2828   for(Int_t i=0; i<kssdflexlayernumber; i++){
2829         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2830                                                                    ymothervertex);
2831     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2832         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2833   }
2834   /////////////////////////////////////
2835   // Setting Layers into Mother Volume
2836   /////////////////////////////////////
2837   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2838   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2839                                                                                                  fSSDKaptonFlexMedium};
2840   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2841                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2842   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2843   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2844   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2845         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2846                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2847                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2848         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2849     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2850                                          +                                         fgkSSDFlexHeight[1])); 
2851     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2852   }
2853   return ssdflexmother;
2854 }
2855 /////////////////////////////////////////////////////////////////////////////////
2856 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2857   /////////////////////////////////////////////////////////////
2858   // Method generating SSD End Flex   
2859   /////////////////////////////////////////
2860   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2861                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2862   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2863                                                 * TMath::DegToRad()*ssdflexradiusmax
2864                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2865                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2866                                                         - 0.1*fgkSSDFlexFullLength;
2867   const Int_t knedges = 20;  
2868   const Int_t karcnumber = 2;
2869   TVector3* vertexposition[karcnumber*(knedges+1)];
2870   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2871   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2872   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2873   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2874                                                                                  - 90.0*TMath::DegToRad()};
2875   TVector3* referencetrans[karcnumber];
2876   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2877                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2878                                                                    radius[0]);
2879   referencetrans[1] = new TVector3(referencetrans[0]->X()
2880                                         +              fgkSSDFlexLength[2],
2881      -              fgkSSDStiffenerHeight);
2882 for(Int_t i=0; i<karcnumber; i++){
2883         for(Int_t j=0; j<knedges+1; j++){
2884                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2885                                                                                                radius[i]*SinD(angle[i]));
2886                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2887         }       
2888   }
2889   ///////////////////////
2890   // Setting the vertices 
2891   ///////////////////////
2892   const Int_t kendflexlayernumber = 4;
2893   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2894   TVector3** vertex[kendflexlayernumber];
2895   for(Int_t i=0; i<kendflexlayernumber; i++) 
2896                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2897   TVector3* transvector[kendflexlayernumber+1];
2898   TVector3* deltatransvector = new TVector3();  
2899   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2900   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2901                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2902   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2903         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2904                                         *                 CosD(fgkSSDFlexAngle),
2905                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2906                                         *         SinD(fgkSSDFlexAngle),0.0);   
2907         *transvector[i] = *transvector[i-1]+*deltatransvector;
2908   }
2909   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2910   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2911   for(Int_t i=0; i<karcnumber; i++){
2912         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2913                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2914                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2915                                               /radius[i];
2916         }
2917   }
2918   for(Int_t i=0; i<kendflexlayernumber; i++){
2919         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2920         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2921         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2922                 if(j<(knedges+1)){
2923                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2924                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2925                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2926                         *vertex[i][j+2] += *referencetrans[0];
2927                         vertex[i][4*(knedges+1)-j+1] = 
2928                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2929                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2930                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2931                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2932                 }
2933                 else{
2934                 
2935                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2936                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2937                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2938                         *vertex[i][j+2] += *referencetrans[1];
2939                         vertex[i][4*(knedges+1)-j+1] = 
2940                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2941                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2942                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2943                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2944            }
2945         }
2946   }
2947   /////////////////////////////////////////////////////////////
2948   // First Mother Volume containing SSDEndFlex
2949   /////////////////////////////////////////////////////////////
2950   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2951   Double_t xmothervertex[kendflexvertexnumber];
2952   Double_t ymothervertex[kendflexvertexnumber];
2953   xmothervertex[0] = vertex[0][0]->X(); 
2954   ymothervertex[0] = vertex[0][0]->Y();
2955   for(Int_t i=1; i<kendflexvertexnumber; i++){
2956         if(i<2*(knedges+1)+2){
2957                 xmothervertex[i] = vertex[3][i]->X();
2958                 ymothervertex[i] = vertex[3][i]->Y();
2959         }
2960         else{
2961                 xmothervertex[i] = vertex[0][i]->X();
2962                 ymothervertex[i] = vertex[0][i]->Y();
2963         }
2964   }
2965   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2966                                                                            xmothervertex,ymothervertex);
2967   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2968   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2969 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2970 //                                                               ssdendflexmothershape,fSSDAir);        
2971   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2972   //////////////////////////////////////
2973   // End Flex TGeoXtru Layer Definition 
2974   //////////////////////////////////////
2975   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2976   TGeoVolume* ssdendflex[kendflexlayernumber];
2977   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2978   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2979   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2980   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2981   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2982                                                                                                         fSSDKaptonFlexMedium};
2983   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2984                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2985   for(Int_t i=0; i<kendflexlayernumber; i++){
2986         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2987                 xvertex[i][j] = vertex[i][j]->X();
2988                 yvertex[i][j] = vertex[i][j]->Y();
2989         }
2990   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2991   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2992   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2993   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2994                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2995   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2996   ssdendflexmother->AddNode(ssdendflex[i],1);
2997   }
2998   /////////////////////////////////////////////////////////////
2999   // Deallocating memory
3000   /////////////////////////////////////////////////////////////
3001   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3002   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3003   for(Int_t i=0; i<kendflexlayernumber; i++){
3004         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3005         delete [] vertex[i];
3006   }
3007   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3008   delete deltatransvector;
3009   /////////////////////////////////////////////////////////////
3010   //ssdendflexmother->CheckOverlaps(0.01);
3011   return ssdendflexmother;
3012 }
3013 ///////////////////////////////////////////////////////////////////////////////
3014 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3015   /////////////////////////////////////////////////////////////
3016   // Method generating the Mounting Block
3017   /////////////////////////////////////////////////////////////  
3018   const Int_t kvertexnumber = 8;
3019   Double_t xvertex[kvertexnumber];
3020   Double_t yvertex[kvertexnumber];
3021   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3022   xvertex[1] = xvertex[0];
3023   xvertex[2] = -xvertex[0];
3024   xvertex[3] = xvertex[2];
3025   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3026                          -                                 fgkSSDMountingBlockLength[2]);
3027   xvertex[5] = xvertex[4];
3028   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3029                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3030                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3031   xvertex[7] = xvertex[6];
3032   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3033                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3034   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3035   yvertex[2] = yvertex[1]; 
3036   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3037   yvertex[4] = yvertex[3];
3038   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3039                          - fgkSSDMountingBlockHeight[0];
3040   yvertex[6] = yvertex[5];
3041   yvertex[7] = yvertex[0];
3042   ///////////////////////////////////////////////////////////////////////
3043   // TGeoXTru Volume definition for Mounting Block Part
3044   ///////////////////////////////////////////////////////////////////////
3045   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3046   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3047   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3048   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3049   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3050                                                                           ssdmountingblockshape,
3051                                                                                   fSSDMountingBlockMedium);
3052   ssdmountingblock->SetLineColor(fColorG10);
3053   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3054   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3055   TGeoRotation* mountingblockrot = new TGeoRotation();
3056   mountingblockrot->SetAngles(90.,180.,-90.);
3057   mountingblockcombitrans->SetRotation(*mountingblockrot);
3058   /////////////////////////////////////////////////////////////
3059   // Generating the Mounting Block Screw Vertices 
3060   /////////////////////////////////////////////////////////////  
3061   const Int_t kscrewvertexnumber = 15;
3062   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3063                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3064                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3065                                  * TMath::RadToDeg();
3066   Double_t phi0 = 90.+alpha;
3067   Double_t phi = 270.-2*alpha;
3068   Double_t deltaphi = phi/kscrewvertexnumber;   
3069   TVector3* screwvertex[kscrewvertexnumber+1];
3070   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3071         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3072                                    *CosD(phi0+i*deltaphi),
3073                                    fgkSSDMountingBlockScrewHoleRadius[0]
3074                                    *SinD(phi0+i*deltaphi));
3075   Double_t xscrewvertex[kscrewvertexnumber+6];
3076   Double_t yscrewvertex[kscrewvertexnumber+6];
3077   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3078   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3079                                   -               fgkSSDMountingBlockScrewHoleEdge);
3080   xscrewvertex[1] = xscrewvertex[0];
3081   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3082   xscrewvertex[2] = screwvertex[0]->X();
3083   yscrewvertex[2] = yscrewvertex[1];
3084   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3085         xscrewvertex[i+3] = screwvertex[i]->X();        
3086         yscrewvertex[i+3] = screwvertex[i]->Y();        
3087   } 
3088   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3089   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3090   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3091   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3092   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3093   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3094   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3095   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3096                                                         +                                  fgkSSDMountingBlockHeight[2]);
3097   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3098                                                                                 ssdmountingblockscrewshape,
3099                                                                                             fSSDMountingBlockMedium);
3100   ssdmountingblockscrew->SetLineColor(fColorG10);
3101   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3102   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3103   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3104                                                                         -                                yscrewvertex[1],
3105                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3106                                                                         -                                fgkSSDMountingBlockHeight[2]
3107                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3108                                                                         +                                fgkSSDMountingBlockHeight[2]
3109                                                                         -                                yvertex[0]));
3110   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3111                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3112                                                                                                                  yscrewvertex[1]
3113                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3114                                                                                                          +fgkSSDMountingBlockHeight[2]
3115                                                                                                          -yvertex[0]));
3116   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3117                                                                                                           yscrewvertex[1],
3118                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3119                                                                         +                                 fgkSSDMountingBlockHeight[2]
3120                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3121                                                                         +                                 fgkSSDMountingBlockHeight[2]
3122                                                                         -                                 yvertex[0]));
3123   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3124                                                                                                          yscrewvertex[1],
3125                                                                         -                                yscrewvertex[1]
3126                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3127                                                                         +                                fgkSSDMountingBlockHeight[2]
3128                                                                         -                                yvertex[0]));
3129   TGeoRotation* ssdmountingblockscrewrot[4];
3130   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3131         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3132     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3133     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3134   for(Int_t i=1; i<4; i++) 
3135         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3136   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3137   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3138   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3139   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3140                                                          +                                xvertex[0],yscrewvertex[1]
3141                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3142                                                          +                                fgkSSDMountingBlockHeight[2]
3143                                                          -                                yvertex[0]),0.);      
3144   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3145   for(Int_t i=0; i<4; i++){
3146         ssdmountingblockscrewmatrix[i] = 
3147                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3148         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3149   }
3150   ///////////////////////////////////////////////////////////////////////
3151   // TGeoXtru for Mother Volume 
3152   ///////////////////////////////////////////////////////////////////////
3153   const Int_t kvertexmothernumber = 12;
3154   Double_t xmothervertex[kvertexmothernumber];
3155   Double_t ymothervertex[kvertexmothernumber];
3156   for(Int_t i=0; i<6; i++){
3157         xmothervertex[i] = xvertex[i];
3158         ymothervertex[i] = yvertex[i];
3159   } 
3160   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3161   ymothervertex[6]  = ymothervertex[5];
3162   xmothervertex[7]  = xmothervertex[6];
3163   ymothervertex[7]  = ymothervertex[4];
3164   xmothervertex[8]  = xmothervertex[7]
3165                                         + 0.5*(fgkSSDMountingBlockLength[1]
3166                                         -          fgkSSDMountingBlockLength[2]);
3167   ymothervertex[8]  = ymothervertex[4];
3168   xmothervertex[9]  = xmothervertex[8];
3169   ymothervertex[9]  = ymothervertex[2];
3170   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3171   ymothervertex[10] = ymothervertex[1];
3172   xmothervertex[11] = xmothervertex[10];
3173   ymothervertex[11] = ymothervertex[0];  
3174   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3175   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3176   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3177   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3178   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3179                                                                           ssdmountingblockmothershape,
3180                                                                                   fSSDAir);
3181   /////////////////////////////////////////////////////////////
3182   // Placing the Volumes into Mother Volume 
3183   /////////////////////////////////////////////////////////////
3184   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3185   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3186   for(Int_t i=0; i<4; i++) 
3187         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3188                                                                         ssdmountingblockscrewmatrix[i]);
3189   /////////////////////////////////////////////////////////////
3190   // Deallocating memory
3191   /////////////////////////////////////////////////////////////
3192   delete mountingblockrot;
3193   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3194   delete ssdmountingblockglobalrot; 
3195   delete ssdmountingblockglobaltrans; 
3196   /////////////////////////////////////////////////////////////
3197   return ssdmountingblockmother;
3198 }
3199 ///////////////////////////////////////////////////////////////////////////////
3200  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3201   /////////////////////////////////////////////////////////////
3202   // Method generating the Mounting Block Clip 
3203   /////////////////////////////////////////////////////////////  
3204   const Int_t kmothervertexnumber = 10;
3205   Double_t xmothervertex[kmothervertexnumber];
3206   Double_t ymothervertex[kmothervertexnumber];
3207   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3208                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3209   xmothervertex[1] = xmothervertex[0];
3210   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3211                                    - fgkMountingBlockClibScrewRadius);
3212   xmothervertex[3] = xmothervertex[2]; 
3213   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3214   xmothervertex[5] = xmothervertex[4]; 
3215   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3216   xmothervertex[7] = xmothervertex[6]; 
3217   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3218   xmothervertex[9] = xmothervertex[8]; 
3219   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3220                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3221   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3222   ymothervertex[2] = ymothervertex[1];
3223   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3224                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3225                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3226   ymothervertex[4] = ymothervertex[3];
3227   ymothervertex[5] = ymothervertex[2];
3228   ymothervertex[6] = ymothervertex[5];
3229   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3230   ymothervertex[8] = ymothervertex[7];
3231   ymothervertex[9] = ymothervertex[0];
3232   ///////////////////////////////////////////////////////////////////////
3233   // TGeoXTru Volume definition for Mounting Block Clip Part
3234   ///////////////////////////////////////////////////////////////////////
3235   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3236   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3237   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3238   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3239   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3240                                                                           ssdmountingblockclipshape,fSSDAir);
3241   ssdmountingblockclip->SetLineColor(4);
3242   ///////////////////////////////////////////////////////////////////////
3243   // TGeoXTru Volume definition for Clip 
3244   ///////////////////////////////////////////////////////////////////////
3245   const Int_t kclipvertexnumber = 6;
3246   Double_t xclipvertex[kclipvertexnumber];
3247   Double_t yclipvertex[kclipvertexnumber];
3248   xclipvertex[0] = xmothervertex[0];
3249   xclipvertex[1] = xclipvertex[0];
3250   xclipvertex[2] = xmothervertex[6];
3251   xclipvertex[3] = xclipvertex[2];
3252   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3253   xclipvertex[5] = xclipvertex[4];
3254   yclipvertex[0] = ymothervertex[0];
3255   yclipvertex[1] = ymothervertex[1];
3256   yclipvertex[2] = yclipvertex[1];
3257   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3258   yclipvertex[4] = yclipvertex[3];
3259   yclipvertex[5] = yclipvertex[0];
3260   TGeoXtru* clipshape = new TGeoXtru(2);
3261   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3262   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3263   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3264                                                          +   fgkMountingBlockClibWidth);
3265   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3266   clip->SetLineColor(18);
3267   ///////////////////////////////////////////////////////////////////////
3268   // Ladder Support Piece  
3269   ///////////////////////////////////////////////////////////////////////
3270   const Int_t ksupportvertexnumber = 4;
3271   Double_t xsupportvertex[ksupportvertexnumber];
3272   Double_t ysupportvertex[ksupportvertexnumber];
3273   xsupportvertex[0] = xclipvertex[5];
3274   xsupportvertex[1] = xsupportvertex[0];
3275   xsupportvertex[2] = xmothervertex[9];
3276   xsupportvertex[3] = xsupportvertex[2];
3277   ysupportvertex[0] = yclipvertex[0];
3278   ysupportvertex[1] = yclipvertex[3];
3279   ysupportvertex[2] = ysupportvertex[1];
3280   ysupportvertex[3] = ysupportvertex[0];
3281   TGeoXtru* supportshape = new TGeoXtru(2);
3282   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3283   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3284   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3285   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3286   support->SetLineColor(9);
3287   ///////////////////////////////////////////////////////////////////////
3288   // TGeoXTru Volume definition for Screw   
3289   ///////////////////////////////////////////////////////////////////////
3290   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3291                                                 0.5*fgkMountingBlockClibScrewRadius};
3292   Int_t edgesnumber[2] = {50,6};
3293   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3294                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3295   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3296   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3297   clipscrew->SetLineColor(12);
3298   TGeoRotation* screwrot = new TGeoRotation();
3299   screwrot->SetAngles(0.,90.,0.);
3300   TGeoTranslation* screwtrans = new TGeoTranslation();
3301   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3302                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3303                                                          0.5*fgkSSDMountingBlockWidth+
3304                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3305   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3306   ///////////////////////////////////////////////////////////////////////
3307   // Placing the Volumes
3308   ///////////////////////////////////////////////////////////////////////
3309   ssdmountingblockclip->AddNode(clip,1);
3310   ssdmountingblockclip->AddNode(support,1);
3311   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3312   /////////////////////////////////////////////////////////////
3313   // Deallocating memory
3314   /////////////////////////////////////////////////////////////  
3315   delete screwtrans;
3316   delete screwrot;
3317   /////////////////////////////////////////////////////////////
3318   return ssdmountingblockclip;
3319 }
3320 ///////////////////////////////////////////////////////////////////////////////
3321 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3322   /////////////////////////////////////////////////////////////
3323   // Method generating the Cooling Tube 
3324   /////////////////////////////////////////////////////////////  
3325    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3326    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3327                                                                                                 new     TGeoTube*[2];
3328    // Ladder Cooling Tubes
3329    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3330                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3331                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
3332                                                   -0.5*fgkSSDTolerance);
3333    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3334                                                                                  coolingtubeshape[0][0]->GetDz());
3335    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3336                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3337                                                   -                                       fgkSSDSensorOverlap-fgkSSDTolerance));
3338    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3339                                                                                  coolingtubeshape[1][0]->GetDz());
3340    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDTolerance));
3342    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3343                                                                                  coolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3344    // End Ladder Cooling Tubes  
3345    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3346    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3347    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3348    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3349                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3350                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3351    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3352                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3353    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3354                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3355                                                   +                     fgkendladdercoolingsupportdistance[1]
3356                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3357    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3358                                                                         endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3359    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3360                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3361                                                   -                     fgkEndLadderMountingBlockPosition[0]
3362                                                   -                     fgkendladdercoolingsupportdistance[1]           
3363                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3364    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3365                                                                         endladdercoolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3366    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3367                                                           0.50 * (fgkMountingBlockToSensorSupport
3368                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3369                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3370                                                         +                 fgkSSDSensorOverlap
3371                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3372                                                         -                 fgkendladdercoolingsupportdistance[2]
3373                                                         -                 fgkEndLadderMountingBlockPosition[1]
3374                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3375    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3376                                                                         endladdercoolingtubeshape[3][0]->GetDz()-0.5*fgkSSDTolerance);
3377    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3378                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3379    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3380                                                                         endladdercoolingtubeshape[4][0]->GetDz()-0.5*fgkSSDTolerance);
3381    // Ladder Cooling Tubes
3382    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3383    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3384                                                                                          new TGeoVolume*[2];
3385    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3386                                                                           fSSDCoolingTubePhynox);
3387    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3388                                                                           fSSDCoolingTubeWater);
3389    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3390                                                                           fSSDCoolingTubePhynox);
3391    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3392                                                                           fSSDCoolingTubeWater);
3393    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3394                                                                           fSSDCoolingTubePhynox);
3395    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3396                                                                           fSSDCoolingTubeWater);
3397    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3398         coolingtube[i][0]->SetLineColor(fColorPhynox);
3399         coolingtube[i][1]->SetLineColor(fColorWater);
3400    }
3401    // End Ladder Cooling Tubes  
3402    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3403    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3404    endladdercoolingtube[i] = new TGeoVolume*[2];
3405    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3406                                                                 endladdercoolingtubeshape[0][0],
3407                                                                 fSSDCoolingTubePhynox);
3408    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3409                                                                 endladdercoolingtubeshape[0][1],
3410                                                                 fSSDCoolingTubeWater);
3411    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3412                                                                 endladdercoolingtubeshape[1][0],
3413                                                                 fSSDCoolingTubePhynox);
3414    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3415                                                                 endladdercoolingtubeshape[1][1],
3416                                                                 fSSDCoolingTubeWater);
3417    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3418                                                                 endladdercoolingtubeshape[2][0],
3419                                                                 fSSDCoolingTubePhynox);
3420    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3421                                                                 endladdercoolingtubeshape[2][1],
3422                                                                 fSSDCoolingTubeWater);
3423    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3424                                                                 endladdercoolingtubeshape[3][0],
3425                                                                 fSSDCoolingTubePhynox);
3426    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3427                                                                 endladdercoolingtubeshape[3][1],
3428                                                                 fSSDCoolingTubeWater);
3429    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3430                                                                 endladdercoolingtubeshape[4][0],
3431                                                                 fSSDCoolingTubePhynox);
3432    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3433                                                                 endladdercoolingtubeshape[4][1],
3434                                                                 fSSDCoolingTubeWater);
3435    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3436                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3437                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3438    }
3439   
3440   /////////////////////////////////////////////////////////////
3441   // Virtual Volume containing Cooling Tubes
3442   /////////////////////////////////////////////////////////////
3443   // Ladder Cooling Tubes
3444   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3445   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3446   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3447                                                                                         coolingtubeshape[i][0]->GetRmax(),
3448                                                                                         coolingtubeshape[i][0]->GetDz());
3449   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3450   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3451                                                                           fSSDAir);
3452   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3453                                                                           fSSDAir);
3454   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3455                                                                           fSSDAir);
3456   // End Ladder Cooling Tubes
3457   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3458   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3459   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3460                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3461                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3462   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3463   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3464                                                                           endladdervirtualcoolingtubeshape[0],
3465                                                                           fSSDAir);
3466   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3467                                                                           endladdervirtualcoolingtubeshape[1],
3468                                                                           fSSDAir);
3469   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3470                                                                           endladdervirtualcoolingtubeshape[2],
3471                                                                           fSSDAir);
3472   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3473                                                                           endladdervirtualcoolingtubeshape[3],
3474                                                                           fSSDAir);
3475   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3476                                                                           endladdervirtualcoolingtubeshape[4],
3477                                                                           fSSDAir);
3478   TList* coolingtubelist = new TList();
3479   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3480         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3481         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3482     coolingtubelist->Add(virtualcoolingtube[i]);
3483   }
3484         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3485         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3486     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3487         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3488         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3489     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3490         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3491         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3492     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3493         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3494         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3495     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3496         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3497         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3498     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3499   return coolingtubelist;
3500 }
3501 ///////////////////////////////////////////////////////////////////////////////
3502 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3503   /////////////////////////////////////////////////////////////
3504   // Method generating SSD Cooling Block    
3505   /////////////////////////////////////////////////////////////
3506   const Int_t kvertexnumber = 8;
3507   ///////////////////////////////////////
3508   // Vertex Positioning for TGeoXTru
3509   ///////////////////////////////////////
3510   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3511   vertexposition[0] = new TVector3(0.0,0.0);
3512   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3513   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3514                                           vertexposition[1]->Y());
3515   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3516                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3517   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3518   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3519                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3520   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3521                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3522                                         - fgkSSDCoolingBlockHoleLength[0]
3523                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3524                                           fgkSSDCoolingBlockHeight[0]
3525                                         - fgkSSDCoolingBlockHoleRadius[1],
3526                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3527   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3528                                         - fgkSSDCoolingBlockHoleLength[0]),
3529                                           vertexposition[6]->Y());
3530   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3531                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3532   Double_t phi = 180.-alpha;
3533   Double_t psi = 180.+2.*alpha;
3534   Double_t deltapsi = psi/nedges;
3535   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3536   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3537                                                   fgkSSDCoolingBlockHoleCenter);
3538   for(Int_t i=0; i<nedges+1; i++){
3539         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3540                                                                                                radius*SinD(phi+i*deltapsi));
3541    *vertexposition[kvertexnumber+i] += (*transvector);
3542   }
3543   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3544   for(Int_t i=0; i<kvertexnumber; i++)
3545     vertexposition[kvertexnumber+nedges+1+i] = 
3546                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3547   ///////////////////////////////////////////////////////////////////////
3548   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3549   ///////////////////////////////////////////////////////////////////////
3550   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3551   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3552   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3553   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3554         xvertexpoints[i] = vertexposition[i]->X();
3555         yvertexpoints[i] = vertexposition[i]->Y();
3556   } 
3557   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3558                                                                                         yvertexpoints);
3559   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3560   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3561   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3562                                                                           ssdcoolingblockshape,
3563                                                                                   fSSDAlCoolBlockMedium);
3564   ssdcoolingblock->SetLineColor(fColorAl);
3565   /////////////////////////////////////////////////////////////
3566   // Deallocating memory
3567   /////////////////////////////////////////////////////////////
3568   delete [] vertexposition;
3569   delete xvertexpoints;
3570   delete yvertexpoints;
3571   /////////////////////////////////////////////////////////////
3572   return ssdcoolingblock;
3573 }
3574 /////////////////////////////////////////////////////////////////////////////////
3575 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3576   ///////////////////////////////////////////////////////
3577   const Int_t kssdchipcablesnumber    = 2;
3578   const Int_t kssdchipcableslaynumber = 2;
3579   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3580   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3581   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3582   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3583                                                  -  fgkSSDChipCablesHeight[0]
3584                                                  -  fgkSSDChipCablesHeight[1]);
3585   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3586   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3587   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3588                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3589                                                           - ssdchipcablesradius[0]
3590                                                           - fgkSSDChipCablesWidth[1]
3591                                                           - fgkSSDChipCablesWidth[2]);
3592   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3593                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3594                                                           +      fgkSSDChipCablesHeight[1]
3595                                                           +      fgkSSDSensorHeight);
3596   ///////////////////////////////////////////////////////
3597   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3598   ///////////////////////////////////////////////////////
3599   TVector3** vertexposition[kssdchipcableslaynumber];
3600   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3601                                                                                                   new TVector3*[4*(nedges+1)+4];
3602   Double_t ratio[4];
3603   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3604   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3605                    /  ssdchipcablesradius[0]; 
3606   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3607                    /  ssdchipcablesradius[0];
3608   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3609                    +  fgkSSDChipCablesHeight[1])
3610                    /  ssdchipcablesradius[0];
3611   Double_t phi = 180.;
3612   Double_t deltaphi = 180./nedges;
3613   Double_t angle = 0.0;
3614   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3615   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3616   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3617         xvertexpoints[i] = new Double_t[kvertexnumber];
3618         yvertexpoints[i] = new Double_t[kvertexnumber];
3619   }  
3620   TVector3* vertex = new TVector3();
3621   TVector3* transvector[kssdchipcableslaynumber];
3622   transvector[0] = new TVector3(fgkSSDChipWidth,
3623                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3624   transvector[1] = new TVector3();
3625   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3626   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3627   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3628                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3629                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3630   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3631         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3632         transvector[1]->SetY(ssdchipcablesradius[0]
3633                                  +               fgkSSDChipCablesHeight[0]
3634                                  +               fgkSSDChipCablesHeight[1]);  
3635         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3636                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3637                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3638                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3639                                                          - i*fgkSSDChipCablesHeight[0]);
3640                 vertexposition[i][2*(nedges+1)+2] = 
3641                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3642                                 +                                fgkSSDChipCablesWidth[1]
3643                                 +                                fgkSSDChipCablesWidth[2],
3644                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3645                                 +                                fgkSSDChipCablesHeight[1]));
3646         vertexposition[i][2*(nedges+1)+3] = 
3647                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3648                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3649                                 -                                fgkSSDChipCablesHeight[i]);
3650             for(Int_t j=0; j<nedges+1; j++){            
3651                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3652                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3653                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3654                         vertexposition[0][(nedges+1)*i+j+2] = 
3655                                                 new TVector3(*vertex+*transvector[i]);
3656                         vertexposition[1][(nedges+1)*i+j+2] = 
3657                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3658                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3659                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3660                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3661                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3662                                                 new TVector3(vertex->X()*ratio[2*i+1]
3663                                                         +                        transvector[i]->X(),
3664                                                                                  vertex->Y()*ratio[2*i+1]
3665                                                         +                transvector[i]->Y());
3666                 }
3667         }
3668         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3669                 for(Int_t j=0; j<kvertexnumber; j++){   
3670                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3671                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3672                 }
3673                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3674                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3675                                                                                 xvertexpoints[i],yvertexpoints[i]);
3676                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3677                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3678                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3679                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3680                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3681                                                           (kssdchipcablesnumber*k+i)%2==0?
3682                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3683                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3684         }
3685         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3686                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3687   }
3688   /////////////////////////////////////////////////////////////
3689   // Mother Volume definition 
3690   /////////////////////////////////////////////////////////////
3691   Double_t ssdchipseparation = fgkSSDSensorLength
3692                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3693                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3694                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3695   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3696   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3697                                                           +fgkSSDChipCablesWidth[1]
3698                                                           +fgkSSDChipCablesWidth[2]);
3699   Double_t dy = fgkSSDChipCablesLength[1];
3700   Double_t dz = SSDChipCablesHeigth;
3701   new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3702   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3703 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3704 //                        ssdchipcablesmotherbox,fSSDAir);
3705   /////////////////////////////////////////////////////////////
3706   // Rotation and Translation Definition for positioning 
3707   /////////////////////////////////////////////////////////////
3708   TGeoRotation* ssdchipcablesrot[5];
3709   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3710   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3711   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3712   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3713   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3714   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3715                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3716   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3717   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3718   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3719   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3720   /////////////////////////////////////////////////////////////
3721   // Deallocating memory
3722   /////////////////////////////////////////////////////////////
3723   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3724         delete [] xvertexpoints[i];
3725         delete [] yvertexpoints[i];
3726   }
3727   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3728   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3729   delete vertex; 
3730   delete ssdchipcablesrot[0];
3731   delete ssdchipcablesrot[1];
3732   delete ssdchipcablesrot[3];
3733   /////////////////////////////////////////////////////////////
3734   return ssdchipcablesmother;
3735 }
3736 ///////////////////////////////////////////////////////////////////////////////
3737 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3738   /////////////////////////////////////////////////////////////
3739   // SSD Chip Assembly
3740   /////////////////////////////////////////////////////////////
3741   TGeoVolume* ssdchipassembly = GetSSDChips();
3742   TList* ssdchipsystemlist = new TList();
3743 //  const Int_t knedges = 20;
3744   const Int_t knedges = 5;
3745   const Int_t kchipsystemnumber = 2;
3746
3747   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3748   const char* chipsytemothername[kchipsystemnumber] = 
3749                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3750   for(Int_t i=0; i<kchipsystemnumber; i++){
3751     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3752   }
3753   /////////////////////////////////////////////////////////////
3754   // SSD Chip Cables
3755   /////////////////////////////////////////////////////////////
3756   TGeoVolume* ssdchipcables[kchipsystemnumber];
3757   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3758   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3759   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3760   //////////////////
3761   for(Int_t i=0; i<kchipsystemnumber; i++){
3762                 ssdchipcables[i] = 
3763                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3764                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3765                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3766                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3767   }
3768   for(Int_t i=0; i<kchipsystemnumber; i++){
3769         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3770                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3771                 ssdchipcablesrot[i][j] = new TGeoRotation();
3772                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3773                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3774                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3775                                                   +                fgkSSDChipSeparationLength),
3776                                                                                         0.5*fgkSSDChipWidth,
3777                                                   -                                     0.5*fgkSSDChipHeight
3778                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3779                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3780                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3781                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3782         }
3783         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3784         ssdchipsystemlist->Add(chipsystemother[i]);     
3785   }
3786   /////////////////////////////////////////////////////////////
3787   // Deallocating memory
3788   /////////////////////////////////////////////////////////////
3789   for(Int_t i=0; i<kchipsystemnumber; i++){
3790         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3791                 delete ssdchipcablesrot[i][j];
3792                 delete ssdchipcablestrans[i][j];
3793         }
3794         delete [] ssdchipcablesrot[i];
3795         delete [] ssdchipcablestrans[i];
3796   }
3797   /////////////////////////////////////////////////////////////
3798   return ssdchipsystemlist;
3799 }
3800
3801 //_____________________________________________________________________________
3802 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3803   /////////////////////////////////////////////////////////////
3804   // SSD Chip Assembly Generation    
3805   /////////////////////////////////////////////////////////////
3806   const Int_t kssdchiprownumber = 2;
3807   TGeoBBox* ssdchipcompshape[2];
3808   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3809                                                                                 0.5*fgkSSDChipLength,
3810                                                                                 0.5*fgkSSDChipWidth,
3811                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3812   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3813                                                                                 0.5*fgkSSDChipLength,
3814                                                                                 0.5*fgkSSDChipWidth,
3815                                                                                 0.5*fgkSSDChipGlueHeight);
3816   TGeoVolume* ssdchipcomp[2];
3817   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3818   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3819                                                                   fSSDChipGlueMedium);
3820   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3821   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3822   TGeoTranslation* ssdchipcomptrans[2];
3823   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3824   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3825   /////////////////////////////////////////////////////////////
3826   // Virtual Volume containing SSDChip   
3827   /////////////////////////////////////////////////////////////
3828   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3829                                                                                                                  0.5*fgkSSDChipWidth,
3830                                                                                                                  0.5*fgkSSDChipHeight);
3831   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3832   /////////////////////////////////////////////////////////////
3833   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3834   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3835                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3836                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3837                                    -  0.5*fgkSSDChipWidth)};
3838   /////////////////////////////////////////////////////////////
3839   // Virtual Volume containing SSDChipAssembly   
3840   /////////////////////////////////////////////////////////////
3841   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3842   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3843   Double_t xmothervertex[kssdmothervertexnumber];
3844   Double_t ymothervertex[kssdmothervertexnumber];
3845   ///////////////////////
3846   // Setting the vertices 
3847   ///////////////////////
3848   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3849   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3850                                    - ymothervertex[0];
3851   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3852   ymothervertex[2] = ymothervertex[1];
3853   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3854   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3855   ymothervertex[4] = ymothervertex[0];
3856   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3857   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3858                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3859   ymothervertex[6] = ymothervertex[5];
3860   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3861                                    - fgkSSDChipWidth;
3862   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3863   ymothervertex[8] = ymothervertex[7];
3864   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3865   ymothervertex[9] = ymothervertex[6];
3866   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3867   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3868   //////////////////////////////////////////////////////////
3869   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3870                                                                         xmothervertex,ymothervertex);
3871   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3872   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3873 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3874 //                                                        ssdchipmothershape,fSSDAir);
3875   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3876    /////////////////////////////////////////////////////////////
3877   for(Int_t i=0; i<kssdchiprownumber; i++)
3878     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3879                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3880                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3881   return ssdchipmother;
3882 }
3883 /////////////////////////////////////////////////////////////////////////////////
3884 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3885   /////////////////////////////////////////////////////////////
3886   // Method returning a List containing pointers to Ladder Cable Volumes    
3887   /////////////////////////////////////////////////////////////
3888   const Int_t kladdercablesegmentnumber = 2;
3889   /////////////////////////////////////////
3890   // LadderSegmentBBox Volume
3891   /////////////////////////////////////////
3892   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3893   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3894                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3895   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3896                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3897                                                                            0.5*fgkSSDFlexWidth[0],
3898                                                                            0.5*fgkSSDLadderCableWidth,
3899                                                                            0.5*fgkSSDFlexHeight[i]); 
3900   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3901                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3902   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3903   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3904                         laddercablesegmentbbox[i] =
3905                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3906                                                                                  laddercablesegmentbboxshape[i],
3907                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3908             fSSDKaptonLadderCableMedium));
3909                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3910                                                                                                                    fColorPolyhamide);
3911   }
3912   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3913   laddercablesegmentbboxtrans[0] = 
3914                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3915                                                                                            0.5*fgkSSDFlexWidth[0],
3916                                                                                            0.5*fgkSSDLadderCableWidth,
3917                                                                                            0.5*fgkSSDFlexHeight[0]);
3918   laddercablesegmentbboxtrans[1] = 
3919                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3920                                                                                            0.5*fgkSSDFlexWidth[0],
3921                                                                                            0.5*fgkSSDLadderCableWidth,
3922                                                                                            fgkSSDFlexHeight[0]
3923                                                                                            +0.5*fgkSSDFlexHeight[1]);
3924   TGeoVolume* laddercablesegmentbboxassembly = 
3925                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3926   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3927                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3928                                                                                             laddercablesegmentbboxtrans[i]);
3929 /////////////////////////////////////////
3930 // LadderSegmentArb8 Volume
3931 /////////////////////////////////////////
3932   const Int_t kvertexnumber = 4;
3933   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3934   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3935                                                                                                   new TVector3*[kvertexnumber];
3936 //Shape Vertex Positioning
3937   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3938         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3939         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3940                                                                                                                   i*fgkSSDFlexHeight[0]);
3941         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3942                                                                                    +                         fgkSSDFlexHeight[1]
3943                                                                                    +                      i*fgkSSDFlexHeight[0]);
3944         laddercablesegmentvertexposition[i][3] = 
3945                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3946                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3947   }
3948   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3949                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3950   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3951                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3952   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3953   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3954                                         GetArbShape(laddercablesegmentvertexposition[i],
3955                                                                 laddercablesegmentwidth[i],
3956                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3957                                                                 laddercablesegmentarbshapename[i]);
3958   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3959                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3960   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3961   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3962                          laddercablesegmentarb[i] =
3963                                                    new TGeoVolume(laddercablesegmentarbname[i],
3964                                                                                   laddercablesegmentarbshape[i],
3965                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3966             fSSDKaptonLadderCableMedium)); 
3967                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3968                                                                                                                    fColorPolyhamide);
3969 }
3970   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3971   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3972                                                                                                  90.,90,-90.);   
3973   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3974                                                                                                   0.,90.,0.);    
3975   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3976                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3977                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3978                                                          + fgkSSDFlexWidth[0],0.,0.,
3979                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3980                                                      *(*laddercablesegmentarbrot[0])));
3981   TGeoVolume* laddercablesegmentarbassembly = 
3982                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3983   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3984   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3985                                                                                    laddercablesegmentarbcombitrans);
3986 /////////////////////////////////////////
3987 // End Ladder Cable Volume
3988 /////////////////////////////////////////
3989   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
3990   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
3991                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
3992   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
3993                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
3994                                                                            0.5*ssdendladdercablelength,
3995                                                                            0.5*fgkSSDLadderCableWidth,
3996                                                                            0.5*fgkSSDFlexHeight[i]);
3997   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
3998                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
3999   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4000   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4001                         ladderendcablesegmentbbox[i] =
4002                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4003                                                                                  ladderendcablesegmentbboxshape[i],
4004                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4005             fSSDKaptonLadderCableMedium));
4006                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4007                                                                                                                    fColorPolyhamide);
4008   }
4009   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4010   ladderendcablesegmentbboxtrans[0] = 
4011                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4012                                                                                            0.5*ssdendladdercablelength,
4013                                                                                            0.5*fgkSSDLadderCableWidth,
4014                                                                                            0.5*fgkSSDFlexHeight[0]);
4015   ladderendcablesegmentbboxtrans[1] = 
4016                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4017                                                                                            0.5*ssdendladdercablelength,
4018                                                                                            0.5*fgkSSDLadderCableWidth,
4019                                                                                            fgkSSDFlexHeight[0]
4020                                                                                            +0.5*fgkSSDFlexHeight[1]);
4021   TGeoVolume* ladderendcablesegmentbboxassembly = 
4022                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4023   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4024                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4025                                                                                             ladderendcablesegmentbboxtrans[i]);
4026 /////////////////////////////////////////
4027   TList* laddercablesegmentlist = new TList();
4028   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4029   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4030   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4031   return laddercablesegmentlist;
4032   }
4033 /////////////////////////////////////////////////////////////////////////////////
4034 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4035   /////////////////////////////////////////////////////////////
4036   // Method generating Ladder Cable Volumes Assemblies    
4037   /////////////////////////////////////////////////////////////
4038   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4039   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4040   for(Int_t i=0; i<n; i++){
4041          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4042                                                         i*(fgkCarbonFiberJunctionWidth),
4043                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4044                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4045     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4046         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4047   }
4048   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4049                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4050                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4051                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4052   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4053   return laddercable;
4054 }
4055 /////////////////////////////////////////////////////////////////////////////////
4056 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4057   /////////////////////////////////////////////////////////////
4058   // Method generating Ladder Cable Volumes Assembly   
4059   /////////////////////////////////////////////////////////////
4060   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4061   char laddercabletransname[100];
4062   for(Int_t i=0; i<n; i++){ 
4063         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4064     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4065         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4066   }
4067   return laddercableassembly;
4068 }
4069 /////////////////////////////////////////////////////////////////////////////////
4070 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4071   /////////////////////////////////////////////////////////////
4072   // Method generating Ladder Cable List Assemblies  
4073   /////////////////////////////////////////////////////////////  
4074   const Int_t kladdercableassemblynumber = 2;
4075   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4076   TGeoVolume* ladderCable[kladdercableassemblynumber];
4077   char laddercableassemblyname[100];
4078   TList* laddercableassemblylist = new TList();
4079   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4080         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4081         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4082         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4083                                          new TGeoCombiTrans((n-1)
4084                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4085                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4086                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4087         laddercableassemblylist->Add(ladderCable[i]);
4088 }
4089   return laddercableassemblylist;
4090 }
4091 ///////////////////////////////////////////////////////////////////////////////
4092 void AliITSv11GeometrySSD::SetLadderSegment(){
4093   /////////////////////////////////////////////////////////////
4094   // Method Generating Ladder Segment Array
4095   /////////////////////////////////////////////////////////////
4096   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4097   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4098   if(!fCreateMaterials) CreateMaterials();
4099   if(!fTransformationMatrices) CreateTransformationMatrices();
4100   if(!fBasicObjects) CreateBasicObjects();
4101   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4102   // Placing Carbon Fiber Support       
4103         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4104                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4105                                                                                         fcarbonfibersupportmatrix[j]);  
4106                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4107                                                                                         fcarbonfibersupportmatrix[j]);
4108   }
4109   // Placing Carbon Fiber Junction
4110     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4111         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4112                                                                    fcarbonfiberjunctionmatrix[j]);
4113   // Placing Carbon Fiber Lower Support
4114         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4115                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4116                                                            fcarbonfiberlowersupportrans[j]);    
4117   // Placing SSD Sensor Support
4118     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4119         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4120                                                                      fssdsensorsupport[1][i],
4121                                                            j+1,fssdsensorsupportmatrix[j]);
4122   // Placing SSD Cooling Tube Support 
4123         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4124                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4125                                                                    fcoolingtubesupportmatrix[j]);
4126   // Placing SSD Cooling Tube  
4127         for(Int_t j=0; j<2; j++)
4128                 for(Int_t k=0; k<2; k++){
4129                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4130                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4131                 }
4132   // Placing SSD Hybrid
4133     switch(i){
4134         case 0: 
4135                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4136                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4137                 break;
4138     case 1:
4139                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4140                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4141                 break;
4142         }
4143         // Placing Cooling Block System
4144     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4145         // Placing SSD Flex
4146         for(Int_t j=0; j<fgkflexnumber; j++){
4147       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4148       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4149         }
4150    }
4151 }
4152 ///////////////////////////////////////////////////////////////////////////////
4153 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4154   /////////////////////////////////////////////////////////////
4155   // Method Generating End Ladder
4156   /////////////////////////////////////////////////////////////
4157   // End Ladder Carbon Fiber Junction 
4158   /////////////////////////////////////////////////////////////
4159   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4160   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4161   if(!fCreateMaterials) CreateMaterials();
4162   if(!fTransformationMatrices) CreateTransformationMatrices();
4163   if(!fBasicObjects) CreateBasicObjects();
4164   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4165         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4166                 fendladdersegment[i]->AddNode(j==2 ? 
4167                                                         fendladdercarbonfiberjunction[i][1] : 
4168                                                         fendladdercarbonfiberjunction[i][0],
4169                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4170   }
4171   /////////////////////////////////////////////////////////////
4172   // End Ladder Carbon Fiber Support 
4173   /////////////////////////////////////////////////////////////
4174   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4175       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4176                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4177                   fendladdercarbonfibermatrix[i][j]);   
4178           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4179                   fendladdercarbonfibermatrix[i][j]);   
4180       }
4181   /////////////////////////////////////////////////////////////
4182   // End Ladder Mounting Block
4183   /////////////////////////////////////////////////////////////
4184   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4185        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4186                                      fendladdermountingblockcombitrans[i]);
4187   /////////////////////////////////////////////////////////////
4188   // End Ladder Mounting Block Clip
4189   /////////////////////////////////////////////////////////////
4190   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4191         for(Int_t j=0; j<2; j++)
4192                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4193                                               fendladdermountingblockclipmatrix[i][j]);
4194   /////////////////////////////////////////////////////////////
4195   // End Ladder Lower Supports
4196   /////////////////////////////////////////////////////////////
4197   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4198                                 fendladderlowersupptrans[0]);
4199   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4200                                 fendladderlowersupptrans[1]);
4201   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4202                                 fendladderlowersupptrans[2]);
4203   /////////////////////////////////////////////////////////////
4204   // End Ladder Cooling Tube Support
4205   /////////////////////////////////////////////////////////////
4206   for(Int_t i=0; i<2; i++) 
4207         for(Int_t j=0; j<(i==0?4:2); j++)   
4208                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4209                                               fendladdercoolingtubesupportmatrix[i][j]);
4210   /////////////////////////////////////////////////////////////
4211   // End Ladder Cooling Tube Support
4212   /////////////////////////////////////////////////////////////
4213 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4214 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4215   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4216   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4217   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4218   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4219   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4220   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4221   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4222   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4223 }
4224 ///////////////////////////////////////////////////////////////////////////////
4225 void AliITSv11GeometrySSD::SetLadder(){
4226   /////////////////////////////////////////////////////////////
4227   // Method Generating Ladder of Layer 5 and 6
4228   /////////////////////////////////////////////////////////////  
4229   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4230                                                                                                 fgkSSDLay6SensorsNumber};
4231   /////////////////////////////////////////////////////////////////////////////                                         
4232   /// Generating Ladder Mother Volume Containing Ladder 
4233   /////////////////////////////////////////////////////////////////////////////          
4234   TGeoXtru* laddershape[fgkladdernumber];       
4235   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4236   const Int_t kmothervertexnumber = 8;  
4237   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4238   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4239   ///////////////////////
4240   // Setting the vertices 
4241   ///////////////////////
4242   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4243                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4244   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4245   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
4246   xmothervertex[0][1] = xmothervertex[0][0];
4247   ymothervertex[0][1] = 0.0;
4248   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4249                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4250   ymothervertex[0][2] = ymothervertex[0][1];
4251   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4252   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4253   xmothervertex[0][4] = -xmothervertex[0][3];
4254   ymothervertex[0][4] = ymothervertex[0][3];
4255   xmothervertex[0][5] = -xmothervertex[0][2];
4256   ymothervertex[0][5] = ymothervertex[0][2];
4257   xmothervertex[0][6] = -xmothervertex[0][1];
4258   ymothervertex[0][6] = ymothervertex[0][1];
4259   xmothervertex[0][7] = -xmothervertex[0][0];
4260   ymothervertex[0][7] = ymothervertex[0][0];
4261   for(Int_t i=0; i<kmothervertexnumber; i++){
4262         xmothervertex[1][i] = xmothervertex[0][i];
4263         ymothervertex[1][i] = ymothervertex[0][i];
4264   }
4265 ///////////////////////////////////////////////////////////////////////////
4266 // Disalignement Mother Volume corrections 25/08/08
4267 ///////////////////////////////////////////////////////////////////////////
4268   TGeoXtru* leftladdershape[fgkladdernumber];   
4269   TGeoXtru* centersensorladdershape[fgkladdernumber];   
4270   TGeoXtru* rightladdershape[fgkladdernumber];  
4271   for(Int_t i=0; i<fgkladdernumber; i++){
4272    leftladdershape[i] = new TGeoXtru(2);
4273    centersensorladdershape[i] = new TGeoXtru(2);
4274    rightladdershape[i] = new TGeoXtru(2);
4275    }
4276   //////////////////////////////////////
4277    // Setting the names for shapes  
4278   //////////////////////////////////////
4279   leftladdershape[0]->SetName("Lay5LeftLadderSegmentContainer");
4280   leftladdershape[1]->SetName("Lay6LeftLadderSegmentContainer");
4281   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
4282   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
4283   rightladdershape[0]->SetName("Lay5RightLadderSegmentContainer");
4284   rightladdershape[1]->SetName("Lay6RightLadderSegmentContainer");
4285   //////////////////////////////////////
4286   Double_t xleftladdervertex[fgkladdernumber][kmothervertexnumber];
4287   Double_t yleftladdervertex[fgkladdernumber][kmothervertexnumber];
4288   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
4289   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
4290   Double_t xrightladdervertex[fgkladdernumber][kmothervertexnumber];
4291   Double_t yrightladdervertex[fgkladdernumber][kmothervertexnumber];
4292   for(Int_t i=0; i<fgkladdernumber; i++)
4293         for(Int_t j=0; j<kmothervertexnumber; j++){
4294                 xleftladdervertex[i][j] = xmothervertex[i][j];
4295                 yleftladdervertex[i][j] = ymothervertex[i][j];
4296                 xcentersensorvertex[i][j] = xmothervertex[i][j];
4297                 ycentersensorvertex[i][j] = ymothervertex[i][j];
4298                 xrightladdervertex[i][j] = xmothervertex[i][j];
4299                 yrightladdervertex[i][j] = ymothervertex[i][j];
4300         }
4301         xcentersensorvertex[0][0] -= fgkSSDModuleSideDisalignment;      
4302         xcentersensorvertex[0][1] =  xcentersensorvertex[0][0];
4303         xcentersensorvertex[0][6] = -xcentersensorvertex[0][1];
4304         xcentersensorvertex[0][7] = -xcentersensorvertex[0][0];
4305
4306         xcentersensorvertex[1][0] = xcentersensorvertex[0][0];  
4307         xcentersensorvertex[1][1] = xcentersensorvertex[0][1];
4308         xcentersensorvertex[1][6] = xcentersensorvertex[0][6];
4309         xcentersensorvertex[1][7] = xcentersensorvertex[0][7];
4310
4311         ycentersensorvertex[0][0] -= fgkSSDModuleVerticalDisalignment;  
4312         ycentersensorvertex[0][7] = ycentersensorvertex[0][0];
4313
4314         ycentersensorvertex[1][0] = ycentersensorvertex[0][0];  
4315         ycentersensorvertex[1][7] = ycentersensorvertex[0][7];
4316         for(Int_t i=0; i<fgkladdernumber; i++){
4317                 // Left Ladder Piece
4318                 leftladdershape[i]->DefinePolygon(kmothervertexnumber,xleftladdervertex[i],
4319                                                                                   yleftladdervertex[i]);
4320                 leftladdershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4321                 leftladdershape[i]->DefineSection(1,-fgkEndLadderCarbonFiberLowerJunctionLength[1]
4322                                                                                         +1.45*fgkSSDMountingBlockWidth);
4323                 // Center Ladder Piece
4324                 centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
4325                                                                           ycentersensorvertex[i]);
4326                 centersensorladdershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]
4327                                                                                                         + 1.45*fgkSSDMountingBlockWidth);
4328                 centersensorladdershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4329                                                                                         +               fgkEndLadderCarbonFiberLowerJunctionLength[0]
4330                                                                                         -               2.4*fgkSSDMountingBlockWidth);
4331                 // Right Ladder Piece
4332                 rightladdershape[i]->DefinePolygon(kmothervertexnumber,xrightladdervertex[i],
4333                                                                                   yrightladdervertex[i]);
4334                 rightladdershape[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4335                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4336                                                                                         -2.4*fgkSSDMountingBlockWidth);
4337                 rightladdershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4338                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4339         }
4340         TGeoCompositeShape* laddershapecontainer[2];
4341         laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4342                                                           "Lay5LeftLadderSegmentContainer+Lay5CenterSensorContainer+Lay5RightLadderSegmentContainer");
4343         laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4344                                                           "Lay6LeftLadderSegmentContainer+Lay6CenterSensorContainer+Lay6RightLadderSegmentContainer");
4345         const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4346     for(Int_t i=0; i<fgkladdernumber; i++){
4347                 fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4348                 fladder[i]->SetLineColor(4);
4349         }
4350 ///////////////////////////////////////////////////////////////////////////
4351  if(!fCreateMaterials) CreateMaterials();
4352  if(!fTransformationMatrices) CreateTransformationMatrices();
4353  if(!fBasicObjects) CreateBasicObjects();
4354  SetLadderSegment(); 
4355  SetEndLadderSegment();
4356   for(Int_t i=0; i<fgkladdernumber; i++){
4357         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4358         //////////////////////////                                              
4359         /// Placing Ladder Segment
4360         //////////////////////////              
4361                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4362                                                                      fladdersegment[i==0 ? 1 : 0],
4363                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4364         //////////////////////////                                              
4365         /// Placing SSD Sensor
4366         //////////////////////////              
4367         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4368                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4369                                                         fssdsensormatrix[i][j]);
4370         }
4371         ///////////////////////////////                                         
4372         /// Placing End Ladder Segment
4373         ///////////////////////////////         
4374     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4375         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4376    }
4377 /////////////////////////////////////////////////////////////////////////////                                           
4378 /// Placing Ladder Cables
4379 /////////////////////////////////////////////////////////////////////////////           
4380   Int_t sidecablenumber[2][2];
4381   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4382   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4383   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4384   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4385   Double_t carbonfibertomoduleposition[3];
4386   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4387   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4388                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4389          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4390          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4391          -            fgkSSDSensorCenterSupportThickness[0]);
4392   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4393                                                                  +   0.5*fgkCoolingTubeSupportHeight
4394          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4395   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4396   Double_t ssdendladdercablelength[4];
4397   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4398                                                          + fgkSSDSensorLength
4399                                                          - fgkSSDModuleStiffenerPosition[1]
4400                                                          - fgkSSDStiffenerWidth 
4401                                                          - fgkSSDFlexWidth[0]
4402                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4403   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4404                                                          + fgkSSDModuleStiffenerPosition[1]
4405                                                          + fgkSSDStiffenerWidth
4406                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4407   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4408                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4409                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4410                                                          - kendladdercablecorrection;
4411   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4412                                                          + carbonfibertomoduleposition[1]
4413                                                          - fgkSSDModuleStiffenerPosition[1]
4414                                                          - fgkSSDStiffenerWidth)
4415                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4416   TList* laddercableassemblylist[4];
4417   const Int_t kendladdercablesnumber = 4;
4418   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4419         for(Int_t j=0; j<kendladdercablesnumber; j++){
4420                 laddercableassemblylist[j] = 
4421                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4422                                                                    ssdendladdercablelength[j]);
4423                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4424                                                                         j<2?1:2,fladdercablematrix[i][j]);
4425   }
4426 }
4427 ////////////////////////////////////////////////////////////////////////////////
4428 void AliITSv11GeometrySSD::SetLayer(){
4429 ////////////////////////////////////////////////////////////////////////////////
4430   // Creating Ladder of Layer 5 and Layer 6
4431   /////////////////////////////////////////////////////////////
4432   if(!fCreateMaterials) CreateMaterials();
4433   if(!fTransformationMatrices) CreateTransformationMatrices();
4434   if(!fBasicObjects) CreateBasicObjects();
4435   SetLadder(); // Generating the ladder of Layer5 and Layer6
4436   const Int_t kssdlayladdernumber[fgklayernumber] = 
4437                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4438   /////////////////////////////////////////////////////////////
4439   // Generating mother volumes for Layer5 and Layer6
4440   /////////////////////////////////////////////////////////////
4441   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4442   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4443   Int_t *ladderindex[fgklayernumber];
4444   Int_t index[fgklayernumber] = {8,9};
4445   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4446   for(Int_t i=0; i<fgklayernumber; i++) 
4447         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4448                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4449                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4450                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4451                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4452         }
4453   /////////////////////////////////////////////////////////////
4454   // Deallocating memory
4455   /////////////////////////////////////////////////////////////
4456   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4457 }
4458 ////////////////////////////////////////////////////////////////////////////////
4459 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4460   /////////////////////////////////////////////////////////////
4461   // Insert the layer 5 in the mother volume. 
4462   /////////////////////////////////////////////////////////////
4463   if (! moth) {
4464     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4465     return;
4466   };
4467   if(!fSSDLayer5) SetLayer();
4468   fMotherVol = moth;
4469   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4470                                                                                 + fgkLay5CenterITSPosition);
4471   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4472  }
4473 ////////////////////////////////////////////////////////////////////////////////
4474 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4475   /////////////////////////////////////////////////////////////
4476   // Insert the layer 6 in the mother volume. 
4477   /////////////////////////////////////////////////////////////
4478   if (! moth) {
4479     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4480     return;
4481   };
4482   if(!fSSDLayer6) SetLayer();
4483   fMotherVol = moth;
4484   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4485                                                                                 + fgkLay6CenterITSPosition);
4486   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4487  }
4488  ////////////////////////////////////////////////////////////////////////////////
4489  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4490   /////////////////////////////////////////////////////////////
4491   // Method generating the Arc structure of Ladder Support 
4492   /////////////////////////////////////////////////////////////
4493   const Int_t kssdlayladdernumber[fgklayernumber] = 
4494                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4495   Double_t mountingsupportedge[fgklayernumber];
4496   Double_t mountingblockratio[fgklayernumber];
4497   Double_t theta[fgklayernumber];
4498   Double_t phi[fgklayernumber];
4499   Double_t psi0[fgklayernumber];
4500   Double_t deltapsi[fgklayernumber];
4501   TVector3* mountingsupportedgevector[fgklayernumber];
4502   for(Int_t i=0; i<fgklayernumber; i++){
4503         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4504     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4505                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4506                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4507                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4508                                                           / kssdlayladdernumber[i])));
4509     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4510     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4511         mountingsupportedgevector[i] = new TVector3();
4512         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4513         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4514                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4515                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4516     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4517     deltapsi[i] = (theta[i]+phi[i])/nedges;
4518   }
4519   TVector3** vertex[fgklayernumber];
4520   TList* vertexlist[fgklayernumber];
4521   Int_t indexedge[fgklayernumber] = {0,0};
4522   for(Int_t i=0; i<fgklayernumber; i++){
4523         vertex[i] = new TVector3*[nedges+1];
4524         vertexlist[i] = new TList();
4525   } 
4526   for(Int_t i=0; i<fgklayernumber; i++){
4527         for(Int_t j=0; j<nedges+1; j++){
4528                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4529                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4530                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4531                 vertexlist[i]->Add(vertex[i][j]);
4532         }
4533         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4534   }
4535   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4536   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4537   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4538   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4539   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4540   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4541   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4542   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4543   for(Int_t i=0; i<fgklayernumber; i++){
4544     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4545     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4546     xcentervertex[i] = new Double_t[indexedge[i]+3];
4547     ycentervertex[i] = new Double_t[indexedge[i]+3];
4548         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4549         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4550         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4551         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4552         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4553                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4554                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4555                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4556                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4557                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4558                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4559                 if(j<indexedge[i]+1){
4560                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4561                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4562                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4563                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4564                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4565                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4566                 }
4567         }
4568         xsidevertex[i][1] = xsidevertex[i][0]; 
4569         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4570         xsidevertex[i][2] = xsidevertex[i][3]; 
4571         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4572         xcentervertex[i][1] = xcentervertex[i][0]; 
4573         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4574         xcentervertex[i][2] = xcentervertex[i][3]; 
4575         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4576         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4577         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4578         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4579         ycenterlowervertex[i][0] = ysidevertex[i][0];
4580         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4581         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4582   }
4583   /////////////////////////////////////////////////////////////
4584   // Building the Arc Structure of Ladder Supports 
4585   /////////////////////////////////////////////////////////////
4586   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4587   TGeoXtru* centermountingsupportshape[fgklayernumber];
4588   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4589   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4590   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4591   TGeoVolume* centermountingblocksupport[fgklayernumber];
4592   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4593   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4594   char sidemountingblockname[100];
4595   char centermountingblockname[100];
4596   char sideladdersupportpiecename[100];
4597   char centerladdersupportpiecename[100];
4598   for(Int_t i=0; i<fgklayernumber; i++){ 
4599         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4600         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4601         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4602         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4603         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4604     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4605                                                                                                 xsidevertex[i],ysidevertex[i]);
4606     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4607                                                                                                          -fgkMountingBlockSupportWidth[0]);
4608     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4609     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4610                                                                           sidemountingblocksupportshape[i],
4611                                                                                   fSSDAlCoolBlockMedium);
4612         sidemountingblocksupport[i]->SetLineColor(9);
4613         centermountingsupportshape[i] = new TGeoXtru(2);
4614     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4615                                                                                                 xcentervertex[i],ycentervertex[i]);
4616         centermountingsupportshape[i]->DefineSection(0,0.);
4617     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4618                                                                                                   -fgkMountingBlockSupportWidth[0]);
4619     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4620                                                                           centermountingsupportshape[i],
4621                                                                                   fSSDAlCoolBlockMedium);
4622         centermountingblocksupport[i]->SetLineColor(9);
4623         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4624     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4625                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4626         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4627                                                                                                          -fgkMountingBlockSupportWidth[0]);
4628     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4629     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4630                                                                           sideladdersupportpieceshape[i],
4631                                                                                   fSSDCarbonFiberMedium);
4632         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4633         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4634     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4635                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4636         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4637     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4638                                                                                                   -fgkMountingBlockSupportWidth[0]);
4639     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4640                                                                           centerladdersupportpieceshape[i],
4641                                                                                   fSSDCarbonFiberMedium);
4642         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4643   }
4644   /////////////////////////////////////////////////////////////
4645   // Building the Up Structure of Ladder Supports 
4646   /////////////////////////////////////////////////////////////
4647   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4648   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4649   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4650   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4651   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4652   //////////////////////////////////////////////////////////
4653   // Setting the volume for TGeoXtru Mounting Block Piece  
4654   //////////////////////////////////////////////////////////
4655   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4656   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4657   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4658   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4659   TGeoVolume* mountingblockpieceup[fgklayernumber];
4660   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4661   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4662   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4663   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4664   char mountingblockpiecedownname[100];
4665   char mountingblockpieceupname[100];
4666   for(Int_t i=0; i<fgklayernumber; i++){
4667     ///////////////////////////
4668     // Mounting Block Down Vertex
4669     ///////////////////////////
4670         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4671     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4672         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4673         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4674                                                                                 + fgkMountingBlockSupportDownHeight;
4675         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4676         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4677                                                                                 + fgkSSDMountingBlockHeight[1]
4678                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4679                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4680         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4681         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4682         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4683         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4684         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4685         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4686         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4687         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4688                                                                                 + fgkSSDMountingBlockHeight[2]
4689                                                                                 - fgkSSDMountingBlockHeight[0];
4690         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4691         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4692         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4693         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4694         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4695                                                                                                          mountingblockpiecedownyvertex[i]);
4696         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4697         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4698         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4699                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4700         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4701     ///////////////////////////
4702     // Mounting Block Up Vertex
4703     ///////////////////////////
4704         mountingblockpieceupshape[i] = new TGeoXtru(2);
4705         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4706         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4707         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4708                                                                                 + fgkMountingBlockSupportUpHeight[i];
4709         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4710         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4711                                                                                 + fgkSSDMountingBlockHeight[1]
4712                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4713                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4714         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4715         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4716         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4717         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4718         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4719         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4720         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4721         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4722                                                                                 + fgkSSDMountingBlockHeight[2]
4723                                                                                 - fgkSSDMountingBlockHeight[0];
4724         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4725         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4726         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4727         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4728         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4729                                                                                                          mountingblockpieceupyvertex[i]);
4730         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4731         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4732         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4733                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4734         mountingblockpieceup[i]->SetLineColor(fColorG10);
4735  }
4736   ///////////////////////////////////////////////////////////////////
4737   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4738   ///////////////////////////////////////////////////////////////////
4739   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4740   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4741   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4742   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4743   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4744   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4745   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4746   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4747   char mountingblocksupportrapezoidowname[100];
4748   char mountingblocksupportrapezoidupname[100];
4749   Double_t scalefactor = 3./4.;
4750   for(Int_t i=0; i<fgklayernumber; i++){
4751   ////////////////////////////////////////////
4752   // Mounting Block Support Down Trapezoid Vertex 
4753   ////////////////////////////////////////////
4754         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4755         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4756                                                                                                  - mountingsupportedge[i];
4757         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4758         mountingblocksupportrapezoidownxvertex[i][1] = 
4759                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4760         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4761                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4762                                                                                              - mountingblockpiecedownyvertex[i][0]);
4763         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4764         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4765         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4766         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4767         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4768         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4769         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4770                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4771         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4772                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4773         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4774         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4775         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4776                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4777         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4778   ////////////////////////////////////////////
4779   // Mounting Block Support Up Trapezoid Vertex 
4780   ////////////////////////////////////////////
4781         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4782         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4783                                                                                                  - mountingsupportedge[i];
4784         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4785         mountingblocksupportrapezoidupxvertex[i][1] = 
4786                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4787         mountingblocksupportrapezoidupyvertex[i][1] = 
4788                                                                                                mountingblockpieceupyvertex[i][0]
4789                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4790                                                                                              - mountingblockpieceupyvertex[i][0]);
4791         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4792         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4793         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4794         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4795         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4796         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4797         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4798                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4799         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4800                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4801         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4802         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4803         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4804                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4805         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4806   }
4807   ///////////////////////////////////////////////////////////////////
4808   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4809   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4810   Double_t boxoriginup[fgklayernumber][2][3];
4811   Double_t boxorigindown[fgklayernumber][2][3];
4812   char mountingblocksupportboxdownname[100];
4813   char mountingblocksupportboxupname[100];
4814   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4815   mountingblocksupportrot->SetAngles(90.,180.,-90);
4816   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4817   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4818   TGeoHMatrix* laddersupportmatrix[2];
4819   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4820   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4821   /////////////////////////////////////////////////////////////
4822   // Creating Mother Volume for Containment
4823   /////////////////////////////////////////////////////////////
4824   Double_t *xmothervertex[fgklayernumber];
4825   Double_t *ymothervertex[fgklayernumber];
4826   for(Int_t i=0; i<fgklayernumber; i++){
4827         xmothervertex[i] = new Double_t[8];
4828         ymothervertex[i] = new Double_t[8];
4829   }  
4830   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4831   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4832   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4833 //  TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4834   TGeoVolumeAssembly* upmotherladdersupport[fgklayernumber];   
4835   char upmotheladdersupportname[100];
4836   char downmotheladdersupportname[100];
4837   for(Int_t i=0; i<fgklayernumber; i++){
4838         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4839                                                     -  mountingsupportedge[i];
4840         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4841         xmothervertex[i][1] = xmothervertex[i][0];
4842         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4843                                                         + fgkMountingBlockSupportWidth[0];
4844         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4845         ymothervertex[i][2] = ymothervertex[i][1];
4846         xmothervertex[i][3] = xmothervertex[i][2];
4847         ymothervertex[i][3] = -ymothervertex[i][0];
4848         xmothervertex[i][4] = -xmothervertex[i][0];
4849         ymothervertex[i][4] = ymothervertex[i][3];
4850         xmothervertex[i][5] = xmothervertex[i][4];
4851         ymothervertex[i][5] = -ymothervertex[i][1];
4852         xmothervertex[i][6] = -xmothervertex[i][2];
4853         ymothervertex[i][6] = ymothervertex[i][5];
4854         xmothervertex[i][7] = xmothervertex[i][6];
4855         ymothervertex[i][7] = ymothervertex[i][0];
4856         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4857         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4858     downmotherladdersupportshape[i] = new TGeoXtru(2);
4859         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4860         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4861     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4862                                                                    +                       fgkMountingBlockSupportDownHeight
4863                                                                    +                       fgkSSDMountingBlockHeight[1]
4864                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4865                                                                    -                       fgkSSDModuleCoolingBlockToSensor);
4866     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4867                                                                           downmotherladdersupportshape[i],fSSDAir);
4868     upmotherladdersupportshape[i] = new TGeoXtru(2);
4869         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4870         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4871     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4872                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4873                                                                    +                       fgkSSDMountingBlockHeight[1]
4874                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4875                                                                    -                       fgkSSDModuleCoolingBlockToSensor);
4876         upmotherladdersupport[i] = new TGeoVolumeAssembly(upmotheladdersupportname);
4877 //    upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4878 //                                                                                        upmotherladdersupportshape[i],fSSDAir);
4879   }
4880   for(Int_t i=0; i<fgklayernumber; i++){
4881         /////////////////////////
4882         // Setting the box origin
4883         /////////////////////////
4884         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4885         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4886                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4887         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4888                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4889   
4890         boxorigindown[i][1][0] = 0.0;
4891         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4892         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4893                                                    -      fgkMountingBlockSupportWidth[0]);
4894                                                    
4895         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4896         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4897                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4898         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4899                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4900   
4901         boxoriginup[i][1][0] = 0.0;
4902         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4903                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4904         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4905                                                  - fgkMountingBlockSupportWidth[0]);
4906   
4907         /////////////////////////
4908     // Setting the boxes    
4909         /////////////////////////
4910         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4911                                                                                  +  fgkSSDMountingBlockLength[0]),
4912                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4913                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4914                                                                                         boxorigindown[i][0]);
4915     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4916                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4917                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4918                                                                                  -  fgkMountingBlockSupportWidth[0]),
4919                                                                                         boxorigindown[i][1]);
4920                                                                                         
4921         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4922                                                                                  +  fgkSSDMountingBlockLength[0]),
4923                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4924                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4925                                                                                         boxoriginup[i][0]);
4926                                                                                         
4927         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4928                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4929                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4930                                                                      -  fgkMountingBlockSupportWidth[0]),
4931                                                                                         boxoriginup[i][1]);
4932         ///////////////////////////////////////
4933     // Adding the Volumes to Mother Volume    
4934         ///////////////////////////////////////
4935         for(Int_t j=0; j<2; j++){
4936                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4937                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4938                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4939                                                                                   mountingblocksupportboxdownshape[i][j],
4940                                                                                   fSSDCarbonFiberMedium);
4941                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4942                                                                                   mountingblocksupportboxupshape[i][j],
4943                                                                                   fSSDCarbonFiberMedium);
4944                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4945                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4946                 for(Int_t k=0; k<2; k++){
4947                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4948 //                      upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4949                 }
4950         }
4951         for(Int_t k=0; k<2; k++){
4952                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4953                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4954                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4955                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4956             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4957                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4958                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4959 //              upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4960 //              upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4961 //              upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4962 //              upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4963 //              upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4964         }
4965   }
4966   TList* laddersupportlist = new TList();
4967   laddersupportlist->Add(downmotherladdersupport[0]); 
4968   laddersupportlist->Add(upmotherladdersupport[0]); 
4969   laddersupportlist->Add(downmotherladdersupport[1]); 
4970   laddersupportlist->Add(upmotherladdersupport[1]); 
4971   /////////////////////////////////////////////////////////////
4972   // Deallocating memory
4973   /////////////////////////////////////////////////////////////
4974   for(Int_t i=0; i<fgklayernumber; i++){
4975         for(Int_t j=0; j<nedges+1; j++)
4976                 delete vertex[i][j];
4977         delete mountingsupportedgevector[i];
4978         delete [] vertex[i];
4979         delete vertexlist[i];
4980         delete [] xsidevertex[i];
4981         delete [] ysidevertex[i];
4982         delete [] xcentervertex[i];
4983         delete [] ycentervertex[i];
4984         delete [] xsidelowervertex[i];
4985         delete [] ysidelowervertex[i];
4986         delete [] xcenterlowervertex[i];
4987         delete [] ycenterlowervertex[i];
4988   }
4989   delete [] xsidevertex;
4990   delete [] ysidevertex;
4991   delete [] xcentervertex;
4992   delete [] ycentervertex;
4993   delete [] xsidelowervertex;
4994   delete [] ysidelowervertex;
4995   delete [] xcenterlowervertex;
4996   delete [] ycenterlowervertex;
4997   delete globalrefladdersupportrot;
4998   delete mountingblocksupportrot;
4999   /////////////////////
5000   return laddersupportlist;     
5001 }
5002  ////////////////////////////////////////////////////////////////////////////////
5003 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
5004 //////////////////////////////////////////
5005 // Method Generating Ladder Support Ring
5006 //////////////////////////////////////////
5007   if(!fCreateMaterials) CreateMaterials();
5008   if(!fTransformationMatrices) CreateTransformationMatrices();
5009   if(!fBasicObjects) CreateBasicObjects();
5010   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5011   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5012     const Int_t kssdlayladdernumber[fgklayernumber] = 
5013                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5014   Double_t mountingsupportedge[fgklayernumber];
5015   Double_t mountingblockratio[fgklayernumber];
5016   Double_t theta[fgklayernumber];
5017   Double_t phi[fgklayernumber];
5018   for(Int_t i=0; i<fgklayernumber; i++){
5019         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5020     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5021                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
5022                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5023                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5024                                                           / kssdlayladdernumber[i])));
5025     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5026                          / fgkMountingBlockSupportRadius[i]);
5027     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5028   }
5029   TGeoRotation* globalrot = new TGeoRotation();
5030   globalrot->SetAngles(0.,-90.,0.); 
5031   TGeoRotation** laddersupportrot[fgklayernumber];
5032   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5033   for(Int_t i=0; i<fgklayernumber; i++){                
5034         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5035         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5036         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5037                 laddersupportrot[i][j] = new TGeoRotation();
5038                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5039                 switch(i){
5040                         case 0: //Ladder of Layer5  
5041                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5042                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5043                                                                             laddersupportmatrix[i][j]); 
5044                         break;
5045                         case 1: //Ladder of Layer6 
5046                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5047                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5048                                                                               laddersupportmatrix[i][j]); 
5049                         break;
5050                 }
5051     }
5052   }
5053   /////////////////////////////////////////////////////////////
5054   // Creating Lower Ladder Support 
5055   /////////////////////////////////////////////////////////////
5056   TVector3** ringsupportvertex[fgklayernumber];         
5057   Double_t angle = 360./nedges;
5058   for(Int_t i=0; i<fgklayernumber; i++){
5059     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5060         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5061                                                         *                          TMath::Cos(theta[i]));
5062         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5063                                                         -                          mountingsupportedge[i],
5064                                                                                    ringsupportvertex[i][0]->Y());
5065         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5066                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5067     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5068         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5069            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5070            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5071            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5072            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5073         }
5074         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5075     for(Int_t j=0; j<nedges+1; j++){
5076                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5077                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5078                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5079         }
5080   }
5081   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5082   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5083   for(Int_t i=0; i<fgklayernumber; i++){
5084         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5085         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5086         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5087                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5088                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5089         }
5090   }
5091 ////////////////////////////////////////////////////////////////////////////////
5092 // Start Corrections 13/06/08
5093 ////////////////////////////////////////////////////////////////////////////////
5094   char lowerladderpconsupportname[100];
5095   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5096   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5097   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5098   Double_t lowerladderpconradiusmax[fgklayernumber];
5099   Double_t lowerladderpconradiusmin[fgklayernumber];
5100   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5101   lowerladdersupportrot->SetAngles(90.,180.,-90);
5102   for(Int_t i=0; i<fgklayernumber; i++){
5103         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5104                                                                 *                          TMath::Cos(theta[i]);
5105     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5106   } 
5107   for(Int_t i=0; i<fgklayernumber; i++){
5108 ///////////////////////////  Modified Version ?///////////////////
5109     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5110         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5111                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5112                                                          lowerladderpconradiusmax[i]);
5113         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5114         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5115     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5116         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5117         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5118  }
5119 ////////////////////////////////////////////////////////////////////////////////
5120 // End Corrections 13/06/08
5121 ////////////////////////////////////////////////////////////////////////////////
5122   /*char lowerladdersupportname[30];
5123   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5124   TGeoVolume* lowerladdersupport[fgklayernumber];
5125   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5126   lowerladdersupportrot->SetAngles(90.,180.,-90);
5127   for(Int_t i=0; i<fgklayernumber; i++){
5128         lowerladdersupportshape[i] = new TGeoXtru(2);
5129         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5130                                                                                           xmothervertex[i],ymothervertex[i]);
5131         lowerladdersupportshape[i]->DefineSection(0,0.);
5132     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5133         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5134     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5135                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5136         lowerladdersupport[i]->SetLineColor(fColorAl);
5137         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5138         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5139   }*/
5140   /////////////////////////////////////////////////////////////
5141   // Deallocating memory
5142   /////////////////////////////////////////////////////////////
5143   for(Int_t i=0; i<fgklayernumber; i++){
5144         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5145                 delete ringsupportvertex[i][j];
5146         delete [] ringsupportvertex[i];
5147   }
5148   for(Int_t i=0; i<fgklayernumber; i++){
5149         delete [] xmothervertex[i];
5150         delete [] ymothervertex[i];
5151   }
5152   delete xmothervertex;
5153   delete ymothervertex; 
5154   delete globalrot;
5155   for(Int_t i=0; i<fgklayernumber; i++){
5156         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5157                 delete laddersupportrot[i][j];
5158         delete [] laddersupportrot[i];
5159   }
5160  }  
5161  ////////////////////////////////////////////////////////////////////////////////
5162  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5163   /////////////////////////////////////////////////////////////
5164   // Method generating Endcap CoverPlate
5165   /////////////////////////////////////////////////////////////
5166   // Holes Definition 
5167   ///////////////////
5168   Int_t nendcapcoverplateholedges = 30;
5169   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5170   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5171                                                           0.5*fgkEndCapCoverPlateThickness};
5172   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5173                                                                                                               nendcapcoverplateholedges,holesection);
5174   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5175                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5176   endcapcoverplatesmallhole->SetLineColor(6);
5177   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5178                                                                                                               nendcapcoverplateholedges,holesection);
5179   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5180                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5181   endcapcoverplatebighole->SetLineColor(6);
5182   //////////////////////////
5183   // Screw Piece Definition 
5184   //////////////////////////
5185   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5186   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5187                                                                                                       CosD(0.5*smallscrewangle),
5188                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5189   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5190                                                                                                 endcapsmallscrewpieceshape,
5191                                                                                                 fSSDCoolingTubePhynox);
5192   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5193   ///////////////////
5194   // Box Definition 
5195   ///////////////////
5196   TGeoBBox* endcapcoverplateboxshape[4];
5197   TGeoVolume* endcapcoverplatebox[4];
5198   Double_t boxorigin[5][3];
5199   boxorigin[0][0] = 0.;
5200   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5201   boxorigin[0][2] = 0.;
5202
5203   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5204   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5205   boxorigin[1][2] = 0.;
5206
5207   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5208                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5209   boxorigin[2][1] = boxorigin[1][1];
5210   boxorigin[2][2] = 0.;
5211
5212   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5213                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5214   boxorigin[3][1] = boxorigin[1][1];
5215   boxorigin[3][2] = 0.;
5216
5217   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5218                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5219                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5220                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5221
5222   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5223                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5224                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5225                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5226                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5227
5228   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5229                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5230                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5231                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5232                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5233
5234   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5235                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5236                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5237                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5238                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5239   
5240   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5241                                                                            fSSDAlCoolBlockMedium);
5242   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5243                                                                            fSSDAlCoolBlockMedium);
5244   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5245                                                                            fSSDAlCoolBlockMedium);
5246   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5247                                                                            fSSDAlCoolBlockMedium);
5248   endcapcoverplatebox[0]->SetLineColor(6);
5249   endcapcoverplatebox[1]->SetLineColor(6);
5250   endcapcoverplatebox[2]->SetLineColor(6);
5251   endcapcoverplatebox[3]->SetLineColor(6);
5252   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5253   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5254                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5255                                                                                         0.5*fgkEndCapCoverPlateThickness,
5256                                                                                         endcapfillingboxorigin);
5257   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5258                                                                            fSSDAlCoolBlockMedium);
5259   endcapfillingbox->SetLineColor(6);
5260   ////////////////////////////
5261   // Contour shape Definition 
5262   ////////////////////////////
5263   const Int_t kcontourvertexnumber = 10;
5264   Double_t xcontourvertex[kcontourvertexnumber];
5265   Double_t ycontourvertex[kcontourvertexnumber];
5266   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5267   xcontourvertex[1] = xcontourvertex[0];
5268   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5269   xcontourvertex[3] = xcontourvertex[2];
5270   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5271   xcontourvertex[5] = xcontourvertex[4];
5272   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5273   xcontourvertex[7] = xcontourvertex[6];
5274   xcontourvertex[8] = xcontourvertex[4];
5275   xcontourvertex[9] = xcontourvertex[8];
5276   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5277                                         - (kendcapcoverplatesmallholenumber[1]-1)
5278                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5279   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5280                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5281   ycontourvertex[2] = ycontourvertex[1];
5282   ycontourvertex[3] = ycontourvertex[0];
5283   ycontourvertex[4] = ycontourvertex[3];
5284   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5285   ycontourvertex[6] = ycontourvertex[5];
5286   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5287                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5288                                         + fgkEndCapCoverPlateSmallHoleRadius;
5289   ycontourvertex[8] = ycontourvertex[7];
5290   ycontourvertex[9] = ycontourvertex[0];
5291
5292   Double_t xboxin, dxboxin, yboxin, dyboxin;
5293   Double_t xboxout, dxboxout, yboxout, dyboxout;
5294   Double_t coordmin, coordmax;
5295   coordmin = -fgkEndCapCoverPlateLength[0];
5296   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5297   xboxout = 0.5*(coordmin+coordmax);
5298   dxboxout = 0.5*(coordmax-coordmin);
5299   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5300                                         - (kendcapcoverplatesmallholenumber[1]-1)
5301                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5302   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5303                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5304   yboxout = 0.5*(coordmin+coordmax);
5305   dyboxout = 0.5*(coordmax-coordmin);
5306   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5307   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5308   xboxin = 0.5*(coordmin+coordmax);
5309   dxboxin = 0.5*(coordmax-coordmin);
5310   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5311   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5312                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5313                                         + fgkEndCapCoverPlateSmallHoleRadius;
5314   yboxin = 0.5*(coordmin+coordmax);
5315   dyboxin = 0.5*(coordmax-coordmin);
5316   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5317   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5318                                                          xboxout, yboxout, 0.);
5319   trendCapCoverPlateContourboxout->RegisterYourself();
5320   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5321   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5322                                                          xboxin, yboxin, 0.);
5323   trendCapCoverPlateContourboxin->RegisterYourself();
5324   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5325         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5326
5327   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5328                                                                            fSSDAlCoolBlockMedium);
5329   contour->SetLineColor(6);
5330   /////////////////////////////
5331   // Hole Contour Shape Definition 
5332   ////////////////////////////
5333   coordmin = xcontourvertex[0];
5334   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5335   xboxout = 0.5*(coordmin+coordmax);
5336   dxboxout = 0.5*(coordmax-coordmin);
5337   coordmin = ycontourvertex[1];
5338   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5339   yboxout = 0.5*(coordmin+coordmax);
5340   dyboxout = 0.5*(coordmax-coordmin);
5341   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5342                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5343   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5344   xboxin = 0.5*(coordmin+coordmax);
5345   dxboxin = 0.5*(coordmax-coordmin);
5346   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5347                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5348   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5349   yboxin = 0.5*(coordmin+coordmax);
5350   dyboxin = 0.5*(coordmax-coordmin);
5351   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5352   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5353                                                          xboxout, yboxout, 0.);
5354   trendCapCoverPlateContourboxout1->RegisterYourself();
5355   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5356   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5357                                                          xboxin, yboxin, 0.);
5358   trendCapCoverPlateContourboxin1->RegisterYourself();
5359   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5360         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5361
5362
5363   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5364   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5365   xboxout = 0.5*(coordmin+coordmax);
5366   dxboxout = 0.5*(coordmax-coordmin);
5367   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5368                                                    - fgkEndCapCoverPlateWidth[0]);
5369   coordmax = ycontourvertex[0];
5370   yboxout = 0.5*(coordmin+coordmax);
5371   dyboxout = 0.5*(coordmax-coordmin);
5372   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5373                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5374   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5375   xboxin = 0.5*(coordmin+coordmax);
5376   dxboxin = 0.5*(coordmax-coordmin);
5377   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5378                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5379                                                    - fgkEndCapCoverPlateWidth[0]
5380                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5381   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5382   yboxin = 0.5*(coordmin+coordmax);
5383   dyboxin = 0.5*(coordmax-coordmin);
5384   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5385   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5386                                                          xboxout, yboxout, 0.);
5387   trendCapCoverPlateContourboxout2->RegisterYourself();
5388   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5389   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5390                                                          xboxin, yboxin, 0.);
5391   trendCapCoverPlateContourboxin2->RegisterYourself();
5392   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5393         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5394   
5395 //  const Int_t kholecontourvertexnumber = 10;
5396
5397   Double_t xholecontourvertex[2][kcontourvertexnumber];
5398   Double_t yholecontourvertex[2][kcontourvertexnumber];
5399   xholecontourvertex[0][0] = xcontourvertex[0];
5400   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5401   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5402   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5403   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5404                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5405                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5406   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5407   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5408                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5409   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5410   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5411   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5412   
5413   yholecontourvertex[0][0] = ycontourvertex[1];
5414   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5415   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5416   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5417   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5418   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5419                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5420   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5421   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5422   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5423   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5424
5425   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5426   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5427   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5428   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5429   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5430                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5431                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5432   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5433   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5434                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5435   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5436   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5437   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5438   
5439   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5440                                                    - fgkEndCapCoverPlateWidth[0]);
5441   yholecontourvertex[1][1] = ycontourvertex[0];
5442   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5443   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5444   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5445   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5446                                                    - fgkEndCapCoverPlateWidth[0]
5447                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5448   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5449   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5450   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5451   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5452
5453   TGeoVolume* holecontour[2];
5454   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5455                                                                   fSSDAlCoolBlockMedium);
5456   holecontour[0]->SetLineColor(6);
5457   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5458                                                                   fSSDAlCoolBlockMedium);
5459   holecontour[1]->SetLineColor(6);
5460   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5461                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5462   TGeoTranslation*  bigholetrans[3];
5463   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5464                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5465   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5466                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5467                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5468   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5469                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5470   /////////////////////////////////
5471   // Mother Volume Xtru Definition 
5472   /////////////////////////////////
5473   const Int_t kmothervertexnumber = 12;
5474   Double_t xmothervertex[kmothervertexnumber];  
5475   Double_t ymothervertex[kmothervertexnumber];  
5476   xmothervertex[0]  = xcontourvertex[0];
5477   xmothervertex[1]  = xmothervertex[0];
5478   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5479   xmothervertex[3]  = xmothervertex[2];
5480   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5481   xmothervertex[5]  = xmothervertex[4];
5482   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5483   xmothervertex[7]  = xmothervertex[6];
5484   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5485                                         + fgkEndCapCoverPlateLength[2]; 
5486   xmothervertex[9]  = xmothervertex[8];
5487   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5488   xmothervertex[11] = xmothervertex[10];
5489   
5490   ymothervertex[0]  = ycontourvertex[0];
5491   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5492   ymothervertex[2]  = ymothervertex[1];
5493   ymothervertex[3]  = ycontourvertex[1];
5494   ymothervertex[4]  = ymothervertex[3];
5495   ymothervertex[5]  = ymothervertex[1];
5496   ymothervertex[6]  = ymothervertex[5];
5497   ymothervertex[7]  = ymothervertex[0];
5498   ymothervertex[8]  = ymothervertex[7];
5499   ymothervertex[9]  = ymothervertex[8]
5500                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5501   ymothervertex[10] = ymothervertex[9];
5502   ymothervertex[11] = ymothervertex[8];
5503   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5504   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5505   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5506   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5507   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5508   ////////////////////////////////////////
5509   // Adding Nodes
5510   ////////////////////////////////////////
5511 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5512   TGeoTranslation*** endcapcoverplatesmallholetrans;
5513   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5514   Double_t transx[4] = {0,
5515                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5516                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5517                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5518                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5519                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5520   Int_t index = 0;
5521   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5522         endcapcoverplatesmallholetrans[i] = 
5523                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5524     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5525                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5526             endcapcoverplatesmallholetrans[i][j] = 
5527                 new TGeoTranslation(transx[i],
5528                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5529             if(index!=10){ 
5530                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5531                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5532                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5533                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5534                 }
5535                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5536                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5537                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5538     }
5539   }
5540   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5541   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5542   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5543   mothercoverplate->AddNode(endcapfillingbox,1);
5544   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5545   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5546   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5547   mothercoverplate->AddNode(holecontour[0],1);
5548   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5549   mothercoverplate->AddNode(holecontour[1],1);  
5550   mothercoverplate->AddNode(contour,1);
5551   /////////////////////////////////
5552   return mothercoverplate;      
5553  }
5554  ////////////////////////////////////////////////////////////////////////////////
5555  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5556   /////////////////////////////////////////////////////////////
5557   // Getting EndCap Cooling Tube 
5558   /////////////////////////////////////////////////////////////
5559   TGeoTorus* endcapcoolingtubetorushape[5];
5560   TGeoVolume* endcapcoolingtubetorus[5];
5561   TGeoTube* endcapcoolingtubeshape[4];
5562   TGeoVolume* endcapcoolingtube[4];
5563   char endcapcoolingtubetorusname[100];
5564   char endcapcoolingtubename[100];
5565   TGeoTorus* endcapcoolingwatertubetorushape[5];
5566   TGeoVolume* endcapcoolingwatertubetorus[5];
5567   TGeoTube* endcapcoolingwatertubeshape[4];
5568   TGeoVolume* endcapcoolingwatertube[4];
5569   char endcapcoolingwatertubetorusname[100];
5570   char endcapcoolingwatertubename[100];
5571   for(Int_t i=0; i<5; i++){
5572         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5573         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5574         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5575         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5576         if(i==3){
5577                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5578                                                                                 fgkEndCapCoolingTubeRadiusMin,
5579                                                                                 fgkEndCapCoolingTubeRadiusMax,
5580                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5581                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5582                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5583                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5584     }
5585         else{
5586                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5587                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5588                                                                            fgkEndCapCoolingTubeRadiusMin,
5589                                                                            fgkEndCapCoolingTubeRadiusMax,
5590                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5591                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5592                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5593                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5594                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5595         }
5596         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5597                                                                                            endcapcoolingtubetorushape[i],
5598                                                                                            fSSDCoolingTubePhynox);
5599         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5600                                                                                                         endcapcoolingwatertubetorushape[i],
5601                                                                                                         fSSDCoolingTubeWater);
5602     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5603     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5604     if(i<4){
5605                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5606                                                                   fgkEndCapCoolingTubeRadiusMax,
5607                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5608                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5609                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5610         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5611                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5612         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5613                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5614                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5615                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5616         }
5617   }
5618   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5619   /////////////////////////////////////////
5620   // Transformation for Volume Positioning 
5621   /////////////////////////////////////////
5622   TGeoCombiTrans* coolingtubecombitrans[6];
5623   TGeoRotation* coolingtuberot[8];
5624   TGeoTranslation* coolingtubetrans[6];
5625   TGeoHMatrix* coolingtubematrix[4];
5626   TGeoCombiTrans* torustubecombitrans[4];
5627   TGeoRotation* torustuberot[7];
5628   TGeoTranslation* torustubetrans[4];
5629   TGeoHMatrix* torustubematrix[5];
5630   TGeoCombiTrans* coolingwatertubecombitrans[6];
5631   TGeoRotation* coolingwatertuberot[8];
5632   TGeoTranslation* coolingwatertubetrans[6];
5633   TGeoHMatrix* coolingwatertubematrix[4];
5634   TGeoCombiTrans* toruswatertubecombitrans[4];
5635   TGeoRotation* toruswatertuberot[7];
5636   TGeoTranslation* toruswatertubetrans[4];
5637   TGeoHMatrix* toruswatertubematrix[5];
5638   for(Int_t i=0; i<8; i++){
5639     if(i<6){
5640          coolingtubetrans[i] = new TGeoTranslation();
5641          coolingwatertubetrans[i] = new TGeoTranslation();
5642     }
5643     if(i<8){
5644          coolingtuberot[i] = new TGeoRotation();
5645          coolingwatertuberot[i] = new TGeoRotation();
5646     }
5647     if(i<4){
5648          torustubetrans[i] = new TGeoTranslation();
5649          toruswatertubetrans[i] = new TGeoTranslation();
5650     }
5651     if(i<7){
5652          torustuberot[i] = new TGeoRotation();
5653          toruswatertuberot[i] = new TGeoRotation();
5654         }
5655   }
5656   /////////////////////////////////////////
5657   // Transformation for Inox Volume Positioning 
5658   /////////////////////////////////////////
5659   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5660                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5661   coolingtuberot[0]->SetAngles(0.,90.,0.);
5662   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5663                                                                                                 *coolingtuberot[0]);
5664                                                                                                 
5665   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5666   coolingtuberot[1]->SetAngles(0.,90.,0.);
5667   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5668                                                                                                 *coolingtuberot[1]);
5669
5670   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5671                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5672                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5673                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5674                                                                           0.);
5675   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5676   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5677                                                                                                 *coolingtuberot[2]);
5678
5679   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5680                                            *                             (*coolingtubecombitrans[1]));
5681
5682   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5683                                                                          endcapcoolingtubeshape[1]->GetDz());
5684   torustuberot[0]->SetAngles(0.,90.,0.); 
5685   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5686
5687   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5688
5689   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5690                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5691   coolingtuberot[3]->SetAngles(0.,90.,0.);
5692   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5693                                                                                                 *coolingtuberot[3]);
5694   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5695   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5696   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5697   
5698   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5699                                                                         endcapcoolingtubeshape[2]->GetDz());
5700   torustuberot[1]->SetAngles(0.,90.,0.); 
5701   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5702   torustuberot[2]->SetAngles(180.,0.,0.); 
5703   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5704   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5705
5706   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5707                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5708   torustuberot[3]->SetAngles(0.,90.,0.); 
5709   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5710   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5711   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5712   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5713
5714   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5715                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5716   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5717   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5718                                                                                                 *coolingtuberot[5]);
5719   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5720   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5721   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5722   
5723   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5724                                                                         endcapcoolingtubeshape[0]->GetDz());
5725   torustuberot[5]->SetAngles(0.,90.,0.); 
5726   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5727   torustuberot[6]->SetAngles(-90.,0.,0.); 
5728   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5729   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5730   
5731   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5732                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5733   coolingtuberot[6]->SetAngles(0.,90.,0.);
5734   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5735                                                                                                 *coolingtuberot[6]);
5736   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5737   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5738   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5739     /////////////////////////////////////////
5740   // Transformation for Water Volume Positioning 
5741   /////////////////////////////////////////
5742   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5743                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5744   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5745   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5746                                                                                                      *coolingwatertuberot[0]);
5747
5748   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5749   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5750   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5751                                                                                                      *coolingwatertuberot[1]);
5752
5753   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5754                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5755                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5756                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5757                                                                               0.);
5758   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5759   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5760                                                                                                     *coolingwatertuberot[2]);
5761
5762   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5763                                            *                                 (*coolingwatertubecombitrans[1]));
5764                                            
5765   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5766                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5767   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5768   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5769                                                                                                    *toruswatertuberot[0]);
5770
5771   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5772                                                   *                                     (*toruswatertubecombitrans[0]));
5773
5774   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5775                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5776   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5777   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5778                                                                                                      *coolingwatertuberot[3]);
5779   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5780   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5781                                                         *                                 (*coolingwatertubecombitrans[3]));
5782   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5783
5784   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5785                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5786   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5787   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5788                                                                                                    *toruswatertuberot[1]);
5789   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5790   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5791                                                   *                 (*toruswatertubecombitrans[1]));
5792   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5793   
5794   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5795                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5796   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5797   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5798                                                                                                    *toruswatertuberot[3]);
5799   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5800   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5801                                                   *                                     (*toruswatertubecombitrans[2]));
5802   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5803
5804   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5805                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5806   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5807   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5808                                                                                                      *coolingwatertuberot[5]);
5809   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5810   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5811                                                         *                                 (*coolingwatertubecombitrans[4]));
5812   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5813   
5814   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5815                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5816   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5817   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5818                                                                                                    *toruswatertuberot[5]);
5819   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5820   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5821                                                   *                 (*toruswatertubecombitrans[3]));
5822   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5823   
5824   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5825                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5826   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5827   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5828                                                                                                      *coolingwatertuberot[6]);
5829   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5830   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5831                                                         *                                 (*coolingwatertubecombitrans[5]));
5832   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5833   /////////////////////////////////////////
5834   // Positioning Volumes
5835   /////////////////////////////////////////
5836   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5837   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5838   
5839   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5840   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5841
5842   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5843   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5844  
5845   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5846   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5847
5848   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5849   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5850
5851   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5852   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5853
5854   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5855   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5856
5857   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5858   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5859   
5860   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5861   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5862  
5863   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5864   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5865   /////////////////////////////////////////////////////////////
5866   // Deallocating memory
5867   /////////////////////////////////////////////////////////////
5868   for(Int_t i=0; i<8; i++){
5869     if(i<6){
5870          delete coolingtubetrans[i];
5871          delete coolingwatertubetrans[i];
5872          if(i!=0){
5873           delete coolingtubecombitrans[i];
5874           delete coolingwatertubecombitrans[i];
5875          }
5876         }
5877     if(i<8){
5878           delete coolingtuberot[i];
5879           delete coolingwatertuberot[i];
5880     }
5881     if(i<4){
5882                 delete torustubetrans[i];
5883                 delete toruswatertubetrans[i];
5884                 delete torustubecombitrans[i];
5885                 delete toruswatertubecombitrans[i];
5886         } 
5887     if(i<7){
5888          delete torustuberot[i];
5889          delete toruswatertuberot[i];
5890         }
5891   }
5892   /////////////////////////////////////////////////////////////
5893   return endcapcoolingtubemother;
5894  }
5895  ////////////////////////////////////////////////////////////////////////////////
5896  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5897   /////////////////////////////////////////////////////////////
5898   // Getting EndCap Cover Side 
5899   /////////////////////////////////////////////////////////////
5900   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5901   const Int_t kvertexnumber = 15; 
5902   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5903   xvertex[0]  = 0.0;
5904   xvertex[1]  = xvertex[0];
5905   xvertex[2]  = fgkEndCapSideCoverLength[0];
5906   xvertex[3]  = fgkEndCapSideCoverLength[1];
5907   xvertex[4]  = xvertex[3];
5908   xvertex[5]  = fgkEndCapSideCoverLength[2];
5909   xvertex[6]  = xvertex[5];
5910   xvertex[7]  = xvertex[2];
5911   xvertex[8]  = xvertex[7];
5912   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5913   xvertex[10] = xvertex[9];
5914   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5915                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5916                           * fgkEndCapSideCoverLength[4];
5917   xvertex[12] = xvertex[11];
5918   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5919                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5920                           * fgkEndCapSideCoverLength[4];
5921   xvertex[14] = xvertex[13];
5922   yvertex[0]  = 0.0;
5923   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5924   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5925   yvertex[3]  = yvertex[2];
5926   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5927   yvertex[5]  = yvertex[4];
5928   yvertex[6]  = yvertex[0];
5929   yvertex[7]  = yvertex[6];
5930   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5931   yvertex[9]  = yvertex[8];
5932   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5933   yvertex[11] = yvertex[10];
5934   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5935   yvertex[13] = yvertex[12];
5936   yvertex[14] = yvertex[6];
5937   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5938   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5939   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5940   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5941   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5942   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5943   endcapsidecovershapein->SetName("endcapsidecovershapein");
5944   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5945   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5946   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5947
5948
5949   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5950   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5951                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5952   endcapsidecover->SetLineColor(fColorPhynox);
5953   ////////////////////////////////////////////
5954   // Defininition of Mother Volume
5955   ////////////////////////////////////////////
5956   const Int_t kmothervertexnumber = 7;
5957   Double_t xmothervertex[kmothervertexnumber]; 
5958   Double_t ymothervertex[kmothervertexnumber]; 
5959   for(Int_t i=0; i<kmothervertexnumber; i++){
5960         xmothervertex[i] = xvertex[i];
5961         ymothervertex[i] = yvertex[i];
5962   }
5963   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5964   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5965   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5966   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5967   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5968                                                                 endcapsidecovermothershape,fSSDAir);
5969   ////////////////////////////////////////////
5970   endcapsidecovermother->AddNode(endcapsidecover,1);
5971   TGeoBBox* endcapsidecoverboxshape[4];
5972   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5973                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5974                                                                0.5*fgkEndCapSideCoverLength[4],
5975                                                                    0.5*fgkEndCapSideCoverThickness); 
5976   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5977                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5978                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5979                                                          -     fgkEndCapSideCoverLength[4]),
5980                                                                    0.5*fgkEndCapSideCoverThickness); 
5981   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5982                                                                0.5*fgkEndCapSideCoverLength[4],
5983                                                                    0.5*fgkEndCapSideCoverThickness); 
5984   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5985                                                                0.5*fgkEndCapSideCoverWidth[5],
5986                                                                    0.5*fgkEndCapSideCoverThickness); 
5987   TGeoVolume* endcapsidecoverbox[4];
5988   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5989   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5990   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5991   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5992   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5993 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5994   TGeoTranslation** endcapsidecoverboxtrans;
5995   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5996   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5997                                                          +                                         fgkEndCapSideCoverLength[0],
5998                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5999                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
6000   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
6001                                                          +                     xvertex[11],
6002                                                                                                    endcapsidecoverboxshape[1]->GetDY()
6003                                                          +                     yvertex[12],0.);
6004   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
6005                                                          +                     xvertex[11],
6006                                                                                                    endcapsidecoverboxshape[2]->GetDY()
6007                                                          +                     yvertex[12]
6008                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
6009                                                          +                     fgkEndCapSideCoverWidth[5],0.);
6010   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
6011   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
6012   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
6013   for(Int_t i=0; i<2; i++)
6014         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
6015                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
6016                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
6017                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6018                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6019                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
6020                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
6021                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
6022         }
6023   for(Int_t i=0; i<2; i++)
6024         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
6025                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
6026                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
6027                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6028                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6029                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
6030                                                         +fgkEndCapSideCoverLength[4]),0.0);
6031                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
6032                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
6033                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
6034                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
6035         }
6036         return endcapsidecovermother;
6037  } 
6038  ////////////////////////////////////////////////////////////////////////////////
6039  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
6040  ////////////////////////////////////////////////////////////////////////////////
6041  // Method returning Interface Card A, Interface Card B, Supply Card 
6042  ////////////////////////////////////////////////////////////////////////////////
6043  /////////////////////
6044  // Supply Card
6045  /////////////////////
6046  // Electronic Board Back Al Plane
6047  const Int_t kelectboardbackvertexnumber = 8;
6048  Double_t xelectboardback[kelectboardbackvertexnumber];
6049  Double_t yelectboardback[kelectboardbackvertexnumber];
6050  xelectboardback[0] = 0.0;
6051  xelectboardback[1] = xelectboardback[0];
6052  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
6053  xelectboardback[3] = xelectboardback[2];
6054  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
6055  xelectboardback[5] = xelectboardback[4];
6056  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
6057  xelectboardback[7] = xelectboardback[6];
6058  
6059  yelectboardback[0] = 0.0;
6060  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
6061  yelectboardback[2] = yelectboardback[1];
6062  yelectboardback[3] = yelectboardback[0];
6063  yelectboardback[4] = yelectboardback[3];
6064  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
6065  yelectboardback[6] = yelectboardback[5];
6066  yelectboardback[7] = yelectboardback[4];
6067  TGeoXtru* electboardbackshape = new TGeoXtru(2);
6068  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
6069                                                                         xelectboardback,yelectboardback); 
6070  electboardbackshape->DefineSection(0,0.0);
6071  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
6072  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
6073                                                                                          electboardbackshape,fSSDSupportRingAl);
6074  electboardback->SetLineColor(fColorAl);
6075  // Electronic Board Kapton Layer
6076  const Int_t kelectlayervertexnumber = 8;
6077  Double_t xelectlayer[kelectlayervertexnumber];
6078  Double_t yelectlayer[kelectlayervertexnumber];
6079  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
6080  xelectlayer[1] = xelectlayer[0];
6081  xelectlayer[2] = fgkEndCapCardElectBoardLength;
6082  xelectlayer[3] = xelectlayer[2];
6083  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
6084      
6085  yelectlayer[0] = 0.0;
6086  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
6087  yelectlayer[2] = yelectlayer[1];
6088  yelectlayer[3] = yelectlayer[0];
6089  yelectlayer[4] = yelectlayer[3];
6090  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
6091  yelectlayer[6] = yelectlayer[5];
6092  yelectlayer[7] = yelectlayer[4];
6093  TGeoXtru* electlayershape = new TGeoXtru(2);
6094  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
6095  electlayershape->DefineSection(0,0.0);
6096  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
6097  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6098                                                                                          electlayershape,fSSDKaptonFlexMedium);
6099  electlayer->SetLineColor(fColorKapton);
6100  // JMD Connector Female
6101  const Int_t kjmdconnectorvertexnumber = 6;
6102  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6103  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6104  xjmdconnectorvertex[0] = 0.0; 
6105  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6106  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6107  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6108  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6109  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6110
6111  yjmdconnectorvertex[0] = 0.0; 
6112  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6113  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6114  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6115  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6116  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6117  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6118  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6119                                                                   yjmdconnectorvertex); 
6120  jmdconnectorshape->DefineSection(0,0.0);
6121  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6122  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6123                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6124  jmdconnector->SetLineColor(fColorG10);
6125  // Top Cable Connector
6126  const Int_t kcableconnectorvertexnumber = 8;
6127  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6128  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6129  xconnectorvertex[0] = 0.0;
6130  xconnectorvertex[1] = xconnectorvertex[0];
6131  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6132  xconnectorvertex[3] = xconnectorvertex[2];
6133  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6134                                          - fgkEndCapCardCableConnectorLength[2];
6135  xconnectorvertex[5] = xconnectorvertex[4];
6136  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6137  xconnectorvertex[7] = xconnectorvertex[6];
6138
6139  yconnectorvertex[0] = 0.0;
6140  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6141  yconnectorvertex[2] = yconnectorvertex[1];
6142  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6143  yconnectorvertex[4] = yconnectorvertex[3];
6144  yconnectorvertex[5] = yconnectorvertex[1];
6145  yconnectorvertex[6] = yconnectorvertex[5];
6146  yconnectorvertex[7] = yconnectorvertex[0];
6147  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6148  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6149                                                                     yconnectorvertex); 
6150  cableconnectorshape->DefineSection(0,0.0);
6151  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6152  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6153                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6154  cableconnector->SetLineColor(fColorG10);
6155  // Strip Connection
6156  TGeoBBox* endcapstripconnectionshape = 
6157                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6158                                                                                          0.5*fgkEndCapStripConnectionThickness,
6159                                                                                          0.5*fgkEndCapStripConnectionWidth);
6160  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6161                                                                                                         endcapstripconnectionshape,
6162                                                                                                         fSSDSupportRingAl);
6163  endcapstripconnection->SetLineColor(fColorAl);
6164  // Interface Card B
6165  const Int_t kcardBvertexnumber = 12; 
6166  Double_t xcardBvertexnumber[kcardBvertexnumber];
6167  Double_t ycardBvertexnumber[kcardBvertexnumber];
6168
6169  xcardBvertexnumber[0]  = 0.0;
6170  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6171  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6172  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6173  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6174  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6175  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6176  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6177  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6178  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6179  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6180  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6181  
6182  ycardBvertexnumber[0]  = 0.0;
6183  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6184  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6185  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6186  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6187  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6188  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6189  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6190  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6191  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6192  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6193  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6194
6195  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6196  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6197  interfacecardBshape->DefineSection(0,0.);
6198  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6199  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6200                                                                                          fSSDMountingBlockMedium);
6201  interfacecardB->SetLineColor(46);
6202  // Interface Card B Electronic Board
6203  const Int_t kelectboardcardBvertexnumber = 14; 
6204  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6205  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6206
6207  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6208  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6209  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6210  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6211  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6212  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6213  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6214  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6215  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6216  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6217  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6218  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6219  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6220  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6221
6222  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6223  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6224  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6225  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6226  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6227  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6228  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6229  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6230  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6231  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6232  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6233  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6234  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6235  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6236
6237  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6238  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6239                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6240  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6241  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6242                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6243  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6244                                                                                           fSSDSupportRingAl);
6245  electboardcardB->SetLineColor(fColorAl);
6246  // Generating Stiffener 2
6247  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6248                                                                                            0.5*fgkEndCapStiffenerThickness,
6249                                                                                            0.5*fgkEndCapStiffenerLength);
6250  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6251  endcapstiffener->SetLineColor(fColorAl);   
6252  // Generating Mother Interface Card B Container
6253  const Int_t kinterfacecardBmothervertexnumber = 10;
6254  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6255  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6256
6257  xinterfacecardBmothervertex[0] = 0.0;
6258  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6259  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6260                                                                 + fgkEndCapInterfaceCardBThickness;
6261  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6262  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6263                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6264  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6265  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6266  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6267  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6268                                                                 + fgkEndCapCardJMDConnectorLength[0];
6269  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6270
6271  yinterfacecardBmothervertex[0] = 0.0;
6272  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6273                                                                 + fgkEndCapInterfaceCardBWidth[1]
6274                                                                 + fgkEndCapInterfaceCardBWidth[2];
6275  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6276  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6277  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6278  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6279  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6280  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6281                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6282                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6283  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6284  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6285  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6286  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6287                                                                                   xinterfacecardBmothervertex,
6288                                                                                   yinterfacecardBmothervertex);
6289  interfacecardBmothershape->DefineSection(0,-1.e-15);
6290  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6291  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6292                                                                                                    interfacecardBmothershape,fSSDAir);
6293  electboardcardB->SetLineColor(fColorAl);
6294  // Positioning Volumes Mother Interface Card B Container 
6295  TGeoRotation* interfacecardBrot = new TGeoRotation();
6296  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6297  interfacecardBrot->SetAngles(90.,-90.,-90.);
6298  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6299  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6300  TGeoRotation* electboardcardBrot = new TGeoRotation();
6301  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6302  electboardcardBrot->SetAngles(90.,90.,-90.);
6303  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6304  TGeoCombiTrans* electboardcardBcombitrans = 
6305                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6306  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6307  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6308  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6309  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6310  TGeoTranslation* jmdconnectorcardBtrans[3];
6311  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6312  for(Int_t i=0; i<3; i++){
6313    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6314                                                          + fgkEndCapCardJMDConnectorLength[0], 
6315                                                            fgkEndCapCardElectBoardLayerWidth[1],
6316                                                            0.5*fgkEndCapCardJMDConnectorThickness
6317                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6318                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6319                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6320    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6321                                                                                                            *jmdconnectorcardBrot);
6322    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6323  }
6324  // Mother Supply Card Container 
6325  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6326  // Interface Card Container
6327  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6328  // Placing Volumes in Mother Supply Card Container
6329  // JMD Connector Positioning
6330  TGeoTranslation* jmdconnectortrans[2];
6331  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6332  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6333                                                                                         fgkEndCapCardElectBoardBackLength[0]
6334                                           -                                             fgkEndCapCardJMDConnectorThickness
6335                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6336  TGeoRotation* jmdconnectorot = new TGeoRotation();
6337  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6338                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6339                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6340                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6341                                                                       fgkEndCapCardJMDConnectorThickness
6342                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6343  jmdconnectorot->SetAngles(90.,180.,-90);
6344  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6345                                                                                 * jmdconnectorot);
6346  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6347  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6348  // Top Cable Connector Placing
6349  TGeoRotation* cableconnectorot[2];
6350  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6351  TGeoTranslation* cableconnectortrans[3];
6352  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6353  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6354  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6355  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6356  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6357                                                                                                                            *cableconnectorot[0]);
6358  TGeoHMatrix* cableconnectormatrix[2];
6359  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6360                                                         new TGeoHMatrix((*cableconnectorot[1])
6361                                                                                    *(*cableconnectorcombitrans));
6362  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6363                                            -                               fgkEndCapCardCableConnectorThickness,
6364                                                                                 fgkEndCapCardCableConnectorLength[0]
6365                                            +                            fgkEndCapCardCableConnectorToLayer);
6366  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6367                                            -                2.*fgkEndCapCardCableConnectorThickness
6368                                            -                            fgkEndCapCardCableConnectorDistance,
6369                                                                                 fgkEndCapCardCableConnectorLength[0]
6370                                            +                            fgkEndCapCardCableConnectorToLayer);
6371  for(Int_t i=0; i<2; i++){
6372         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6373     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6374  }
6375  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6376  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6377  electboardbackrot->SetAngles(90.,-90.,-90.);
6378  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6379                                                         +                fgkEndCapCardJMDConnectorLength[0]
6380                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6381  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6382                                                                                                                            *electboardbackrot);
6383  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6384  // Electronic Board Kapton Layer Positioning
6385  TGeoRotation* electlayerrot = new TGeoRotation();
6386  TGeoTranslation* electlayertrans[2];
6387  TGeoCombiTrans* electlayercombitrans[2];
6388  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6389  electlayerrot->SetAngles(90.,-90.,-90.);
6390  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6391                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6392  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6393                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6394                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6395  for(Int_t i=0; i<2; i++){
6396         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6397         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6398  }
6399  // Placing Volumes in Mother Interface Card Container
6400  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6401  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6402  for(Int_t i=0; i<2; i++){
6403         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6404  }
6405  /////////////////////////////////////////////////////////////
6406  // Generation of Card Interface Container
6407  /////////////////////////////////////////////////////////////
6408  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6409                                                   - fgkEndCapCardJMDConnectorLength[0]
6410                                                   - fgkEndCapInterfaceCardBThickness
6411                                                   - 9.*fgkEndCapStripConnectionThickness
6412                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6413  const Int_t kcardinterfacecontainervertexnumber = 14;
6414  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6415  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6416  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6417                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6418  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6419  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6420                                                                    + fgkEndCapStripConnectionThickness
6421                                                                    - fgkEndCapCardElectBoardLayerThickness
6422                                                                    - fgkEndCapCardCableConnectorWidth[0];
6423  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6424  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6425  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6426  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6427                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6428  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6429  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6430                                                                    + fgkEndCapInterfaceCardBThickness;
6431  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6432  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6433                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6434  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6435  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6436                                    - fgkEndCapInterfaceElectBoardCardBThickness
6437                                                                    + fgkEndCapCardJMDConnectorLength[0]
6438                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6439  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6440
6441  ycardinterfacecontainervertex[0]  = 0.;
6442  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6443                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6444                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6445  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6446  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6447                                                                    - fgkEndCapStripConnectionWidth;
6448  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6449  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6450  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6451  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6452                                                                    + fgkEndCapInterfaceCardBWidth[1]
6453                                                                    + fgkEndCapInterfaceCardBWidth[2];
6454  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6455  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6456  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6457  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6458  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6459  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6460  
6461  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6462  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6463                                                                                   xcardinterfacecontainervertex,
6464                                                                                   ycardinterfacecontainervertex);
6465  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6466                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6467  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6468                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6469  TGeoVolume** cardinterfacecontainer;
6470  cardinterfacecontainer = new TGeoVolume*[4];
6471  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6472                                                                                         interfacecardmothershape,fSSDAir); 
6473  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6474                                                                                         interfacecardmothershape,fSSDAir); 
6475  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6476                                                                                         interfacecardmothershape,fSSDAir); 
6477  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6478                                                                                         interfacecardmothershape,fSSDAir); 
6479  /////////////////////////////////
6480  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6481  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6482  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6483  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6484  /////////////////////////////////
6485  TGeoRotation* endcapstripconnectionrot[2];
6486  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6487  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6488  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6489  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6490                                                                         *                                 (*endcapstripconnectionrot[0]));
6491  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6492  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6493                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6494                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6495                                                                                         -endcapstripconnectionshape->GetDZ(),
6496                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6497  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6498  TGeoTranslation* cardinterfacetrans[9];
6499  TGeoHMatrix* cardinterfacematrix[9]; 
6500  for(Int_t i=0; i<7; i++){ 
6501         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6502                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6503                                                                                                 0.0,0.0);  
6504         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6505                                                    *                             (*endcapstripconnectionmatrix));
6506  }
6507  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6508                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6509                                                                                                 0.0,0.0);  
6510  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6511                                                 *                                 (*endcapstripconnectionmatrix));
6512  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6513                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6514                                                                                                 0.0,0.0);  
6515  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6516                                                 *                                 (*endcapstripconnectionmatrix));
6517
6518  for(Int_t i=0; i<4; i++){
6519         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6520                                                                            cardinterfacematrix[7]);                             
6521         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6522                                                                            cardinterfacematrix[8]);                             
6523  }
6524  TGeoTranslation* mothersupplycardtrans = 
6525                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6526                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6527                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6528  TGeoHMatrix* mothersupplycardmatrix[7];
6529  Int_t index[4] = {1,1,1,1};
6530  for(Int_t i=0; i<7; i++){
6531         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6532                                                         *                                 (*mothersupplycardtrans));
6533         for(Int_t j=0; j<4; j++){
6534                 switch(j){
6535                         case 0: //Layer5 EndCap Left Side  
6536                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6537                                                                                                    cardinterfacematrix[i]);                             
6538                                 if(i!=0){
6539                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6540                                                                                                            mothersupplycardmatrix[i]);                  
6541                                         index[j]++;
6542
6543                                 }
6544                         break;
6545                         case 1: //Layer5 EndCap Rigth Side  
6546                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6547                                                                                                    cardinterfacematrix[i]);                     
6548                                 if(i>0&&i<6){
6549                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6550                                                                                                            mothersupplycardmatrix[i]);                  
6551                                         index[j]++;
6552                                 }
6553                         break;
6554                         case 2: //Layer6 EndCap Left Side  
6555                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6556                                                                                                    cardinterfacematrix[i]);                             
6557                                 if(i!=6){
6558                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6559                                                                                                            mothersupplycardmatrix[i]);                  
6560                                         index[j]++;
6561                                 }
6562                         break;
6563                         case 3: //Layer6 EndCap Right Side  
6564                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6565                                                                                                    cardinterfacematrix[i]);                             
6566                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6567                                                                                                    mothersupplycardmatrix[i]);                  
6568                                 index[j]++;
6569                         break;
6570                 }
6571         }
6572  }
6573  // Positioning Interface 
6574  TGeoTranslation* motherinterfacecardtrans = 
6575                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6576                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6577                                                          -fgkEndCapCardElectBoardLayerThickness
6578                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6579  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6580                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6581  // Positioning Interface Card B 
6582  TGeoTranslation* interfacecardBmothertrans = 
6583                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6584                                                                                 + 2.*fgkEndCapStripConnectionThickness
6585                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6586                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6587                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6588  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6589                                                                                                                          interfacecardBmothertrans);
6590  // Positioning Stiffener 
6591  TGeoTranslation* endcapstiffenertrans = 
6592                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6593                                                                            +    2.0*fgkEndCapStripConnectionThickness
6594                                                                            +    fgkEndCapInterfaceCardBThickness
6595                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6596                                                                            +    stiffenertransx
6597                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6598                                                                                         endcapstiffenershape->GetDZ()
6599                                                                            -    0.5*(fgkEndCapStiffenerLength
6600                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6601  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6602  /////////////////////////////////////////////////////////////
6603  // Deallocating memory
6604  /////////////////////////////////////////////////////////////
6605  delete interfacecardBrot;
6606  delete interfacecardBtrans;
6607  delete electboardcardBtrans;
6608  delete electboardcardBrot; 
6609  delete jmdconnectorcardBrot;
6610  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6611  delete jmdconnectorot;
6612  delete jmdconnectortrans[1];
6613  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6614  delete cableconnectorcombitrans;
6615  delete electboardbacktrans;
6616  delete electboardbackrot;
6617  delete electlayerrot;
6618  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6619  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6620  delete mothersupplycardtrans;
6621  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6622  /////////////////////////////////////////////////////////////
6623  return cardinterfacecontainer;
6624  }
6625  ////////////////////////////////////////////////////////////////////////////////
6626  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6627   /////////////////////////////////////////////////////////////
6628   // Method returning EndCap Mother Volume
6629   /////////////////////////////////////////////////////////////
6630   const Int_t kendcapcoverplatesmallholenumber = 9;
6631   Double_t endcapmotherorigin[3];
6632   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6633                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6634                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6635   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6636                                           -                      fgkEndCapCoverPlateWidth[2]
6637                                           -       (kendcapcoverplatesmallholenumber-1)
6638                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6639                                           +  0.5*(fgkEndCapSideCoverLength[2]
6640                                           +               fgkEndCapCoverPlateWidth[1]
6641                                           -       fgkEndCapCoverPlateWidth[0])
6642                                           -      (fgkEndCapCoverPlateWidth[1]
6643                                           -       fgkEndCapCoverPlateWidth[0]);
6644   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6645                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6646                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6647                                                 +      fgkEndCapSideCoverWidth[1]
6648                                                 +      fgkEndCapSideCoverThickness
6649                                                 +      fgkEndCapKaptonFoilThickness);
6650   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6651                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6652                                                           +              2.0* fgkEndCapSideCoverThickness),
6653                                                                          0.5* (fgkEndCapSideCoverLength[2]
6654                                                           +                    fgkEndCapCoverPlateWidth[1]
6655                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6656                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6657                                                       +                                    fgkEndCapSideCoverWidth[1]
6658                                                           +                                       fgkEndCapSideCoverThickness
6659                                                       +                                   fgkEndCapKaptonFoilThickness),
6660                                                                                          endcapmotherorigin);
6661   TGeoVolume** endcapassembly;  
6662   endcapassembly = new TGeoVolume*[4];
6663   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6664                                                                                         endcapmothershape,fSSDAir); 
6665   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6666                                                                                         endcapmothershape,fSSDAir); 
6667   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6668                                                                                         endcapmothershape,fSSDAir); 
6669   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6670                                                                                         endcapmothershape,fSSDAir); 
6671  /////////////////////////////////
6672  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6673  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6674  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6675  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6676  /////////////////////////////////
6677   /////////////////////////////////////////////////////
6678   // Placing Endcap Cover Plate
6679   /////////////////////////////////////////////////////
6680   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6681   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6682   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6683   TGeoCombiTrans* endcapcoverplatecombitrans = 
6684                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6685                                                                                          endcapcoverplaterot);
6686   TGeoTranslation* endcapcoverplatetrans = 
6687                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6688   TGeoHMatrix* endcapcoverplatematrix = 
6689                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6690                                                                           *       (*endcapcoverplatecombitrans));
6691   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6692   /////////////////////////////////////////////////////
6693   // Placing Endcap Side Cover
6694   /////////////////////////////////////////////////////
6695   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6696   TGeoRotation* endcapsidecoverot[2];
6697   TGeoCombiTrans* endcapsidecovercombitrans[3];
6698   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6699   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6700   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6701                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6702                                                                                         - fgkEndCapCoverPlateWidth[2]
6703                                                                                     - (kendcapcoverplatesmallholenumber-1)
6704                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6705                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6706                                                                                         + fgkEndCapSideCoverLength[2],
6707                                                                                           0.5*(fgkEndCapSideCoverThickness
6708                                                                                         + fgkEndCapCoverPlateThickness)
6709                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6710                                                                                           endcapsidecoverot[0]);
6711   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6712   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6713                                                                                                         0.5*fgkEndCapCoverPlateThickness
6714                                                                                                         -fgkEndCapSideCoverWidth[1],
6715                                                                                                         endcapsidecoverot[1]);
6716   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6717                                                                                                         +fgkEndCapCoverPlateLength[3]
6718                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6719                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6720                                                                                                         0.5*fgkEndCapCoverPlateThickness
6721                                                                                                         -fgkEndCapSideCoverWidth[1],
6722                                                                                                         endcapsidecoverot[1]);
6723   TGeoHMatrix* endcapsidecovermatrix[2];
6724   for(Int_t i=0; i<2; i++){
6725    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6726                                                         *                                 (*endcapsidecovercombitrans[0]));
6727         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6728                                                                                                                 endcapsidecovermatrix[i]);
6729   }
6730   /////////////////////////////////////////////////////
6731   // Placing Endcap Cooling Tube
6732   /////////////////////////////////////////////////////
6733   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6734   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6735   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6736   TGeoCombiTrans* endcapccolingtubecombitrans 
6737                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6738                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6739                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6740                                                 - fgkEndCapCoolingTubeToCoverSide,
6741                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6742                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6743   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6744                                                                                                           endcapccolingtubecombitrans);
6745   /////////////////////////////////////////////////////
6746   // Placing Screws 
6747   /////////////////////////////////////////////////////
6748   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6749                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6750   Int_t screwcoverplatedgesnumber[2] = {20,20};
6751   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6752                                                                                 fgkEndCapCoverPlateThickness
6753                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6754   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6755                                                                                                  screwcoverplatedgesnumber,
6756                                                                                                  screwcoverplatesection);
6757   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6758                                                                                            screwcoverplateshape,
6759                                                                                            fSSDCoolingTubePhynox); 
6760   screwcoverplate->SetLineColor(12);
6761   Double_t transx[4] = {0,
6762                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6763                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6764                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6765                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6766                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6767   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6768 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6769   TGeoTranslation*** endcapcoverplatescrewtrans;
6770   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6771   Int_t index = 0;
6772   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6773         endcapcoverplatescrewtrans[i] = 
6774                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6775     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6776                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6777         if(index==1||index==9||index==28||index==36){
6778                         endcapcoverplatescrewtrans[i][j] = 
6779                                 new TGeoTranslation(transx[i],
6780                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6781                                                                         fgkEndCapSideCoverThickness);
6782                 }
6783                 else{
6784                         endcapcoverplatescrewtrans[i][j] = 
6785                                 new TGeoTranslation(transx[i],
6786                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6787                                                                         0.);
6788                 }
6789             if(index!=19) 
6790                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6791                                                                                           endcapcoverplatescrewtrans[i][j]);
6792         }
6793   }
6794   /////////////////////////////////////////////////////
6795   // Placing Cover Plate Clips 
6796   /////////////////////////////////////////////////////
6797   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6798                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6799                                                                                                          0.5*fgkEndCapSideCoverThickness);
6800   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6801                                                                                                         endcapcoverplateclipshape,
6802                                                                                                         fSSDCoolingTubePhynox);
6803   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6804                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6805                                                                                                          0.5*fgkEndCapSideCoverThickness);
6806   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6807                                                                                                         endcapcoverplatedownclipshape,
6808                                                                                                         fSSDCoolingTubePhynox);
6809   TGeoTranslation* endcapcoverplatecliptrans[4];
6810   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6811                                                            -                     fgkEndCapCoverPlateLength[0]
6812                                                            -                     fgkEndCapSideCoverThickness,
6813                                                                                                          0.0,
6814                                                                                                  0.5*(fgkEndCapSideCoverThickness
6815                                                            +                                              fgkEndCapCoverPlateThickness));
6816   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6817                                                            -                     fgkEndCapCoverPlateLength[0]
6818                                                            -                     fgkEndCapSideCoverThickness,
6819                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6820                                                            *                                     fgkEndCapSideCoverWidth[5],
6821                                                                                                  0.5*(fgkEndCapSideCoverThickness
6822                                                            +                                              fgkEndCapCoverPlateThickness));
6823   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6824                                                            -                     fgkEndCapCoverPlateLength[0]
6825                                                            +                                     fgkEndCapCoverPlateLength[1]
6826                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6827                                                            -                                     fgkEndCapCoverPlateClipLength
6828                                                            +                                 fgkEndCapSideCoverThickness,
6829                                                                                                          0.0,
6830                                                                                                  0.5*(fgkEndCapSideCoverThickness
6831                                                            +                                              fgkEndCapCoverPlateThickness));
6832   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6833                                                            -                     fgkEndCapCoverPlateLength[0]
6834                                                            +                                     fgkEndCapCoverPlateLength[1]
6835                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6836                                                            -                                     fgkEndCapCoverPlateClipLength
6837                                                            +                                 fgkEndCapSideCoverThickness,
6838                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6839                                                            *                                     fgkEndCapSideCoverWidth[5],
6840                                                                                                  0.5*(fgkEndCapSideCoverThickness
6841                                                            +                                              fgkEndCapCoverPlateThickness));
6842   endcapcoverplateclip->SetLineColor(fColorPhynox);
6843   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6844   for(Int_t i=0; i<4; i++) 
6845         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6846                                                                                                    endcapcoverplatecliptrans[i]);  
6847   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6848   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6849                                                                    -                     fgkEndCapCoverPlateLength[0]
6850                                                                    -                     fgkEndCapSideCoverThickness,
6851                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6852                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6853                                                                                                         0.5*(fgkEndCapSideCoverThickness
6854                                                                +                                         fgkEndCapCoverPlateThickness)
6855                                                                    -                     fgkEndCapSideCoverWidth[1]
6856                                                                    -                                     fgkEndCapSideCoverThickness);
6857   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6858                                                                    -                     fgkEndCapCoverPlateLength[0]
6859                                                                    -                     fgkEndCapSideCoverThickness,
6860                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6861                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6862                                                                    +                            fgkEndCapSideCoverLength[2]
6863                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6864                                                                                                         0.5*(fgkEndCapSideCoverThickness
6865                                                                +                                         fgkEndCapCoverPlateThickness)
6866                                                                    -                     fgkEndCapSideCoverWidth[1]
6867                                                                    -                                     fgkEndCapSideCoverThickness);
6868   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6869                                                                    -                     fgkEndCapCoverPlateLength[0]
6870                                                                    +                     fgkEndCapSideCoverThickness
6871                                                                    +                     fgkEndCapCoverPlateLength[1]
6872                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6873                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6874                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6875                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6876                                                                                                         0.5*(fgkEndCapSideCoverThickness
6877                                                                +                                         fgkEndCapCoverPlateThickness)
6878                                                                    -                     fgkEndCapSideCoverWidth[1]
6879                                                                    -                                     fgkEndCapSideCoverThickness);
6880   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6881                                                                    -                     fgkEndCapCoverPlateLength[0]
6882                                                                    +                     fgkEndCapSideCoverThickness
6883                                                                    +                     fgkEndCapCoverPlateLength[1]
6884                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6885                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6886                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6887                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6888                                                                    +                                 fgkEndCapSideCoverLength[2]
6889                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6890                                                                                                         0.5*(fgkEndCapSideCoverThickness
6891                                                                +                                         fgkEndCapCoverPlateThickness)
6892                                                                    -                     fgkEndCapSideCoverWidth[1]
6893                                                                    -                                     fgkEndCapSideCoverThickness);
6894   for(Int_t i=0; i<4; i++)
6895         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6896                                                                                                    endcapcoverplatedowncliptrans[i]);
6897   /////////////////////////////////////////////////////
6898   // Placing Kapton Foil
6899   /////////////////////////////////////////////////////
6900   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6901                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6902                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6903   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6904                                                                                                 endcapkaptonfoilshape,
6905                                                                                                 fSSDKaptonFlexMedium);
6906   endcapkaptonfoil->SetLineColor(8);
6907   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6908                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6909                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6910                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6911                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6912                                                                              -                     fgkEndCapSideCoverWidth[1]
6913                                                                                  -                     fgkEndCapSideCoverThickness);
6914   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6915   /////////////////////////////////////////////////////////////
6916   // Placing Electronic Tubes
6917   /////////////////////////////////////////////////////////////
6918   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6919                                                                              - fgkEndCapInterfaceCardBThickness
6920                                                                              - 9.*fgkEndCapStripConnectionThickness
6921                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6922                                                                                fgkEndCapKaptonFoilWidth
6923                                                                              - fgkEndCapInterfaceCardBThickness
6924                                                                              - 9.*fgkEndCapStripConnectionThickness
6925                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6926                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6927   TGeoVolume* endcapeffectivecables[2];
6928   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6929                                                                                          fgkEndCapEffectiveCableRadiusMax,
6930                                                                                          endcapeffectivecableswidth[0],
6931                                                                                          10,"EndCapEffectiveCables1"); 
6932   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6933                                                                                          fgkEndCapEffectiveCableRadiusMax,
6934                                                                                          endcapeffectivecableswidth[1],
6935                                                                                          25,"EndCapEffectiveCables2"); 
6936   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6937   TGeoTranslation* endcapeffectivecablestrans[2];
6938   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6939                                           -                                                        0.5*endcapeffectivecableswidth[0]
6940                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6941                                           -                                                               fgkEndCapCoverPlateWidth[2]
6942                                           -                                             (kendcapcoverplatesmallholenumber-1)
6943                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6944                                           +                                             fgkEndCapSideCoverLength[2],
6945                                           -                     0.5*fgkEndCapCoverPlateThickness
6946                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6947                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6948                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6949   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6950                                           -                                                        0.5*endcapeffectivecableswidth[1]
6951                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6952                                           -                                                               fgkEndCapCoverPlateWidth[2]
6953                                           -                                             (kendcapcoverplatesmallholenumber-1)
6954                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6955                                           +                                         fgkEndCapSideCoverLength[2],
6956                                           -                     0.5*fgkEndCapCoverPlateThickness
6957                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6958                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6959                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6960   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6961   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6962   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6963                                                                                                                    *endcapeffectivecablesrot);
6964   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6965                                                                                                                    *endcapeffectivecablesrot);
6966 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6967 //                                                                                                        endcapeffectivecablescombitrans[0]);
6968   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6969                                                                                                           endcapeffectivecablescombitrans[1]);
6970   /////////////////////////////////////////////////////////////
6971   // Placing End Cap Cards
6972   /////////////////////////////////////////////////////////////
6973   TGeoVolume** endcapcards = GetEndCapCards();
6974   TGeoRotation* endcapcardsrot[2];
6975   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6976   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6977   TGeoTranslation* endcapcardstrans[2]; 
6978   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6979                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6980   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6981   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6982   TGeoHMatrix* endcapcardsmatrix[2];
6983   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6984   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6985                                                   - fgkEndCapCardJMDConnectorLength[0]
6986                                                   - fgkEndCapInterfaceCardBThickness
6987                                                   - 9.*fgkEndCapStripConnectionThickness
6988                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6989   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6990                                           -                                             fgkEndCapCoverPlateLength[0]
6991                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6992                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6993                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6994                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6995                                           -                                                               fgkEndCapInterfaceCardBThickness
6996                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6997                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6998                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6999                                           -                                                               fgkEndCapCoverPlateWidth[2]
7000                                           -                                             (kendcapcoverplatesmallholenumber-1)
7001                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7002                                           +                     fgkEndCapKaptonFoilWidth,
7003                                                                                           0.5*fgkEndCapCoverPlateThickness
7004                                           -                                                     fgkEndCapSideCoverWidth[1]);
7005   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
7006   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
7007    /////////////////////////////////////////////////////////////
7008   // Deallocating memory
7009   /////////////////////////////////////////////////////////////
7010   delete endcapcoverplaterot;
7011   delete endcapcoverplatecombitrans;
7012   delete endcapcoverplatetrans;
7013   for(Int_t i=0; i<3; i++){
7014    delete endcapsidecovercombitrans[i];
7015    if(i<2) delete endcapsidecoverot[i]; 
7016   }
7017   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
7018   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
7019   delete endcapcardsmatrix[0];
7020   return endcapassembly;
7021  } 
7022  ////////////////////////////////////////////////////////////////////////////////
7023  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
7024                                                                                                                         Double_t radiusmax, 
7025                                                                                                                         Double_t width, 
7026                                                                                                                         Int_t ncables,
7027                                                                                                                         const char* volname){
7028   /////////////////////////////////////////////////////////////
7029   // Generating EndCap High Voltage Tubes 
7030   /////////////////////////////////////////////////////////////
7031   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
7032   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
7033
7034   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
7035   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
7036                                                                                                    effectiveouteradius,0.5*width);
7037   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
7038                                                                                                 effectiveinnertubeshape,
7039                                                                                                 fSSDStiffenerConnectorMedium);
7040   effectiveinnertube->SetLineColor(41);
7041   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
7042                                                                                                 effectiveoutertubeshape,
7043                                                                                                 fSSDKaptonChipCableMedium);
7044   effectiveoutertube->SetLineColor(39);
7045   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
7046   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
7047   effectivemothertube->AddNode(effectiveinnertube,1);
7048   effectivemothertube->AddNode(effectiveoutertube,1);
7049   return effectivemothertube;
7050  } 
7051  ////////////////////////////////////////////////////////////////////////////////
7052  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
7053   /////////////////////////////////////////////////////////////
7054   // Generating EndCap Support Layer 5 and Layer 6 
7055   /////////////////////////////////////////////////////////////
7056   const Int_t knedges = 5;
7057   ///////////////////////////////////////////////
7058   // Setting the vertices for TGeoXtru Up Volume
7059   ///////////////////////////////////////////////
7060   const Int_t klayernumber = 2;
7061   Double_t xupvertex[klayernumber][knedges+3];
7062   Double_t yupvertex[klayernumber][knedges+3];
7063   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
7064   Double_t middledgeangle[klayernumber] = {0.0,0.0};
7065   Double_t middlepsi[klayernumber] = {0.0,0.0};
7066   for(Int_t i=0; i<klayernumber; i++){
7067         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
7068         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
7069         xupvertex[i][2] = -xupvertex[i][1];
7070         xupvertex[i][3] = -xupvertex[i][0];
7071
7072         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
7073         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
7074         yupvertex[i][2] =  yupvertex[i][1];
7075         yupvertex[i][3] =  yupvertex[i][0];
7076         
7077     middledgeangle[i] = upedgeangle[i]/knedges;
7078     middlepsi[i] = 90.0-0.5*upedgeangle[i];
7079     for(Int_t j=1; j<knedges; j++){
7080                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
7081                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
7082         }
7083   }
7084   ////////////////////////////////////
7085   // Generating Up TGeoXtru
7086   ////////////////////////////////////
7087   TGeoXtru* upendcapsupportshape[klayernumber];
7088   TGeoVolume* upendcapsupport[klayernumber]; 
7089   char upendcapsupportname[100]; 
7090   for(Int_t i=0; i<klayernumber; i++){
7091    upendcapsupportshape[i] = new TGeoXtru(2);
7092    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
7093    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
7094    upendcapsupportshape[i]->DefineSection(0,0.);
7095    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7096    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7097                                                                         fSSDSupportRingAl);
7098    upendcapsupport[i]->SetLineColor(5);
7099   }
7100   ///////////////////////////////////////////////
7101   // Setting the vertices for TGeoXtru Down Volume
7102   ///////////////////////////////////////////////
7103   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7104   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7105   for(Int_t i=0; i<klayernumber; i++){
7106         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7107         xdownvertex[i][1] =  xupvertex[i][0];
7108         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7109         ydownvertex[i][1] =  yupvertex[i][0];
7110         for(Int_t j=0; j<knedges; j++){
7111                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7112                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7113         } 
7114         for(Int_t j=0; j<knedges; j++){
7115                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7116                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7117                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7118                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7119         }
7120   }
7121   ////////////////////////////////////
7122   // Generating Down TGeoXtru
7123   ////////////////////////////////////  
7124   TGeoXtru* downendcapsupportshape[klayernumber];
7125   TGeoVolume* downendcapsupport[klayernumber]; 
7126   char downendcapsupportname[100]; 
7127   for(Int_t i=0; i<klayernumber; i++){
7128         downendcapsupportshape[i] = new TGeoXtru(2);
7129     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7130         downendcapsupportshape[i] = new TGeoXtru(2);
7131         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7132     if(i==0){
7133                 downendcapsupportshape[i]->DefineSection(0,0.);
7134                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7135     }
7136         else{
7137                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7138                                                                  -                 fgkEndCapSupportLowWidth[i]);
7139                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7140         }
7141     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7142                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7143         downendcapsupport[i]->SetLineColor(5);
7144   }
7145   ///////////////////////////////////////////////
7146   // Setting TGeoPgon Volume
7147   ///////////////////////////////////////////////
7148   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7149                                                                                                    fgkSSDLay6LadderNumber};
7150   TGeoPgon* endcapsupportmothershape[klayernumber];
7151   TGeoVolume** endcapsupportmother;
7152   endcapsupportmother = new TGeoVolume*[klayernumber];
7153   char endcapsupportmothername[100];
7154   for(Int_t i=0; i<klayernumber; i++){
7155         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7156     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7157         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7158     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7159                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7160     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7161                                                                                         fSSDAir);       
7162   }
7163   ////////////////////////////////////
7164   TGeoRotation** endcapsupportrot[klayernumber];
7165   for(Int_t i=0; i<2; i++){
7166         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7167         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7168            endcapsupportrot[i][j] = new TGeoRotation();
7169            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7170        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7171        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7172         }
7173   }
7174   return endcapsupportmother;
7175  } 
7176  ////////////////////////////////////////////////////////////////////////////////
7177  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7178   /////////////////////////////////////////////////////////////
7179   // Setting End Cap Support Layer 5 and 6. 
7180   /////////////////////////////////////////////////////////////
7181   const Int_t kendcapcoverplatesmallholenumber = 9;
7182   const Int_t klayernumber = 2;
7183   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7184                                                                                                    fgkSSDLay6LadderNumber};
7185   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7186                                                                                 360.0/kssdlayladdernumber[1]};
7187   TGeoVolume** endcapsupport = EndCapSupport();
7188   TGeoVolume** endcapassembly = GetEndCapAssembly();
7189   TGeoPgon* endcapsupportshape[klayernumber];
7190   Double_t* radiusmin[klayernumber];
7191   Double_t* radiusmax[klayernumber];
7192   for(Int_t i=0; i<klayernumber; i++){
7193     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7194         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7195         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7196   }  
7197   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7198   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7199                                                                           endcapassemblyshape->GetDY(),
7200                                                                           endcapassemblyshape->GetDZ()};
7201   ///////////////////////////////////////////////
7202   // Setting TGeoPgon Volume for Mother Container
7203   ///////////////////////////////////////////////
7204   TGeoPgon* endcapsupportsystemshape[klayernumber];
7205   char endcapsupportsystemothername[100];
7206   for(Int_t i=0; i<klayernumber; i++){
7207         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7208     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7209         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7210                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7211                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7212                                                                                            +2.*endcapassemblycenter[2])
7213                                                                                            /CosD(0.5*upedgeangle[i]));  
7214     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7215                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7216                                                                                              - fgkEndCapCoverPlateWidth[0]),
7217                                                                                            *radiusmin[i],
7218                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7219                                                                                            +2.*endcapassemblycenter[2])
7220                                                                                            /CosD(0.5*upedgeangle[i]));
7221   }
7222   fgkEndCapSupportSystem = new TGeoVolume*[4];
7223   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7224                                                                           endcapsupportsystemshape[0],fSSDAir); 
7225   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7226                                                                           endcapsupportsystemshape[0],fSSDAir); 
7227   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7228                                                                           endcapsupportsystemshape[1],fSSDAir); 
7229   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7230                                                                           endcapsupportsystemshape[1],fSSDAir); 
7231   ///////////////////////////////////////////////
7232   TGeoTranslation* endcapassemblytrans[klayernumber];
7233   for(Int_t i=0; i<klayernumber; i++)
7234         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7235                                                                            -  fgkEndCapSideCoverThickness
7236                                                                            +  endcapassemblycenter[0],
7237                                                                            -  0.5*fgkEndCapCoverPlateThickness
7238                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7239                                                                            +  2.0*endcapassemblycenter[2]
7240                                                                            +  0.5*fgkEndCapSupportLength[i]
7241                                                                            /  TanD(0.5*upedgeangle[i]),
7242                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7243                                                                            -  fgkEndCapCoverPlateWidth[2]
7244                                                                            - (kendcapcoverplatesmallholenumber-1)
7245                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7246   TGeoRotation** endcapassemblyrot[klayernumber];
7247   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7248   for(Int_t i=0; i<klayernumber; i++){
7249    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7250    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7251    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7252    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7253    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7254    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7255    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7256    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7257         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7258         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7259    }
7260   }
7261   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7262                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7263   for(Int_t i=0; i<2*klayernumber; i++){
7264         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7265                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7266                                                                                                                                            endcapassemblymatrix[1][j+2]);
7267         }
7268         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7269   }
7270    /////////////////////////////////////////////////////////////
7271   // Deallocating memory
7272   /////////////////////////////////////////////////////////////
7273   for(Int_t i=0; i<klayernumber; i++){
7274         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7275                 delete endcapassemblyrot[i][j];
7276         }
7277         delete endcapassemblyrot[i];
7278         delete endcapassemblymatrix[i][0];
7279         delete endcapassemblymatrix[i][1];
7280   }
7281   /////////////////////////////////////////////////////////////
7282   }
7283   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7284   /////////////////////////////////////////////////////////////
7285   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7286   /////////////////////////////////////////////////////////////
7287   if (! moth) {
7288     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7289     return;
7290   };
7291   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7292   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7293   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7294                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7295                                                                            +            fgkEndCapSupportCenterLay5Position
7296                                                                            -            fgkEndCapSideCoverLength[2]);
7297   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7298                                                                                                 fgkEndCapSideCoverLength[2]
7299                                                                            -        fgkEndCapSupportCenterLay5Position
7300                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7301   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7302   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7303   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7304         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7305   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7306   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7307    /////////////////////////////////////////////////////////////
7308   // Deallocating memory
7309   /////////////////////////////////////////////////////////////
7310   delete endcapsupportsystemrot;
7311   delete endcapsupportsystemITSCentertrans[1];
7312  }
7313   /////////////////////////////////////////////////////////////
7314   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7315   /////////////////////////////////////////////////////////////
7316   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7317   /////////////////////////////////////////////////////////////
7318   if (! moth) {
7319     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7320     return;
7321   };
7322   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7323   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7324   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7325                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7326                                                                            +            fgkEndCapSupportCenterLay6Position
7327                                                                            -            fgkEndCapSideCoverLength[2]);
7328   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7329                                                                                                 fgkEndCapSideCoverLength[2]
7330                                                                            -        fgkEndCapSupportCenterLay6Position
7331                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7332   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7333   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7334   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7335         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7336   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7337   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7338    /////////////////////////////////////////////////////////////
7339   // Deallocating memory
7340   /////////////////////////////////////////////////////////////
7341   delete endcapsupportsystemrot;
7342   delete endcapsupportsystemITSCentertrans[1];
7343  }
7344  ////////////////////////////////////////////////////////////////////////////////
7345  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7346   /////////////////////////////////////////////////////////////
7347   // Setting Ladder Support of Layer 5. 
7348   /////////////////////////////////////////////////////////////
7349   if (! moth) {
7350     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7351     return;
7352   };
7353   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7354   fMotherVol = moth;
7355   TGeoTranslation* centerITSRingSupportLay5trans[2];
7356   for(Int_t i=0; i<2; i++){
7357         centerITSRingSupportLay5trans[i] = 
7358                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7359     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7360   }
7361  }
7362  ////////////////////////////////////////////////////////////////////////////////
7363  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7364   /////////////////////////////////////////////////////////////
7365   // Setting Ladder Support of Layer 6. 
7366   /////////////////////////////////////////////////////////////
7367   if (! moth) {
7368     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7369     return;
7370   };
7371   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7372   fMotherVol = moth;
7373   TGeoTranslation* centerITSRingSupportLay6trans[2];
7374   for(Int_t i=0; i<2; i++){
7375         centerITSRingSupportLay6trans[i] = 
7376                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7377     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7378   }
7379  }
7380  ////////////////////////////////////////////////////////////////////////////////
7381  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7382   /////////////////////////////////////////////////////////////
7383   // Setting Ladder Support of Layer 6. 
7384   /////////////////////////////////////////////////////////////
7385   if (! moth) {
7386     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7387     return;
7388   };
7389   if(!fSSDCone) SetSSDCone();
7390   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7391                                                                 +                                         fgkSSDCentralAL3SupportLength);
7392     moth->AddNode(fSSDCone,1,ssdconetrans);
7393 }
7394  ////////////////////////////////////////////////////////////////////////////////
7395  void AliITSv11GeometrySSD::SetSSDCone(){
7396   /////////////////////////////////////////////////////////////
7397   // Method generating SSDCone 
7398   /////////////////////////////////////////////////////////////
7399   if(!fCreateMaterials) CreateMaterials();
7400   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7401   Double_t ssdpconesectionradiusmax[16];
7402   Double_t ssdpconesectionradiusmin[16];
7403   Double_t ssdpconezsection[16];
7404   TGeoPcon* ssdpconelittleholeshape[8];
7405   TGeoVolume* ssdpconelittlehole[8];
7406   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7407   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7408   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7409                                                       / SinD(fgkSSDPConeAngle)
7410                                                           + ssdpconesectionradiusmin[0];
7411   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7412                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7413                                                           / SinD(fgkSSDPConeAngle);
7414   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7415   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7416                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7417   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7418   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7419                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7420   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7421   ssdpconelittlehole[0]->SetLineColor(4);
7422   /////////////////////////////////////////////////////////////
7423   ssdpconezsection[2] = ssdpconezsection[1];  
7424   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7425   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7426   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7427                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7428                                                           / SinD(fgkSSDPConeAngle);
7429   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7430                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7431   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7432                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7433   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7434                                                                    * TMath::RadToDeg();
7435   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7436                                                                                                           60.-ssdpconelittleholeangle,2);    
7437   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7438                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7439   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7440   ssdpconelittlehole[1]->SetLineColor(4);
7441   TGeoRotation* ssdconelittleholerot[6];
7442   for(Int_t i=0; i<6; i++){
7443         ssdconelittleholerot[i] = new TGeoRotation();
7444     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7445   }
7446   /////////////////////////////////////////////////////////////
7447   ssdpconezsection[4] = ssdpconezsection[3];  
7448   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7449   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7450   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7451                                                           * CosD(fgkSSDPConeAngle)
7452                                                           / SinD(fgkSSDPConeAngle);
7453   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7454   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7455                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7456   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7457   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7458                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7459   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7460   ssdpconelittlehole[2]->SetLineColor(4);
7461   ///////////////////////////////////////////////////
7462   ssdpconezsection[6] = ssdpconezsection[5];  
7463   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7464   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7465   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7466                                                           -ssdpconezsection[0]
7467                                                           * CosD(fgkSSDPConeAngle)
7468                                                           / SinD(fgkSSDPConeAngle);
7469   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7470   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7471                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7472   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7473                                                                    * TMath::RadToDeg();
7474   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7475                                                                                                           45.-ssdpconemiddleholeangle,2);    
7476   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7477                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7478   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7479   ssdpconelittlehole[3]->SetLineColor(4);
7480   TGeoRotation* ssdconemiddleholerot[8];
7481   for(Int_t i=0; i<8; i++){
7482         ssdconemiddleholerot[i] = new TGeoRotation();
7483     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7484   }
7485   /////////////////////////////////////////////////////////////
7486   ssdpconezsection[8] = ssdpconezsection[7];  
7487   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7488   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7489   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7490                                                           * CosD(fgkSSDPConeAngle)
7491                                                           / SinD(fgkSSDPConeAngle);
7492   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7493   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7494                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7495   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7496   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7497                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7498   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7499   ssdpconelittlehole[4]->SetLineColor(4);
7500   /////////////////////////////////////////////////////////////
7501   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7502   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7503                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7504                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7505                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7506                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7507   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7508   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7509                                                                                  * TMath::RadToDeg();
7510   ssdpconezsection[10] = ssdpconezsection[9];
7511   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7512   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7513   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7514                                                           * CosD(fgkSSDPConeAngle)
7515                                                           / SinD(fgkSSDPConeAngle);
7516   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7517   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7518                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7519   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7520                                                                                         ssdpconetrapezoidsectionangle,2);    
7521   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7522                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7523   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7524   ssdpconelittlehole[5]->SetLineColor(4);
7525   TGeoRotation* ssdconeupradiusrot[8];
7526   for(Int_t i=0; i<8; i++){
7527         ssdconeupradiusrot[i] = new TGeoRotation();
7528     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7529   }
7530   /////////////////////////////////////////////////////////////
7531   ssdpconezsection[12] = ssdpconezsection[11];
7532   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7533   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7534   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7535   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7536   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7537   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7538   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7539                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7540   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7541   ssdpconelittlehole[6]->SetLineColor(4);
7542   /////////////////////////////////////////////////////////////
7543   ssdpconezsection[14] = 0.0;
7544   ssdpconezsection[15] = ssdpconezsection[0];
7545   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7546   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7547   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7548   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7549   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7550   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7551                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7552   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7553   ssdpconelittlehole[7]->SetLineColor(4);
7554   /////////////////////////////////////////////////////////////
7555   TGeoTube* ssdtubeconeshape[2];
7556   TGeoVolume* ssdtubecone[2];
7557   TGeoTranslation* ssdtubeconetrans[2];
7558   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7559                                                                            fgkSSDPConeExternalRadius,
7560                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7561   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7562                                                                            0.5*ssdpconezsection[0]); 
7563   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7564   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7565   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7566                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7567                                           + ssdpconezsection[13]);
7568   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7569   ssdtubecone[0]->SetLineColor(4);
7570   ssdtubecone[1]->SetLineColor(4);
7571   /////////////////////////////////////////////////////////////
7572   // Mother Volume Container
7573   /////////////////////////////////////////////////////////////
7574   Double_t ssdconemotherradiusmin[8];
7575   Double_t ssdconemotherradiusmax[8];
7576   Double_t ssdconemothersection[8]; 
7577   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7578   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7579   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7580   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7581   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7582   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7583   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7584   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7585   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7586   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7587   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7588   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7589   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7590   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7591   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7592   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7593   ssdconemothersection[0] = 0.0;
7594   ssdconemothersection[1] = ssdpconezsection[0];
7595   ssdconemothersection[2] = ssdpconezsection[0];
7596   ssdconemothersection[3] = ssdpconezsection[11];
7597   ssdconemothersection[4] = ssdpconezsection[11];
7598   ssdconemothersection[5] = ssdpconezsection[13];
7599   ssdconemothersection[6] = ssdpconezsection[13];
7600   ssdconemothersection[7] = fgkSSDPConeLength;
7601   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7602   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7603                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7604   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7605   /////////////////////////////////////////////////////////////
7606   //Placing the Volumes into Mother 
7607   /////////////////////////////////////////////////////////////
7608   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7609   for(Int_t i=0; i<6; i++){
7610         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7611   }
7612   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7613   for(Int_t i=0; i<8; i++){
7614     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7615   }
7616   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7617   for(Int_t i=0; i<8; i++){
7618     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7619   }
7620   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7621   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7622   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7623   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7624   /////////////////////////////////////////////////////////////
7625   // ITS General Support
7626   /////////////////////////////////////////////////////////////
7627   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7628                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7629   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7630   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7631                                                                              - fgkSSDCentralAL3SupportLength);
7632   ssdcentralsupport->SetLineColor(4);
7633   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7634   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7635                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7636   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7637   TGeoTranslation* ssdcentralal3supportrans[3]; 
7638   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7639   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7640                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7641   ssdcentralal3support->SetLineColor(4);
7642   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7643   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7644   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7645   Double_t ssdpconcentralradiusmin[2];
7646   Double_t ssdpconcentralradiusmax[2];
7647   Double_t ssdpconcentralsection[2];
7648   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7649   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7650   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7651   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7652   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7653   ssdpconcentralsection[1] = 0.;
7654   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7655                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7656   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7657   ssdpconcentralal3->SetLineColor(4);
7658   fSSDCone->AddNode(ssdpconcentralal3,1);
7659   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7660   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7661   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7662                                                                 -2.*fgkSSDCentralAL3SupportLength);
7663   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7664                                                                                                                      *ssdcentralal3supportrot);
7665   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7666   TGeoRotation* ssdconemotherot = new TGeoRotation();
7667   ssdconemotherot->SetAngles(90.,180.,-90.);
7668   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7669                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7670   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7671   fSSDCone->AddNode(ssdconemother,1);
7672   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7673   /////////////////////////////////////////////////////////////
7674   // Deallocating memory
7675   /////////////////////////////////////////////////////////////
7676   delete ssdcentralal3supportrot;
7677   delete ssdcentralal3supportrans[2];
7678   delete ssdconemotherot;
7679   delete ssdconemothertrans;
7680   /////////////////////////////////////////////////////////////
7681  }
7682  ////////////////////////////////////////////////////////////////////////////////
7683  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7684   /////////////////////////////////////////////////////////////
7685   // Setting SSD Cables
7686   /////////////////////////////////////////////////////////////
7687   if (! moth) {
7688     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7689     return;
7690   };
7691   TGeoVolume* ssdcables = SetSSDCables();
7692   moth->AddNode(ssdcables,1);
7693 }
7694  ////////////////////////////////////////////////////////////////////////////////
7695  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7696   /////////////////////////////////////////////////////////////
7697   // Method generating SSDCables
7698   /////////////////////////////////////////////////////////////
7699   // SSD Layer 5 Cables
7700   //////////////////////////////////////////////////////////////////////////////////////////////////
7701   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7702   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7703   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7704   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7705   //////////////////////////////////////////////////////////////////////////////////////////////////
7706   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7707   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7708                                                                             -  fgkSSDLowerPConeRadius)
7709                                                                             * TanD(fgkSSDPConeAngle);
7710   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7711                                                                               + fgkEndCapSupportCenterLay5Position
7712                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7713   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7714                                                                            - ssdcableslay5startconedistance; 
7715   ssdcablelay5rightsidelength *= ssdcablesfactor;
7716   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7717   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7718                                                                                                 ssdcableslay5rightsideradiusmax,
7719                                                                                                 0.5*ssdcablelay5rightsidelength); 
7720   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7721                                                                                                          ssdcablelay5rightubeshape,
7722                                                                                                          fSSDCopper);
7723   ssdcablelay5righttube->SetLineColor(9);
7724   TGeoTranslation* ssdcablelay5rightrans = 
7725                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7726                                                                                  +              fgkEndCapSupportCenterLay5Position
7727                                                                                  +      0.5*ssdcablelay5rightsidelength);
7728   ////////////////////////////////////
7729   //  Double_t cablescapacity[20];
7730   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7731   ////////////////////////////////////
7732   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7733   ////////////////////////////////////
7734   // TGeoPCone Volumes
7735   ///////////////////////////////////
7736   TGeoPcon* ssdcableslay5pconshape[3];
7737   TGeoVolume* ssdcableslay5pcon[3]; 
7738   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7739   Double_t ssdcableslay5pconzsection[6];
7740   Double_t ssdcableslay5pconrmin[6];
7741   Double_t ssdcableslay5pconrmax[6];
7742   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7743   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7744   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7745   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7746   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7747                                                            + fgkEndCapSupportCenterLay5Position
7748                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7749   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7750                                                            + fgkSSDCentralAL3SupportLength
7751                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7752                                                            * TanD(fgkSSDPConeAngle);      
7753   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7754                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7755   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7756                                                            ssdcableslay5pconshape[0],fSSDCopper);
7757   ssdcableslay5pcon[0]->SetLineColor(9);
7758   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7759 ////////////////////////////////////
7760 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7761 ////////////////////////////////////
7762   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7763   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7764                                                            + fgkSSDCentralAL3SupportLength
7765                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7766                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7767   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7768                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7769                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7770   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7771                                                                                    ssdcableangle,2);   
7772   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7773   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7774   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7775                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7776   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7777   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7778   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7779                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7780   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7781   ssdcableslay5pcon[1]->SetLineColor(9);
7782   ////////////////////////////////////
7783   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7784                                                                                    ssdcableangle,2);   
7785   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7786   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7787   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7788   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7789   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7790   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7791                                                            * TanD(fgkSSDPConeAngle)
7792                                                            + 0.5*fgkSSDCentralSupportLength
7793                                                            + fgkSSDCentralAL3SupportLength;
7794   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7795   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7796                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7797   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7798   ssdcableslay5pcon[2]->SetLineColor(9);
7799 ////////////////////////////////////
7800   TGeoRotation* ssdcableslay5pconrot[4];        
7801   for(Int_t i=0; i<4; i++){
7802    ssdcableslay5pconrot[i] = new TGeoRotation();
7803    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7804    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7805    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7806   }
7807   ////////////////////////////////////
7808   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7809   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7810   ////////////////////////////////////
7811   // Positioning Left SSD Cables Part
7812   ////////////////////////////////////
7813   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7814                                                                                                         - 0.5*ssdcablelay5rightsidelength
7815                                                                                                         - fgkEndCapSupportCenterLay5Position
7816                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7817   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7818   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7819   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7820   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7821   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7822   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7823         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7824         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7825     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7826   }
7827   ////////////////////////////////////
7828   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7829   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7830   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7831   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7832   /////////////////////////////////////////////////////////////
7833   // Water Tubes Layer 5
7834   /////////////////////////
7835   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7836                                                                                      ssdcableslay5rightsideradiusmax
7837                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7838                                                                                      0.5*ssdcablelay5rightsidelength); 
7839   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7840                                                                                                          ssdcablelay5rightubewatershape,
7841                                                                                                          fSSDCoolingTubeWater);
7842   ssdcablelay5rightwatertube->SetLineColor(7);
7843   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7844   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7845   ////////////////////////////////////
7846   // TGeoPCone Water Volumes Layer 
7847   ///////////////////////////////////
7848   TGeoPcon* ssdcableslay5pconwatershape[3];
7849   TGeoVolume* ssdcableslay5pconwater[3]; 
7850   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7851   Double_t ssdcableslay5pconwaterzsection[6];
7852   Double_t ssdcableslay5pcwateronrmin[6];
7853   Double_t ssdcableslay5pconwaterrmax[6];
7854   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7855   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7856                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7857   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7858   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7859                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7860   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7861   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7862   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7863                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7864   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7865                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7866   ssdcableslay5pconwater[0]->SetLineColor(7);
7867   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7868   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7869 ////////////////////////////////////
7870   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7871   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7872   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7873                                                                                                 ssdcableangle,2);   
7874   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7875   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7876                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7877   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7878   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7879                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7880   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7881                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7882   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7883                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7884   ssdcableslay5pconwater[1]->SetLineColor(7);
7885 ////////////////////////////////////
7886   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7887                                                                                                 ssdcableangle,2);   
7888   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7889   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7890                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7891   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7892   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7893                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7894   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7895   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7896   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7897                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7898   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7899                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7900   ssdcableslay5pconwater[2]->SetLineColor(7);
7901 ////////////////////////////////////
7902   TGeoRotation* ssdcableslay5pconwaterot[4];    
7903   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7904   for(Int_t i=0; i<4; i++){
7905    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7906    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7907    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7908         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7909         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7910         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7911         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7912         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7913   }
7914   /////////////////////////
7915   // SSD Layer 6 Cables
7916   /////////////////////////
7917   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7918   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7919   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7920   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7921                                                                                                 ssdcableslay6rightsideradiusmax,
7922                                                                                                 0.5*ssdcablelay6rightsidelength); 
7923   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7924                                                                                                          ssdcablelay6rightubeshape,
7925                                                                                                          fSSDCopper);
7926   ssdcablelay6righttube->SetLineColor(9);
7927   TGeoTranslation* ssdcablelay6rightrans = 
7928                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7929                                                                                  +              fgkEndCapSupportCenterLay6Position
7930                                                                                  +      0.5*ssdcablelay6rightsidelength);
7931   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7932                                                                                                         - 0.5*ssdcablelay6rightsidelength
7933                                                                                                         - fgkEndCapSupportCenterLay6Position
7934                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7935   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7936   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7937   ////////////////////////////////////
7938   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7939   ////////////////////////////////////
7940   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7941                                                                                    ssdcableangle,2);   
7942   TGeoVolume* ssdcableslay6pcon;
7943   Double_t ssdcableslay6pconrmin[2];
7944   Double_t ssdcableslay6pconrmax[2];
7945   Double_t ssdcableslay6pconzsection[2];
7946   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7947   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7948   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7949   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7950   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7951                                                            + fgkEndCapSupportCenterLay6Position
7952                                                            + ssdcablelay6rightsidelength;
7953   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7954   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7955                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7956   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7957                                                            ssdcableslay6pconshape,fSSDCopper);
7958   ssdcableslay6pcon->SetLineColor(9);
7959   for(Int_t i=0; i<4; i++){
7960    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7961    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7962   }
7963   ////////////////////////////////////
7964   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7965   /////////////////////////
7966   // Water Tubes Layer 6
7967   /////////////////////////
7968   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7969                                                                                                                   ssdcableslay6rightsideradiusmax
7970                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7971                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7972   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7973                                                                                                          ssdcablelay6righwatertubeshape,
7974                                                                                                          fSSDCoolingTubeWater);
7975   ssdcablelay6rightwatertube->SetLineColor(7);
7976   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7977   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7978   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7979                                                                                    ssdcableangle,2);   
7980   TGeoVolume* ssdcableslay6waterpcon;
7981   Double_t ssdcableslay6waterpconrmin[2];
7982   Double_t ssdcableslay6waterpconrmax[2];
7983   Double_t ssdcableslay6waterpconzsection[2];
7984   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7985   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7986                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7987   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7988   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7989   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7990                                                            + fgkEndCapSupportCenterLay6Position
7991                                                            + ssdcablelay6rightsidelength;
7992   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7993   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7994                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7995   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7996                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7997   ssdcableslay6waterpcon->SetLineColor(7);
7998   TGeoRotation* ssdcableslay6pconwaterot[4];    
7999   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
8000   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
8001   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
8002   for(Int_t i=0; i<4; i++){
8003    ssdcableslay6pconwaterot[i] = new TGeoRotation();
8004    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
8005    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
8006                                                                                  * (*ssdcableslay6pconwaterot[i]));   
8007    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
8008    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
8009   }
8010   ////////////////////////////////////////
8011   // From ITS Ring to Patch Panel3-RB26
8012   ////////////////////////////////////////
8013   Double_t ssdcablepatchpanel3BB26radiusmin[2];
8014   Double_t ssdcablepatchpanel3BB26radiusmax[2];
8015   Double_t ssdcablepatchpanel3RB26zsection[2];
8016   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
8017   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
8018                                                                           + fgkSSDCablesLay5RightSideHeight
8019                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8020   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
8021   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
8022                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8023                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8024   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
8025                                                                                  + fgkSSDCentralAL3SupportLength
8026                                                                                  + fgkSSDPConeZLength[0];
8027   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
8028   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
8029                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8030                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8031   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
8032                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
8033   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
8034                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
8035   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
8036   TGeoRotation* ssdcablepatchpanel3B26rot[3];
8037   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
8038   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
8039   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
8040                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8041   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
8042   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
8043                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8044   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
8045   ////////////////////////////////////
8046   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
8047   ////////////////////////////////////////
8048   //  ITS Ring Cables RB26 Part
8049   ////////////////////////////////////////
8050   Double_t ssdcableitsring3BB26pconzsection[2];
8051   Double_t ssdcableitsring3BB26pconrmin[2];
8052   Double_t ssdcableitsring3BB26pconrmax[2];
8053   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
8054                                                                           + fgkSSDCentralAL3SupportLength
8055                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
8056   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
8057   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8058   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
8059                                                                   + fgkSSDCablesLay5RightSideHeight
8060                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8061   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
8062   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
8063   TGeoPcon* ssdcableitsring3BB26pconshape[4];
8064   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8065                                                                    -              0.5*ssdcableangle,ssdcableangle
8066                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
8067                                                                    -                             fgkSSDCableAngle),2);
8068   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8069                                                                    -              0.5*ssdcableangle,ssdcableangle
8070                                                                    +                      3.0*fgkSSDCableAngle
8071                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8072   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
8073                                                                    -              0.5*ssdcableangle,ssdcableangle
8074                                                                    -                      fgkSSDCableAngle
8075                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
8076   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8077                                                                    -              0.5*ssdcableangle,ssdcableangle
8078                                                                    +                      3.0*fgkSSDCableAngle
8079                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8080   for(Int_t i=0;i<4;i++)
8081         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
8082                                                          ssdcableitsring3BB26pconrmin[j],
8083                                                          ssdcableitsring3BB26pconrmax[j]); 
8084   TGeoVolume* ssdcableitsring3BB26pcon[4];
8085   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
8086                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
8087   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
8088                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
8089   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
8090                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
8091   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
8092                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
8093   for(Int_t i=0;i<4;i++){
8094         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
8095         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
8096 }
8097   ////////////////////////////////////
8098   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8099   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8100   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8101   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8102   ////////////////////////////////////////
8103   // From ITS Ring to Patch Panel2-RB24
8104   ////////////////////////////////////////
8105   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8106   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8107   Double_t ssdcablepatchpanel3RB24zsection[2];
8108   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8109   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8110   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8111   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8112                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8113                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8114                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8115   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8116                                                                          -  fgkSSDCentralAL3SupportLength
8117                                                                          -  fgkSSDPConeZLength[0];
8118   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8119   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8120                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8121                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8122   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8123                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8124   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8125                                                                                                 ssdcablepatchpanel3RB24pconshape,
8126                                                                                                 fSSDCopper);
8127   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8128   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8129   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8130   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
8131   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8132                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8133   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
8134   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8135                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8136   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8137   ////////////////////////////////////
8138   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8139   ////////////////////////////////////////
8140   //  ITS Ring Cables RB24 Part
8141   ////////////////////////////////////////
8142   Double_t ssdcableitsring3BB24pconzsection[2];
8143   Double_t ssdcableitsring3BB24pconrmin[2];
8144   Double_t ssdcableitsring3BB24pconrmax[2];
8145   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8146   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8147   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8148   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8149                                                                   + fgkSSDCablesLay5RightSideHeight
8150                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8151   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8152   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8153   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8154   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8155                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8156                                                                    -                             fgkSSDCableAngle),2);
8157   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8158                                                                      ssdcableangle-fgkSSDCableAngle
8159                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8160   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8161                                                                    -                      fgkSSDCableAngle
8162                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8163   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8164                                                                                                   ssdcableangle-fgkSSDCableAngle
8165                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8166   for(Int_t i=0;i<4;i++)
8167         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8168                                                          ssdcableitsring3BB24pconrmin[j],
8169                                                          ssdcableitsring3BB24pconrmax[j]); 
8170   TGeoVolume* ssdcableitsring3BB24pcon[4];
8171   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8172                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8173   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8174                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8175   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8176                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8177   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8178                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8179   for(Int_t i=0;i<4;i++){
8180         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8181         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8182 }
8183   ////////////////////////////////////
8184   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8185   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8186   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8187   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8188   ////////////////////////////////////
8189   // Volumes for Material Budget 
8190   ////////////////////////////////////
8191   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8192                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8193                                                                                                          ssdcableslay6rightsideradiusmax
8194                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8195                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8196   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8197                                                                                                          ssdcablelay6materialbudgetubeshape,
8198                                                                                                          fSSDCopper);
8199   ssdcablelay6materialbudgetube->SetLineColor(9);
8200   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8201   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8202
8203   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8204                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8205   TGeoVolume* ssdcablelay6materialbudgetpcon;
8206   Double_t ssdcablelay6materialbudgetpconrmin[2];
8207   Double_t ssdcablelay6materialbudgetpconrmax[2];
8208   Double_t ssdcablelay6materialbudgetpconzsection[2];
8209   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8210                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8211   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8212                                                                                 + fgkSSDCableMaterialBudgetHeight;
8213   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8214   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8215   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8216                                                                                         + fgkEndCapSupportCenterLay6Position
8217                                                                                         + ssdcablelay6rightsidelength;
8218   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8219   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8220                                                   ssdcablelay6materialbudgetpconzsection[i],
8221                                                   ssdcablelay6materialbudgetpconrmin[i],
8222                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8223   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8224                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8225   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8226   for(Int_t i=0; i<4; i++){
8227    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8228    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8229   }
8230 ////////////////////////////////////
8231  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8232   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8233   Double_t ssdcablesvolume = 0.0;
8234   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8235   std::cout << ssdcablesvolume << std::endl;*/
8236   return ssdcablesmother;
8237  }
8238  ////////////////////////////////////////////////////////////////////////////////
8239 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8240                                                                         Double_t height, const char* shapename, Int_t isign) const{
8241   /////////////////////////////////////////////////////////////
8242   // Method generating an Arb shape 
8243   /////////////////////////////////////////////////////////////
8244   const Int_t kvertexnumber = 8;
8245   const Int_t ktransvectnumber = 2;
8246   TVector3* vertex[kvertexnumber];
8247   TVector3* transvector[2];
8248   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8249   /////////////////////////////////////////////////////////////
8250   //Setting the vertices for TGeoArb8
8251   /////////////////////////////////////////////////////////////
8252   vertex[0] = new TVector3(*vertexpos[0]);
8253   vertex[1] = new TVector3(*vertexpos[1]);
8254   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8255   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8256   vertex[4] = new TVector3(*vertexpos[2]);
8257   vertex[5] = new TVector3(*vertexpos[3]);
8258   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8259   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8260   /////////////////////////////////////////////////////////////
8261   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8262   for(Int_t i = 0; i<kvertexnumber;i++) 
8263                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8264   /////////////////////////////////////////////////////////////
8265   // Deallocating memory
8266   /////////////////////////////////////////////////////////////
8267   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8268   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8269   /////////////////////////////////////////////////////////////
8270   return arbshape;
8271
8272 ///////////////////////////////////////////////////////////////////////////////
8273 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8274                                                                 Double_t rmax, Int_t nedges, Double_t height){
8275   /////////////////////////////////////////////////////////////
8276   // Method generating Arc shape 
8277   /////////////////////////////////////////////////////////////
8278         const Int_t kvertexnumber = 2*nedges+2;
8279         TGeoXtru* arcshape = new TGeoXtru(2);   
8280         TVector3** vertexposition[2];
8281         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8282         Double_t angle = 0.;
8283     for(Int_t i=0; i<nedges+1; i++){ 
8284                 angle = 90.+0.5*phi-i*(phi/nedges);
8285                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8286                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8287         }
8288         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8289         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8290         for(Int_t i=0; i<kvertexnumber; i++){ 
8291                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8292                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8293                 }
8294                 else if(i>=1&&i<nedges+2)
8295                 {
8296                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8297                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8298                 }
8299         else
8300                 {
8301                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8302                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8303                 }
8304     }
8305   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8306   arcshape->DefineSection(0,-0.5*height);
8307   arcshape->DefineSection(1,0.5*height);
8308   /////////////////////////////////////////////////////////////
8309   // Deallocating memory
8310   /////////////////////////////////////////////////////////////
8311   for(Int_t i=0; i<2; i++){
8312         for(Int_t j=0; j<nedges+1; j++)
8313                 delete vertexposition[i][j];
8314         delete [] vertexposition[i];
8315   }
8316   delete [] xvertexpoints;
8317   delete [] yvertexpoints;
8318   /////////////////////////////////////////////////////////////
8319         return arcshape;
8320 }
8321 ////////////////////////////////////////////////////////////////////////////////
8322 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8323   ///////////////////////////////////////////////////////////////////////
8324   // Method Generating the Screw Shape  
8325   // radius[0]: outer radius
8326   // radius[1]: inner radius
8327   // edgesnumber[0]: outer number of edges
8328   // edgesnumber[1]: inner number of edges
8329   // section[0]: lower section position
8330   // section[1]: higher section position
8331   ///////////////////////////////////////////////////////////////////////
8332   Double_t outradius = radius[0];
8333   Double_t inradius = radius[1];
8334   Int_t outvertexnumber = edgesnumber[0];
8335   Int_t invertexnumber = edgesnumber[1];
8336   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8337   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8338   for(Int_t i=0; i<outvertexnumber; i++){
8339         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8340         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8341   }
8342   for(Int_t i=0; i<invertexnumber; i++){
8343         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8344         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8345   }
8346   TGeoXtru* screwshapeout = new TGeoXtru(2);
8347   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8348   screwshapeout->DefineSection(0,section[0]);
8349   screwshapeout->DefineSection(1,section[1]);
8350   TGeoXtru* screwshapein = new TGeoXtru(2);
8351   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8352   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8353   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8354   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8355   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8356   
8357   delete [] xscrewvertex;
8358   delete [] yscrewvertex;
8359   return screwshape;
8360 }
8361 ////////////////////////////////////////////////////////////////////////////////
8362 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8363   ///////////////////////////////////////////////////////////////////////
8364   // Method Generating the Hole Shape  
8365   // radius of the Hole
8366   // nedges: number of edges to approximate the circle
8367   ///////////////////////////////////////////////////////////////////////
8368   Double_t* xholevertex = new Double_t[nedges];
8369   Double_t* yholevertex = new Double_t[nedges];
8370   Double_t z  = 0.5*(section[0]+section[1]);
8371   Double_t dz = 0.5*(section[1]-section[0]);
8372   TGeoTranslation *tr = 0;
8373   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8374      tr = new TGeoTranslation(0.,0.,z);
8375      tr->RegisterYourself();
8376   }   
8377   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8378   for(Int_t i=0; i<nedges; i++){
8379         xholevertex[i] = radius*CosD(i*360./nedges);
8380         yholevertex[i] = radius*SinD(i*360./nedges);
8381   }
8382   TGeoXtru* holeshapeout = new TGeoXtru(2);
8383   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8384   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8385   holeshapeout->DefineSection(1,section[1]+0.01);
8386   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8387   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8388   
8389   delete [] xholevertex;
8390   delete [] yholevertex;
8391   return holeshape;
8392 }
8393 ////////////////////////////////////////////////////////////////////////////////
8394 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8395   /////////////////////////////////////////////////////////////
8396   // Given an axis specified by param, it gives the reflection of the point
8397   // respect to the axis
8398   /////////////////////////////////////////////////////////////
8399   TVector3* n = new TVector3(param[0],param[1],param[2]);
8400   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8401   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8402   /////////////////////////////////////////////////////////////
8403   // Deallocating memory
8404   /////////////////////////////////////////////////////////////
8405   delete n;
8406   /////////////////////////////////////////////////////////////
8407   return reflectedvector;
8408 }
8409 ////////////////////////////////////////////////////////////////////////////////
8410 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8411                                                        Double_t dx,
8412                                                        Double_t dy,
8413                                                        Double_t dz) const{
8414   /////////////////////////////////////////////////////////////
8415   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8416   /////////////////////////////////////////////////////////////
8417   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8418   const Double_t *vect = hmatrix->GetTranslation();
8419   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8420   hmatrix->SetTranslation(newvect);
8421   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8422   delete hmatrix;
8423   return matrix;
8424 }
8425 ////////////////////////////////////////////////////////////////////////////////
8426 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8427   /////////////////////////////////////////////////////////////
8428   // Method returning the Medium type 
8429   /////////////////////////////////////////////////////////////
8430   char ch[100];
8431   sprintf(ch, "ITS_%s",mediumName);
8432   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8433   if (! medium)
8434     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8435   return medium;
8436 }
8437 ////////////////////////////////////////////////////////////////////////////////
8438 void AliITSv11GeometrySSD::CreateMaterials(){
8439 ///////////////////////////////////
8440 // This part has to be modified
8441 ///////////////////////////////////
8442   ///////////////////////////////////
8443   // Silicon for Sensor
8444   /////////////////////////////////// 
8445   fSSDSensorMedium = GetMedium("SI$");
8446   ///////////////////////////////////
8447   // Silicon Mixture for Sensor
8448   /////////////////////////////////// 
8449   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8450   fSSDChipGlueMedium = GetMedium("EPOXY$");
8451   ///////////////////////////////////
8452   // Stiffener Components Materials
8453   /////////////////////////////////// 
8454   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8455   ///////////////////////////  
8456   // Stiffener Connectors 
8457   ///////////////////////////  
8458   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8459   ////////////////////////////////  
8460   // Stiffener 0603-1812 Capacitor
8461   ////////////////////////////////  
8462   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8463   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8464   ///////////////////////////  
8465   // Stiffener Hybrid Wire 
8466   ///////////////////////////  
8467   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8468   ///////////////////////////  
8469   // Al for Cooling Block
8470   ///////////////////////////  
8471   fSSDAlCoolBlockMedium = GetMedium("AL$");
8472   //////////////////////////////////////////////////////  
8473   // Kapton and Al for Chip Cable Flex and Ladder Cables
8474   //////////////////////////////////////////////////////  
8475   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8476   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8477   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8478   fSSDAlTraceFlexMedium = GetMedium("AL$");
8479   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8480   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8481   /////////////////////////////////////////////////////////////////  
8482   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8483   //////////////////////////////////////////////////////////////////  
8484   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8485   /////////////////////////////////////////////////////////////////  
8486   // G10 for Detector Leg, TubeHolder
8487   //////////////////////////////////////////////////////////////////  
8488   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8489   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8490   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8491   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8492   /////////////////////////////////////////////////////////////////  
8493   // Water and Phynox for Cooling Tube
8494   //////////////////////////////////////////////////////////////////  
8495   fSSDCoolingTubeWater = GetMedium("WATER$");
8496   fSSDCoolingTubePhynox = GetMedium("INOX$");
8497   /////////////////////////////////////////////////////////////////////
8498   // Material for Support Rings
8499   /////////////////////////////////////////////////////////////////////
8500   fSSDSupportRingAl = GetMedium("AL$");
8501   fSSDRohaCellCone = GetMedium("ROHACELL$");
8502   /////////////////////////////////////////////////////////////////////
8503   fSSDAir = GetMedium("SDD AIR$");
8504   fSSDCopper = GetMedium("COPPER$");
8505   fCreateMaterials = kTRUE;
8506 }
8507 /////////////////////////////////////////////////////////////////////