]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Added filling of data structures for Kalman smoothing
[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 /////////////////////////////////////////////////////////////////////////////////
43 // Names of the Sensitive Volumes of Layer 5 and Layer 6
44 /////////////////////////////////////////////////////////////////////////////////
45 const char* AliITSv11GeometrySSD::fgkSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgkSSDsensitiveVolName6 = "ITSssdSensitivL6";
47 /////////////////////////////////////////////////////////////////////////////////
48 //Parameters for SSD Geometry
49 /////////////////////////////////////////////////////////////////////////////////
50 // Variable for Vertical Disalignement of Modules
51 /////////////////////////////////////////////////////////////////////////////////
52 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
55 // For ladders:
56 const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.520*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.295*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603CapLength  =  0.900*fgkmm;  // Includes solder
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
97 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812CapLength  =  0.215*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   1.400*fgkmm;   
101 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = {44.32*fgkmm, 0.33*fgkmm};
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
105 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       =   0.25*fgkSSDStiffenerHeight;
108 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
109 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSnHeight     =   0.15*fgkmm;
111 /////////////////////////////////////////////////////////////////////////////////
112 // Cooling Block (lengths are in mm and angles in degrees)
113 /////////////////////////////////////////////////////////////////////////////////
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
117                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
119   {1.025*fgkmm, 0.120*fgkmm};  // Added 50 micron tolerance for thicker wall cooling pipe (March 2010)
120 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
121                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
122 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
123                                                                                                                                          1.500*fgkmm;
124 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
125                                                                                                                                          0.300*fgkmm;
126 /////////////////////////////////////////////////////////////////////////////////
127 // SSD Sensor (lengths are in mm and angles in degrees)
128 /////////////////////////////////////////////////////////////////////////////////
129 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
130                                                                                                                  "SSDSensorSensitiveVol";
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
132 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
135                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
136 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
137 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
138 /////////////////////////////////////////////////////////////////////////////////
139 // Flex (lengths are in mm and angles in degrees)
140 /////////////////////////////////////////////////////////////////////////////////
141 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
143                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
144                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
145                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
146                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
147                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
149                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
151                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
152 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
153 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
154 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
155 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
156                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
157 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
158                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
159 /////////////////////////////////////////////////////////////////////////////////
160 // SSD Ladder Cable (lengths are in mm and angles in degrees)
161 /////////////////////////////////////////////////////////////////////////////////
162 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
163 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableHeight[2] = {  0.030*fgkmm*17.5/23.5,  1.25 * 0.030*fgkmm};   // Al covers ~ 17.5/23.5 of surface, Kapton includes glue+foam   
164 /////////////////////////////////////////////////////////////////////////////////
165 // SSD Module (lengths are in mm and angles in degrees)
166 /////////////////////////////////////////////////////////////////////////////////
167 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
168                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
169 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
170                                                                                                                                         45.600*fgkmm;
171 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
172                                                                                                                                          5.075*fgkmm;
173 /////////////////////////////////////////////////////////////////////////////////
174 // Sensor Support (lengths are in mm and angles in degrees)
175 /////////////////////////////////////////////////////////////////////////////////
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
177                                                                                                                                          5.800*fgkmm;
178 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
179                                                                                                                                          2.000*fgkmm;
180 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
181                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
182                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
183 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
184 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
185 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
186                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
187 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
188                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
189                                                             +  fgkSSDSensorSideSupportThickness[0])
190                                                                 -  fgkSSDSensorSideSupportLength;
191 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
192                                                                                                                                     5.250*fgkmm;
193 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
194                                                                                                                                         1.680*fgkmm;
195 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
196                                                                   = {fgkSSDSensorSideSupportHeight[0]
197                                                                   +  fgkSSDSensorSideSupportThickness[0],
198                                                                          fgkSSDSensorSideSupportHeight[1]
199                                                                   +  fgkSSDSensorSideSupportThickness[1]};
200 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
201                                                                   =  {fgkSSDSensorSideSupportThickness[0],
202                                                                           fgkSSDSensorSideSupportThickness[1]};
203 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
204                                                                                                                                    19.000*fgkmm;
205 /////////////////////////////////////////////////////////////////////////////////
206 // Chip Cables (lengths are in mm and angles in degrees)
207 /////////////////////////////////////////////////////////////////////////////////
208 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
209                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
210 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
211                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
212                                                                   -  (fgkSSDSensorSideSupportHeight[1]
213                                                                   -   fgkSSDSensorSideSupportHeight[0])
214                                                                   -   fgkSSDModuleVerticalDisalignment
215                                                                   -   fgkSSDCoolingBlockHoleCenter
216                                                                   -   fgkSSDStiffenerHeight
217                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
218                                                                           fgkSSDModuleCoolingBlockToSensor
219                                                                   -   fgkSSDModuleVerticalDisalignment  
220                                                                   -   fgkSSDCoolingBlockHoleCenter
221                                                                   -       fgkSSDStiffenerHeight
222                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
223 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
224                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
225 /////////////////////////////////////////////////////////////////////////////////
226 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
227 /////////////////////////////////////////////////////////////////////////////////
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
229                                                                                                                                         3.820*fgkmm;
230 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
231 //                                                                                                                                         3.780;
232 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
233                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
235                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
236 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
237                                                                                                                                 { 30.00, 90.00};
238 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
239                                                                                                                                          1.78*fgkmm;
240 /////////////////////////////////////////////////////////////////////////////////
241 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
242 /////////////////////////////////////////////////////////////////////////////////
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
244                                                                    = fgkSSDModuleSensorSupportDistance
245                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
247 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
248                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
249 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
250                                                                                                                                         1.630*fgkmm;
251 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
252 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
253                                                                         = fgkCarbonFiberTriangleLength
254                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
255                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
256                                                                         * TMath::DegToRad());
257 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
258                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
259                                                                         - fgkCarbonFiberSupportWidth)
260                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
261                                                                         - fgkCarbonFiberSupportWidth;
262 /////////////////////////////////////////////////////////////////////////////////
263 // Carbon Fiber Lower Support Parameters (lengths are in mm)
264 /////////////////////////////////////////////////////////////////////////////////
265 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
266 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
267                                                                                                                                           =  0.950*fgkmm;
268 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
269                                                                                                                                           =  1.600*fgkmm;
270 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
271                                                                                                                                           =  0.830*fgkmm;
272 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
273                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
274 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
275                                                                         = fgkCarbonFiberJunctionWidth
276                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
277                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
278 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
279                                                                         = {fgkCarbonFiberLowerSupportWidth
280                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
281                                                                            fgkCarbonFiberLowerSupportWidth
282                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
283                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
284 /////////////////////////////////////////////////////////////////////////////////
285 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
286 /////////////////////////////////////////////////////////////////////////////////
287 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
288                                                            {0.5 * (fgkSSDLay5LadderLength
289                                                                         -  fgkSSDLay5SensorsNumber
290                                                                         *  fgkCarbonFiberJunctionWidth
291                                                                         -  fgkCarbonFiberLowerSupportWidth),
292                                                                 0.5 * (fgkSSDLay5LadderLength
293                                                                         -  fgkSSDLay5SensorsNumber
294                                                                         *  fgkCarbonFiberJunctionWidth
295                                                                         +  fgkCarbonFiberLowerSupportWidth)};
296 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
297                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
298                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
299 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
300                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
301                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
302 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
303                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
304 /////////////////////////////////////////////////////////////////////////////////
305 // Cooling Tube Support (lengths are in mm and angles in degrees)
306 /////////////////////////////////////////////////////////////////////////////////
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
309                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
312 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
313 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
314                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
315 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
316                                                                                                                                           11.70*fgkmm;
317 /////////////////////////////////////////////////////////////////////////////////
318 // Cooling Tube (lengths are in mm and angles in degrees)
319 /////////////////////////////////////////////////////////////////////////////////
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
321 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  1.915*fgkmm/2; // Nominal + 50 micron tolerance; real pipes are closer to 450 micron wall thickness
322 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
323                                                                                                         fgkCarbonFiberJunctionWidth;
324 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
325                                                                          fgkSSDModuleSensorSupportDistance
326                                                                   +      fgkSSDCoolingBlockLength;
327 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
328 /////////////////////////////////////////////////////////////////////////////////
329 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
330 /////////////////////////////////////////////////////////////////////////////////
331 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
332                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
333 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
334                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
335 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
336                                                                                                                                           20.0*fgkmm;
337 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
338                                                                                                                                                     40.0;
339 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
340                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
341 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
342                                                                                                                                           2.5*fgkmm;
343 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
344                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
345 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
346                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
347 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
348                                                                                                                                           1.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
350                                                                                                                                           6.0*fgkmm;
351 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeight      =  
352                                                                                                                                           4.0*fgkmm;
353 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
354                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
355 /////////////////////////////////////////////////////////////////////////////////
356 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
357 /////////////////////////////////////////////////////////////////////////////////
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
359 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
360 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
363 /////////////////////////////////////////////////////////////////////////////////
364 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
365 /////////////////////////////////////////////////////////////////////////////////
366 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
368 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
369                                                                                                   -  fgkSSDMountingBlockHeight[1]
370                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
371                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
372                                                                                                   -      fgkMountingBlockSupportDownHeight,
373                                                                                                          fgkSSDLay6RadiusMin
374                                                                                                   -  fgkSSDMountingBlockHeight[1]
375                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
376                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
377                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
378 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
379                                                                                                     -  fgkSSDMountingBlockHeight[1]
380                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
381                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
382                                                                                                         -  fgkMountingBlockSupportRadius[0],
383                                                                                                            fgkSSDLay6RadiusMax
384                                                                                                     -  fgkSSDMountingBlockHeight[1]
385                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
386                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
387                                                                                                         -  fgkMountingBlockSupportRadius[1]};
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeight = 10.0*fgkmm; // To be verified
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
390 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
391 /////////////////////////////////////////////////////////////////////////////////
392 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
393 /////////////////////////////////////////////////////////////////////////////////
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
398                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
400                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
401 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
402                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
408 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
409 /////////////////////////////////////////////////////////////////////////////////
410 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
411 /////////////////////////////////////////////////////////////////////////////////
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
414 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
415 /////////////////////////////////////////////////////////////////////////////////
416 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
417 /////////////////////////////////////////////////////////////////////////////////
418 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
419                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
423                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
424 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
425                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
426 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
427 /////////////////////////////////////////////////////////////////////////////////
428 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
429 /////////////////////////////////////////////////////////////////////////////////
430 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
431                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
432 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
433                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
434                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
435 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
436 /////////////////////////////////////////////////////////////////////////////////
437 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
438 /////////////////////////////////////////////////////////////////////////////////
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
440                                                                                                            {62.0*fgkmm,21.87*fgkmm};
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
442                                                                                                             {47.0*fgkmm,0.35*fgkmm};
443 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
444                                                                                                                                           1.0*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
447                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
448 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
449                                                                                                                                          0.15*fgkmm;
450 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
451                                                                                                                                          19.0*fgkmm;
452 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
453                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
454 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
455                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
456 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
457                                                                                                                                           2.1*fgkmm;
458 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
459                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
460 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
461                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
462 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
463                                                                                                                                            19*fgkmm; 
464 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
465                                                                                                                                           1.0*fgkmm;
466 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
467                                                                                                                                           3.6*fgkmm;
468 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
469                                                                                                                                          61.0*fgkmm; 
470 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
471                                                                                                                                          5.97*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
474                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
475                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
476 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
477                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
478 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
479                                                                                                                                           1.0*fgkmm; 
480 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
481                                                                                                                                    = 0.15*fgkmm; 
482 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
483                                                                                                                                          20.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
488 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
489 /////////////////////////////////////////////////////////////////////////////////
490 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
491 /////////////////////////////////////////////////////////////////////////////////
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 624.9*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
500 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
501 /////////////////////////////////////////////////////////////////////////////////
502 // SSD Cone Parameters (lengths are in mm and angles in degrees)
503 /////////////////////////////////////////////////////////////////////////////////
504 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
509 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
526 /////////////////////////////////////////////////////////////////////////////////
527 // SSD Cables Parameters (lengths are in mm and angles in degrees)
528 /////////////////////////////////////////////////////////////////////////////////
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
533 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
536 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeight = 87.5*fgkmm;
542 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
544 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
545 /////////////////////////////////////////////////////////////////////////////////
546 ClassImp(AliITSv11GeometrySSD)
547 /////////////////////////////////////////////////////////////////////////////////
548 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
549   AliITSv11Geometry(),
550   fSSDChipMedium(),
551   fSSDChipGlueMedium(),
552   fSSDStiffenerMedium(),
553   fSSDStiffenerConnectorMedium(),
554   fSSDStiffener0603CapacitorMedium(),
555   fSSDStiffener1812CapacitorMedium(),
556   fSSDStiffenerCapacitorCapMedium(),
557   fSSDStiffenerHybridWireMedium(),
558   fSSDKaptonFlexMedium(),
559   fSSDAlTraceFlexMedium(),
560   fSSDAlTraceLadderCableMedium(),
561   fSSDKaptonLadderCableMedium(),
562   fSSDKaptonChipCableMedium(),
563   fSSDAlTraceChipCableMedium(),
564   fSSDAlCoolBlockMedium(),
565   fSSDSensorMedium(),
566   fSSDSensorSupportMedium(),
567   fSSDCarbonFiberMedium(),
568   fSSDTubeHolderMedium(),
569   fSSDCoolingTubeWater(),
570   fSSDCoolingTubePhynox(),
571   fSSDSupportRingAl(),
572   fSSDMountingBlockMedium(),
573   fSSDRohaCellCone(),
574   fSSDAir(),
575   fSSDCopper(),
576   fSSDSn(),
577   fCreateMaterials(kFALSE),
578   fTransformationMatrices(kFALSE),
579   fBasicObjects(kFALSE),
580   fcarbonfiberjunction(),
581   fcoolingtubesupport(),
582   fhybridmatrix(),
583   fssdcoolingblocksystem(),
584   fcoolingblocksystematrix(),
585   fssdstiffenerflex(),
586   fssdendflex(),
587   fcoolingtube(0),
588   fendladdercoolingtubesupportmatrix(),
589   fendladdermountingblock(),
590   fendladdermountingblockclip(),
591   fSSDSensor5(),
592   fSSDSensor6(),
593   fSSDLayer5(), 
594   fSSDLayer6(),
595   fMotherVol(),
596   fLay5LadderSupportRing(),
597   fLay6LadderSupportRing(),
598   fgkEndCapSupportSystem(),
599   fSSDCone(),
600   fColorCarbonFiber(4),
601   fColorRyton(5),
602   fColorPhynox(14),
603   fColorSilicon(3),
604   fColorAl(38),
605   fColorNiSn(40),
606   fColorKapton(6),
607   fColorPolyhamide(5),
608   fColorStiffener(9),
609   fColorEpoxy(30),
610   fColorWater(7),
611   fColorG10(41)
612 {
613   ////////////////////////
614   // Standard constructor
615   ////////////////////////
616   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++){
617     fendladdermountingblockcombitrans[i] = NULL;
618   }
619   for (Int_t i=0; i < fgkcarbonfibersupportnumber; i++) {
620     fcarbonfibersupport[i] = 0;
621     fcarbonfibersupportmatrix[i] = 0;
622   }
623   for (Int_t i=0; i < fgkcarbonfiberjunctionumber; i++) {
624     fcarbonfiberjunctionmatrix[i] = 0;
625   }
626   for (Int_t i=0; i < fgkcarbonfiberlowersupportnumber; i++) {
627     fcarbonfiberlowersupport[i] = 0;
628     fcarbonfiberlowersupportrans[0] = 0;
629   }
630   for (Int_t i=0; i < fgkvolumekind; i++) {
631     fssdsensorsupport[i] = 0;
632   }
633   for (Int_t i=0; i < fgkssdsensorsupportnumber; i++) {
634     fssdsensorsupportmatrix[i] = 0;
635   }
636   for (Int_t i=0; i < fgkcoolingtubesupportnumber; i++) {
637     fcoolingtubesupportmatrix[i] = 0;
638   }
639   for (Int_t i=0; i < fgkhybridcompnumber; i++) {
640     fssdhybridcomponent[i] = 0;
641   }
642   for (Int_t i=0; i < fgkcoolingblocknumber; i++) {
643     fcoolingblockmatrix[i] = 0;
644   }
645   for (Int_t i=0; i < fgkflexnumber; i++) {
646     fstiffenerflexmatrix[i] = 0;
647     fendflexmatrix[i] = 0;
648   }
649   for (Int_t i=0; i < fgkendladdercoolingtubenumber; i++) {
650     fendladdercoolingtube[i] = 0;
651     for (Int_t j = 0; j < 2; j++) 
652       fendladdercoolingtubematrix[i][j] = 0;
653   }
654   for (Int_t i=0; i < fgkendlabbercarbonfiberjunctionumber; i++) {
655     fendladdercarbonfiberjunction[i] = 0;
656   }
657   for (Int_t i=0; i < fgkendladdercarbonfiberjunctionmatrixnumber; i++) {
658     fendladdercarbonfiberjunctionmatrix[i] = 0;
659   }
660   for (Int_t i=0; i < fgkendladdercarbonfibermatrixnumber; i++) {
661     fendladdercarbonfibermatrix[i] = 0;
662   }
663   for (Int_t i=0; i < fgkendladdermountingblocknumber; i++) {
664     fendladdermountingblockclipmatrix[i] = 0;
665   }
666   for (Int_t i = 0; i < fgkendladderlowersuppnumber+1; i++) {
667     fendladderlowersupptrans[i] = 0;
668   }
669   for (Int_t i = 0; i < fgkladdercablesnumber; i++) {
670     fladdercablematrix[i] = 0;
671   }
672   for (Int_t i = 0; i < fgkladdersegmentnumber; i++) {
673     fladdersegment[i] = 0;
674   }
675   for (Int_t i = 0; i < fgkladdernumber; i++) {
676     fladder[i] = 0;
677     fladdermatrix[i] = 0;
678     fssdsensormatrix[i] = 0;
679     flayermatrix[i] = 0;
680   }
681   for (Int_t i = 0; i < 2; i++) {
682     fLay5LadderSupport[i] = 0;
683     fLay6LadderSupport[i] = 0;
684     fcoolingtubematrix[i] = NULL;
685     fendladdersegment[i] = NULL;
686     fendladdersegmentmatrix[i] = NULL;
687   }
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[2];
993   TVector3* localcoolingtubevect[2];
994
995   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
996                                                   -fgkCarbonFiberTriangleLength),
997                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
998                                             - fgkCarbonFiberLowerSupportWidth 
999                                             - fgkLowerSupportToSensorZ ,
1000                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1001   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
1002                                               localcoolingtubevect[0]->Y(),
1003                                               localcoolingtubevect[0]->Z());
1004   for(Int_t j=0; j<2; j++){
1005     localcoolingtubetrans[j] = 
1006         new TGeoTranslation(localcoolingtubevect[j]->X(),
1007                             localcoolingtubevect[j]->Y(),
1008                             localcoolingtubevect[j]->Z());
1009      fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
1010                                              *(*localcoolingtuberot));
1011   }
1012   /////////////////////////////////////////////////////////////
1013   // SSD End Ladder Cooling Tube Transformations
1014   /////////////////////////////////////////////////////////////
1015   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1016   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1017   TGeoTranslation** localendlladdercoolingtubetrans[2];
1018   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
1019   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
1020   for(Int_t i=0; i<2; i++)      
1021         for(Int_t j=0; j<2; j++)        
1022                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1023
1024   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
1025   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1026                                                                         -        fgkCoolingTubeSupportRmax)
1027                                                                         +        fgkCarbonFiberJunctionLength,
1028                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1029                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1030   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1031                                                                         -        fgkCoolingTubeSupportRmax)
1032                                                                         -        fgkCarbonFiberJunctionLength
1033                                                                         +    fgkCarbonFiberTriangleLength,
1034                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1035                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1036
1037   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1038                                                           -   fgkCoolingTubeSupportRmax)
1039                                                         +       fgkCarbonFiberJunctionLength,
1040                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1041                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1042   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1043                                                   -      fgkCoolingTubeSupportRmax)
1044                                                   -      fgkCarbonFiberJunctionLength
1045                                                   +    fgkCarbonFiberTriangleLength,
1046                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1047                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1048   for(Int_t i=0; i<2; i++)
1049         for(Int_t j=0; j<2; j++){
1050                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1051                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1052         }
1053   /////////////////////////////////////////////////////////////
1054   // SSD Hybrid Components Transformations
1055   /////////////////////////////////////////////////////////////
1056   const Int_t khybridmatrixnumber = 3;
1057   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1058   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1059                                             0.5*fgkSSDStiffenerWidth,
1060                                             0.5*fgkSSDStiffenerHeight);
1061   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1062                                             fgkSSDModuleStiffenerPosition[1],0.0);
1063
1064   localhybridtrans[2] = new TGeoTranslation(
1065                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1066                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1067                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1068                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1069                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1070                       -       fgkSSDSensorCenterSupportThickness[0]),
1071                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1072                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1073                                           -       fgkSSDModuleVerticalDisalignment)); 
1074   fhybridmatrix = new TGeoHMatrix();
1075   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1076   /////////////////////////////////////////////////////////////
1077   // SSD Cooling Block Transformations
1078   /////////////////////////////////////////////////////////////
1079   TGeoTranslation localcoolingblocktrans (fcoolingtubematrix[0]->GetTranslation()[0] 
1080                                           - 0.5*fgkSSDCoolingBlockLength,
1081                                           fhybridmatrix->GetTranslation()[1]-0.5*fgkSSDStiffenerWidth,
1082                                           fhybridmatrix->GetTranslation()[2]+0.5*fgkSSDStiffenerHeight+
1083                                           0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1084   fcoolingblocksystematrix = new TGeoHMatrix(localcoolingblocktrans);
1085   /////////////////////////////////////////////////////////////
1086   // SSD Stiffener Flex Transformations
1087   /////////////////////////////////////////////////////////////
1088   const Int_t klocalflexmatrixnumber = 4;
1089   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1090   for(Int_t i=0; i<fgkflexnumber; i++)    
1091       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1092   for(Int_t i=0; i<fgkflexnumber; i++)
1093       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1094             localflexmatrix[i][j] = new TGeoCombiTrans();
1095   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1096                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1097                                                                   -    fgkSSDStiffenerWidth;
1098   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1099                                         +0.5*fgkSSDStiffenerLength,
1100                                          0.5*fgkSSDStiffenerWidth,
1101                                         -0.5*fgkSSDStiffenerHeight
1102                                         -0.5*fgkSSDFlexHeight[0]);
1103   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1104                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1105                                         -0.5*fgkSSDStiffenerWidth,
1106                                         -0.5*fgkSSDStiffenerHeight
1107                                         -0.5*fgkSSDFlexHeight[0]);
1108   TGeoRotation* localflexrot = new TGeoRotation();
1109   localflexrot->SetAngles(180.,0.,0.);    
1110   localflexmatrix[1][0]->SetRotation(localflexrot);
1111   for(Int_t i=0; i<fgkflexnumber; i++)
1112       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1113             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1114   for(Int_t i=0; i<fgkflexnumber; i++){
1115       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1116       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1117             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1118   }
1119   /////////////////////////////////////////////////////////////
1120   // SSD End Flex Transformations
1121   /////////////////////////////////////////////////////////////
1122   TGeoRotation* localendflexrot = new TGeoRotation();
1123   localendflexrot->SetAngles(0.0,90.0,0.0);
1124   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1125   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1126                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1127   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1128                             * TMath::DegToRad()*ssdflexradiusmax
1129                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1130                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1131                                                                                    - 0.1*fgkSSDFlexFullLength;
1132   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1133                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1134                             +      fgkSSDFlexLength[2];
1135   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1136                               0.5*fgkSSDFlexWidth[0],
1137                               2.*fgkSSDStiffenerHeight
1138                             + 0.5*fgkSSDFlexHeight[0]);      
1139   localendflexmatrix->SetRotation(localendflexrot);
1140   for(Int_t i=0; i<fgkflexnumber; i++) 
1141       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1142   /////////////////////////////////////////////////////////////
1143   // End Ladder Carbon Fiber Junction
1144   /////////////////////////////////////////////////////////////
1145   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1146   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1147   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1148   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1149       localendladdercarbonfiberjunctionmatrix[i] 
1150             = new TGeoCombiTrans*[fgkendladdercarbonfiberjunctionmatrixnumber];
1151       localendladdercarbonfiberjunctionrot[i] 
1152             = new TGeoRotation*[fgkendladdercarbonfiberjunctionmatrixnumber];
1153       localendladdercarbonfiberjunctiontrans[i] 
1154             = new TGeoTranslation*[fgkendladdercarbonfiberjunctionmatrixnumber];
1155       fendladdercarbonfiberjunctionmatrix[i]
1156             = new TGeoHMatrix*[fgkendladdercarbonfiberjunctionmatrixnumber];
1157   }
1158   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1159       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1160             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1161             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1162       }
1163   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1164       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
1165           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1166   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1167       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1168                               0.0,0.0);
1169       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1170                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1171                 *                     SinD(fgkCarbonFiberTriangleAngle),
1172                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1173   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1174   }
1175   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1176   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1177   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1178   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1179       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1180       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1181       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1182       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1183             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1184       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1185             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1186                                *localendladdercarbonfiberjunctionglobalrot[i]);
1187   }
1188   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1189       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1190             localendladdercarbonfiberjunctionmatrix[i][j] = 
1191                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1192                                      *localendladdercarbonfiberjunctionrot[i][j]);
1193            fendladdercarbonfiberjunctionmatrix[i][j] =
1194             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1195             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1196       }  
1197   /////////////////////////////////////////////////////////////
1198   // End Ladder Carbon Fiber Support
1199   /////////////////////////////////////////////////////////////
1200   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1201   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1202       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1203       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1204             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1205       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1206   }
1207   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1208       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1209             fendladdercarbonfibermatrix[i][j] = 
1210             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1211             *(*fcarbonfibersupportmatrix[j]));
1212   /////////////////////////////////////////////////////////////
1213   // End Ladder SSD Mounting Block
1214   /////////////////////////////////////////////////////////////
1215   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1216       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1217   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1218       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1219                                 +        fgkSSDMountingBlockLength[1])
1220                                 +  0.5*fgkCarbonFiberTriangleLength,
1221                                 fgkEndLadderMountingBlockPosition[i],
1222                                 -  fgkSSDMountingBlockHeight[1]
1223                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1224   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1225   endladdermountingblockrot->SetAngles(0.,90.,0.);
1226   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1227         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1228   /////////////////////////////////////////////////////////////
1229   // End Ladder SSD Mounting Block Clip Matrix 
1230   /////////////////////////////////////////////////////////////
1231   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1232         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1233   
1234   TGeoRotation* localendladdercliprot = new TGeoRotation();
1235   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1236   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1237                                                                                   -     fgkSSDMountingBlockLength[1])
1238                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1239   localendladdercliprot->SetAngles(90.,180.,-90.);
1240   TGeoCombiTrans* localendladderclipcombitrans = 
1241                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1242   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1243         for(Int_t j=0; j<2; j++){
1244                 fendladdermountingblockclipmatrix[i][j] = 
1245                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1246                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1247         }
1248   /////////////////////////////////////////////////////////////
1249   // End Ladder Carbon Fiber Lower Support
1250   /////////////////////////////////////////////////////////////
1251   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1252       fendladderlowersupptrans[i] = 
1253             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1254                         +  0.5*fgkSSDMountingBlockWidth),
1255                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1256   fendladderlowersupptrans[0]->SetDz(-0.5*fgkCarbonFiberLowerSupportHeight-fgkSSDTolerance);
1257   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1258                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1259                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1260                                                                          0.0);
1261   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1262  /////////////////////////////////////////////////////////////
1263   // Matrix for positioning Ladder into mother volume
1264   /////////////////////////////////////////////////////////////
1265   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1266   for(Int_t i=0; i<fgkladdernumber; i++) 
1267         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1268   TGeoRotation* localladdermotherrot = new TGeoRotation();
1269   localladdermotherrot->SetAngles(0.,90.,0.);  
1270   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1271   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1272   for(Int_t i=0; i<fgkladdernumber; i++){
1273         localladdermothertrans[i] = new TGeoTranslation(0.,
1274                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1275                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1276                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1277                                                           * fgkCarbonFiberJunctionWidth,0.);
1278         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1279                                                                                                                 *localladdermotherrot);
1280         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1281         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1282   }
1283   /////////////////////////////////////////////////////////////
1284   // Ladder Cables Matrices
1285   /////////////////////////////////////////////////////////////
1286   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1287                                              + fgkSSDFlexHeight[1];  
1288   Double_t ssdladdercabletransx[3];
1289   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1290                                                   *   SinD(2.*fgkSSDFlexAngle)
1291                                                   *       CosD(2.*fgkSSDFlexAngle);
1292   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1293                                                   -     ssdladdercabletransx[0]
1294                                                   /     SinD(2.*fgkSSDFlexAngle))
1295                                                   *     CosD(fgkSSDFlexAngle);                                          
1296   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1297                                                   *       TMath::DegToRad()*ssdflexradiusmax
1298                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1299                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1300                                                   -       fgkSSDLadderCableWidth)
1301                                                   *       CosD(2.*fgkSSDFlexAngle);
1302   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1303                                                   *     TanD(2.*fgkSSDFlexAngle),
1304                                                         ssdladdercabletransx[1]
1305                                                   *     TanD(fgkSSDFlexAngle),
1306                                                         ssdladdercabletransx[2]
1307                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1308   TGeoRotation* localladdercablerot[3]; 
1309   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1310   localladdercablerot[0]->SetAngles(90.,0.,0.);
1311   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1312   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1313                                                  *                        (*localladdercablerot[0]));
1314   //TGeoRotation* localladdercablerot = new TGeoRotation();     
1315   //localladdercablerot->SetAngles(90.,0.,0.);
1316   ////////////////////////////////////////////
1317   // LocalLadderCableCombiTransMatrix
1318   ////////////////////////////////////////////
1319   const Int_t klocalladdersidecablesnumber = 2;
1320   const Int_t klocalladdercombitransnumber = 5;
1321   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1322   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1323          localladdercablecombitransmatrix[i] = 
1324                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1325   ///////////////////////////////////////////
1326   // Left Side Ladder Cables Transformations
1327   ///////////////////////////////////////////
1328   localladdercablecombitransmatrix[0][0]  =
1329                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1330                                                 0.,0.,NULL);
1331   localladdercablecombitransmatrix[0][1] = 
1332         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1333                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1334                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1335                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1336                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1337                                            + fgkSSDSensorCenterSupportLength
1338                                            - fgkSSDSensorCenterSupportThickness[0]),
1339                                            - (fgkSSDModuleCoolingBlockToSensor
1340                                            + 0.5*fgkCoolingTubeSupportHeight
1341                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1342                                            - fgkSSDChipHeight),NULL);
1343   localladdercablecombitransmatrix[0][2] = 
1344                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1345                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1346   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1347                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1348                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1349                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1350                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1351                                                                                                 new TGeoRotation("",180.,0.,0.));
1352   localladdercablecombitransmatrix[0][4] = 
1353                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1354                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1355                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1356                                                           0.,
1357                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1358                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1359                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1360                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1361   ///////////////////////////////////////////
1362   // Rigth Side Ladder Cables Transformations
1363   ///////////////////////////////////////////
1364   TGeoCombiTrans* localladdercablessdmodulematrix = 
1365         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1366                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1367                                                                          fgkSSDStiffenerWidth,
1368                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1369   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1370    localladdercablecombitransmatrix[1][i] = 
1371                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1372                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1373   ///////////////////////////////////////////
1374   // Setting LadderCableHMatrix
1375   ///////////////////////////////////////////
1376   Int_t beamaxistrans[2][3];
1377   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1378   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1379   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1380   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1381   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1382   beamaxistrans[1][2] = beamaxistrans[1][0];
1383   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1384   TGeoRotation* laddercablerot = new TGeoRotation();
1385   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1386   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1387   Double_t* laddercabletransvector;     
1388   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1389         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1390         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1391   }
1392   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1393         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1394                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1395                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1396                         localladdercablehmatrix[i][j]->MultiplyLeft(
1397                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1398         }
1399                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1400                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1401                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1402                                                                          laddercabletransvector[1]
1403                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1404                                         *                                fgkCarbonFiberJunctionWidth,
1405                                                                          laddercabletransvector[2]);
1406                 laddercablecombitrans->SetRotation(*laddercablerot);
1407                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1408                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1409         }
1410     fladdercablematrix[i][2] = 
1411                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1412                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1413         fladdercablematrix[i][3] = 
1414                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1415                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1416   }
1417   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1418     for(Int_t j=0; j<klocalladdercombitransnumber-1; j++) 
1419       fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1420   
1421   ///////////////////////////////////////////
1422   // Setting Ladder HMatrix
1423   ///////////////////////////////////////////
1424   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1425                                                                                                 fgkSSDLay6SensorsNumber};
1426   for(Int_t i=0; i<fgkladdernumber; i++){
1427         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1428         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1429                 fladdermatrix[i][j] = new TGeoHMatrix();
1430                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1431                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1432                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1433         }
1434   }
1435   ///////////////////////////////////////////
1436   // Setting SSD Sensor Matrix 
1437   ///////////////////////////////////////////
1438   TGeoCombiTrans* localssdsensorcombitrans[2];
1439   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1440   localssdsensorrot->SetAngles(0.,90.,0.);      
1441   TGeoTranslation* localssdsensortrans[2];
1442   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1443   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1444                                          fgkCarbonFiberJunctionWidth 
1445                                          - fgkCarbonFiberLowerSupportWidth 
1446                                          - fgkLowerSupportToSensorZ,
1447                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1448                                           -             fgkSSDModuleCoolingBlockToSensor
1449                                           +    (fgkSSDSensorSideSupportHeight[1]
1450                                           -             fgkSSDSensorSideSupportHeight[0]));
1451   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1452                                          fgkCarbonFiberJunctionWidth 
1453                                          - fgkCarbonFiberLowerSupportWidth 
1454                                          - fgkLowerSupportToSensorZ,
1455                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1456                                                         -fgkSSDModuleCoolingBlockToSensor);
1457
1458   for(Int_t i=0; i<2; i++) 
1459         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1460                                                                                                          *localssdsensorrot);   
1461     for(Int_t i=0; i<fgkladdernumber; i++){
1462         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1463         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1464                 switch(i){
1465                         case 0: //Ladder of Layer5  
1466                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1467                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1468                                                                                                 *localssdsensorcombitrans[1])));
1469                         break;
1470                         case 1: //Ladder of Layer6 
1471                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1472                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1473                                                                                                 *localssdsensorcombitrans[0])));
1474                 break;
1475                 }
1476           }
1477   }     
1478   //////////////////////////
1479   // Setting SSD End Ladder  
1480   //////////////////////////
1481   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1482   for(Int_t i=0; i<2; i++){
1483         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1484         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1485         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1486         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1487         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1488         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1489         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1490         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1491    }
1492   /////////////////////////////////////////////////////
1493   // Setting the CombiTransformation to pass ITS center 
1494   /////////////////////////////////////////////////////
1495   Double_t itscentertransz[fgklayernumber];
1496   itscentertransz[0] = fgkSSDLay5LadderLength
1497                                          - fgkLay5CenterITSPosition;
1498   itscentertransz[1] = fgkSSDLay6LadderLength
1499                                          - fgkLay6CenterITSPosition;
1500   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1501                                                    + 0.5*fgkCoolingTubeSupportHeight;
1502   TGeoRotation* itscenterrot[3];
1503   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1504   itscenterrot[0]->SetAngles(90.,180.,-90.);
1505   itscenterrot[1]->SetAngles(0.,90.,0.);
1506   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1507   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1508   for(Int_t i=0; i<fgklayernumber; i++) 
1509         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1510                                                          itssensortransy,
1511                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1512                                                    - itscentertransz[i],itscenterrot[2]);
1513   TGeoRotation** locallayerrot[fgklayernumber];
1514   TGeoTranslation** locallayertrans[fgklayernumber];    
1515   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1516   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1517   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1518                                          - fgkLay5CenterITSPosition);
1519   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1520                                          - fgkLay6CenterITSPosition);
1521   const Int_t kssdlayladdernumber[fgklayernumber] = 
1522                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1523   for(Int_t i=0; i<fgklayernumber; i++){
1524     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1525     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1526         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1527         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1528   }
1529   Double_t layerladderangleposition[fgklayernumber] = 
1530                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1531   Double_t layerradius = 0.;
1532   for(Int_t i=0; i<fgklayernumber; i++){        
1533         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1534                 switch(i){
1535                         case 0: //Ladder of Layer5  
1536                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1537                         break;
1538                         case 1: //Ladder of Layer6 
1539                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1540                 break;
1541                 }
1542                 locallayerrot[i][j] = new TGeoRotation();
1543                 locallayertrans[i][j] = new TGeoTranslation();
1544                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1545                 locallayertrans[i][j]->SetTranslation(layerradius 
1546                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1547                                                             layerradius 
1548                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1549                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1550                                                                          *locallayerrot[i][j]);
1551                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1552                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1553                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1554         }
1555   }
1556   /////////////////////////////////////////////////////////////
1557   // Deallocating memory
1558   /////////////////////////////////////////////////////////////
1559   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1560         delete carbonfiberot[i];
1561         delete localcarbonfibersupportmatrix[i];
1562   }
1563   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1564      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1565        delete localcarbonfiberjunctionmatrix[i][j];
1566            delete localcarbonfiberjunctionrot[i][j];
1567            delete localcarbonfiberjunctiontrans[i][j];
1568            }
1569        delete [] localcarbonfiberjunctionmatrix[i];
1570        delete [] localcarbonfiberjunctionrot[i];
1571        delete [] localcarbonfiberjunctiontrans[i];
1572   }
1573   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1574            delete localcarbonfiberlowersupportrans[i];
1575   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1576      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1577        delete localssdsensorsupportmatrix[i][j];
1578            delete localssdsensorsupportrot[i][j];
1579            delete localssdsensorsupportrans[i][j];
1580            }
1581        delete [] localssdsensorsupportmatrix[i];
1582        delete [] localssdsensorsupportrot[i];
1583        delete [] localssdsensorsupportrans[i];
1584   }
1585   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1586         delete localcoolingtubesupportmatrix[i];
1587         delete localcoolingtubesupportrot[i];
1588         delete localcoolingtubesupportrans[i];
1589   }
1590   for(Int_t j=0; j<2; j++){
1591     delete localcoolingtubevect[j];
1592     delete localcoolingtubetrans[j];
1593   }
1594  delete endladdermountingblockrot;
1595  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1596  for(Int_t i=0; i<fgkflexnumber; i++){
1597       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1598             delete localflexmatrix[i][j];
1599       delete [] localflexmatrix[i];
1600  }
1601  delete localendlladdercoolingtuberot;
1602  for(Int_t i=0; i<2; i++){
1603         for(Int_t j=0; j<2; j++)
1604           delete localendlladdercoolingtubetrans[i][j];
1605         delete [] localendlladdercoolingtubetrans[i];
1606   }
1607
1608  delete localflexrot;
1609  delete localendflexrot;
1610  delete localendflexmatrix;
1611  for(Int_t i=0; i<fgkladdernumber; i++){ 
1612         delete localladdermothertrans[i];
1613         delete localladdermothercombitrans[i];
1614   }
1615  delete localladdermotherrot;
1616  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1617       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1618             delete localendladdercarbonfiberjunctionmatrix[i][j];
1619             delete localendladdercarbonfiberjunctionrot[i][j];
1620             delete localendladdercarbonfiberjunctiontrans[i][j];
1621       }
1622       delete [] localendladdercarbonfiberjunctionmatrix[i];
1623       delete [] localendladdercarbonfiberjunctionrot[i];
1624       delete [] localendladdercarbonfiberjunctiontrans[i];
1625       delete localendladdercarbonfiberjunctionglobalrot[i];
1626       delete localendladdercarbonfiberjunctionglobaltrans[i];
1627       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1628  }
1629   for(Int_t i=0; i<2; i++){
1630         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1631         delete [] localendladdercooltubetrans[i];
1632   }
1633   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1634       delete localendladdercarbonfibertrans[i];
1635   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1636   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1637         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1638                 delete localladdercablecombitransmatrix[i][j];
1639                 delete []localladdercablecombitransmatrix[i];
1640   }
1641   delete localendladdercliprot;
1642   delete localendladdercliptrans;
1643   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1644         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1645                 delete localladdercablehmatrix[i][j];
1646         delete []localladdercablehmatrix[i];
1647   }
1648   delete laddercablerot;
1649   delete laddercabletrans;
1650   delete laddercablecombitrans;
1651   delete localladdercablessdmodulematrix;
1652   delete localssdsensorrot;     
1653   for(Int_t i=0; i<2; i++){
1654         delete localssdsensortrans[i];
1655         delete localssdsensorcombitrans[i];
1656   }
1657   for(Int_t i=0; i<fgklayernumber; i++){
1658         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1659                 delete locallayerrot[i][j];
1660                 delete locallayertrans[i][j];
1661                 delete locallayercombitrans[i][j];
1662     }
1663         delete [] locallayerrot[i];
1664         delete [] locallayertrans[i];
1665         delete [] locallayercombitrans[i];
1666         delete localbeamaxistrans[i];
1667   }
1668   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1669   for(Int_t i=0; i<fgkladdernumber; i++){
1670         for(Int_t j=0; j<fgkladdernumber; j++)
1671                 delete ladderglobalmatrix[i][j];
1672         delete [] ladderglobalmatrix[i];
1673   }
1674   /////////////////////////////////////////////////////////////
1675   fTransformationMatrices = kTRUE;      
1676 }
1677 ///////////////////////////////////////////////////////////////////////////////
1678 void AliITSv11GeometrySSD::CreateBasicObjects(){
1679   /////////////////////////////////////////////////////////////  
1680   // Method generating the Objects of SSD Geometry    
1681   /////////////////////////////////////////////////////////////
1682   // SSD Sensor
1683   ///////////////////////////////////
1684   SetSSDSensor();
1685   /////////////////////////////////////////////////////////////  
1686   // Carbon Fiber Support    
1687   /////////////////////////////////////////////////////////////  
1688   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1689   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1690       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1691   /////////////////////////////////////////////////////////////
1692   // Carbon Fiber Junction 
1693   /////////////////////////////////////////////////////////////
1694   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1695   /////////////////////////////////////////////////////////////
1696   // Carbon Fiber Lower Support
1697   /////////////////////////////////////////////////////////////
1698   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1699   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1700         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1701   /////////////////////////////
1702   // SSD Sensor Support
1703   /////////////////////////////
1704   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1705                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1706   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1707                                                                          fgkSSDSensorSideSupportThickness[1]};
1708   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1709         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1710                                                                                            fgkSSDSensorSideSupportHeight[i],
1711                                                                                            fgkSSDSensorSideSupportWidth,
1712                                                                                            sidesupporthickness);  
1713         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1714                                                                                            fgkSSDSensorCenterSupportHeight[i],
1715                                                                                            fgkSSDSensorCenterSupportWidth,
1716                                                                                            sidesupporthickness);
1717   }
1718   /////////////////////////////////////////////////////////////
1719   // SSD Cooling Tube Support
1720   /////////////////////////////////////////////////////////////
1721   Int_t edgesnumber = 3;
1722   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1723   /////////////////////////////////////////////////////////////
1724   // SSD Hybrid
1725   /////////////////////////////////////////////////////////////
1726   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1727   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1728         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1729   /////////////////////////////////////////////////////////////
1730   // SSD Cooling Block System
1731   /////////////////////////////////////////////////////////////
1732   fssdcoolingblocksystem = GetCoolingBlockSystem();
1733    /////////////////////////////////////////////////////////////
1734   // SSD Cooling Tube
1735   /////////////////////////////////////////////////////////////
1736   CreateCoolingTubes();
1737   /////////////////////////////////////////////////////////////
1738   // SSD Flex  
1739   /////////////////////////////////////////////////////////////
1740   fssdstiffenerflex = GetSSDStiffenerFlex();
1741   fssdendflex = GetSSDEndFlex();
1742   ///////////////////////////////////
1743   // End Ladder Carbon Fiber Junction
1744   ///////////////////////////////////
1745   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1746                                                    fendladdercarbonfiberjunction[i] = 
1747                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1748   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1749     fendladdercarbonfiberjunction[i][0] = 
1750                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1751     fendladdercarbonfiberjunction[i][1] = 
1752                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1753   }
1754   ///////////////////////////////////
1755   // End Ladder Mounting Block
1756   ///////////////////////////////////
1757   fendladdermountingblock = GetSSDMountingBlock();
1758   ///////////////////////////////////
1759   // End Ladder Mounting Block
1760   ///////////////////////////////////
1761   fendladdermountingblockclip = GetMountingBlockClip();
1762   ///////////////////////////////////
1763   // Ladder Support 
1764   ///////////////////////////////////
1765   TList* laddersupportlist = GetMountingBlockSupport(20);
1766   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1767   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1768   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1769   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1770   /////////////////////////////////////////////////////////////
1771   // Deallocating memory
1772   /////////////////////////////////////////////////////////////
1773   delete carbonfibersupportlist;
1774   delete carbonfiberlowersupportlist;
1775   delete ssdhybridcomponentslist;
1776   delete laddersupportlist;
1777   /////////////////////////////////////////////////////////////
1778   fBasicObjects = kTRUE;
1779 }
1780 /////////////////////////////////////////////////////////////////////////////////
1781 void AliITSv11GeometrySSD::SetSSDSensor(){
1782   ////////////////////////////////////////////////////////////////
1783   // Method generating SSD Sensors: it sets the private variables
1784   // fSSDSensor5, fSSDSensor6  
1785   ////////////////////////////////////////////////////////////////
1786   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1787   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1788   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1789                                                 0.5*ssdsensitivewidth,
1790                                                 0.5*fgkSSDSensorHeight,
1791                                                 0.5*ssdsensitivelength);
1792   TGeoVolume* ssdsensorsensitiveLay5 = 
1793         new TGeoVolume(fgkSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1794   TGeoVolume* ssdsensorsensitiveLay6 = 
1795         new TGeoVolume(fgkSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1796   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1797   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1798   TGeoBBox* ssdsensorinsensitiveshape[2];
1799   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1800                                                 0.5*fgkSSDSensorInsensitiveWidth,
1801                                                 0.5*fgkSSDSensorHeight,
1802                                                 0.5*fgkSSDSensorLength);
1803   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1804                                                 0.5*ssdsensitivewidth,
1805                                                 0.5*fgkSSDSensorHeight,
1806                                                 0.5*fgkSSDSensorInsensitiveWidth);
1807   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1808                                              "SSDSensorInsensitive2"};
1809   TGeoVolume* ssdsensorinsensitive[2];
1810   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1811       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1812                      fSSDSensorMedium);
1813       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1814   }
1815   /////////////////////////////////////////////////////////////
1816   // Virtual Volume containing SSD Sensor  
1817   /////////////////////////////////////////////////////////////
1818   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1819                                                                                              0.5*fgkSSDSensorWidth,
1820                                                                                              0.5*fgkSSDSensorHeight,
1821                                                                                              0.5*fgkSSDSensorLength);
1822   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1823                                                                                  fSSDAir);      
1824   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1825                                                                                  fSSDAir);      
1826   /////////////////////////////////////////////////////////////
1827   for(Int_t i=0; i<4; i++){ 
1828             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1829             ssdsensorinsensitive[1],i<2?1:2,
1830                         new TGeoTranslation(
1831                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1832       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1833                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1834       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1835             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1836             ssdsensorinsensitive[1],i<2?1:2,
1837                         new TGeoTranslation(
1838                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1839       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1840                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1841       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1842   }
1843     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1844     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1845 }
1846 ///////////////////////////////////////////////////////////////////////////////
1847 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1848   /////////////////////////////////////////////////////////////  
1849   // Method generating the Carbon Fiber Support   
1850   /////////////////////////////////////////////////////////////  
1851   const Int_t kvertexnumber = 4;
1852   const Int_t kshapesnumber = 2;
1853   TVector3** vertexposition[kshapesnumber];
1854   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1855   Double_t carbonfibersupportxaxisEdgeproj = 
1856                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1857         *       TMath::DegToRad());
1858   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1859                                  /                         fgkCarbonFiberSupportXAxisLength);
1860   /////////////////////
1861   //Vertex Positioning
1862   ////////////////////
1863   vertexposition[0][0] = new TVector3();
1864   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1865                                                                           fgkCarbonFiberSupportYAxisLength);
1866   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1867                                                                           carbonfibersupportxaxisEdgeproj
1868                                            *                      TMath::Tan(theta));
1869   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1870                                            -                      carbonfibersupportxaxisEdgeproj,
1871                                                                           fgkCarbonFiberSupportYAxisLength
1872                                            -                      vertexposition[0][2]->Y());
1873   ////////////////////////////////////////////////////
1874   //Setting the parameters for Isometry Transformation
1875   ////////////////////////////////////////////////////
1876   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1877                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1878                                                                  +      fgkCarbonFiberSupportWidth);
1879   Double_t* param = new Double_t[4]; 
1880   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1881   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1882     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1883                  (GetReflection(vertexposition[0][j],param))->Y());
1884   const char* carbonfibersupportshapename[kshapesnumber] = 
1885                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1886   const char* carbonfibersupportname[kshapesnumber] = 
1887                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1888   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1889   TGeoVolume* carbonfibersupport[kshapesnumber];
1890   TList* carbonfibersupportlist = new TList();
1891   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1892   Double_t carbonfibersupportheight = 
1893           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1894           *TMath::DegToRad());
1895   for(Int_t i = 0; i< kshapesnumber; i++){
1896    carbonfibersupportshape[i] = 
1897                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1898                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1899    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1900                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1901    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1902    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1903    }
1904   /////////////////////////////////////////////////////////////
1905   // Deallocating memory
1906   /////////////////////////////////////////////////////////////
1907   for(Int_t i=0; i< kshapesnumber; i++){
1908      for(Int_t j=0; j< kvertexnumber; j++)
1909            delete vertexposition[i][j];
1910        delete [] vertexposition[i];
1911   }
1912   delete [] param;
1913   /////////////////////////////////////////////////////////////
1914    return carbonfibersupportlist;
1915 }
1916 /////////////////////////////////////////////////////////////////////////////////
1917 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1918   /////////////////////////////////////////////////////////////
1919   // Method generating SSD Carbon Fiber Junction
1920   /////////////////////////////////////////////////////////////
1921   const Int_t kvertexnumber = 6;
1922   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
1923   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1924                                             *  TMath::DegToRad()),-1.,0.,0.};
1925   TVector3* vertex[kvertexnumber];
1926   vertex[0] = new TVector3();
1927   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
1928                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1929                         *                         TMath::DegToRad()),
1930                                                   fgkCarbonFiberJunctionEdge[0]
1931                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
1932                         *                         TMath::DegToRad()));
1933   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength-fgkSSDTolerance,
1934                                                    fgkCarbonFiberJunctionEdge[1]);
1935   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength-fgkSSDTolerance); 
1936   vertex[1] = GetReflection(vertex[5],reflectionparam); 
1937   vertex[2] = GetReflection(vertex[4],reflectionparam); 
1938   Double_t xvertexpoints[6], yvertexpoints[6];
1939   for(Int_t i=0; i<kvertexnumber; i++) 
1940           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
1941   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
1942   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
1943   carbonfiberjunctionshape->DefineSection(1,0.5*width);
1944   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
1945                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
1946   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
1947   /////////////////////////////////////////////////////////////
1948   // Deallocating memory
1949   /////////////////////////////////////////////////////////////
1950   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
1951   ///////////////////////////////////////////////////////////// 
1952   return carbonfiberjunction;
1953 }
1954 ////////////////////////////////////////////////////////////////////////////////
1955 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
1956   /////////////////////////////////////////////////////////////
1957   // Method generating the Carbon Fiber Lower Support   
1958   /////////////////////////////////////////////////////////////  
1959   const Int_t kvertexnumber = 4;
1960   const Int_t kshapesnumber = 2;
1961   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
1962                                                                 fgkCarbonFiberLowerSupportWidth};
1963   TVector3** vertexposition[kshapesnumber];
1964   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
1965                                                  new TVector3*[kvertexnumber];
1966   //First Shape Vertex Positioning
1967   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
1968   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
1969                                            -            fgkCarbonFiberLowerSupportLowerLenght);
1970   vertexposition[0][2] = new TVector3();
1971   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
1972   //Second Shape Vertex Positioning
1973   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
1974                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
1975                                  /                              fgkCarbonFiberTriangleLength);
1976   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
1977                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
1978                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1979   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
1980                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
1981                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1982   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
1983   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
1984                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
1985   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
1986                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
1987   const char* carbonfiberlowersupportname[kshapesnumber] = 
1988                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
1989   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
1990   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
1991   TList* carbonfiberlowersupportlist = new TList();
1992   for(Int_t i = 0; i< kshapesnumber; i++){ 
1993         carbonfiberlowersupportshape[i] = 
1994                                                                 GetArbShape(vertexposition[i],width,
1995                                                                                         fgkCarbonFiberLowerSupportHeight,
1996                                                                                         carbonfiberlowersupportshapename[i]);
1997     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
1998                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
1999         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2000     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2001   }
2002   /////////////////////////////////////////////////////////////
2003   // Deallocating memory
2004   /////////////////////////////////////////////////////////////
2005   for(Int_t i=0; i< kshapesnumber; i++){
2006      for(Int_t j=0; j< kvertexnumber; j++)
2007            delete vertexposition[i][j];
2008        delete [] vertexposition[i];
2009   }
2010   /////////////////////////////////////////////////////////////
2011   return carbonfiberlowersupportlist;
2012 }
2013 ///////////////////////////////////////////////////////////////////////////////
2014 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2015                                                                  Double_t width, const Double_t* thickness)const{
2016   /////////////////////////////////////////////////////////////
2017   // Method generating the Sensor Support   
2018   /////////////////////////////////////////////////////////////  
2019         const Int_t kvertexnumber = 6;
2020         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2021     TVector3* vertexposition[kvertexnumber];
2022         vertexposition[0] = new TVector3();     
2023         vertexposition[1] = new TVector3(0.0,length);   
2024         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2025         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2026         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2027         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2028         Double_t xvertexpoints[6], yvertexpoints[6];
2029         for(Int_t i=0; i<kvertexnumber; i++) 
2030                 xvertexpoints[i] = vertexposition[i]->X(), 
2031                 yvertexpoints[i] = vertexposition[i]->Y();
2032     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2033     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2034     ssdsensorsupportshape->DefineSection(1,0.5*width);
2035     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2036                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2037   /////////////////////////////////////////////////////////////
2038   // Deallocating memory
2039   /////////////////////////////////////////////////////////////
2040         for (Int_t i=0; i<kvertexnumber; i++)
2041                 delete vertexposition[i];
2042   /////////////////////////////////////////////////////////////
2043     return ssdsensorsupport;
2044 }
2045 ////////////////////////////////////////////////////////////////////////////////
2046 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2047   /////////////////////////////////////////////////////////////
2048   // Method generating the Cooling Tube Support
2049   /////////////////////////////////////////////////////////////
2050   if(nedges%2!=0) nedges--;     
2051   const Int_t kvertexnumber = nedges+5;
2052   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2053                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2054   Double_t angle = 90.+phi;
2055   Double_t psi = 90.-phi;
2056   ///////////////////////////////////////
2057   // Vertex Positioning for TGeoXTru
2058   ///////////////////////////////////////
2059   TVector3** vertexposition = new TVector3*[kvertexnumber];
2060
2061   Double_t router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
2062   vertexposition[0] = new TVector3(router*CosD(angle),
2063                                                                    router*SinD(angle));
2064   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2065                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2066   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2067                                                                    fgkCoolingTubeSupportRmax);
2068   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2069                                                                    fgkCoolingTubeSupportRmax);
2070   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2071                                                                     vertexposition[1]->Y());
2072
2073   for(Int_t i=0; i<nedges; i++)
2074         vertexposition[i+5] = 
2075                 new TVector3(router*CosD(psi+i*(2.*phi/nedges)),
2076                              router*SinD(psi+i*(2.*phi/nedges)));
2077   ///////////////////////////////////////////////////////////////////////
2078   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2079   ///////////////////////////////////////////////////////////////////////
2080   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2081   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2082   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2083   for(Int_t i=0; i<kvertexnumber; i++){
2084         xvertexpoints[i] = vertexposition[i]->X();
2085         yvertexpoints[i] = vertexposition[i]->Y();
2086   } 
2087   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2088                                                                                         yvertexpoints);
2089   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2090   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2091   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2092                                                                           coolingtubesupportarcshape,
2093                                                                                   fSSDTubeHolderMedium);
2094   coolingtubesupportarc->SetLineColor(fColorG10);
2095   //////////////////////////////////////////////////////////////////////////
2096   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2097   //////////////////////////////////////////////////////////////////////////
2098   TGeoTubeSeg* coolingtubesupportsegshape = 
2099                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2100                                                                                         fgkCoolingTubeSupportRmax,
2101                                                                                         0.5*fgkCoolingTubeSupportWidth,
2102                                                                                         phi,360-phi);
2103   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2104                                                                                         coolingtubesupportsegshape,
2105                                                                                         fSSDTubeHolderMedium);
2106   coolingtubesupportseg->SetLineColor(fColorG10);
2107   //////////////////////////////////////////////////////////////////////////
2108   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2109   //////////////////////////////////////////////////////////////////////////
2110   Double_t* boxorigin = new Double_t[3];
2111   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2112   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2113   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2114                                                                                  0.5*fgkCoolingTubeSupportHeight,
2115                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2116   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2117                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2118   coolingtubesupportbox->SetLineColor(fColorG10);
2119   //////////////////////////////////////////////////////////////////////////
2120   // Cooling Tube for Cooling Tube Support 
2121   //////////////////////////////////////////////////////////////////////////
2122   TGeoXtru* coolingtubearcshape[2];
2123   coolingtubearcshape[0] = new TGeoXtru(2);     
2124   Double_t* xvert = new Double_t[nedges+2];
2125   Double_t* yvert = new Double_t[nedges+2];
2126   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2127   ////////////////////////////////////////
2128   // Positioning the vertices for TGeoXTru
2129   ////////////////////////////////////////
2130   xvert[0] = 0., yvert[0] = 0.;
2131   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2132   for(Int_t i=0; i< nedges; i++)
2133                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2134                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2135   ////////////////////////////////////////
2136   // Defining TGeoXTru PolyGone
2137   ////////////////////////////////////////
2138   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2139   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2140   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2141   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2142                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2143   TGeoVolume* coolingtubearc[2];
2144   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2145                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2146   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2147                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2148   coolingtubearc[0]->SetLineColor(fColorWater);
2149   coolingtubearc[1]->SetLineColor(fColorPhynox);
2150   ////////////////////////////////////////////
2151   // Defining TGeoTubeSeg Part of Cooling Tube
2152   ////////////////////////////////////////////
2153   TGeoTubeSeg* coolingtubesegshape[2];
2154   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2155                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2156   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2157                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2158   TGeoVolume* coolingtubeseg[2];
2159   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2160                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2161   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2162                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2163   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2164   coolingtubeseg[1]->SetLineColor(fColorWater);
2165   /////////////////////////////////////////////////////////////
2166   // Virtual Volume containing Cooling Tube Support  
2167   /////////////////////////////////////////////////////////////
2168   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2169   const Int_t kvirtualvertexnumber = 8;
2170   TVector3* virtualvertex[kvirtualvertexnumber];
2171    ////////////////////////////////////////
2172   // Positioning the vertices for TGeoXTru
2173   ////////////////////////////////////////
2174   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2175   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2176   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2177   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2178   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2179   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2180   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2181   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2182   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2183   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2184         xmothervertex[i] = virtualvertex[i]->X(),
2185         ymothervertex[i] = virtualvertex[i]->Y();
2186   ////////////////////////////////////////
2187   // Defining TGeoXTru PolyGone
2188   ////////////////////////////////////////
2189   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2190                                                                                                                                          ymothervertex);
2191   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2192   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2193   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2194     virtualCoolingTubeSupportShape,fSSDAir); */
2195   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
2196
2197   ////////////////////////////////////////
2198   // Positioning Volumes in Virtual Volume
2199   ////////////////////////////////////////
2200   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2201   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2202   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2203   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2204   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2205   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2206   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2207   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2208   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2209   /////////////////////////////////////////////////////////////
2210   // Deallocating memory
2211   /////////////////////////////////////////////////////////////
2212   delete [] vertexposition;
2213   delete [] xvertexpoints;
2214   delete [] yvertexpoints;
2215   delete [] xvert;
2216   delete [] yvert;
2217   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2218         delete virtualvertex[i];
2219   /////////////////////////////////////////////////////////////
2220         return virtualcoolingtubesupport;
2221 }
2222 /////////////////////////////////////////////////////////////////////////////////
2223 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2224   /////////////////////////////////////////////////////////////
2225   // Method generating List containing SSD Hybrid Components   
2226   /////////////////////////////////////////////////////////////
2227   TList* ssdhybridlist = new TList();
2228   const Int_t kssdstiffenernumber = 2;
2229   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2230                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2231                                                                   -    fgkSSDStiffenerWidth;
2232   Double_t ssdchipcablesradius[kssdstiffenernumber];
2233   for(Int_t i=0; i<kssdstiffenernumber; i++)
2234           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2235                                -  fgkSSDChipCablesHeight[0]
2236                                -  fgkSSDChipCablesHeight[1]);
2237   /////////////////////////////////////////////////////////////
2238   // Mother Volumes Containers 
2239   /////////////////////////////////////////////////////////////
2240   const Int_t kmothernumber = 2;
2241   const Int_t kmothervertexnumber = 8;
2242   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2243   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2244
2245   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
2246   TGeoVolume* ssdhybridmother[kmothernumber][2];
2247
2248   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
2249   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
2250   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
2251
2252   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2253   for(Int_t i=0; i<kmothernumber; i++){
2254     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
2255     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
2256     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
2257     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2258       -fgkSSDChipCablesHeight[i+2];
2259     
2260     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
2261     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
2262     xmothervertex[i][3] = xmothervertex[i][2];
2263     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1]+fgkSSDTolerance;
2264
2265     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
2266     ymothervertex[i][4] = ymothervertex[i][3];
2267     xmothervertex[i][5] = xmothervertex[i][4];
2268     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i]-fgkSSDTolerance;
2269
2270     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
2271     ymothervertex[i][6] = ymothervertex[i][5];
2272     
2273     xmothervertex[i][7] = xmothervertex[i][6];
2274     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
2275     TGeoXtru *shape = new TGeoXtru(2);
2276     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
2277     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
2278     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
2279     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
2280     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
2281     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2282    }   
2283   /////////////////////////////////////////////////////////////
2284   // SSD Stiffener   
2285   /////////////////////////////////////////////////////////////
2286   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2287                                              0.5*fgkSSDStiffenerLength,
2288                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2289                                              0.5*fgkSSDStiffenerHeight);
2290   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2291                                             fSSDStiffenerMedium);  
2292   ssdstiffener->SetLineColor(fColorStiffener); 
2293
2294 ////////////////////////////
2295 // Capacitor 0603-2200 nF
2296 ///////////////////////////
2297   const Int_t knapacitor0603number = 5;
2298   TGeoBBox* capacitor0603mothershape =  new TGeoBBox("Capacitor0603MotherShape",
2299                                                0.5*fgkSSDCapacitor0603Length + fgkSSDCapacitor0603CapLength,
2300                                                0.5*fgkSSDCapacitor0603Width,
2301                                                0.5*fgkSSDCapacitor0603Height);
2302   TGeoVolume* capacitor0603mother = new TGeoVolume("Capacitor0603Mother",capacitor0603mothershape,
2303                                              fSSDAir); 
2304
2305   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2306                                                0.5*fgkSSDCapacitor0603Length,
2307                                                0.5*fgkSSDCapacitor0603Width,
2308                                                0.5*fgkSSDCapacitor0603Height);
2309   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2310                                              fSSDStiffener0603CapacitorMedium); 
2311   capacitor0603->SetLineColor(fColorAl);
2312   TGeoTranslation *cap0603trans = new TGeoTranslation(0.,0.,0.);
2313   capacitor0603mother->AddNode(capacitor0603,1,cap0603trans);
2314
2315   TGeoBBox* capacitor0603capshape =  new TGeoBBox("Capacitor0603CapShape",
2316                                                0.5*fgkSSDCapacitor0603CapLength,
2317                                                0.5*fgkSSDCapacitor0603Width,
2318                                                0.5*fgkSSDCapacitor0603Height);
2319   TGeoVolume* capacitor0603cap = new TGeoVolume("Capacitor0603Cap",capacitor0603capshape,
2320                                              fSSDStiffenerCapacitorCapMedium); 
2321   capacitor0603cap->SetLineColor(fColorNiSn);
2322   TGeoTranslation *cap0603captrans1 = new TGeoTranslation(- capacitor0603shape->GetDX() - capacitor0603capshape->GetDX(),0.,0.);
2323   capacitor0603mother->AddNode(capacitor0603cap,1,cap0603captrans1);
2324   TGeoTranslation *cap0603captrans2 = new TGeoTranslation(capacitor0603shape->GetDX() + capacitor0603capshape->GetDX(),0.,0.);
2325   capacitor0603mother->AddNode(capacitor0603cap,2,cap0603captrans2);
2326
2327
2328   TGeoVolume* ssdchip = GetSSDChip();
2329
2330   const Int_t knedges = 5;
2331   TGeoVolume *ssdchipcables[2];
2332
2333   for(Int_t i=0; i<kmothernumber; i++){
2334     for(Int_t j=0; j<kssdstiffenernumber; j++){
2335       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
2336       for(Int_t k=1; k<knapacitor0603number+1; k++){
2337         ssdhybridmother[i][j]->AddNode(capacitor0603mother,k,
2338                                        new TGeoCombiTrans("",
2339                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
2340                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
2341                                                           (k-3.)/6*fgkSSDStiffenerLength,
2342                                                           hybridmotherrotInv));
2343       }
2344     }
2345     
2346     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
2347     for(Int_t k=0; k<fgkSSDChipNumber; k++){
2348       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
2349                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
2350                                                             - fgkSSDChipCablesHeight[i+2],
2351                                                             (k+0.5-fgkSSDChipNumber/2)*
2352                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
2353       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
2354                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
2355                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
2356                                                      hybridmotherrotInv);
2357       for(Int_t j=0; j<kssdstiffenernumber; j++){
2358         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
2359         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
2360       }
2361     }  
2362     // Final placement by assembly
2363     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
2364     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
2365     ssdhybridlist->Add(ssdhybridassembly[i]);
2366   }    
2367   /////////////////////////////////////////////////////////////
2368   // Mother Volume Containing Capacitor Part 
2369   /////////////////////////////////////////////////////////////
2370   const Int_t kcapacitormothernumber = 8;
2371   Double_t xcapacitorvertex[kcapacitormothernumber];
2372   Double_t ycapacitorvertex[kcapacitormothernumber];  
2373   ///////////////////////
2374   // Setting the vertices 
2375   ///////////////////////
2376   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2377   xcapacitorvertex[1] = xcapacitorvertex[0];   
2378   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2379   xcapacitorvertex[3] = xcapacitorvertex[2];   
2380   xcapacitorvertex[4] = xcapacitorvertex[0];   
2381   xcapacitorvertex[5] = xcapacitorvertex[0];   
2382   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2383   xcapacitorvertex[7] = xcapacitorvertex[6];   
2384   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2385   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2386   ycapacitorvertex[2] = ycapacitorvertex[1];   
2387   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2388   ycapacitorvertex[4] = ycapacitorvertex[3];   
2389   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2390   ycapacitorvertex[6] = ycapacitorvertex[5];   
2391   ycapacitorvertex[7] = ycapacitorvertex[0];   
2392   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2393   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2394                                               ycapacitorvertex);
2395   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2396   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2397 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2398 //                                          fSSDAir);
2399   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2400 ////////////////////////////
2401 // Connector 
2402 ///////////////////////////
2403   const Int_t kssdconnectorlayernumber = 3;
2404   TGeoBBox* ssdconnectorshape[kssdconnectorlayernumber];
2405   Double_t ssdConnectorThickness[kssdconnectorlayernumber]={fgkSSDConnectorAlHeight,fgkSSDConnectorNiHeight,fgkSSDConnectorSnHeight};
2406   /*
2407   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2408   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2409                                    +  fgkSSDConnectorAlHeight};  
2410   */
2411   Double_t ssdconnectororigin[3] = {0,0,0.5*fgkSSDStiffenerHeight};
2412   const char* ssdconnectorname[kssdconnectorlayernumber] = {"SSDConnectorAl","SSDConnectorNi","SSDConnectorSn"};
2413   TGeoMedium *ssdConnectorMedium[kssdconnectorlayernumber]={fSSDAlTraceFlexMedium,fSSDStiffenerConnectorMedium,fSSDSn};
2414   TGeoVolume* ssdconnector[kssdconnectorlayernumber];
2415   for(Int_t i=0; i<kssdconnectorlayernumber; i++){
2416     ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2417       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2418                                           0.5*fgkSSDConnectorWidth,
2419                                           0.5*ssdConnectorThickness[i],
2420                                           ssdconnectororigin);
2421       ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2422       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2423                                        ssdConnectorMedium[i]);      
2424       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorNiSn);
2425   }
2426   const Int_t kssdconnectornumber = 4;
2427   TGeoTranslation* ssdconnectortrans[kssdconnectornumber];
2428   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2429                        +  fgkSSDConnectorPosition[0]
2430                        -  fgkSSDConnectorSeparation
2431                        -  1.5*fgkSSDConnectorLength,
2432                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2433                        -  fgkSSDConnectorPosition[1]
2434                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2435   ssdconnectortrans[1] = new TGeoTranslation(
2436                        -  ssdstiffenershape->GetDX()
2437                        +  fgkSSDConnectorPosition[0]
2438                        -  0.5*fgkSSDConnectorLength,
2439                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2440                        -  fgkSSDConnectorPosition[1]
2441                        -  ssdconnectorshape[0]->GetDY(),0.0);
2442   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2443                        -  fgkSSDConnectorPosition[0]
2444                        +  fgkSSDConnectorSeparation
2445                        +  1.5*fgkSSDConnectorLength,
2446                           -(ssdstiffenershape->GetDY()
2447                        -  fgkSSDConnectorPosition[1]
2448                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2449   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2450                        -  fgkSSDConnectorPosition[0]
2451                        +  0.5*fgkSSDConnectorLength,
2452                           -(ssdstiffenershape->GetDY()
2453                        -  fgkSSDConnectorPosition[1]
2454                        -  ssdconnectorshape[0]->GetDY()),0.0);
2455   for(Int_t i=0; i<kssdconnectornumber; i++) {
2456     Int_t nlay = kssdconnectorlayernumber - 1;
2457     if (i == 1 || i == 2)
2458       nlay++;
2459     for(Int_t j=0; j<nlay; j++)
2460       ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2461   }
2462 ////////////////////////////
2463 // Capacitor 1812-330 nF
2464 /////////////////////////// 
2465 //  Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2466   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2467                                                                                          0.5*fgkSSDCapacitor1812Length,
2468                                                                                          0.5*fgkSSDCapacitor1812Width,
2469                                                0.5*fgkSSDCapacitor1812Height);
2470   //            ssdcapacitor1812origin);
2471   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2472                                              fSSDStiffener1812CapacitorMedium); 
2473   capacitor1812->SetLineColor(fColorAl);
2474   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2475                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2476                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2477   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2478
2479   TGeoBBox* capacitor1812capshape =  new TGeoBBox("Capacitor1812CapShape",
2480     0.5*fgkSSDCapacitor1812CapLength, 0.5*fgkSSDCapacitor1812Width,
2481     0.5*fgkSSDCapacitor1812Height);
2482   TGeoVolume* capacitor1812cap = new TGeoVolume("Capacitor1812Cap",capacitor1812capshape,
2483                                              fSSDStiffenerCapacitorCapMedium);
2484   capacitor1812cap->SetLineColor(fColorNiSn);
2485   TGeoTranslation* capacitor1812captrans1 = new TGeoTranslation(
2486         - capacitor1812shape->GetDX() - capacitor1812capshape->GetDX(),
2487         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2488         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2489         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2490   ssdhybridcapacitormother->AddNode(capacitor1812cap,1,capacitor1812captrans1);
2491   TGeoTranslation* capacitor1812captrans2 = new TGeoTranslation(
2492         capacitor1812shape->GetDX() + capacitor1812capshape->GetDX(),
2493         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2494         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2495         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2496   ssdhybridcapacitormother->AddNode(capacitor1812cap,2,capacitor1812captrans2);
2497
2498 ////////////////////////////
2499 //Hybrid Wire
2500 ////////////////////////////
2501   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2502                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2503                                  - fgkSSDConnectorSeparation;
2504   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2505                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2506   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2507
2508   Double_t wireangle = TMath::ATan(wirex/wirey);
2509   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2510                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2511   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2512                                              fSSDStiffenerHybridWireMedium); 
2513   hybridwire->SetLineColor(fColorPhynox);
2514   TGeoCombiTrans* hybridwirecombitrans[2];
2515   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2516                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2517                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2518                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2519                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2520                                    ssdstiffenershape->GetDZ()
2521                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight+fgkSSDConnectorSnHeight,
2522                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2523   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2524                             0.0,
2525                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2526                             0.0,        
2527                             new TGeoRotation("HybridWireRot2",
2528                           - wireangle*TMath::RadToDeg(),0.,0.));
2529   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2530   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2531   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2532   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2533   ssdhybridlist->Add(ssdhybridcapacitormother);
2534   /////////////////////////////////////////////////////////////
2535   // Deallocating memory
2536   /////////////////////////////////////////////////////////////
2537   delete hybridwirecombitrans[0];
2538   delete hybridwirecombitrans[1];
2539   return ssdhybridlist;
2540   /////////////////////////////////////////////////////////////
2541 }
2542 ///////////////////////////////////////////////////////////////////////////////
2543 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2544   /////////////////////////////////////////////////////////////
2545   // SSD Cooling Block System
2546   /////////////////////////////////////////////////////////////
2547   // SSD Cooling Block and Cooling Tube Transformations
2548   /////////////////////////////////////////////////////////////
2549   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2550   localcoolingblockrot->SetAngles(0.,90.,0.);
2551   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2552   TVector3* coolingblocktransvector;
2553   coolingblocktransvector = new TVector3(fgkCoolingTubeSeparation,
2554                                                                   fgkSSDSensorLength
2555                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2556                                                                 - fgkSSDCoolingBlockWidth);
2557   const Int_t kcoolingblocktransnumber = 2;
2558   const Int_t kcoolingblocknumber = 4;
2559   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2560   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2561   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2562   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2563     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2564       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X(),//+2*coolingtubedistance,
2565                                              j*coolingblocktransvector->Y(),
2566                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2567                                                     + fgkCoolingTubeRmax));
2568       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2569     }
2570   }
2571   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2572   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2573   /////////////////////////////////////////////////////////////
2574   // Adding Cooling block to mother volume
2575   /////////////////////////////////////////////////////////////
2576   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2577     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2578   }
2579   /////////////////////////////////////////////////////////////
2580   // Deallocating memory
2581   /////////////////////////////////////////////////////////////
2582   delete coolingblocktransvector;
2583   delete localcoolingblockrot;
2584
2585   return coolingsystemother;
2586 }
2587 /////////////////////////////////////////////////////////////////////////////////
2588 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2589   /////////////////////////////////////////////////////////////
2590   // SSD Flex
2591   /////////////////////////////////////////////////////////////
2592   const Int_t kssdflexlayernumber = 2;
2593   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2594   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2595   const Int_t kmothervertexnumber = 17; 
2596   Double_t xmothervertex[kmothervertexnumber];
2597   Double_t ymothervertex[kmothervertexnumber];
2598   /////////////////////////////////////////////
2599   // Auxiliary variables for vertex positioning
2600   /////////////////////////////////////////////
2601   const Int_t kssdflexboxnumber = 5;
2602   Double_t ssdflexboxlength[kssdflexboxnumber];
2603   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2604                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2605                                           *     fgkSSDChipSeparationLength
2606                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2607                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2608   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2609   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2610                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2611   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2612   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2613                                           -     ssdflexboxlength[1];
2614   Double_t ssdflexboxwidth[kssdflexboxnumber];
2615   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2616   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2617   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2618   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2619   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2620   ///////////////////////
2621   // Setting the vertices 
2622   ///////////////////////
2623   xmothervertex[0]  = 0.0;
2624   xmothervertex[1]  = xmothervertex[0];
2625   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2626   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2627                                         + ssdflexboxlength[4];
2628   xmothervertex[4]  = xmothervertex[3];
2629   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2630   xmothervertex[6]  = xmothervertex[5];
2631   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2632   xmothervertex[8]  = xmothervertex[7];
2633   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2634   xmothervertex[10] = xmothervertex[9]; 
2635   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2636   xmothervertex[12] = xmothervertex[11];
2637   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2638   xmothervertex[14] = xmothervertex[13];
2639   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2640   xmothervertex[16] = xmothervertex[15];
2641   ymothervertex[0]  = 0.0;
2642   ymothervertex[1]  = fgkSSDFlexWidth[1];
2643   ymothervertex[2]  = fgkSSDFlexWidth[0];
2644   ymothervertex[3]  = ymothervertex[2];
2645   ymothervertex[4]  = ymothervertex[0];
2646   ymothervertex[5]  = ymothervertex[4];
2647   ymothervertex[6]  = ssdflexboxwidth[2];
2648   ymothervertex[7]  = ymothervertex[6];
2649   ymothervertex[8]  = ymothervertex[0];
2650   ymothervertex[9]  = ymothervertex[8];
2651   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2652   ymothervertex[11] = ymothervertex[10];
2653   ymothervertex[12] = ymothervertex[0];
2654   ymothervertex[13] = ymothervertex[12];
2655   ymothervertex[14] = ymothervertex[7];
2656   ymothervertex[15] = ymothervertex[14];
2657   ymothervertex[16] = ymothervertex[0];
2658   /////////////////////////////////////////////////////////////
2659   // First Mother Volume containing SSDFlex
2660   /////////////////////////////////////////////////////////////
2661   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2662   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2663                                                                     ymothervertex);
2664   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2665   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2666   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2667 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2668 //                                                                                       fSSDAir);
2669   /////////////////////////////////////////////////////////////
2670   // SSDFlex Layer Shapes
2671   /////////////////////////////////////////////////////////////
2672   for(Int_t i=0; i<kssdflexlayernumber; i++){
2673         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2674                                                                    ymothervertex);
2675     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2676         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2677   }
2678   /////////////////////////////////////
2679   // Setting Layers into Mother Volume
2680   /////////////////////////////////////
2681   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2682   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2683                                                                                                  fSSDKaptonFlexMedium};
2684   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2685                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2686   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2687   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2688   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2689         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2690                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2691                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2692         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2693     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2694                                          +                                         fgkSSDFlexHeight[1])); 
2695     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2696   }
2697   return ssdflexmother;
2698 }
2699 /////////////////////////////////////////////////////////////////////////////////
2700 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2701   /////////////////////////////////////////////////////////////
2702   // Method generating SSD End Flex   
2703   /////////////////////////////////////////
2704   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2705                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2706   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2707                                                 * TMath::DegToRad()*ssdflexradiusmax
2708                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2709                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2710                                                         - 0.1*fgkSSDFlexFullLength;
2711   const Int_t knedges = 20;  
2712   const Int_t karcnumber = 2;
2713   TVector3* vertexposition[karcnumber*(knedges+1)];
2714   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2715   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2716   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2717   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2718                                                                                  - 90.0*TMath::DegToRad()};
2719   TVector3* referencetrans[karcnumber];
2720   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2721                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2722                                                                    radius[0]);
2723   referencetrans[1] = new TVector3(referencetrans[0]->X()
2724                                         +              fgkSSDFlexLength[2],
2725      -              fgkSSDStiffenerHeight);
2726 for(Int_t i=0; i<karcnumber; i++){
2727         for(Int_t j=0; j<knedges+1; j++){
2728                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2729                                                                                                radius[i]*SinD(angle[i]));
2730                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2731         }       
2732   }
2733   ///////////////////////
2734   // Setting the vertices 
2735   ///////////////////////
2736   const Int_t kendflexlayernumber = 4;
2737   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2738   TVector3** vertex[kendflexlayernumber];
2739   for(Int_t i=0; i<kendflexlayernumber; i++) 
2740                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2741   TVector3* transvector[kendflexlayernumber+1];
2742   TVector3* deltatransvector = new TVector3();  
2743   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2744   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2745                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2746   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2747         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2748                                         *                 CosD(fgkSSDFlexAngle),
2749                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2750                                         *         SinD(fgkSSDFlexAngle),0.0);   
2751         *transvector[i] = *transvector[i-1]+*deltatransvector;
2752   }
2753   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2754   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2755   for(Int_t i=0; i<karcnumber; i++){
2756         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2757                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2758                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2759                                               /radius[i];
2760         }
2761   }
2762   for(Int_t i=0; i<kendflexlayernumber; i++){
2763         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2764         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2765         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2766                 if(j<(knedges+1)){
2767                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2768                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2769                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2770                         *vertex[i][j+2] += *referencetrans[0];
2771                         vertex[i][4*(knedges+1)-j+1] = 
2772                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2773                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2774                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2775                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2776                 }
2777                 else{
2778                 
2779                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2780                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2781                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2782                         *vertex[i][j+2] += *referencetrans[1];
2783                         vertex[i][4*(knedges+1)-j+1] = 
2784                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2785                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2786                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2787                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2788            }
2789         }
2790   }
2791   /////////////////////////////////////////////////////////////
2792   // First Mother Volume containing SSDEndFlex
2793   /////////////////////////////////////////////////////////////
2794   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2795   Double_t xmothervertex[kendflexvertexnumber];
2796   Double_t ymothervertex[kendflexvertexnumber];
2797   xmothervertex[0] = vertex[0][0]->X(); 
2798   ymothervertex[0] = vertex[0][0]->Y();
2799   for(Int_t i=1; i<kendflexvertexnumber; i++){
2800         if(i<2*(knedges+1)+2){
2801                 xmothervertex[i] = vertex[3][i]->X();
2802                 ymothervertex[i] = vertex[3][i]->Y();
2803         }
2804         else{
2805                 xmothervertex[i] = vertex[0][i]->X();
2806                 ymothervertex[i] = vertex[0][i]->Y();
2807         }
2808   }
2809   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2810                                                                            xmothervertex,ymothervertex);
2811   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2812   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2813 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2814 //                                                               ssdendflexmothershape,fSSDAir);        
2815   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2816   //////////////////////////////////////
2817   // End Flex TGeoXtru Layer Definition 
2818   //////////////////////////////////////
2819   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2820   TGeoVolume* ssdendflex[kendflexlayernumber];
2821   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2822   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2823   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2824   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2825   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2826                                                                                                         fSSDKaptonFlexMedium};
2827   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2828                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2829   for(Int_t i=0; i<kendflexlayernumber; i++){
2830         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2831                 xvertex[i][j] = vertex[i][j]->X();
2832                 yvertex[i][j] = vertex[i][j]->Y();
2833         }
2834   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2835   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2836   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2837   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2838                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2839   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2840   ssdendflexmother->AddNode(ssdendflex[i],1);
2841   }
2842   /////////////////////////////////////////////////////////////
2843   // Deallocating memory
2844   /////////////////////////////////////////////////////////////
2845   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2846   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2847   for(Int_t i=0; i<kendflexlayernumber; i++){
2848         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2849         delete [] vertex[i];
2850   }
2851   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2852   delete deltatransvector;
2853   /////////////////////////////////////////////////////////////
2854   //ssdendflexmother->CheckOverlaps(0.01);
2855   return ssdendflexmother;
2856 }
2857 ///////////////////////////////////////////////////////////////////////////////
2858 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
2859   /////////////////////////////////////////////////////////////
2860   // Method generating the Mounting Block
2861   /////////////////////////////////////////////////////////////  
2862   const Int_t kvertexnumber = 8;
2863   Double_t xvertex[kvertexnumber];
2864   Double_t yvertex[kvertexnumber];
2865   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
2866   xvertex[1] = xvertex[0];
2867   xvertex[2] = -xvertex[0];
2868   xvertex[3] = xvertex[2];
2869   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
2870                          -                                 fgkSSDMountingBlockLength[2]);
2871   xvertex[5] = xvertex[4];
2872   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
2873                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
2874                          -     fgkSSDMountingBlockScrewHoleRadius[0];
2875   xvertex[7] = xvertex[6];
2876   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
2877                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
2878   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
2879   yvertex[2] = yvertex[1]; 
2880   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
2881   yvertex[4] = yvertex[3];
2882   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
2883                          - fgkSSDMountingBlockHeight[0];
2884   yvertex[6] = yvertex[5];
2885   yvertex[7] = yvertex[0];
2886
2887   ///////////////////////////////////////////////////////////////////////
2888   // TGeoXTru Volume definition for Mounting Block Part
2889   ///////////////////////////////////////////////////////////////////////
2890   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
2891   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
2892   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
2893   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
2894   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
2895                                                                           ssdmountingblockshape,
2896                                                                                   fSSDMountingBlockMedium);
2897   ssdmountingblock->SetLineColor(fColorG10);
2898   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
2899   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
2900   TGeoRotation* mountingblockrot = new TGeoRotation();
2901   mountingblockrot->SetAngles(90.,180.,-90.);
2902   mountingblockcombitrans->SetRotation(*mountingblockrot);
2903   /////////////////////////////////////////////////////////////
2904   // Generating the Mounting Block Screw Vertices 
2905   /////////////////////////////////////////////////////////////  
2906   const Int_t kscrewvertexnumber = 15;
2907   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
2908                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
2909                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
2910                                  * TMath::RadToDeg();
2911   Double_t phi0 = 90.+alpha;
2912   Double_t phi = 270.-2*alpha;
2913   Double_t deltaphi = phi/kscrewvertexnumber;   
2914   TVector3* screwvertex[kscrewvertexnumber+1];
2915   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
2916         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
2917                                    *CosD(phi0+i*deltaphi),
2918                                    fgkSSDMountingBlockScrewHoleRadius[0]
2919                                    *SinD(phi0+i*deltaphi));
2920   Double_t xscrewvertex[kscrewvertexnumber+6];
2921   Double_t yscrewvertex[kscrewvertexnumber+6];
2922   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
2923   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
2924                                   -               fgkSSDMountingBlockScrewHoleEdge);
2925   xscrewvertex[1] = xscrewvertex[0];
2926   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
2927   xscrewvertex[2] = screwvertex[0]->X();
2928   yscrewvertex[2] = yscrewvertex[1];
2929   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
2930         xscrewvertex[i+3] = screwvertex[i]->X();        
2931         yscrewvertex[i+3] = screwvertex[i]->Y();        
2932   } 
2933   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
2934   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
2935   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
2936   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
2937   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
2938   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
2939   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
2940   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
2941                                                         +                                  fgkSSDMountingBlockHeight[2]);
2942   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
2943                                                                                 ssdmountingblockscrewshape,
2944                                                                                             fSSDMountingBlockMedium);
2945   ssdmountingblockscrew->SetLineColor(fColorG10);
2946   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
2947   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
2948   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
2949                                                                         -                                yscrewvertex[1],
2950                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
2951                                                                         -                                fgkSSDMountingBlockHeight[2]
2952                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2953                                                                         +                                fgkSSDMountingBlockHeight[2]
2954                                                                         -                                yvertex[0]));
2955   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
2956                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
2957                                                                                                                  yscrewvertex[1]
2958                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2959                                                                                                          +fgkSSDMountingBlockHeight[2]
2960                                                                                                          -yvertex[0]));
2961   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
2962                                                                                                           yscrewvertex[1],
2963                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
2964                                                                         +                                 fgkSSDMountingBlockHeight[2]
2965                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2966                                                                         +                                 fgkSSDMountingBlockHeight[2]
2967                                                                         -                                 yvertex[0]));
2968   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
2969                                                                                                          yscrewvertex[1],
2970                                                                         -                                yscrewvertex[1]
2971                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2972                                                                         +                                fgkSSDMountingBlockHeight[2]
2973                                                                         -                                yvertex[0]));
2974   TGeoRotation* ssdmountingblockscrewrot[4];
2975   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
2976         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
2977     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
2978     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
2979   for(Int_t i=1; i<4; i++) 
2980         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
2981   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
2982   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
2983   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
2984   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
2985                                                          +                                xvertex[0],yscrewvertex[1]
2986                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2987                                                          +                                fgkSSDMountingBlockHeight[2]
2988                                                          -                                yvertex[0]),0.);      
2989   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
2990   for(Int_t i=0; i<4; i++){
2991         ssdmountingblockscrewmatrix[i] = 
2992                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
2993         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
2994   }
2995   ///////////////////////////////////////////////////////////////////////
2996   // TGeoXtru for Mother Volume 
2997   ///////////////////////////////////////////////////////////////////////
2998   const Int_t kvertexmothernumber = 12;
2999   Double_t xmothervertex[kvertexmothernumber];
3000   Double_t ymothervertex[kvertexmothernumber];
3001   for(Int_t i=0; i<6; i++){
3002         xmothervertex[i] = xvertex[i];
3003         ymothervertex[i] = yvertex[i];
3004   } 
3005   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3006   ymothervertex[6]  = ymothervertex[5];
3007   xmothervertex[7]  = xmothervertex[6];
3008   ymothervertex[7]  = ymothervertex[4] - fgkSSDTolerance;
3009   xmothervertex[8]  = xmothervertex[7]
3010                                         + 0.5*(fgkSSDMountingBlockLength[1]
3011                                         -          fgkSSDMountingBlockLength[2]);
3012   ymothervertex[8]  = ymothervertex[7];
3013   xmothervertex[9]  = xmothervertex[8];
3014   ymothervertex[9]  = ymothervertex[2];
3015   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3016   ymothervertex[10] = ymothervertex[1];
3017   xmothervertex[11] = xmothervertex[10];
3018   ymothervertex[11] = ymothervertex[0];  
3019   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3020   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3021   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3022   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3023   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3024                                                                           ssdmountingblockmothershape,
3025                                                                                   fSSDAir);
3026   /////////////////////////////////////////////////////////////
3027   // Placing the Volumes into Mother Volume 
3028   /////////////////////////////////////////////////////////////
3029   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3030   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3031   for(Int_t i=0; i<4; i++) 
3032         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3033                                                                         ssdmountingblockscrewmatrix[i]);
3034   /////////////////////////////////////////////////////////////
3035   // Deallocating memory
3036   /////////////////////////////////////////////////////////////
3037   delete mountingblockrot;
3038   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3039   delete ssdmountingblockglobalrot; 
3040   delete ssdmountingblockglobaltrans; 
3041   /////////////////////////////////////////////////////////////
3042   return ssdmountingblockmother;
3043 }
3044 ///////////////////////////////////////////////////////////////////////////////
3045  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3046   /////////////////////////////////////////////////////////////
3047   // Method generating the Mounting Block Clip 
3048   /////////////////////////////////////////////////////////////  
3049   const Int_t kmothervertexnumber = 10;
3050   Double_t xmothervertex[kmothervertexnumber];
3051   Double_t ymothervertex[kmothervertexnumber];
3052   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3053                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3054   xmothervertex[1] = xmothervertex[0];
3055   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3056                                    - fgkMountingBlockClibScrewRadius);
3057   xmothervertex[3] = xmothervertex[2]; 
3058   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3059   xmothervertex[5] = xmothervertex[4]; 
3060   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3061   xmothervertex[7] = xmothervertex[6]; 
3062   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3063   xmothervertex[9] = xmothervertex[8]; 
3064   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3065                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3066   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3067   ymothervertex[2] = ymothervertex[1];
3068   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3069                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3070                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3071   ymothervertex[4] = ymothervertex[3];
3072   ymothervertex[5] = ymothervertex[2];
3073   ymothervertex[6] = ymothervertex[5];
3074   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3075   ymothervertex[8] = ymothervertex[7];
3076   ymothervertex[9] = ymothervertex[0];
3077
3078   ///////////////////////////////////////////////////////////////////////
3079   // TGeoXTru Volume definition for Mounting Block Clip Part
3080   ///////////////////////////////////////////////////////////////////////
3081   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3082   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3083   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3084   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3085   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3086                                                                           ssdmountingblockclipshape,fSSDAir);
3087   ssdmountingblockclip->SetLineColor(4);
3088   ///////////////////////////////////////////////////////////////////////
3089   // TGeoXTru Volume definition for Clip 
3090   ///////////////////////////////////////////////////////////////////////
3091   const Int_t kclipvertexnumber = 6;
3092   Double_t xclipvertex[kclipvertexnumber];
3093   Double_t yclipvertex[kclipvertexnumber];
3094   xclipvertex[0] = xmothervertex[0];
3095   xclipvertex[1] = xclipvertex[0];
3096   xclipvertex[2] = xmothervertex[6];
3097   xclipvertex[3] = xclipvertex[2];
3098   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3099   xclipvertex[5] = xclipvertex[4];
3100   yclipvertex[0] = ymothervertex[0];
3101   yclipvertex[1] = ymothervertex[1];
3102   yclipvertex[2] = yclipvertex[1];
3103   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3104   yclipvertex[4] = yclipvertex[3];
3105   yclipvertex[5] = yclipvertex[0];
3106   TGeoXtru* clipshape = new TGeoXtru(2);
3107   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3108   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3109   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3110                                                          +   fgkMountingBlockClibWidth);
3111   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3112   clip->SetLineColor(18);
3113   ///////////////////////////////////////////////////////////////////////
3114   // Ladder Support Piece  
3115   ///////////////////////////////////////////////////////////////////////
3116   const Int_t ksupportvertexnumber = 4;
3117   Double_t xsupportvertex[ksupportvertexnumber];
3118   Double_t ysupportvertex[ksupportvertexnumber];
3119   xsupportvertex[0] = xclipvertex[5];
3120   xsupportvertex[1] = xsupportvertex[0];
3121   xsupportvertex[2] = xmothervertex[9];
3122   xsupportvertex[3] = xsupportvertex[2];
3123   ysupportvertex[0] = yclipvertex[0];
3124   ysupportvertex[1] = yclipvertex[3];
3125   ysupportvertex[2] = ysupportvertex[1];
3126   ysupportvertex[3] = ysupportvertex[0];
3127   TGeoXtru* supportshape = new TGeoXtru(2);
3128   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3129   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3130   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3131   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3132   support->SetLineColor(9);
3133   ///////////////////////////////////////////////////////////////////////
3134   // TGeoXTru Volume definition for Screw   
3135   ///////////////////////////////////////////////////////////////////////
3136   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3137                                                 0.5*fgkMountingBlockClibScrewRadius};
3138   Int_t edgesnumber[2] = {50,6};
3139   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3140                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3141   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3142   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3143   clipscrew->SetLineColor(12);
3144   TGeoRotation* screwrot = new TGeoRotation();
3145   screwrot->SetAngles(0.,90.,0.);
3146   TGeoTranslation* screwtrans = new TGeoTranslation();
3147   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3148                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3149                                                          0.5*fgkSSDMountingBlockWidth+
3150                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3151   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3152   ///////////////////////////////////////////////////////////////////////
3153   // Placing the Volumes
3154   ///////////////////////////////////////////////////////////////////////
3155   ssdmountingblockclip->AddNode(clip,1);
3156   ssdmountingblockclip->AddNode(support,1);
3157   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3158   /////////////////////////////////////////////////////////////
3159   // Deallocating memory
3160   /////////////////////////////////////////////////////////////  
3161   delete screwtrans;
3162   delete screwrot;
3163   /////////////////////////////////////////////////////////////
3164   return ssdmountingblockclip;
3165 }
3166 ///////////////////////////////////////////////////////////////////////////////
3167 void AliITSv11GeometrySSD::CreateCoolingTubes() {
3168   /////////////////////////////////////////////////////////////
3169   // Method generating the Cooling Tube 
3170   // sets fcoolingtube and returns list for endladdercoolingtube
3171   /////////////////////////////////////////////////////////////  
3172   TGeoTube *coolingtubeshape[2];
3173   // Ladder Cooling Tubes
3174
3175   // MvL: Simplified cooling tubes
3176   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,0.5*fgkCoolingTubeLength);
3177   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,coolingtubeshape[0]->GetDz());
3178
3179   // End Ladder Cooling Tubes   
3180   TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3181   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3182     endladdercoolingtubeshape[i] = new  TGeoTube*[2];
3183
3184   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
3185   endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3186                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0] - sensZshift));
3187   endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3188                                                  endladdercoolingtubeshape[0][0]->GetDz());
3189   endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3190                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1] + sensZshift));
3191   endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3192                                                  endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3193   // Ladder Cooling Tubes
3194   TGeoVolume* coolingtube[2];
3195   coolingtube[0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0], fSSDCoolingTubePhynox);
3196   coolingtube[1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[1], fSSDCoolingTubeWater);
3197   coolingtube[0]->SetLineColor(fColorPhynox);
3198   coolingtube[1]->SetLineColor(fColorWater);
3199
3200   // End Ladder Cooling Tubes   
3201   TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3202   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3203     endladdercoolingtube[i] = new TGeoVolume*[2];
3204   endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3205                                               endladdercoolingtubeshape[0][0],
3206                                               fSSDCoolingTubePhynox);
3207   endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3208                                               endladdercoolingtubeshape[0][1],
3209                                               fSSDCoolingTubeWater);
3210   endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3211                                               endladdercoolingtubeshape[1][0],
3212                                               fSSDCoolingTubePhynox);
3213   endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3214                                               endladdercoolingtubeshape[1][1],
3215                                               fSSDCoolingTubeWater);
3216   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3217     endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3218     endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3219   }
3220   
3221   /////////////////////////////////////////////////////////////
3222   // Virtual Volume containing Cooling Tubes
3223   /////////////////////////////////////////////////////////////
3224   // Ladder Cooling Tubes
3225   TGeoTube* virtualcoolingtubeshape = new TGeoTube(coolingtubeshape[1]->GetRmin(),
3226                                                    coolingtubeshape[0]->GetRmax(),
3227                                                    coolingtubeshape[0]->GetDz());
3228   fcoolingtube = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape, fSSDAir);
3229   fcoolingtube->AddNode(coolingtube[0],1);
3230   fcoolingtube->AddNode(coolingtube[1],1);
3231
3232   // End Ladder Cooling Tubes
3233   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3234   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3235     endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3236                                                        endladdercoolingtubeshape[i][0]->GetRmax(),
3237                                                        endladdercoolingtubeshape[i][0]->GetDz());
3238   fendladdercoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3239                                             endladdervirtualcoolingtubeshape[0],
3240                                             fSSDAir);
3241   fendladdercoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3242                                             endladdervirtualcoolingtubeshape[1],
3243                                             fSSDAir);
3244   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3245   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3246   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3247   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);  
3248 }
3249 ///////////////////////////////////////////////////////////////////////////////
3250 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3251   /////////////////////////////////////////////////////////////
3252   // Method generating SSD Cooling Block    
3253   /////////////////////////////////////////////////////////////
3254   const Int_t kvertexnumber = 8;
3255   ///////////////////////////////////////
3256   // Vertex Positioning for TGeoXTru
3257   ///////////////////////////////////////
3258   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3259   vertexposition[0] = new TVector3(0.0,0.0);
3260   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3261   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3262                                           vertexposition[1]->Y());
3263   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3264                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3265   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3266   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3267                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3268   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3269                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3270                                         - fgkSSDCoolingBlockHoleLength[0]
3271                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3272                                           fgkSSDCoolingBlockHeight[0]
3273                                         - fgkSSDCoolingBlockHoleRadius[1],
3274                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3275   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3276                                         - fgkSSDCoolingBlockHoleLength[0]),
3277                                           vertexposition[6]->Y());
3278   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3279                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3280   Double_t phi = 180.-alpha;
3281   Double_t psi = 180.+2.*alpha;
3282   Double_t deltapsi = psi/nedges;
3283   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3284   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3285                                                   fgkSSDCoolingBlockHoleCenter);
3286   for(Int_t i=0; i<nedges+1; i++){
3287         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3288                                                                                                radius*SinD(phi+i*deltapsi));
3289    *vertexposition[kvertexnumber+i] += (*transvector);
3290   }
3291   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3292   for(Int_t i=0; i<kvertexnumber; i++)
3293     vertexposition[kvertexnumber+nedges+1+i] = 
3294                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3295   ///////////////////////////////////////////////////////////////////////
3296   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3297   ///////////////////////////////////////////////////////////////////////
3298   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3299   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3300   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3301   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3302         xvertexpoints[i] = vertexposition[i]->X();
3303         yvertexpoints[i] = vertexposition[i]->Y();
3304   } 
3305   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3306                                                                                         yvertexpoints);
3307   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3308   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3309   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3310                                                                           ssdcoolingblockshape,
3311                                                                                   fSSDAlCoolBlockMedium);
3312   ssdcoolingblock->SetLineColor(fColorAl);
3313   /////////////////////////////////////////////////////////////
3314   // Deallocating memory
3315   /////////////////////////////////////////////////////////////
3316   delete [] vertexposition;
3317   delete [] xvertexpoints;
3318   delete [] yvertexpoints;
3319   /////////////////////////////////////////////////////////////
3320   return ssdcoolingblock;
3321 }
3322 /////////////////////////////////////////////////////////////////////////////////
3323 void AliITSv11GeometrySSD::GetSSDChipCables(TGeoVolume *&cableL, TGeoVolume *&cableR, Double_t SSDChipCablesHeight, Int_t nedges){
3324   ///////////////////////////////////////////////////////
3325   static const Int_t kssdchipcablesnumber    = 2;  // Number of cables: left and right
3326   static const Int_t kssdchipcableslaynumber = 2;  // Number of layers: Al and Kapton
3327   static const Int_t kvertexnumber                        = 4*(nedges+1)+4;
3328   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3329   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3330   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeight
3331                                                  -  fgkSSDChipCablesHeight[0]
3332                                                  -  fgkSSDChipCablesHeight[1]);
3333   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3334   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3335   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3336                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3337                                                           - ssdchipcablesradius[0]
3338                                                           - fgkSSDChipCablesWidth[1]
3339                                                           - fgkSSDChipCablesWidth[2]);
3340   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3341                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3342                                                           +      fgkSSDChipCablesHeight[1]
3343                                                           +      fgkSSDSensorHeight);
3344   ///////////////////////////////////////////////////////
3345   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3346   ///////////////////////////////////////////////////////
3347   TVector3** vertexposition[kssdchipcableslaynumber];
3348   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3349                                                                                                   new TVector3*[4*(nedges+1)+4];
3350   Double_t ratio[4];
3351   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3352   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3353                    /  ssdchipcablesradius[0]; 
3354   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3355                    /  ssdchipcablesradius[0];
3356   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3357                    +  fgkSSDChipCablesHeight[1])
3358                    /  ssdchipcablesradius[0];
3359   Double_t phi = 180.;
3360   Double_t deltaphi = 180./nedges;
3361   Double_t angle = 0.0;
3362
3363   Double_t xvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3364   Double_t yvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3365
3366   TVector3* vertex = new TVector3();
3367   TVector3* transvector[kssdchipcableslaynumber];
3368   transvector[0] = new TVector3(fgkSSDChipWidth,
3369                                                                 SSDChipCablesHeight-ssdchipcablesradius[0]);
3370   transvector[1] = new TVector3();
3371   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcablesnumber];
3372   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcablesnumber];
3373   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcablesnumber] = 
3374                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3375                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3376   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3377         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3378         transvector[1]->SetY(ssdchipcablesradius[0]
3379                                  +               fgkSSDChipCablesHeight[0]
3380                                  +               fgkSSDChipCablesHeight[1]);  
3381         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3382                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeight
3383                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3384                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeight
3385                                                          - i*fgkSSDChipCablesHeight[0]);
3386                 vertexposition[i][2*(nedges+1)+2] = 
3387                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3388                                 +                                fgkSSDChipCablesWidth[1]
3389                                 +                                fgkSSDChipCablesWidth[2],
3390                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3391                                 +                                fgkSSDChipCablesHeight[1]));
3392         vertexposition[i][2*(nedges+1)+3] = 
3393                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3394                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3395                                 -                                fgkSSDChipCablesHeight[i]);
3396             for(Int_t j=0; j<nedges+1; j++){            
3397                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3398                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3399                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3400                         vertexposition[0][(nedges+1)*i+j+2] = 
3401                                                 new TVector3(*vertex+*transvector[i]);
3402                         vertexposition[1][(nedges+1)*i+j+2] = 
3403                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3404                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3405                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3406                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3407                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3408                                                 new TVector3(vertex->X()*ratio[2*i+1]
3409                                                         +                        transvector[i]->X(),
3410                                                                                  vertex->Y()*ratio[2*i+1]
3411                                                         +                transvector[i]->Y());
3412                 }
3413         }
3414         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3415                 for(Int_t j=0; j<kvertexnumber; j++){   
3416                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3417                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3418                 }
3419                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3420                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3421                                                                                 xvertexpoints[i],yvertexpoints[i]);
3422                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3423                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3424                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3425                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3426                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3427                                                           (kssdchipcablesnumber*k+i)%2==0?
3428                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3429                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3430         }
3431         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3432                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3433   }
3434   /////////////////////////////////////////////////////////////
3435   // Mother Volume definition 
3436   /////////////////////////////////////////////////////////////
3437   static const Int_t kmothervertexnumber = 8;
3438   Double_t xmothervertex[kmothervertexnumber];
3439   Double_t ymothervertex[kmothervertexnumber];
3440   xmothervertex[0] = xvertexpoints[0][1];
3441   ymothervertex[0] = yvertexpoints[0][1];
3442   xmothervertex[1] = xvertexpoints[0][2+nedges/2];
3443   ymothervertex[1] = yvertexpoints[0][1];
3444   xmothervertex[2] = xvertexpoints[0][2+nedges/2];
3445   ymothervertex[2] = yvertexpoints[0][2+nedges];
3446   xmothervertex[3] = xvertexpoints[0][3+nedges];
3447   ymothervertex[3] = yvertexpoints[0][3+nedges];
3448   xmothervertex[4] = xvertexpoints[0][3+2*nedges];
3449   ymothervertex[4] = yvertexpoints[0][3+2*nedges]+fgkSSDTolerance;
3450   xmothervertex[5] = xvertexpoints[0][4+2*nedges];
3451   ymothervertex[5] = yvertexpoints[0][4+2*nedges]+fgkSSDTolerance;
3452   xmothervertex[6] = xvertexpoints[1][5+2*nedges];
3453   ymothervertex[6] = yvertexpoints[1][5+2*nedges];
3454   xmothervertex[7] = xvertexpoints[0][1];
3455   ymothervertex[7] = yvertexpoints[1][5+2*nedges];
3456   TGeoXtru *ssdchipcablemothershape = new TGeoXtru(2);
3457   ssdchipcablemothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3458   ssdchipcablemothershape->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3459   ssdchipcablemothershape->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3460
3461   cableL = new TGeoVolume("SSDChipCableMotherLeft",ssdchipcablemothershape,fSSDAir);
3462   cableR = new TGeoVolume("SSDChipCableMotherRight",ssdchipcablemothershape,fSSDAir);
3463
3464   cableL->AddNode(ssdchipcable[0],1);
3465   cableL->AddNode(ssdchipcable[1],1);
3466   cableR->AddNode(ssdchipcable[2],1);
3467   cableR->AddNode(ssdchipcable[3],1);  
3468
3469   /////////////////////////////////////////////////////////////
3470   // Deallocating memory
3471   /////////////////////////////////////////////////////////////
3472   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3473   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3474   delete vertex; 
3475   /////////////////////////////////////////////////////////////
3476 }
3477 //_____________________________________________________________________________
3478 TGeoVolume* AliITSv11GeometrySSD::GetSSDChip() const{
3479   /////////////////////////////////////////////////////////////
3480   // SSD Chip Assembly Generation    
3481   /////////////////////////////////////////////////////////////
3482   TGeoBBox* ssdchipcompshape[2];
3483   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3484                                                                                 0.5*fgkSSDChipLength,
3485                                                                                 0.5*fgkSSDChipWidth,
3486                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3487   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3488                                                                                 0.5*fgkSSDChipLength,
3489                                                                                 0.5*fgkSSDChipWidth,
3490                                                                                 0.5*fgkSSDChipGlueHeight);
3491   TGeoVolume* ssdchipcomp[2];
3492   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3493   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3494                                                                   fSSDChipGlueMedium);
3495   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3496   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3497   TGeoTranslation* ssdchipcomptrans[2];
3498   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3499   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3500   /////////////////////////////////////////////////////////////
3501   // Virtual Volume containing SSDChip   
3502   /////////////////////////////////////////////////////////////
3503   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3504                                                                                                                  0.5*fgkSSDChipWidth,
3505                                                                                                                  0.5*fgkSSDChipHeight);
3506   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3507   /////////////////////////////////////////////////////////////
3508   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3509   return ssdchip;
3510 }
3511 /////////////////////////////////////////////////////////////////////////////////
3512 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3513   /////////////////////////////////////////////////////////////
3514   // Method returning a List containing pointers to Ladder Cable Volumes    
3515   //
3516   // Return list contains 3 assemblies: cable box, cable arb shape and the end part of the cable
3517   //                                    each contains 2 volumes, one for polyamide and one for aluminium
3518   /////////////////////////////////////////////////////////////
3519   const Int_t kladdercablesegmentnumber = 2;
3520   /////////////////////////////////////////
3521   // LadderSegmentBBox Volume
3522   /////////////////////////////////////////
3523   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3524   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3525                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3526
3527
3528   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3529                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3530   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3531
3532   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3533                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3534                                                                                            0.5*fgkSSDFlexWidth[0],
3535                                                                                            0.5*fgkSSDLadderCableWidth,
3536                                                                        0.5*fgkSSDLadderCableHeight[0]),
3537                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3538                                                                                            0.5*fgkSSDFlexWidth[0],
3539                                                                                            0.5*fgkSSDLadderCableWidth,
3540                                                                                            fgkSSDLadderCableHeight[0]
3541                                                                                            +0.5*fgkSSDLadderCableHeight[1])
3542                                                                                    };
3543   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3544   static TGeoVolume* laddercablesegmentarbassembly = 
3545                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3546
3547   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3548   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3549
3550   if (laddercablesegmentbboxshape[0] == 0) { 
3551     // Initialise static shapes and volumes 
3552   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3553                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3554                                                                            0.5*fgkSSDFlexWidth[0],
3555                                                                            0.5*fgkSSDLadderCableWidth,
3556                                                                            0.5*fgkSSDLadderCableHeight[i]); 
3557
3558   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3559                         laddercablesegmentbbox[i] =
3560                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3561                                                                                  laddercablesegmentbboxshape[i],
3562                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3563             fSSDKaptonLadderCableMedium));
3564                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3565                                                                                                                    fColorPolyhamide);
3566   }
3567   
3568   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3569                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3570                                                                                             laddercablesegmentbboxtrans[i]);
3571 /////////////////////////////////////////
3572 // LadderSegmentArb8 Volume
3573 /////////////////////////////////////////
3574   const Int_t kvertexnumber = 4;
3575   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3576   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3577                                                                                                   new TVector3*[kvertexnumber];
3578 //Shape Vertex Positioning
3579   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3580         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3581         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3582                                                                                                                   i*fgkSSDFlexHeight[0]);
3583         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3584                                                                                    +                         fgkSSDFlexHeight[1]
3585                                                                                    +                      i*fgkSSDFlexHeight[0]);
3586         laddercablesegmentvertexposition[i][3] = 
3587                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3588                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3589   }
3590   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3591                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3592   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3593                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3594
3595   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3596                                         GetArbShape(laddercablesegmentvertexposition[i],
3597                                                                 laddercablesegmentwidth[i],
3598                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3599                                                                 laddercablesegmentarbshapename[i]);
3600   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3601                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3602
3603   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3604                          laddercablesegmentarb[i] =
3605                                                    new TGeoVolume(laddercablesegmentarbname[i],
3606                                                                                   laddercablesegmentarbshape[i],
3607                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3608             fSSDKaptonLadderCableMedium)); 
3609                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3610                                                                                                                    fColorPolyhamide);
3611 }
3612   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3613   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3614                                                                                                  90.,90,-90.);   
3615   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3616                                                                                                   0.,90.,0.);    
3617   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3618                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3619                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3620                                                          + fgkSSDFlexWidth[0],0.,0.,
3621                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3622                                                      *(*laddercablesegmentarbrot[0])));
3623   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3624   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3625                                                                                    laddercablesegmentarbcombitrans);
3626   }  // End of static initialisations
3627 /////////////////////////////////////////
3628 // End Ladder Cable Volume
3629 // Note: this part depends explicitly on the length passed as an argument to the function
3630 /////////////////////////////////////////
3631   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
3632   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
3633                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
3634   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
3635                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
3636                                                                            0.5*ssdendladdercablelength,
3637                                                                            0.5*fgkSSDLadderCableWidth,
3638                                                                            0.5*fgkSSDLadderCableHeight[i]);
3639   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
3640                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
3641   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
3642   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3643                         ladderendcablesegmentbbox[i] =
3644                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
3645                                                                                  ladderendcablesegmentbboxshape[i],
3646                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3647             fSSDKaptonLadderCableMedium));
3648                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3649                                                                                                                    fColorPolyhamide);
3650   }
3651   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
3652   ladderendcablesegmentbboxtrans[0] = 
3653                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
3654                                                                                            0.5*ssdendladdercablelength,
3655                                                                                            0.5*fgkSSDLadderCableWidth,
3656                                                                                            0.5*fgkSSDLadderCableHeight[0]);
3657   ladderendcablesegmentbboxtrans[1] = 
3658                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
3659                                                                                            0.5*ssdendladdercablelength,
3660                                                                                            0.5*fgkSSDLadderCableWidth,
3661                                                                                            fgkSSDLadderCableHeight[0]
3662                                                                                            +0.5*fgkSSDLadderCableHeight[1]);
3663   TGeoVolume* ladderendcablesegmentbboxassembly = 
3664                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
3665   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3666                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
3667                                                                                             ladderendcablesegmentbboxtrans[i]);
3668 /////////////////////////////////////////
3669   TList* laddercablesegmentlist = new TList();
3670   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
3671   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
3672   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
3673   return laddercablesegmentlist;
3674 }
3675
3676 /////////////////////////////////////////////////////////////////////////////////
3677 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
3678   /////////////////////////////////////////////////////////////
3679   // Method generating Ladder Cable of given length (n modules + end)
3680   // Called by GetLadderCableAssembly
3681   /////////////////////////////////////////////////////////////
3682   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
3683   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
3684   for(Int_t i=0; i<n; i++){
3685          TGeoTranslation* laddercabletrans = new TGeoTranslation(
3686                                                         i*(fgkCarbonFiberJunctionWidth),
3687                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3688                                                         i*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3689     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
3690     if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
3691  
3692   }
3693   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
3694                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3695                                                              fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3696                                                              (n-1)*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3697   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
3698   return laddercable;
3699 }
3700 /////////////////////////////////////////////////////////////////////////////////
3701 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
3702   ///////////////////////////////////////////////////////////////////
3703   // Main method generating Ladder Cable bundles containing n cables
3704   ///////////////////////////////////////////////////////////////////
3705   Double_t totalLength = ssdendladdercablelength+(n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0];
3706   Double_t cableOrig[3] = {0.5*totalLength,1.5*fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1])};
3707   TGeoBBox *laddercableshape = new TGeoBBox(0.5*totalLength,0.5*fgkSSDLadderCableWidth,0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]),cableOrig);
3708   TGeoVolume* laddercable = new TGeoVolume("LadderCableMother", laddercableshape, fSSDAir);
3709   char laddercabletransname[100];
3710   for(Int_t i=0; i<n; i++){ 
3711     snprintf(laddercabletransname,100,"LadderCableTrans%i",i+1);
3712     laddercable->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
3713                          new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0,0));
3714   }
3715   return laddercable;
3716 }
3717 /////////////////////////////////////////////////////////////////////////////////
3718 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
3719   /////////////////////////////////////////////////////////////
3720   // Method generating Ladder Cable List Assemblies  
3721   // containing two cables bundles, i.e. P+N readout for one endcap
3722   /////////////////////////////////////////////////////////////  
3723   const Int_t kladdercableassemblynumber = 2; 
3724   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
3725   TGeoVolume* ladderCable[kladdercableassemblynumber];
3726   char laddercableassemblyname[100];
3727   TList* laddercableassemblylist = new TList();
3728   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
3729     snprintf(laddercableassemblyname,100,"LadderCableAssembly%i",i+1);
3730         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
3731         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
3732                                          new TGeoCombiTrans((n-1)
3733                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3734                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
3735                                                                                         0.,new TGeoRotation("",180,0.,0.)));
3736         laddercableassemblylist->Add(ladderCable[i]);
3737 }
3738   return laddercableassemblylist;
3739 }
3740 ///////////////////////////////////////////////////////////////////////////////
3741 void AliITSv11GeometrySSD::SetLadderSegment(){
3742   /////////////////////////////////////////////////////////////
3743   // Method Generating Ladder Segment Array
3744   /////////////////////////////////////////////////////////////
3745   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
3746   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
3747
3748   /* MvL: tried to create mother volume. Requires changes in all rotations, bc xtru is always along z-axis
3749   TGeoXtru *laddersegmentshape = new TGeoXtru(2);
3750   static const Int_t ntrianglevtx = 3;
3751   Double_t xtrianglevtx[ntrianglevtx]={-0.5*fgkCarbonFiberTriangleLength,fgkCarbonFiberTriangleLength, 0};
3752   Double_t ytrianglevtx[ntrianglevtx]={0, 0, fgkCarbonFiberTriangleLength * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad())};
3753   laddersegmentshape->DefinePolygon(ntrianglevtx,xtrianglevtx,ytrianglevtx);
3754   laddersegmentshape->DefineSection(0,0);
3755   laddersegmentshape->DefineSection(1,fgkCarbonFiberJunctionWidth);  // MVL
3756   fladdersegment[0] = new TGeoVolume("LadderSegment1",laddersegmentshape,fSSDAir);      
3757   fladdersegment[1] = new TGeoVolume("LadderSegment2",laddersegmentshape,fSSDAir);      
3758   */
3759
3760   if(!fCreateMaterials) CreateMaterials();
3761   if(!fTransformationMatrices) CreateTransformationMatrices();
3762   if(!fBasicObjects) CreateBasicObjects();
3763   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
3764   // Placing Carbon Fiber Support       
3765         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
3766                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3767                                                                                         fcarbonfibersupportmatrix[j]);  
3768                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3769                                                                                         fcarbonfibersupportmatrix[j]);
3770   }
3771   // Placing Carbon Fiber Junction
3772         for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++) {
3773         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
3774                                                                    fcarbonfiberjunctionmatrix[j]);
3775   }
3776   // Placing Carbon Fiber Lower Support
3777     for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++) {
3778                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
3779                                                            fcarbonfiberlowersupportrans[j]);    
3780     }
3781   // Placing SSD Sensor Support
3782     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
3783         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
3784                                                                      fssdsensorsupport[1][i],
3785                                                            j+1,fssdsensorsupportmatrix[j]);
3786   // Placing SSD Cooling Tube Support 
3787         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
3788                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3789                                                                    fcoolingtubesupportmatrix[j]);
3790   // Placing SSD Cooling Tube  
3791         fladdersegment[i]->AddNode(fcoolingtube,1,fcoolingtubematrix[0]);
3792         fladdersegment[i]->AddNode(fcoolingtube,2,fcoolingtubematrix[1]);
3793   // Placing SSD Hybrid
3794     switch(i){
3795         case 0: 
3796                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
3797                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3798                 break;
3799     case 1:
3800                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
3801                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3802                 break;
3803         }
3804         // Placing Cooling Block System
3805       fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
3806         // Placing SSD Flex
3807       for(Int_t j=0; j<fgkflexnumber; j++){
3808         fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
3809         fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
3810       }
3811    }
3812 }
3813 ///////////////////////////////////////////////////////////////////////////////
3814 void AliITSv11GeometrySSD::SetEndLadderSegment(){
3815   /////////////////////////////////////////////////////////////
3816   // Method Generating End Ladder
3817   /////////////////////////////////////////////////////////////
3818   // End Ladder Carbon Fiber Junction 
3819   /////////////////////////////////////////////////////////////
3820   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
3821   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
3822   if(!fCreateMaterials) CreateMaterials();
3823   if(!fTransformationMatrices) CreateTransformationMatrices();
3824   if(!fBasicObjects) CreateBasicObjects();
3825   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
3826         for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
3827                 fendladdersegment[i]->AddNode(j==2 ? 
3828                                                         fendladdercarbonfiberjunction[i][1] : 
3829                                                         fendladdercarbonfiberjunction[i][0],
3830                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
3831   }
3832   /////////////////////////////////////////////////////////////
3833   // End Ladder Carbon Fiber Support 
3834   /////////////////////////////////////////////////////////////
3835   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
3836       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
3837                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3838                   fendladdercarbonfibermatrix[i][j]);   
3839           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3840                   fendladdercarbonfibermatrix[i][j]);   
3841       }
3842   /////////////////////////////////////////////////////////////
3843   // End Ladder Mounting Block
3844   /////////////////////////////////////////////////////////////
3845   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3846        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
3847                                      fendladdermountingblockcombitrans[i]);
3848   /////////////////////////////////////////////////////////////
3849   // End Ladder Mounting Block Clip
3850   /////////////////////////////////////////////////////////////
3851   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3852         for(Int_t j=0; j<2; j++)
3853                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
3854                                               fendladdermountingblockclipmatrix[i][j]);
3855   /////////////////////////////////////////////////////////////
3856   // End Ladder Lower Supports
3857   /////////////////////////////////////////////////////////////
3858   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
3859                                 fendladderlowersupptrans[0]);
3860   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
3861                                 fendladderlowersupptrans[1]);
3862   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
3863                                 fendladderlowersupptrans[2]);
3864   /////////////////////////////////////////////////////////////
3865   // End Ladder Cooling Tube Support
3866   /////////////////////////////////////////////////////////////
3867   for(Int_t i=0; i<2; i++) 
3868         for(Int_t j=0; j<(i==0?4:2); j++)   
3869                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3870                                               fendladdercoolingtubesupportmatrix[i][j]);
3871   /////////////////////////////////////////////////////////////
3872   // End Ladder Cooling Tube Support
3873   /////////////////////////////////////////////////////////////
3874   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]); 
3875   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);
3876   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[1][0]);
3877   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[1][1]); 
3878 }
3879 ///////////////////////////////////////////////////////////////////////////////
3880 void AliITSv11GeometrySSD::SetLadder(){
3881   /////////////////////////////////////////////////////////////
3882   // Method Generating Ladder of Layer 5 and 6
3883   /////////////////////////////////////////////////////////////  
3884   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
3885                                                                                                 fgkSSDLay6SensorsNumber};
3886   /////////////////////////////////////////////////////////////////////////////                                         
3887   /// Generating Ladder Mother Volume Containing Ladder 
3888   /////////////////////////////////////////////////////////////////////////////          
3889   TGeoXtru* laddershape[fgkladdernumber];       
3890   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
3891   const Int_t kmothervertexnumber = 8;  
3892   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
3893   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
3894   ///////////////////////
3895   // Setting the vertices 
3896   ///////////////////////
3897   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
3898                                                                 * (fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]);
3899   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
3900   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
3901   xmothervertex[0][1] = xmothervertex[0][0];
3902   ymothervertex[0][1] = -0.5*fgkCoolingTubeSupportHeight; // 0.0; MvL 20-apr-2010
3903   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
3904                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
3905   ymothervertex[0][2] = ymothervertex[0][1];
3906   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
3907   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
3908   xmothervertex[0][4] = -xmothervertex[0][3];
3909   ymothervertex[0][4] = ymothervertex[0][3];
3910   xmothervertex[0][5] = -xmothervertex[0][2];
3911   ymothervertex[0][5] = ymothervertex[0][2];
3912   xmothervertex[0][6] = -xmothervertex[0][1];
3913   ymothervertex[0][6] = ymothervertex[0][1];
3914   xmothervertex[0][7] = -xmothervertex[0][0];
3915   ymothervertex[0][7] = ymothervertex[0][0];
3916   for(Int_t i=0; i<kmothervertexnumber; i++){
3917         xmothervertex[1][i] = xmothervertex[0][i];
3918         ymothervertex[1][i] = ymothervertex[0][i];
3919   }
3920 ///////////////////////////////////////////////////////////////////////////
3921 // Disalignement Mother Volume corrections 25/08/08
3922 ///////////////////////////////////////////////////////////////////////////
3923   TGeoXtru* leftladdershape1[fgkladdernumber];  
3924   TGeoXtru* leftladdershape2[fgkladdernumber];  
3925   TGeoXtru* centersensorladdershape[fgkladdernumber];   
3926   TGeoXtru* rightladdershape1[fgkladdernumber]; 
3927   TGeoXtru* rightladdershape2[fgkladdernumber]; 
3928   for(Int_t i=0; i<fgkladdernumber; i++){
3929     leftladdershape1[i] = new TGeoXtru(2);
3930     leftladdershape2[i] = new TGeoXtru(2);
3931     centersensorladdershape[i] = new TGeoXtru(2);
3932     rightladdershape1[i] = new TGeoXtru(2);
3933     rightladdershape2[i] = new TGeoXtru(2);
3934   }
3935   //////////////////////////////////////
3936   // Setting the names for shapes  
3937   //////////////////////////////////////
3938   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
3939   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
3940   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
3941   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
3942   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
3943   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
3944   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
3945   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
3946   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
3947   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
3948   //////////////////////////////////////
3949   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
3950   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
3951   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
3952   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
3953   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
3954   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
3955   for(Int_t i=0; i<fgkladdernumber; i++) {
3956     for(Int_t j=0; j<kmothervertexnumber; j++){
3957       xcentersensorvertex[i][j] = xmothervertex[i][j];
3958       ycentersensorvertex[i][j] = ymothervertex[i][j];
3959       xend1laddervertex[i][j] = xmothervertex[i][j];
3960       yend1laddervertex[i][j] = ymothervertex[i][j];
3961       xend2laddervertex[i][j] = xmothervertex[i][j];
3962       yend2laddervertex[i][j] = ymothervertex[i][j];
3963     }
3964     // Add some space around sensors to accommodate misalignments
3965     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
3966     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
3967     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
3968     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
3969     
3970     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
3971     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
3972     
3973     // Center Ladder Piece
3974     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
3975                                               ycentersensorvertex[i]);
3976     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
3977                                                  + 1.45*fgkSSDMountingBlockWidth);
3978     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
3979                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
3980                                                  - 2.4*fgkSSDMountingBlockWidth);
3981
3982     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
3983
3984     // Cuts off first corner (neg x)
3985     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
3986     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
3987     // Cuts off last part (pos x)
3988     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
3989     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
3990
3991     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
3992                                        yend1laddervertex[i]);
3993     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
3994     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
3995                                          - fgkEndLadderMountingBlockPosition[0]);
3996     
3997     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
3998                                        yend2laddervertex[i]);
3999     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4000                                          - fgkEndLadderMountingBlockPosition[0]); 
4001     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4002                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4003
4004     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4005                                         yend1laddervertex[i]);
4006     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4007                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4008                                         -2.4*fgkSSDMountingBlockWidth);
4009     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4010                                         + fgkEndLadderMountingBlockPosition[1]);
4011
4012     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4013                                         yend2laddervertex[i]);
4014     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4015                                            + fgkEndLadderMountingBlockPosition[1]);
4016     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4017                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4018   }
4019   TGeoCompositeShape* laddershapecontainer[2];
4020   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4021                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4022                                                    "+Lay5CenterSensorContainer"
4023                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4024   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4025                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4026                                                    "+Lay6CenterSensorContainer"
4027                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4028   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4029   for(Int_t i=0; i<fgkladdernumber; i++){
4030     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4031     fladder[i]->SetLineColor(4);
4032   }
4033 ///////////////////////////////////////////////////////////////////////////
4034  if(!fCreateMaterials) CreateMaterials();
4035  if(!fTransformationMatrices) CreateTransformationMatrices();
4036  if(!fBasicObjects) CreateBasicObjects();
4037  SetLadderSegment(); 
4038  SetEndLadderSegment();
4039   for(Int_t i=0; i<fgkladdernumber; i++){
4040         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4041         //////////////////////////                                              
4042         /// Placing Ladder Segment
4043         //////////////////////////              
4044                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4045                                                                      fladdersegment[i==0 ? 1 : 0],
4046                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4047         //////////////////////////                                              
4048         /// Placing SSD Sensor
4049         //////////////////////////              
4050         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4051                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4052                                                         fssdsensormatrix[i][j]);
4053         }
4054         ///////////////////////////////                                         
4055         /// Placing End Ladder Segment
4056         ///////////////////////////////         
4057         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4058         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4059    }
4060 /////////////////////////////////////////////////////////////////////////////                                           
4061 /// Placing Ladder Cables
4062 /////////////////////////////////////////////////////////////////////////////           
4063   Int_t sidecablenumber[2][2];
4064   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4065   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4066   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4067   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4068   Double_t carbonfibertomoduleposition[3];
4069   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4070   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4071                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4072          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4073          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4074          -            fgkSSDSensorCenterSupportThickness[0]);
4075   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4076                                                                  +   0.5*fgkCoolingTubeSupportHeight
4077          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4078   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4079   Double_t ssdendladdercablelength[4];
4080   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4081                                                          + fgkSSDSensorLength
4082                                                          - fgkSSDModuleStiffenerPosition[1]
4083                                                          - fgkSSDStiffenerWidth 
4084                                                          - fgkSSDFlexWidth[0]
4085                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4086   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4087                                                          + fgkSSDModuleStiffenerPosition[1]
4088                                                          + fgkSSDStiffenerWidth
4089                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4090   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4091                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4092                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4093                                                          - kendladdercablecorrection;
4094   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4095                                                          + carbonfibertomoduleposition[1]
4096                                                          - fgkSSDModuleStiffenerPosition[1]
4097                                                          - fgkSSDStiffenerWidth)
4098                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4099
4100   TList* laddercableassemblylist[4];
4101   const Int_t kendladdercablesnumber = 4;
4102   TGeoRotation *laddercablerot = new TGeoRotation();
4103   laddercablerot->SetAngles(90.,60.,-90.);
4104   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4105         for(Int_t j=0; j<kendladdercablesnumber; j++){
4106                 laddercableassemblylist[j] = 
4107                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4108                                                                    ssdendladdercablelength[j]);
4109                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4110                                                                         j<2?1:2,fladdercablematrix[i][j]);
4111   }
4112 }
4113 ////////////////////////////////////////////////////////////////////////////////
4114 void AliITSv11GeometrySSD::SetLayer(){
4115 ////////////////////////////////////////////////////////////////////////////////
4116   // Creating Ladder of Layer 5 and Layer 6
4117   /////////////////////////////////////////////////////////////
4118   if(!fCreateMaterials) CreateMaterials();
4119   if(!fTransformationMatrices) CreateTransformationMatrices();
4120   if(!fBasicObjects) CreateBasicObjects();
4121   SetLadder(); // Generating the ladder of Layer5 and Layer6
4122   const Int_t kssdlayladdernumber[fgklayernumber] = 
4123                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4124   /////////////////////////////////////////////////////////////
4125   // Generating mother volumes for Layer5 and Layer6
4126   /////////////////////////////////////////////////////////////
4127   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4128   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4129   Int_t *ladderindex[fgklayernumber];
4130   Int_t index[fgklayernumber] = {8,9};
4131   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4132   for(Int_t i=0; i<fgklayernumber; i++) 
4133         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4134                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4135                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4136                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4137                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4138         }
4139   /////////////////////////////////////////////////////////////
4140   // Deallocating memory
4141   /////////////////////////////////////////////////////////////
4142   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
4143 }
4144 ////////////////////////////////////////////////////////////////////////////////
4145 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4146   /////////////////////////////////////////////////////////////
4147   // Insert the layer 5 in the mother volume. 
4148   /////////////////////////////////////////////////////////////
4149   if (! moth) {
4150     AliError("Can't insert layer5, mother is null!\n");
4151     return;
4152   };
4153   if(!fSSDLayer5) SetLayer();
4154   fMotherVol = moth;
4155   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4156                                                                                 + fgkLay5CenterITSPosition);
4157   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4158  }
4159 ////////////////////////////////////////////////////////////////////////////////
4160 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4161   /////////////////////////////////////////////////////////////
4162   // Insert the layer 6 in the mother volume. 
4163   /////////////////////////////////////////////////////////////
4164   if (! moth) {
4165     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4166     return;
4167   };
4168   if(!fSSDLayer6) SetLayer();
4169   fMotherVol = moth;
4170   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4171                                                                                 + fgkLay6CenterITSPosition);
4172   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4173  }
4174  ////////////////////////////////////////////////////////////////////////////////
4175  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4176   /////////////////////////////////////////////////////////////
4177   // Method generating the Arc structure of Ladder Support 
4178   /////////////////////////////////////////////////////////////
4179   const Int_t kssdlayladdernumber[fgklayernumber] = 
4180                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4181   Double_t mountingsupportedge[fgklayernumber];
4182   Double_t mountingblockratio[fgklayernumber];
4183   Double_t theta[fgklayernumber];
4184   Double_t phi[fgklayernumber];
4185   Double_t psi0[fgklayernumber];
4186   Double_t deltapsi[fgklayernumber];
4187   TVector3* mountingsupportedgevector[fgklayernumber];
4188   for(Int_t i=0; i<fgklayernumber; i++){
4189         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4190     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4191                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4192                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4193                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4194                                                           / kssdlayladdernumber[i])));
4195     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4196     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4197         mountingsupportedgevector[i] = new TVector3();
4198         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4199         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4200                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4201                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4202     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4203     deltapsi[i] = (theta[i]+phi[i])/nedges;
4204   }
4205   TVector3** vertex[fgklayernumber];
4206   TList* vertexlist[fgklayernumber];
4207   Int_t indexedge[fgklayernumber] = {0,0};
4208   for(Int_t i=0; i<fgklayernumber; i++){
4209         vertex[i] = new TVector3*[nedges+1];
4210         vertexlist[i] = new TList();
4211   } 
4212   for(Int_t i=0; i<fgklayernumber; i++){
4213         for(Int_t j=0; j<nedges+1; j++){
4214                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4215                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4216                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4217                 vertexlist[i]->Add(vertex[i][j]);
4218         }
4219         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4220   }
4221   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4222   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4223   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4224   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4225   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4226   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4227   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4228   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4229   for(Int_t i=0; i<fgklayernumber; i++){
4230     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4231     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4232     xcentervertex[i] = new Double_t[indexedge[i]+3];
4233     ycentervertex[i] = new Double_t[indexedge[i]+3];
4234         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4235         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4236         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4237         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4238         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4239                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4240                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4241                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4242                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4243                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4244                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4245                 if(j<indexedge[i]+1){
4246                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4247                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4248                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4249                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4250                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4251                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4252                 }
4253         }
4254         xsidevertex[i][1] = xsidevertex[i][0]; 
4255         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4256         xsidevertex[i][2] = xsidevertex[i][3]; 
4257         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4258         xcentervertex[i][1] = xcentervertex[i][0]; 
4259         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4260         xcentervertex[i][2] = xcentervertex[i][3]; 
4261         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4262         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4263         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4264         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4265         ycenterlowervertex[i][0] = ysidevertex[i][0];
4266         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4267         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4268   }
4269   /////////////////////////////////////////////////////////////
4270   // Building the Arc Structure of Ladder Supports 
4271   /////////////////////////////////////////////////////////////
4272   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4273   TGeoXtru* centermountingsupportshape[fgklayernumber];
4274   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4275   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4276   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4277   TGeoVolume* centermountingblocksupport[fgklayernumber];
4278   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4279   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4280   char sidemountingblockname[100];
4281   char centermountingblockname[100];
4282   char sideladdersupportpiecename[100];
4283   char centerladdersupportpiecename[100];
4284   for(Int_t i=0; i<fgklayernumber; i++){ 
4285     snprintf(sidemountingblockname,100,"MountingBlockSupportSideLay%dArc",i+5);
4286     snprintf(centermountingblockname,100,"MountingBlockSupportCenterLay%dArc",i+5);
4287     snprintf(sideladdersupportpiecename,100,"SideLadderSupportPieceLay%d",i+5);
4288     snprintf(centerladdersupportpiecename,100,"CenterLadderSupportPieceLay%d",i+5);
4289     sidemountingblocksupportshape[i] = new TGeoXtru(2);
4290     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4291                                                                                                 xsidevertex[i],ysidevertex[i]);
4292     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4293                                                                                                          -fgkMountingBlockSupportWidth[0]);
4294     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4295     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4296                                                                           sidemountingblocksupportshape[i],
4297                                                                                   fSSDAlCoolBlockMedium);
4298         sidemountingblocksupport[i]->SetLineColor(9);
4299         centermountingsupportshape[i] = new TGeoXtru(2);
4300     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4301                                                                                                 xcentervertex[i],ycentervertex[i]);
4302         centermountingsupportshape[i]->DefineSection(0,0.);
4303     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4304                                                                                                   -fgkMountingBlockSupportWidth[0]);
4305
4306     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4307                                                                           centermountingsupportshape[i],
4308                                                                                   fSSDAlCoolBlockMedium);
4309         centermountingblocksupport[i]->SetLineColor(9);
4310         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4311     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4312                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4313         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4314                                                                                                          -fgkMountingBlockSupportWidth[0]);
4315     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4316     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4317                                                                           sideladdersupportpieceshape[i],
4318                                                                                   fSSDCarbonFiberMedium);
4319         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4320         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4321     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4322                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4323         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4324     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4325                                                                                                   -fgkMountingBlockSupportWidth[0]);
4326     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4327                                                                           centerladdersupportpieceshape[i],
4328                                                                                   fSSDCarbonFiberMedium);
4329         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4330   }
4331   /////////////////////////////////////////////////////////////
4332   // Building the Up Structure of Ladder Supports 
4333   /////////////////////////////////////////////////////////////
4334   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4335   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4336   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4337   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4338   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4339   //////////////////////////////////////////////////////////
4340   // Setting the volume for TGeoXtru Mounting Block Piece  
4341   //////////////////////////////////////////////////////////
4342   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4343   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4344   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4345   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4346   TGeoVolume* mountingblockpieceup[fgklayernumber];
4347   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4348   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4349   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4350   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4351   char mountingblockpiecedownname[100];
4352   char mountingblockpieceupname[100];
4353   for(Int_t i=0; i<fgklayernumber; i++){
4354     ///////////////////////////
4355     // Mounting Block Down Vertex
4356     ///////////////////////////
4357         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4358         snprintf(mountingblockpiecedownname,100,"MountingBlockPieceDownLay%d",i+5);
4359         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4360         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4361                                               + fgkMountingBlockSupportDownHeight 
4362                                               - fgkSSDLadderVerticalDisalignment;
4363         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4364         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4365                                                                                 + fgkSSDMountingBlockHeight[1]
4366                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4367                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4368         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4369         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4370         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4371         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4372         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4373         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4374         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4375         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4376                                                                                 + fgkSSDMountingBlockHeight[2]
4377                                                                                 - fgkSSDMountingBlockHeight[0];
4378         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4379         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4380         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4381         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4382         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4383                                                                                                          mountingblockpiecedownyvertex[i]);
4384         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4385         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4386         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4387                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4388         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4389
4390     ///////////////////////////
4391     // Mounting Block Up Vertex
4392     ///////////////////////////
4393         mountingblockpieceupshape[i] = new TGeoXtru(2);
4394         snprintf(mountingblockpieceupname,100,"MountingBlockPieceUpLay%d",i+5);
4395         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4396         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4397                                                                                 + fgkMountingBlockSupportUpHeight[i]
4398                                               - fgkSSDLadderVerticalDisalignment;
4399         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4400         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4401                                                                                 + fgkSSDMountingBlockHeight[1]
4402                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4403                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4404         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4405         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4406         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4407         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4408         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4409         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4410         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4411         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4412                                                                                 + fgkSSDMountingBlockHeight[2]
4413                                                                                 - fgkSSDMountingBlockHeight[0];
4414         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4415         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4416         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4417         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4418
4419         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4420                                                                                                          mountingblockpieceupyvertex[i]);
4421         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4422         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4423         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4424                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4425         mountingblockpieceup[i]->SetLineColor(fColorG10);
4426  }
4427   ///////////////////////////////////////////////////////////////////
4428   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4429   ///////////////////////////////////////////////////////////////////
4430   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4431   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4432   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4433   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4434   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4435   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4436   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4437   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4438   char mountingblocksupportrapezoidowname[100];
4439   char mountingblocksupportrapezoidupname[100];
4440   Double_t scalefactor = 3./4.;
4441   for(Int_t i=0; i<fgklayernumber; i++){
4442   ////////////////////////////////////////////
4443   // Mounting Block Support Down Trapezoid Vertex 
4444   ////////////////////////////////////////////
4445         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4446         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4447                                                                                                  - mountingsupportedge[i];
4448         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4449         mountingblocksupportrapezoidownxvertex[i][1] = 
4450                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4451         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4452                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4453                                                                                              - mountingblockpiecedownyvertex[i][0]);
4454         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4455         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4456         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4457         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4458         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4459         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4460
4461         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4462                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4463         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4464                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4465         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4466         snprintf(mountingblocksupportrapezoidowname,100,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4467         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4468                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4469         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4470   ////////////////////////////////////////////
4471   // Mounting Block Support Up Trapezoid Vertex 
4472   ////////////////////////////////////////////
4473         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4474         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4475                                                                                                  - mountingsupportedge[i];
4476         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4477         mountingblocksupportrapezoidupxvertex[i][1] = 
4478                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4479         mountingblocksupportrapezoidupyvertex[i][1] = 
4480                                                                                                mountingblockpieceupyvertex[i][0]
4481                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4482                                                                                              - mountingblockpieceupyvertex[i][0]);
4483         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4484         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4485         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4486         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4487         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4488         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4489
4490         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4491                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4492         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4493                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4494         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4495         snprintf(mountingblocksupportrapezoidupname,100,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4496         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4497                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4498         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4499   }
4500   ///////////////////////////////////////////////////////////////////
4501   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4502   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4503   Double_t boxoriginup[fgklayernumber][2][3];
4504   Double_t boxorigindown[fgklayernumber][2][3];
4505   char mountingblocksupportboxdownname[100];
4506   char mountingblocksupportboxupname[100];
4507   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4508   mountingblocksupportrot->SetAngles(90.,180.,-90);
4509   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4510   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4511   TGeoHMatrix* laddersupportmatrix[2];
4512   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4513   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4514   /////////////////////////////////////////////////////////////
4515   // Creating Mother Volume for Containment
4516   /////////////////////////////////////////////////////////////
4517   Double_t *xmothervertex[fgklayernumber];
4518   Double_t *ymothervertex[fgklayernumber];
4519   for(Int_t i=0; i<fgklayernumber; i++){
4520         xmothervertex[i] = new Double_t[8];
4521         ymothervertex[i] = new Double_t[8];
4522   }  
4523   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4524   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4525   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4526   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4527   char upmotheladdersupportname[100];
4528   char downmotheladdersupportname[100];
4529   for(Int_t i=0; i<fgklayernumber; i++){
4530         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4531                                                     -  mountingsupportedge[i];
4532         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4533         xmothervertex[i][1] = xmothervertex[i][0];
4534         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4535                                                         + fgkMountingBlockSupportWidth[0];
4536         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4537         ymothervertex[i][2] = ymothervertex[i][1];
4538         xmothervertex[i][3] = xmothervertex[i][2];
4539         ymothervertex[i][3] = -ymothervertex[i][0];
4540         xmothervertex[i][4] = -xmothervertex[i][0];
4541         ymothervertex[i][4] = ymothervertex[i][3];
4542         xmothervertex[i][5] = xmothervertex[i][4];
4543         ymothervertex[i][5] = -ymothervertex[i][1];
4544         xmothervertex[i][6] = -xmothervertex[i][2];
4545         ymothervertex[i][6] = ymothervertex[i][5];
4546         xmothervertex[i][7] = xmothervertex[i][6];
4547         ymothervertex[i][7] = ymothervertex[i][0];
4548
4549         snprintf(downmotheladdersupportname,100,"LadderSupportDownLay%d",i+5);
4550         snprintf(upmotheladdersupportname,100,"LadderSupportUpLay%d",i+5);
4551
4552         downmotherladdersupportshape[i] = new TGeoXtru(2);
4553         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4554         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4555         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4556                                                                    +                       fgkMountingBlockSupportDownHeight
4557                                                                    +                       fgkSSDMountingBlockHeight[1]
4558                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4559                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4560                                                        - fgkSSDLadderVerticalDisalignment);
4561         
4562 //                                                 - fgkSSDModuleVerticalDisalignment);
4563         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4564
4565         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4566                                                                           downmotherladdersupportshape[i],fSSDAir);
4567     upmotherladdersupportshape[i] = new TGeoXtru(2);
4568         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4569         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4570     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4571                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4572                                                                    +                       fgkSSDMountingBlockHeight[1]
4573                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4574                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4575                                                  - fgkSSDLadderVerticalDisalignment);
4576
4577      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4578                                                                                           upmotherladdersupportshape[i],fSSDAir);
4579   }
4580   for(Int_t i=0; i<fgklayernumber; i++){
4581         /////////////////////////
4582         // Setting the box origin
4583         /////////////////////////
4584         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4585         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4586                                                    +  0.5*fgkMountingBlockSupportDownHeight
4587                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4588         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4589                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4590   
4591         boxorigindown[i][1][0] = 0.0;
4592         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4593         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4594                                                    -      fgkMountingBlockSupportWidth[0]);
4595                                                    
4596         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4597         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4598                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4599                                - 0.5*fgkSSDLadderVerticalDisalignment;
4600         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4601                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4602   
4603         boxoriginup[i][1][0] = 0.0;
4604         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4605         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4606                                                  - fgkMountingBlockSupportWidth[0]);
4607   
4608         /////////////////////////
4609     // Setting the boxes    
4610         /////////////////////////
4611         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4612                                                                                  +  fgkSSDMountingBlockLength[0]),
4613                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4614                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4615                                                                                         boxorigindown[i][0]);
4616         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4617                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4618                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4619                                                                                  -  fgkMountingBlockSupportWidth[0]),
4620                                                                                         boxorigindown[i][1]);
4621                                                                                         
4622         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4623                                                                                  +  fgkSSDMountingBlockLength[0]),
4624                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4625                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4626                                                                                         boxoriginup[i][0]);
4627
4628         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4629                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4630                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4631                                                                      -  fgkMountingBlockSupportWidth[0]),
4632                                                                                         boxoriginup[i][1]);
4633         ///////////////////////////////////////
4634         // Adding the Volumes to Mother Volume    
4635         ///////////////////////////////////////
4636         for(Int_t j=0; j<2; j++){
4637           snprintf(mountingblocksupportboxdownname,100,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4638           snprintf(mountingblocksupportboxupname,100,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4639           mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4640                                                              mountingblocksupportboxdownshape[i][j],
4641                                                              fSSDCarbonFiberMedium);
4642           mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4643                                                            mountingblocksupportboxupshape[i][j],
4644                                                            fSSDCarbonFiberMedium);
4645                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4646                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4647                 for(Int_t k=0; k<2; k++){
4648                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4649                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4650                 }
4651         }
4652         for(Int_t k=0; k<2; k++){
4653                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4654                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4655                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4656                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4657                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4658                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4659                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4660                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4661                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4662                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4663                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4664                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4665         }
4666   }
4667   TList* laddersupportlist = new TList();
4668   laddersupportlist->Add(downmotherladdersupport[0]); 
4669   laddersupportlist->Add(upmotherladdersupport[0]); 
4670   laddersupportlist->Add(downmotherladdersupport[1]); 
4671   laddersupportlist->Add(upmotherladdersupport[1]); 
4672   /////////////////////////////////////////////////////////////
4673   // Deallocating memory
4674   /////////////////////////////////////////////////////////////
4675   for(Int_t i=0; i<fgklayernumber; i++){
4676         for(Int_t j=0; j<nedges+1; j++)
4677                 delete vertex[i][j];
4678         delete mountingsupportedgevector[i];
4679         delete [] vertex[i];
4680         delete vertexlist[i];
4681         delete [] xsidevertex[i];
4682         delete [] ysidevertex[i];
4683         delete [] xcentervertex[i];
4684         delete [] ycentervertex[i];
4685         delete [] xsidelowervertex[i];
4686         delete [] ysidelowervertex[i];
4687         delete [] xcenterlowervertex[i];
4688         delete [] ycenterlowervertex[i];
4689         delete [] xmothervertex[i];
4690         delete [] ymothervertex[i];
4691   }
4692   delete [] xsidevertex;
4693   delete [] ysidevertex;
4694   delete [] xcentervertex;
4695   delete [] ycentervertex;
4696   delete [] xsidelowervertex;
4697   delete [] ysidelowervertex;
4698   delete [] xcenterlowervertex;
4699   delete [] ycenterlowervertex;
4700   delete globalrefladdersupportrot;
4701   delete mountingblocksupportrot;
4702   /////////////////////
4703   return laddersupportlist;     
4704 }
4705  ////////////////////////////////////////////////////////////////////////////////
4706 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4707 //////////////////////////////////////////
4708 // Method Generating Ladder Support Ring
4709 //////////////////////////////////////////
4710   if(!fCreateMaterials) CreateMaterials();
4711   if(!fTransformationMatrices) CreateTransformationMatrices();
4712   if(!fBasicObjects) CreateBasicObjects();
4713   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4714   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4715     const Int_t kssdlayladdernumber[fgklayernumber] = 
4716                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4717   Double_t mountingsupportedge[fgklayernumber];
4718   Double_t mountingblockratio[fgklayernumber];
4719   Double_t theta[fgklayernumber];
4720   Double_t phi[fgklayernumber];
4721   for(Int_t i=0; i<fgklayernumber; i++){
4722         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4723     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4724                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4725                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4726                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4727                                                           / kssdlayladdernumber[i])));
4728     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4729                          / fgkMountingBlockSupportRadius[i]);
4730     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4731   }
4732   TGeoRotation* globalrot = new TGeoRotation();
4733   globalrot->SetAngles(0.,-90.,0.); 
4734   TGeoRotation** laddersupportrot[fgklayernumber];
4735   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
4736   for(Int_t i=0; i<fgklayernumber; i++){                
4737         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
4738         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
4739         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4740                 laddersupportrot[i][j] = new TGeoRotation();
4741                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
4742                 switch(i){
4743                         case 0: //Ladder of Layer5  
4744                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4745                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
4746                                                                             laddersupportmatrix[i][j]); 
4747                         break;
4748                         case 1: //Ladder of Layer6 
4749                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4750                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
4751                                                                               laddersupportmatrix[i][j]); 
4752                         break;
4753                 }
4754     }
4755   }
4756   /////////////////////////////////////////////////////////////
4757   // Creating Lower Ladder Support 
4758   /////////////////////////////////////////////////////////////
4759   TVector3** ringsupportvertex[fgklayernumber];         
4760   Double_t angle = 360./nedges;
4761   for(Int_t i=0; i<fgklayernumber; i++){
4762     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
4763         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
4764                                                         *                          TMath::Cos(theta[i]));
4765         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
4766                                                         -                          mountingsupportedge[i],
4767                                                                                    ringsupportvertex[i][0]->Y());
4768         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
4769                                                                                    ringsupportvertex[i][1]->Y());                                                                               
4770     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
4771         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
4772            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
4773            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
4774            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
4775            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
4776         }
4777         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
4778     for(Int_t j=0; j<nedges+1; j++){
4779                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
4780                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*CosD(90.0-j*angle),
4781                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*SinD(90.0-j*angle));
4782         }
4783   }
4784   Double_t **xmothervertex = new Double_t*[fgklayernumber];
4785   Double_t **ymothervertex = new Double_t*[fgklayernumber];
4786   for(Int_t i=0; i<fgklayernumber; i++){
4787         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4788         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4789         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
4790                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
4791                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
4792         }
4793   }
4794 ////////////////////////////////////////////////////////////////////////////////
4795 // Start Corrections 13/06/08
4796 ////////////////////////////////////////////////////////////////////////////////
4797   char lowerladderpconsupportname[100];
4798   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
4799   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
4800   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
4801   Double_t lowerladderpconradiusmax[fgklayernumber];
4802   Double_t lowerladderpconradiusmin[fgklayernumber];
4803   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4804   lowerladdersupportrot->SetAngles(90.,180.,-90);
4805   for(Int_t i=0; i<fgklayernumber; i++){
4806         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
4807                                                                 *                          TMath::Cos(theta[i]);
4808     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeight;
4809   } 
4810   for(Int_t i=0; i<fgklayernumber; i++){
4811 ///////////////////////////  Modified Version ?///////////////////
4812     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
4813         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
4814                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
4815                                                          lowerladderpconradiusmax[i]);
4816         snprintf(lowerladderpconsupportname,100,"LowerLadderPConSupportNameLay%d",i+5);
4817         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
4818     lowerladderpconsupport[i]->SetLineColor(fColorAl);
4819         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
4820         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
4821  }
4822 ////////////////////////////////////////////////////////////////////////////////
4823 // End Corrections 13/06/08
4824 ////////////////////////////////////////////////////////////////////////////////
4825   /*char lowerladdersupportname[30];
4826   TGeoXtru* lowerladdersupportshape[fgklayernumber];
4827   TGeoVolume* lowerladdersupport[fgklayernumber];
4828   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4829   lowerladdersupportrot->SetAngles(90.,180.,-90);
4830   for(Int_t i=0; i<fgklayernumber; i++){
4831         lowerladdersupportshape[i] = new TGeoXtru(2);
4832         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
4833                                                                                           xmothervertex[i],ymothervertex[i]);
4834         lowerladdersupportshape[i]->DefineSection(0,0.);
4835     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4836         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
4837     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
4838                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
4839         lowerladdersupport[i]->SetLineColor(fColorAl);
4840         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
4841         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
4842   }*/
4843   /////////////////////////////////////////////////////////////
4844   // Deallocating memory
4845   /////////////////////////////////////////////////////////////
4846   for(Int_t i=0; i<fgklayernumber; i++){
4847         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
4848                 delete ringsupportvertex[i][j];
4849         delete [] ringsupportvertex[i];
4850   }
4851   for(Int_t i=0; i<fgklayernumber; i++){
4852         delete [] xmothervertex[i];
4853         delete [] ymothervertex[i];
4854   }
4855   delete [] xmothervertex;
4856   delete [] ymothervertex; 
4857   delete globalrot;
4858   for(Int_t i=0; i<fgklayernumber; i++){
4859         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
4860                 delete laddersupportrot[i][j];
4861         delete [] laddersupportrot[i];
4862   }
4863  }  
4864  ////////////////////////////////////////////////////////////////////////////////
4865  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
4866   /////////////////////////////////////////////////////////////
4867   // Method generating Endcap CoverPlate
4868   /////////////////////////////////////////////////////////////
4869   // Holes Definition 
4870   ///////////////////
4871   Int_t nendcapcoverplateholedges = 30;
4872   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
4873   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
4874                                                           0.5*fgkEndCapCoverPlateThickness};
4875   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
4876                                                                                                               nendcapcoverplateholedges,holesection);
4877   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
4878                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
4879   endcapcoverplatesmallhole->SetLineColor(6);
4880   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
4881                                                                                                               nendcapcoverplateholedges,holesection);
4882   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
4883                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
4884   endcapcoverplatebighole->SetLineColor(6);
4885   //////////////////////////
4886   // Screw Piece Definition 
4887   //////////////////////////
4888   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
4889   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
4890                                                                                                       CosD(0.5*smallscrewangle),
4891                                                                                                       0.5*fgkEndCapCoverPlateThickness);
4892   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
4893                                                                                                 endcapsmallscrewpieceshape,
4894                                                                                                 fSSDCoolingTubePhynox);
4895   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
4896   ///////////////////
4897   // Box Definition 
4898   ///////////////////
4899   TGeoBBox* endcapcoverplateboxshape[4];
4900   TGeoVolume* endcapcoverplatebox[4];
4901   Double_t boxorigin[5][3];
4902   boxorigin[0][0] = 0.;
4903   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
4904   boxorigin[0][2] = 0.;
4905
4906   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
4907   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
4908   boxorigin[1][2] = 0.;
4909
4910   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
4911                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
4912   boxorigin[2][1] = boxorigin[1][1];
4913   boxorigin[2][2] = 0.;
4914
4915   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
4916                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
4917   boxorigin[3][1] = boxorigin[1][1];
4918   boxorigin[3][2] = 0.;
4919
4920   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4921                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
4922                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
4923                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
4924
4925   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
4926                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4927                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4928                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4929                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
4930
4931   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
4932                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4933                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4934                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4935                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
4936
4937   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
4938                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4939                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4940                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4941                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
4942   
4943   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
4944                                                                            fSSDAlCoolBlockMedium);
4945   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
4946                                                                            fSSDAlCoolBlockMedium);
4947   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
4948                                                                            fSSDAlCoolBlockMedium);
4949   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
4950                                                                            fSSDAlCoolBlockMedium);
4951   endcapcoverplatebox[0]->SetLineColor(6);
4952   endcapcoverplatebox[1]->SetLineColor(6);
4953   endcapcoverplatebox[2]->SetLineColor(6);
4954   endcapcoverplatebox[3]->SetLineColor(6);
4955   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
4956   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4957                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
4958                                                                                         0.5*fgkEndCapCoverPlateThickness,
4959                                                                                         endcapfillingboxorigin);
4960   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
4961                                                                            fSSDAlCoolBlockMedium);
4962   endcapfillingbox->SetLineColor(6);
4963   ////////////////////////////
4964   // Contour shape Definition 
4965   ////////////////////////////
4966   const Int_t kcontourvertexnumber = 10;
4967   Double_t xcontourvertex[kcontourvertexnumber];
4968   Double_t ycontourvertex[kcontourvertexnumber];
4969   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
4970   xcontourvertex[1] = xcontourvertex[0];
4971   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
4972   xcontourvertex[3] = xcontourvertex[2];
4973   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
4974   xcontourvertex[5] = xcontourvertex[4];
4975   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
4976   xcontourvertex[7] = xcontourvertex[6];
4977   xcontourvertex[8] = xcontourvertex[4];
4978   xcontourvertex[9] = xcontourvertex[8];
4979   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
4980                                         - (kendcapcoverplatesmallholenumber[1]-1)
4981                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
4982   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
4983                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
4984   ycontourvertex[2] = ycontourvertex[1];
4985   ycontourvertex[3] = ycontourvertex[0];
4986   ycontourvertex[4] = ycontourvertex[3];
4987   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
4988   ycontourvertex[6] = ycontourvertex[5];
4989   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
4990                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
4991                                         + fgkEndCapCoverPlateSmallHoleRadius;
4992   ycontourvertex[8] = ycontourvertex[7];
4993   ycontourvertex[9] = ycontourvertex[0];
4994
4995   Double_t xboxin, dxboxin, yboxin, dyboxin;
4996   Double_t xboxout, dxboxout, yboxout, dyboxout;
4997   Double_t coordmin, coordmax;
4998   coordmin = -fgkEndCapCoverPlateLength[0];
4999   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5000   xboxout = 0.5*(coordmin+coordmax);
5001   dxboxout = 0.5*(coordmax-coordmin);
5002   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5003                                         - (kendcapcoverplatesmallholenumber[1]-1)
5004                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5005   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5006                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5007   yboxout = 0.5*(coordmin+coordmax);
5008   dyboxout = 0.5*(coordmax-coordmin);
5009   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5010   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5011   xboxin = 0.5*(coordmin+coordmax);
5012   dxboxin = 0.5*(coordmax-coordmin);
5013   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5014   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5015                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5016                                         + fgkEndCapCoverPlateSmallHoleRadius;
5017   yboxin = 0.5*(coordmin+coordmax);
5018   dyboxin = 0.5*(coordmax-coordmin);
5019   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5020   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5021                                                          xboxout, yboxout, 0.);
5022   trendCapCoverPlateContourboxout->RegisterYourself();
5023   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5024   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5025                                                          xboxin, yboxin, 0.);
5026   trendCapCoverPlateContourboxin->RegisterYourself();
5027   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5028         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5029
5030   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5031                                                                            fSSDAlCoolBlockMedium);
5032   contour->SetLineColor(6);
5033   /////////////////////////////
5034   // Hole Contour Shape Definition 
5035   ////////////////////////////
5036   coordmin = xcontourvertex[0];
5037   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5038   xboxout = 0.5*(coordmin+coordmax);
5039   dxboxout = 0.5*(coordmax-coordmin);
5040   coordmin = ycontourvertex[1];
5041   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5042   yboxout = 0.5*(coordmin+coordmax);
5043   dyboxout = 0.5*(coordmax-coordmin);
5044   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5045                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5046   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5047   xboxin = 0.5*(coordmin+coordmax);
5048   dxboxin = 0.5*(coordmax-coordmin);
5049   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5050                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5051   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5052   yboxin = 0.5*(coordmin+coordmax);
5053   dyboxin = 0.5*(coordmax-coordmin);
5054   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5055   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5056                                                          xboxout, yboxout, 0.);
5057   trendCapCoverPlateContourboxout1->RegisterYourself();
5058   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5059   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5060                                                          xboxin, yboxin, 0.);
5061   trendCapCoverPlateContourboxin1->RegisterYourself();
5062   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5063         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5064
5065
5066   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5067   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5068   xboxout = 0.5*(coordmin+coordmax);
5069   dxboxout = 0.5*(coordmax-coordmin);
5070   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5071                                                    - fgkEndCapCoverPlateWidth[0]);
5072   coordmax = ycontourvertex[0];
5073   yboxout = 0.5*(coordmin+coordmax);
5074   dyboxout = 0.5*(coordmax-coordmin);
5075   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5076                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5077   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5078   xboxin = 0.5*(coordmin+coordmax);
5079   dxboxin = 0.5*(coordmax-coordmin);
5080   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5081                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5082                                                    - fgkEndCapCoverPlateWidth[0]
5083                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5084   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5085   yboxin = 0.5*(coordmin+coordmax);
5086   dyboxin = 0.5*(coordmax-coordmin);
5087   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5088   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5089                                                          xboxout, yboxout, 0.);
5090   trendCapCoverPlateContourboxout2->RegisterYourself();
5091   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5092   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5093                                                          xboxin, yboxin, 0.);
5094   trendCapCoverPlateContourboxin2->RegisterYourself();
5095   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5096         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5097   
5098 //  const Int_t kholecontourvertexnumber = 10;
5099
5100   Double_t xholecontourvertex[2][kcontourvertexnumber];
5101   Double_t yholecontourvertex[2][kcontourvertexnumber];
5102   xholecontourvertex[0][0] = xcontourvertex[0];
5103   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5104   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5105   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5106   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5107                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5108                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5109   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5110   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5111                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5112   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5113   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5114   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5115   
5116   yholecontourvertex[0][0] = ycontourvertex[1];
5117   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5118   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5119   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5120   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5121   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5122                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5123   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5124   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5125   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5126   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5127
5128   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5129   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5130   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5131   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5132   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5133                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5134                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5135   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5136   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5137                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5138   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5139   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5140   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5141   
5142   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5143                                                    - fgkEndCapCoverPlateWidth[0]);
5144   yholecontourvertex[1][1] = ycontourvertex[0];
5145   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5146   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5147   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5148   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5149                                                    - fgkEndCapCoverPlateWidth[0]
5150                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5151   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5152   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5153   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5154   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5155
5156   TGeoVolume* holecontour[2];
5157   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5158                                                                   fSSDAlCoolBlockMedium);
5159   holecontour[0]->SetLineColor(6);
5160   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5161                                                                   fSSDAlCoolBlockMedium);
5162   holecontour[1]->SetLineColor(6);
5163   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5164                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5165   TGeoTranslation*  bigholetrans[3];
5166   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5167                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5168   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5169                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5170                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5171   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5172                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5173   /////////////////////////////////
5174   // Mother Volume Xtru Definition 
5175   /////////////////////////////////
5176   const Int_t kmothervertexnumber = 12;
5177   Double_t xmothervertex[kmothervertexnumber];  
5178   Double_t ymothervertex[kmothervertexnumber];  
5179   xmothervertex[0]  = xcontourvertex[0];
5180   xmothervertex[1]  = xmothervertex[0];
5181   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5182   xmothervertex[3]  = xmothervertex[2];
5183   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5184   xmothervertex[5]  = xmothervertex[4];
5185   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5186   xmothervertex[7]  = xmothervertex[6];
5187   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5188                                         + fgkEndCapCoverPlateLength[2]; 
5189   xmothervertex[9]  = xmothervertex[8];
5190   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5191   xmothervertex[11] = xmothervertex[10];
5192   
5193   ymothervertex[0]  = ycontourvertex[0];
5194   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5195   ymothervertex[2]  = ymothervertex[1];
5196   ymothervertex[3]  = ycontourvertex[1];
5197   ymothervertex[4]  = ymothervertex[3];
5198   ymothervertex[5]  = ymothervertex[1];
5199   ymothervertex[6]  = ymothervertex[5];
5200   ymothervertex[7]  = ymothervertex[0];
5201   ymothervertex[8]  = ymothervertex[7];
5202   ymothervertex[9]  = ymothervertex[8]
5203                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5204   ymothervertex[10] = ymothervertex[9];
5205   ymothervertex[11] = ymothervertex[8];
5206   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5207   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5208   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5209   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5210   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5211   ////////////////////////////////////////
5212   // Adding Nodes
5213   ////////////////////////////////////////
5214 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5215   TGeoTranslation*** endcapcoverplatesmallholetrans;
5216   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5217   Double_t transx[4] = {0,
5218                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5219                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5220                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5221                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5222                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5223   Int_t index = 0;
5224   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5225         endcapcoverplatesmallholetrans[i] = 
5226                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5227     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5228                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5229             endcapcoverplatesmallholetrans[i][j] = 
5230                 new TGeoTranslation(transx[i],
5231                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5232             if(index!=10){ 
5233                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5234                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5235                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5236                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5237                 }
5238                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5239                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5240                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5241     }
5242   }
5243   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5244   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5245   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5246   mothercoverplate->AddNode(endcapfillingbox,1);
5247   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5248   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5249   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5250   mothercoverplate->AddNode(holecontour[0],1);
5251   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5252   mothercoverplate->AddNode(holecontour[1],1);  
5253   mothercoverplate->AddNode(contour,1);
5254   
5255   for (Int_t i = 0; i < kendcapcoverplatesmallholenumber[0]; i++) 
5256     delete [] endcapcoverplatesmallholetrans[i];
5257   delete [] endcapcoverplatesmallholetrans;
5258   /////////////////////////////////
5259   return mothercoverplate;      
5260  }
5261  ////////////////////////////////////////////////////////////////////////////////
5262  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5263   /////////////////////////////////////////////////////////////
5264   // Getting EndCap Cooling Tube 
5265   /////////////////////////////////////////////////////////////
5266   TGeoTorus* endcapcoolingtubetorushape[5];
5267   TGeoVolume* endcapcoolingtubetorus[5];
5268   TGeoTube* endcapcoolingtubeshape[4];
5269   TGeoVolume* endcapcoolingtube[4];
5270   char endcapcoolingtubetorusname[100];
5271   char endcapcoolingtubename[100];
5272   TGeoTorus* endcapcoolingwatertubetorushape[5];
5273   TGeoVolume* endcapcoolingwatertubetorus[5];
5274   TGeoTube* endcapcoolingwatertubeshape[4];
5275   TGeoVolume* endcapcoolingwatertube[4];
5276   char endcapcoolingwatertubetorusname[100];
5277   char endcapcoolingwatertubename[100];
5278   for(Int_t i=0; i<5; i++){
5279     snprintf(endcapcoolingtubetorusname,100,"EndCapCoolingTubeTorus%d",i+1);
5280     snprintf(endcapcoolingtubename,100,"EndCapCoolingTube%d",i+1);
5281     snprintf(endcapcoolingwatertubetorusname,100,"EndCapCoolingWaterTubeTorus%d",i+1);
5282     snprintf(endcapcoolingwatertubename,100,"EndCapCoolingWaterTube%d",i+1);
5283     if(i==3){
5284       endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5285                                                     fgkEndCapCoolingTubeRadiusMin,
5286                                                     fgkEndCapCoolingTubeRadiusMax,
5287                                                     90.0,fgkEndCapCoolingTubeAngle[3]);
5288       endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5289                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5290                                                          90.0,fgkEndCapCoolingTubeAngle[3]);
5291     }
5292     else{
5293       endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5294                                                     :fgkEndCapCoolingTubeAxialRadius[1],
5295                                                     fgkEndCapCoolingTubeRadiusMin,
5296                                                     fgkEndCapCoolingTubeRadiusMax,
5297                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5298       endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5299                                                          :fgkEndCapCoolingTubeAxialRadius[1],
5300                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5301                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5302     }
5303         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5304                                                                                            endcapcoolingtubetorushape[i],
5305                                                                                            fSSDCoolingTubePhynox);
5306         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5307                                                                                                         endcapcoolingwatertubetorushape[i],
5308                                                                                                         fSSDCoolingTubeWater);
5309     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5310     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5311     if(i<4){
5312                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5313                                                                   fgkEndCapCoolingTubeRadiusMax,
5314                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5315                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5316                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5317         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5318                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5319         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5320                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5321                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5322                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5323         }
5324   }
5325   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5326   /////////////////////////////////////////
5327   // Transformation for Volume Positioning 
5328   /////////////////////////////////////////
5329   TGeoCombiTrans* coolingtubecombitrans[6];
5330   TGeoRotation* coolingtuberot[8];
5331   TGeoTranslation* coolingtubetrans[6];
5332   TGeoHMatrix* coolingtubematrix[4];
5333   TGeoCombiTrans* torustubecombitrans[4];
5334   TGeoRotation* torustuberot[7];
5335   TGeoTranslation* torustubetrans[4];
5336   TGeoHMatrix* torustubematrix[5];
5337   TGeoCombiTrans* coolingwatertubecombitrans[6];
5338   TGeoRotation* coolingwatertuberot[8];
5339   TGeoTranslation* coolingwatertubetrans[6];
5340   TGeoHMatrix* coolingwatertubematrix[4];
5341   TGeoCombiTrans* toruswatertubecombitrans[4];
5342   TGeoRotation* toruswatertuberot[7];
5343   TGeoTranslation* toruswatertubetrans[4];
5344   TGeoHMatrix* toruswatertubematrix[5];
5345   for(Int_t i=0; i<8; i++){
5346     if(i<6){
5347          coolingtubetrans[i] = new TGeoTranslation();
5348          coolingwatertubetrans[i] = new TGeoTranslation();
5349     }
5350     if(i<8){
5351          coolingtuberot[i] = new TGeoRotation();
5352          coolingwatertuberot[i] = new TGeoRotation();
5353     }
5354     if(i<4){
5355          torustubetrans[i] = new TGeoTranslation();
5356          toruswatertubetrans[i] = new TGeoTranslation();
5357     }
5358     if(i<7){
5359          torustuberot[i] = new TGeoRotation();
5360          toruswatertuberot[i] = new TGeoRotation();
5361         }
5362   }
5363   /////////////////////////////////////////
5364   // Transformation for Inox Volume Positioning 
5365   /////////////////////////////////////////
5366   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5367                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5368   coolingtuberot[0]->SetAngles(0.,90.,0.);
5369   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5370                                                                                                 *coolingtuberot[0]);
5371                                                                                                 
5372   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5373   coolingtuberot[1]->SetAngles(0.,90.,0.);
5374   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5375                                                                                                 *coolingtuberot[1]);
5376
5377   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5378                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5379                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5380                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5381                                                                           0.);
5382   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5383   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5384                                                                                                 *coolingtuberot[2]);
5385
5386   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5387                                            *                             (*coolingtubecombitrans[1]));
5388
5389   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5390                                                                          endcapcoolingtubeshape[1]->GetDz());
5391   torustuberot[0]->SetAngles(0.,90.,0.); 
5392   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5393
5394   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5395
5396   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5397                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5398   coolingtuberot[3]->SetAngles(0.,90.,0.);
5399   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5400                                                                                                 *coolingtuberot[3]);
5401   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5402   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5403   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5404   
5405   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5406                                                                         endcapcoolingtubeshape[2]->GetDz());
5407   torustuberot[1]->SetAngles(0.,90.,0.); 
5408   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5409   torustuberot[2]->SetAngles(180.,0.,0.); 
5410   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5411   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5412
5413   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5414                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5415   torustuberot[3]->SetAngles(0.,90.,0.); 
5416   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5417   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5418   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5419   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5420
5421   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5422                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5423   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5424   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5425                                                                                                 *coolingtuberot[5]);
5426   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5427   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5428   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5429   
5430   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5431                                                                         endcapcoolingtubeshape[0]->GetDz());
5432   torustuberot[5]->SetAngles(0.,90.,0.); 
5433   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5434   torustuberot[6]->SetAngles(-90.,0.,0.); 
5435   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5436   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5437   
5438   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5439                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5440   coolingtuberot[6]->SetAngles(0.,90.,0.);
5441   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5442                                                                                                 *coolingtuberot[6]);
5443   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5444   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5445   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5446     /////////////////////////////////////////
5447   // Transformation for Water Volume Positioning 
5448   /////////////////////////////////////////
5449   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5450                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5451   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5452   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5453                                                                                                      *coolingwatertuberot[0]);
5454
5455   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5456   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5457   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5458                                                                                                      *coolingwatertuberot[1]);
5459
5460   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5461                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5462                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5463                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5464                                                                               0.);
5465   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5466   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5467                                                                                                     *coolingwatertuberot[2]);
5468
5469   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5470                                            *                                 (*coolingwatertubecombitrans[1]));
5471                                            
5472   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5473                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5474   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5475   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5476                                                                                                    *toruswatertuberot[0]);
5477
5478   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5479                                                   *                                     (*toruswatertubecombitrans[0]));
5480
5481   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5482                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5483   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5484   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5485                                                                                                      *coolingwatertuberot[3]);
5486   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5487   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5488                                                         *                                 (*coolingwatertubecombitrans[3]));
5489   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5490
5491   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5492                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5493   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5494   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5495                                                                                                    *toruswatertuberot[1]);
5496   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5497   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5498                                                   *                 (*toruswatertubecombitrans[1]));
5499   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5500   
5501   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5502                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5503   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5504   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5505                                                                                                    *toruswatertuberot[3]);
5506   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5507   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5508                                                   *                                     (*toruswatertubecombitrans[2]));
5509   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5510
5511   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5512                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5513   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5514   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5515                                                                                                      *coolingwatertuberot[5]);
5516   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5517   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5518                                                         *                                 (*coolingwatertubecombitrans[4]));
5519   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5520   
5521   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5522                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5523   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5524   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5525                                                                                                    *toruswatertuberot[5]);
5526   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5527   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5528                                                   *                 (*toruswatertubecombitrans[3]));
5529   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5530   
5531   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5532                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5533   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5534   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5535                                                                                                      *coolingwatertuberot[6]);
5536   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5537   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5538                                                         *                                 (*coolingwatertubecombitrans[5]));
5539   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5540   /////////////////////////////////////////
5541   // Positioning Volumes
5542   /////////////////////////////////////////
5543   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5544   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5545   
5546   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5547   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5548
5549   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5550   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5551  
5552   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5553   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5554
5555   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5556   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5557
5558   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5559   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5560
5561   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5562   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5563
5564   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5565   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5566   
5567   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5568   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5569  
5570   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5571   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5572   /////////////////////////////////////////////////////////////
5573   // Deallocating memory
5574   /////////////////////////////////////////////////////////////
5575   for(Int_t i=0; i<8; i++){
5576     if(i<6){
5577          delete coolingtubetrans[i];
5578          delete coolingwatertubetrans[i];
5579          if(i!=0){
5580           delete coolingtubecombitrans[i];
5581           delete coolingwatertubecombitrans[i];
5582          }
5583         }
5584     if(i<8){
5585           delete coolingtuberot[i];
5586           delete coolingwatertuberot[i];
5587     }
5588     if(i<4){
5589                 delete torustubetrans[i];
5590                 delete toruswatertubetrans[i];
5591                 delete torustubecombitrans[i];
5592                 delete toruswatertubecombitrans[i];
5593         } 
5594     if(i<7){
5595          delete torustuberot[i];
5596          delete toruswatertuberot[i];
5597         }
5598   }
5599   /////////////////////////////////////////////////////////////
5600   return endcapcoolingtubemother;
5601  }
5602  ////////////////////////////////////////////////////////////////////////////////
5603  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5604   /////////////////////////////////////////////////////////////
5605   // Getting EndCap Cover Side 
5606   /////////////////////////////////////////////////////////////
5607   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5608   const Int_t kvertexnumber = 15; 
5609   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5610   xvertex[0]  = 0.0;
5611   xvertex[1]  = xvertex[0];
5612   xvertex[2]  = fgkEndCapSideCoverLength[0];
5613   xvertex[3]  = fgkEndCapSideCoverLength[1];
5614   xvertex[4]  = xvertex[3];
5615   xvertex[5]  = fgkEndCapSideCoverLength[2];
5616   xvertex[6]  = xvertex[5];
5617   xvertex[7]  = xvertex[2];
5618   xvertex[8]  = xvertex[7];
5619   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5620   xvertex[10] = xvertex[9];
5621   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5622                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5623                           * fgkEndCapSideCoverLength[4];
5624   xvertex[12] = xvertex[11];
5625   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5626                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5627                           * fgkEndCapSideCoverLength[4];
5628   xvertex[14] = xvertex[13];
5629   yvertex[0]  = 0.0;
5630   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5631   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5632   yvertex[3]  = yvertex[2];
5633   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5634   yvertex[5]  = yvertex[4];
5635   yvertex[6]  = yvertex[0];
5636   yvertex[7]  = yvertex[6];
5637   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5638   yvertex[9]  = yvertex[8];
5639   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5640   yvertex[11] = yvertex[10];
5641   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5642   yvertex[13] = yvertex[12];
5643   yvertex[14] = yvertex[6];
5644   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5645   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5646   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5647   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5648   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5649   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5650   endcapsidecovershapein->SetName("endcapsidecovershapein");
5651   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5652   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5653   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5654
5655
5656   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5657   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5658                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5659   endcapsidecover->SetLineColor(fColorPhynox);
5660   ////////////////////////////////////////////
5661   // Defininition of Mother Volume
5662   ////////////////////////////////////////////
5663   const Int_t kmothervertexnumber = 7;
5664   Double_t xmothervertex[kmothervertexnumber]; 
5665   Double_t ymothervertex[kmothervertexnumber]; 
5666   for(Int_t i=0; i<kmothervertexnumber; i++){
5667         xmothervertex[i] = xvertex[i];
5668         ymothervertex[i] = yvertex[i];
5669   }
5670   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5671   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5672   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5673   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5674   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5675                                                                 endcapsidecovermothershape,fSSDAir);
5676   ////////////////////////////////////////////
5677   endcapsidecovermother->AddNode(endcapsidecover,1);
5678   TGeoBBox* endcapsidecoverboxshape[4];
5679   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5680                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5681                                                                0.5*fgkEndCapSideCoverLength[4],
5682                                                                    0.5*fgkEndCapSideCoverThickness); 
5683   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5684                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5685                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5686                                                          -     fgkEndCapSideCoverLength[4]),
5687                                                                    0.5*fgkEndCapSideCoverThickness); 
5688   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5689                                                                0.5*fgkEndCapSideCoverLength[4],
5690                                                                    0.5*fgkEndCapSideCoverThickness); 
5691   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5692                                                                0.5*fgkEndCapSideCoverWidth[5],
5693                                                                    0.5*fgkEndCapSideCoverThickness); 
5694   TGeoVolume* endcapsidecoverbox[4];
5695   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5696   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5697   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5698   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5699   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5700 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5701   TGeoTranslation** endcapsidecoverboxtrans;
5702   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5703   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5704                                                          +                                         fgkEndCapSideCoverLength[0],
5705                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5706                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5707   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5708                                                          +                     xvertex[11],
5709                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5710                                                          +                     yvertex[12],0.);
5711   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5712                                                          +                     xvertex[11],
5713                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5714                                                          +                     yvertex[12]
5715                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5716                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5717   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5718   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5719   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5720   for(Int_t i=0; i<2; i++)
5721         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5722                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5723                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5724                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5725                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5726                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5727                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5728                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5729         }
5730   for(Int_t i=0; i<2; i++)
5731         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5732                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5733                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5734                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5735                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5736                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5737                                                         +fgkEndCapSideCoverLength[4]),0.0);
5738                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5739                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5740                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5741                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5742         }
5743   delete [] endcapsidecoverboxtrans;
5744   return endcapsidecovermother;
5745  } 
5746  ////////////////////////////////////////////////////////////////////////////////
5747  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5748  ////////////////////////////////////////////////////////////////////////////////
5749  // Method returning Interface Card A, Interface Card B, Supply Card 
5750  ////////////////////////////////////////////////////////////////////////////////
5751  /////////////////////
5752  // Supply Card
5753  /////////////////////
5754  // Electronic Board Back Al Plane
5755  const Int_t kelectboardbackvertexnumber = 8;
5756  Double_t xelectboardback[kelectboardbackvertexnumber];
5757  Double_t yelectboardback[kelectboardbackvertexnumber];
5758  xelectboardback[0] = 0.0;
5759  xelectboardback[1] = xelectboardback[0];
5760  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5761  xelectboardback[3] = xelectboardback[2];
5762  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5763  xelectboardback[5] = xelectboardback[4];
5764  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5765  xelectboardback[7] = xelectboardback[6];
5766  
5767  yelectboardback[0] = 0.0;
5768  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5769  yelectboardback[2] = yelectboardback[1];
5770  yelectboardback[3] = yelectboardback[0];
5771  yelectboardback[4] = yelectboardback[3];
5772  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5773  yelectboardback[6] = yelectboardback[5];
5774  yelectboardback[7] = yelectboardback[4];
5775  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5776  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5777                                                                         xelectboardback,yelectboardback); 
5778  electboardbackshape->DefineSection(0,0.0);
5779  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5780  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5781                                                                                          electboardbackshape,fSSDSupportRingAl);
5782  electboardback->SetLineColor(fColorAl);
5783  // Electronic Board Kapton Layer
5784  const Int_t kelectlayervertexnumber = 8;
5785  Double_t xelectlayer[kelectlayervertexnumber];
5786  Double_t yelectlayer[kelectlayervertexnumber];
5787  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5788  xelectlayer[1] = xelectlayer[0];
5789  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5790  xelectlayer[3] = xelectlayer[2];
5791  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5792      
5793  yelectlayer[0] = 0.0;
5794  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5795  yelectlayer[2] = yelectlayer[1];
5796  yelectlayer[3] = yelectlayer[0];
5797  yelectlayer[4] = yelectlayer[3];
5798  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5799  yelectlayer[6] = yelectlayer[5];
5800  yelectlayer[7] = yelectlayer[4];
5801  TGeoXtru* electlayershape = new TGeoXtru(2);
5802  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5803  electlayershape->DefineSection(0,0.0);
5804  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5805  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5806                                                                                          electlayershape,fSSDKaptonFlexMedium);
5807  electlayer->SetLineColor(fColorKapton);
5808  // JMD Connector Female
5809  const Int_t kjmdconnectorvertexnumber = 6;
5810  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5811  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5812  xjmdconnectorvertex[0] = 0.0; 
5813  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5814  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5815  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5816  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5817  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5818
5819  yjmdconnectorvertex[0] = 0.0; 
5820  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5821  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5822  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5823  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5824  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5825  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5826  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5827                                                                   yjmdconnectorvertex); 
5828  jmdconnectorshape->DefineSection(0,0.0);
5829  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
5830  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
5831                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
5832  jmdconnector->SetLineColor(fColorG10);
5833  // Top Cable Connector
5834  const Int_t kcableconnectorvertexnumber = 8;
5835  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
5836  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
5837  xconnectorvertex[0] = 0.0;
5838  xconnectorvertex[1] = xconnectorvertex[0];
5839  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
5840  xconnectorvertex[3] = xconnectorvertex[2];
5841  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
5842                                          - fgkEndCapCardCableConnectorLength[2];
5843  xconnectorvertex[5] = xconnectorvertex[4];
5844  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
5845  xconnectorvertex[7] = xconnectorvertex[6];
5846
5847  yconnectorvertex[0] = 0.0;
5848  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
5849  yconnectorvertex[2] = yconnectorvertex[1];
5850  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
5851  yconnectorvertex[4] = yconnectorvertex[3];
5852  yconnectorvertex[5] = yconnectorvertex[1];
5853  yconnectorvertex[6] = yconnectorvertex[5];
5854  yconnectorvertex[7] = yconnectorvertex[0];
5855  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
5856  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
5857                                                                     yconnectorvertex); 
5858  cableconnectorshape->DefineSection(0,0.0);
5859  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
5860  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
5861                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
5862  cableconnector->SetLineColor(fColorG10);
5863  // Strip Connection
5864  TGeoBBox* endcapstripconnectionshape = 
5865                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
5866                                                                                          0.5*fgkEndCapStripConnectionThickness,
5867                                                                                          0.5*fgkEndCapStripConnectionWidth);
5868  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
5869                                                                                                         endcapstripconnectionshape,
5870                                                                                                         fSSDSupportRingAl);
5871  endcapstripconnection->SetLineColor(fColorAl);
5872  // Interface Card B
5873  const Int_t kcardBvertexnumber = 12; 
5874  Double_t xcardBvertexnumber[kcardBvertexnumber];
5875  Double_t ycardBvertexnumber[kcardBvertexnumber];
5876
5877  xcardBvertexnumber[0]  = 0.0;
5878  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
5879  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
5880  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
5881  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
5882  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
5883  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
5884  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
5885  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
5886  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
5887  xcardBvertexnumber[10] = xcardBvertexnumber[7];
5888  xcardBvertexnumber[11] = xcardBvertexnumber[10];
5889  
5890  ycardBvertexnumber[0]  = 0.0;
5891  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
5892  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
5893  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
5894  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
5895  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
5896  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
5897  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
5898  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
5899  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
5900  ycardBvertexnumber[10] = ycardBvertexnumber[9];
5901  ycardBvertexnumber[11] = ycardBvertexnumber[0];
5902
5903  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
5904  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
5905  interfacecardBshape->DefineSection(0,0.);
5906  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
5907  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
5908                                                                                          fSSDMountingBlockMedium);
5909  interfacecardB->SetLineColor(46);
5910  // Interface Card B Electronic Board
5911  const Int_t kelectboardcardBvertexnumber = 14; 
5912  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
5913  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
5914
5915  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
5916  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
5917  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
5918  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
5919  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
5920  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
5921  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
5922  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
5923  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
5924  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
5925  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
5926  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
5927  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
5928  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
5929
5930  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
5931  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
5932  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
5933  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
5934  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
5935  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
5936  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
5937  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
5938  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
5939  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
5940  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
5941  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
5942  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
5943  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
5944
5945  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
5946  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
5947                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
5948  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
5949  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
5950                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
5951  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
5952                                                                                           fSSDSupportRingAl);
5953  electboardcardB->SetLineColor(fColorAl);
5954  // Generating Stiffener 2
5955  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
5956                                                                                            0.5*fgkEndCapStiffenerThickness,
5957                                                                                            0.5*fgkEndCapStiffenerLength);
5958  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
5959  endcapstiffener->SetLineColor(fColorAl);   
5960  // Generating Mother Interface Card B Container
5961  const Int_t kinterfacecardBmothervertexnumber = 10;
5962  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
5963  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
5964
5965  xinterfacecardBmothervertex[0] = 0.0;
5966  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
5967  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
5968                                                                 + fgkEndCapInterfaceCardBThickness;
5969  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
5970  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
5971                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
5972  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
5973  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
5974  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
5975  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
5976                                                                 + fgkEndCapCardJMDConnectorLength[0];
5977  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
5978
5979  yinterfacecardBmothervertex[0] = 0.0;
5980  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
5981                                                                 + fgkEndCapInterfaceCardBWidth[1]
5982                                                                 + fgkEndCapInterfaceCardBWidth[2];
5983  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
5984  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
5985  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
5986  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
5987  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
5988  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
5989                                                                 + fgkEndCapCardJMDConnectorWidth[0]
5990                                                                 + fgkEndCapCardJMDConnectorWidth[1];
5991  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
5992  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
5993  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
5994  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
5995                                                                                   xinterfacecardBmothervertex,
5996                                                                                   yinterfacecardBmothervertex);
5997  interfacecardBmothershape->DefineSection(0,-1.e-15);
5998  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
5999  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6000                                                                                                    interfacecardBmothershape,fSSDAir);
6001  electboardcardB->SetLineColor(fColorAl);
6002  // Positioning Volumes Mother Interface Card B Container 
6003  TGeoRotation* interfacecardBrot = new TGeoRotation();
6004  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6005  interfacecardBrot->SetAngles(90.,-90.,-90.);
6006  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6007  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6008  TGeoRotation* electboardcardBrot = new TGeoRotation();
6009  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6010  electboardcardBrot->SetAngles(90.,90.,-90.);
6011  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6012  TGeoCombiTrans* electboardcardBcombitrans = 
6013                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6014  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6015  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6016  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6017  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6018  TGeoTranslation* jmdconnectorcardBtrans[3];
6019  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6020  for(Int_t i=0; i<3; i++){
6021    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6022                                                          + fgkEndCapCardJMDConnectorLength[0], 
6023                                                            fgkEndCapCardElectBoardLayerWidth[1],
6024                                                            0.5*fgkEndCapCardJMDConnectorThickness
6025                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6026                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6027                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6028    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6029                                                                                                            *jmdconnectorcardBrot);
6030    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6031  }
6032  // Mother Supply Card Container 
6033  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6034  // Interface Card Container
6035  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6036  // Placing Volumes in Mother Supply Card Container
6037  // JMD Connector Positioning
6038  TGeoTranslation* jmdconnectortrans[2];
6039  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6040  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6041                                                                                         fgkEndCapCardElectBoardBackLength[0]
6042                                           -                                             fgkEndCapCardJMDConnectorThickness
6043                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6044  TGeoRotation* jmdconnectorot = new TGeoRotation();
6045  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6046                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6047                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6048                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6049                                                                       fgkEndCapCardJMDConnectorThickness
6050                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6051  jmdconnectorot->SetAngles(90.,180.,-90);
6052  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6053                                                                                 * jmdconnectorot);
6054  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6055  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6056  // Top Cable Connector Placing
6057  TGeoRotation* cableconnectorot[2];
6058  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6059  TGeoTranslation* cableconnectortrans[3];
6060  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6061  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6062  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6063  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6064  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6065                                                                                                                            *cableconnectorot[0]);
6066  TGeoHMatrix* cableconnectormatrix[2];
6067  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6068                                                         new TGeoHMatrix((*cableconnectorot[1])
6069                                                                                    *(*cableconnectorcombitrans));
6070  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6071                                            -                               fgkEndCapCardCableConnectorThickness,
6072                                                                                 fgkEndCapCardCableConnectorLength[0]
6073                                            +                            fgkEndCapCardCableConnectorToLayer);
6074  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6075                                            -                2.*fgkEndCapCardCableConnectorThickness
6076                                            -                            fgkEndCapCardCableConnectorDistance,
6077                                                                                 fgkEndCapCardCableConnectorLength[0]
6078                                            +                            fgkEndCapCardCableConnectorToLayer);
6079  for(Int_t i=0; i<2; i++){
6080         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6081     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6082  }
6083  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6084  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6085  electboardbackrot->SetAngles(90.,-90.,-90.);
6086  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6087                                                         +                fgkEndCapCardJMDConnectorLength[0]
6088                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6089  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6090                                                                                                                            *electboardbackrot);
6091  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6092  // Electronic Board Kapton Layer Positioning
6093  TGeoRotation* electlayerrot = new TGeoRotation();
6094  TGeoTranslation* electlayertrans[2];
6095  TGeoCombiTrans* electlayercombitrans[2];
6096  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6097  electlayerrot->SetAngles(90.,-90.,-90.);
6098  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6099                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6100  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6101                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6102                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6103  for(Int_t i=0; i<2; i++){
6104         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6105         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6106  }
6107  // Placing Volumes in Mother Interface Card Container
6108  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6109  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6110  for(Int_t i=0; i<2; i++){
6111         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6112  }
6113  /////////////////////////////////////////////////////////////
6114  // Generation of Card Interface Container
6115  /////////////////////////////////////////////////////////////
6116  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6117                                                   - fgkEndCapCardJMDConnectorLength[0]
6118                                                   - fgkEndCapInterfaceCardBThickness
6119                                                   - 9.*fgkEndCapStripConnectionThickness
6120                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6121  const Int_t kcardinterfacecontainervertexnumber = 14;
6122  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6123  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6124  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6125                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6126  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6127  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6128                                                                    + fgkEndCapStripConnectionThickness
6129                                                                    - fgkEndCapCardElectBoardLayerThickness
6130                                                                    - fgkEndCapCardCableConnectorWidth[0];
6131  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6132  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6133  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6134  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6135                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6136  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6137  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6138                                                                    + fgkEndCapInterfaceCardBThickness;
6139  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6140  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6141                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6142  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6143  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6144                                    - fgkEndCapInterfaceElectBoardCardBThickness
6145                                                                    + fgkEndCapCardJMDConnectorLength[0]
6146                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6147  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6148
6149  ycardinterfacecontainervertex[0]  = 0.;
6150  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6151                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6152                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6153  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6154  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6155                                                                    - fgkEndCapStripConnectionWidth;
6156  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6157  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6158  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6159  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6160                                                                    + fgkEndCapInterfaceCardBWidth[1]
6161                                                                    + fgkEndCapInterfaceCardBWidth[2];
6162  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6163  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6164  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6165  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6166  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6167  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6168  
6169  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6170  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6171                                                                                   xcardinterfacecontainervertex,
6172                                                                                   ycardinterfacecontainervertex);
6173  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6174                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6175  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6176                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6177  TGeoVolume** cardinterfacecontainer;
6178  cardinterfacecontainer = new TGeoVolume*[4];
6179  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6180                                                                                         interfacecardmothershape,fSSDAir); 
6181  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6182                                                                                         interfacecardmothershape,fSSDAir); 
6183  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6184                                                                                         interfacecardmothershape,fSSDAir); 
6185  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6186                                                                                         interfacecardmothershape,fSSDAir); 
6187  /////////////////////////////////
6188  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6189  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6190  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6191  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6192  /////////////////////////////////
6193  TGeoRotation* endcapstripconnectionrot[2];
6194  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6195  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6196  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6197  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6198                                                                         *                                 (*endcapstripconnectionrot[0]));
6199  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6200  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6201                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6202                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6203                                                                                         -endcapstripconnectionshape->GetDZ(),
6204                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6205  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6206  TGeoTranslation* cardinterfacetrans[9];
6207  TGeoHMatrix* cardinterfacematrix[9]; 
6208  for(Int_t i=0; i<7; i++){ 
6209         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6210                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6211                                                                                                 0.0,0.0);  
6212         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6213                                                    *                             (*endcapstripconnectionmatrix));
6214  }
6215  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6216                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6217                                                                                                 0.0,0.0);  
6218  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6219                                                 *                                 (*endcapstripconnectionmatrix));
6220  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6221                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6222                                                                                                 0.0,0.0);  
6223  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6224                                                 *                                 (*endcapstripconnectionmatrix));
6225
6226  for(Int_t i=0; i<4; i++){
6227         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6228                                                                            cardinterfacematrix[7]);                             
6229         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6230                                                                            cardinterfacematrix[8]);                             
6231  }
6232  TGeoTranslation* mothersupplycardtrans = 
6233                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6234                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6235                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6236  TGeoHMatrix* mothersupplycardmatrix[7];
6237  Int_t index[4] = {1,1,1,1};
6238  for(Int_t i=0; i<7; i++){
6239         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6240                                                         *                                 (*mothersupplycardtrans));
6241         for(Int_t j=0; j<4; j++){
6242                 switch(j){
6243                         case 0: //Layer5 EndCap Left Side  
6244                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6245                                                                                                    cardinterfacematrix[i]);                             
6246                                 if(i!=0){
6247                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6248                                                                                                            mothersupplycardmatrix[i]);                  
6249                                         index[j]++;
6250
6251                                 }
6252                         break;
6253                         case 1: //Layer5 EndCap Rigth Side  
6254                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6255                                                                                                    cardinterfacematrix[i]);                     
6256                                 if(i>0&&i<6){
6257                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6258                                                                                                            mothersupplycardmatrix[i]);                  
6259                                         index[j]++;
6260                                 }
6261                         break;
6262                         case 2: //Layer6 EndCap Left Side  
6263                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6264                                                                                                    cardinterfacematrix[i]);                             
6265                                 if(i!=6){
6266                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6267                                                                                                            mothersupplycardmatrix[i]);                  
6268                                         index[j]++;
6269                                 }
6270                         break;
6271                         case 3: //Layer6 EndCap Right Side  
6272                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6273                                                                                                    cardinterfacematrix[i]);                             
6274                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6275                                                                                                    mothersupplycardmatrix[i]);                  
6276                                 index[j]++;
6277                         break;
6278                 }
6279         }
6280  }
6281  // Positioning Interface 
6282  TGeoTranslation* motherinterfacecardtrans = 
6283                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6284                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6285                                                          -fgkEndCapCardElectBoardLayerThickness
6286                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6287  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6288                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6289  // Positioning Interface Card B 
6290  TGeoTranslation* interfacecardBmothertrans = 
6291                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6292                                                                                 + 2.*fgkEndCapStripConnectionThickness
6293                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6294                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6295                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6296  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6297                                                                                                                          interfacecardBmothertrans);
6298  // Positioning Stiffener 
6299  TGeoTranslation* endcapstiffenertrans = 
6300                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6301                                                                            +    2.0*fgkEndCapStripConnectionThickness
6302                                                                            +    fgkEndCapInterfaceCardBThickness
6303                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6304                                                                            +    stiffenertransx
6305                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6306                                                                                         endcapstiffenershape->GetDZ()
6307                                                                            -    0.5*(fgkEndCapStiffenerLength
6308                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6309  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6310  /////////////////////////////////////////////////////////////
6311  // Deallocating memory
6312  /////////////////////////////////////////////////////////////
6313  delete interfacecardBrot;
6314  delete interfacecardBtrans;
6315  delete electboardcardBtrans;
6316  delete electboardcardBrot; 
6317  delete jmdconnectorcardBrot;
6318  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6319  delete jmdconnectorot;
6320  delete jmdconnectortrans[1];
6321  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6322  delete cableconnectorcombitrans;
6323  delete electboardbacktrans;
6324  delete electboardbackrot;
6325  delete electlayerrot;
6326  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6327  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6328  delete mothersupplycardtrans;
6329  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6330  /////////////////////////////////////////////////////////////
6331  return cardinterfacecontainer;
6332  }
6333  ////////////////////////////////////////////////////////////////////////////////
6334  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6335   /////////////////////////////////////////////////////////////
6336   // Method returning EndCap Mother Volume
6337   /////////////////////////////////////////////////////////////
6338   const Int_t kendcapcoverplatesmallholenumber = 9;
6339   Double_t endcapmotherorigin[3];
6340   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6341                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6342                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6343   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6344                                           -                      fgkEndCapCoverPlateWidth[2]
6345                                           -       (kendcapcoverplatesmallholenumber-1)
6346                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6347                                           +  0.5*(fgkEndCapSideCoverLength[2]
6348                                           +               fgkEndCapCoverPlateWidth[1]
6349                                           -       fgkEndCapCoverPlateWidth[0])
6350                                           -      (fgkEndCapCoverPlateWidth[1]
6351                                           -       fgkEndCapCoverPlateWidth[0]);
6352   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6353                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6354                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6355                                                 +      fgkEndCapSideCoverWidth[1]
6356                                                 +      fgkEndCapSideCoverThickness
6357                                                 +      fgkEndCapKaptonFoilThickness);
6358   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6359                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6360                                                           +              2.0* fgkEndCapSideCoverThickness),
6361                                                                          0.5* (fgkEndCapSideCoverLength[2]
6362                                                           +                    fgkEndCapCoverPlateWidth[1]
6363                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6364                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6365                                                       +                                    fgkEndCapSideCoverWidth[1]
6366                                                           +                                       fgkEndCapSideCoverThickness
6367                                                       +                                   fgkEndCapKaptonFoilThickness),
6368                                                                                          endcapmotherorigin);
6369   TGeoVolume** endcapassembly;  
6370   endcapassembly = new TGeoVolume*[4];
6371   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6372                                                                                         endcapmothershape,fSSDAir); 
6373   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6374                                                                                         endcapmothershape,fSSDAir); 
6375   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6376                                                                                         endcapmothershape,fSSDAir); 
6377   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6378                                                                                         endcapmothershape,fSSDAir); 
6379  /////////////////////////////////
6380  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6381  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6382  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6383  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6384  /////////////////////////////////
6385   /////////////////////////////////////////////////////
6386   // Placing Endcap Cover Plate
6387   /////////////////////////////////////////////////////
6388   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6389   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6390   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6391   TGeoCombiTrans* endcapcoverplatecombitrans = 
6392                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6393                                                                                          endcapcoverplaterot);
6394   TGeoTranslation* endcapcoverplatetrans = 
6395                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6396   TGeoHMatrix* endcapcoverplatematrix = 
6397                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6398                                                                           *       (*endcapcoverplatecombitrans));
6399   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6400   /////////////////////////////////////////////////////
6401   // Placing Endcap Side Cover
6402   /////////////////////////////////////////////////////
6403   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6404   TGeoRotation* endcapsidecoverot[2];
6405   TGeoCombiTrans* endcapsidecovercombitrans[3];
6406   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6407   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6408   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6409                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6410                                                                                         - fgkEndCapCoverPlateWidth[2]
6411                                                                                     - (kendcapcoverplatesmallholenumber-1)
6412                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6413                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6414                                                                                         + fgkEndCapSideCoverLength[2],
6415                                                                                           0.5*(fgkEndCapSideCoverThickness
6416                                                                                         + fgkEndCapCoverPlateThickness)
6417                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6418                                                                                           endcapsidecoverot[0]);
6419   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6420   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6421                                                                                                         0.5*fgkEndCapCoverPlateThickness
6422                                                                                                         -fgkEndCapSideCoverWidth[1],
6423                                                                                                         endcapsidecoverot[1]);
6424   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6425                                                                                                         +fgkEndCapCoverPlateLength[3]
6426                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6427                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6428                                                                                                         0.5*fgkEndCapCoverPlateThickness
6429                                                                                                         -fgkEndCapSideCoverWidth[1],
6430                                                                                                         endcapsidecoverot[1]);
6431   TGeoHMatrix* endcapsidecovermatrix[2];
6432   for(Int_t i=0; i<2; i++){
6433    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6434                                                         *                                 (*endcapsidecovercombitrans[0]));
6435         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6436                                                                                                                 endcapsidecovermatrix[i]);
6437   }
6438   /////////////////////////////////////////////////////
6439   // Placing Endcap Cooling Tube
6440   /////////////////////////////////////////////////////
6441   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6442   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6443   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6444   TGeoCombiTrans* endcapccolingtubecombitrans 
6445                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6446                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6447                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6448                                                 - fgkEndCapCoolingTubeToCoverSide,
6449                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6450                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6451   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6452                                                                                                           endcapccolingtubecombitrans);
6453   /////////////////////////////////////////////////////
6454   // Placing Screws 
6455   /////////////////////////////////////////////////////
6456   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6457                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6458   Int_t screwcoverplatedgesnumber[2] = {20,20};
6459   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6460                                                                                 fgkEndCapCoverPlateThickness
6461                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6462   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6463                                                                                                  screwcoverplatedgesnumber,
6464                                                                                                  screwcoverplatesection);
6465   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6466                                                                                            screwcoverplateshape,
6467                                                                                            fSSDCoolingTubePhynox); 
6468   screwcoverplate->SetLineColor(12);
6469   Double_t transx[4] = {0,
6470                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6471                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6472                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6473                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6474                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6475   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6476 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6477   TGeoTranslation*** endcapcoverplatescrewtrans;
6478   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6479   Int_t index = 0;
6480   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6481         endcapcoverplatescrewtrans[i] = 
6482                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6483     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6484                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6485         if(index==1||index==9||index==28||index==36){
6486                         endcapcoverplatescrewtrans[i][j] = 
6487                                 new TGeoTranslation(transx[i],
6488                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6489                                                                         fgkEndCapSideCoverThickness);
6490                 }
6491                 else{
6492                         endcapcoverplatescrewtrans[i][j] = 
6493                                 new TGeoTranslation(transx[i],
6494                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6495                                                                         0.);
6496                 }
6497             if(index!=19) 
6498                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6499                                                                                           endcapcoverplatescrewtrans[i][j]);
6500         }
6501   }
6502   /////////////////////////////////////////////////////
6503   // Placing Cover Plate Clips 
6504   /////////////////////////////////////////////////////
6505   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6506                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6507                                                                                                          0.5*fgkEndCapSideCoverThickness);
6508   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6509                                                                                                         endcapcoverplateclipshape,
6510                                                                                                         fSSDCoolingTubePhynox);
6511   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6512                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6513                                                                                                          0.5*fgkEndCapSideCoverThickness);
6514   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6515                                                                                                         endcapcoverplatedownclipshape,
6516                                                                                                         fSSDCoolingTubePhynox);
6517   TGeoTranslation* endcapcoverplatecliptrans[4];
6518   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6519                                                            -                     fgkEndCapCoverPlateLength[0]
6520                                                            -                     fgkEndCapSideCoverThickness,
6521                                                                                                          0.0,
6522                                                                                                  0.5*(fgkEndCapSideCoverThickness
6523                                                            +                                              fgkEndCapCoverPlateThickness));
6524   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6525                                                            -                     fgkEndCapCoverPlateLength[0]
6526                                                            -                     fgkEndCapSideCoverThickness,
6527                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6528                                                            *                                     fgkEndCapSideCoverWidth[5],
6529                                                                                                  0.5*(fgkEndCapSideCoverThickness
6530                                                            +                                              fgkEndCapCoverPlateThickness));
6531   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6532                                                            -                     fgkEndCapCoverPlateLength[0]
6533                                                            +                                     fgkEndCapCoverPlateLength[1]
6534                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6535                                                            -                                     fgkEndCapCoverPlateClipLength
6536                                                            +                                 fgkEndCapSideCoverThickness,
6537                                                                                                          0.0,
6538                                                                                                  0.5*(fgkEndCapSideCoverThickness
6539                                                            +                                              fgkEndCapCoverPlateThickness));
6540   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6541                                                            -                     fgkEndCapCoverPlateLength[0]
6542                                                            +                                     fgkEndCapCoverPlateLength[1]
6543                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6544                                                            -                                     fgkEndCapCoverPlateClipLength
6545                                                            +                                 fgkEndCapSideCoverThickness,
6546                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6547                                                            *                                     fgkEndCapSideCoverWidth[5],
6548                                                                                                  0.5*(fgkEndCapSideCoverThickness
6549                                                            +                                              fgkEndCapCoverPlateThickness));
6550   endcapcoverplateclip->SetLineColor(fColorPhynox);
6551   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6552   for(Int_t i=0; i<4; i++) 
6553         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6554                                                                                                    endcapcoverplatecliptrans[i]);  
6555   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6556   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6557                                                                    -                     fgkEndCapCoverPlateLength[0]
6558                                                                    -                     fgkEndCapSideCoverThickness,
6559                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6560                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6561                                                                                                         0.5*(fgkEndCapSideCoverThickness
6562                                                                +                                         fgkEndCapCoverPlateThickness)
6563                                                                    -                     fgkEndCapSideCoverWidth[1]
6564                                                                    -                                     fgkEndCapSideCoverThickness);
6565   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6566                                                                    -                     fgkEndCapCoverPlateLength[0]
6567                                                                    -                     fgkEndCapSideCoverThickness,
6568                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6569                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6570                                                                    +                            fgkEndCapSideCoverLength[2]
6571                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6572                                                                                                         0.5*(fgkEndCapSideCoverThickness
6573                                                                +                                         fgkEndCapCoverPlateThickness)
6574                                                                    -                     fgkEndCapSideCoverWidth[1]
6575                                                                    -                                     fgkEndCapSideCoverThickness);
6576   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6577                                                                    -                     fgkEndCapCoverPlateLength[0]
6578                                                                    +                     fgkEndCapSideCoverThickness
6579                                                                    +                     fgkEndCapCoverPlateLength[1]
6580                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6581                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6582                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6583                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6584                                                                                                         0.5*(fgkEndCapSideCoverThickness
6585                                                                +                                         fgkEndCapCoverPlateThickness)
6586                                                                    -                     fgkEndCapSideCoverWidth[1]
6587                                                                    -                                     fgkEndCapSideCoverThickness);
6588   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6589                                                                    -                     fgkEndCapCoverPlateLength[0]
6590                                                                    +                     fgkEndCapSideCoverThickness
6591                                                                    +                     fgkEndCapCoverPlateLength[1]
6592                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6593                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6594                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6595                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6596                                                                    +                                 fgkEndCapSideCoverLength[2]
6597                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6598                                                                                                         0.5*(fgkEndCapSideCoverThickness
6599                                                                +                                         fgkEndCapCoverPlateThickness)
6600                                                                    -                     fgkEndCapSideCoverWidth[1]
6601                                                                    -                                     fgkEndCapSideCoverThickness);
6602   for(Int_t i=0; i<4; i++)
6603         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6604                                                                                                    endcapcoverplatedowncliptrans[i]);
6605   /////////////////////////////////////////////////////
6606   // Placing Kapton Foil
6607   /////////////////////////////////////////////////////
6608   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6609                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6610                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6611   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6612                                                                                                 endcapkaptonfoilshape,
6613                                                                                                 fSSDKaptonFlexMedium);
6614   endcapkaptonfoil->SetLineColor(8);
6615   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6616                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6617                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6618                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6619                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6620                                                                              -                     fgkEndCapSideCoverWidth[1]
6621                                                                                  -                     fgkEndCapSideCoverThickness);
6622   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6623   /////////////////////////////////////////////////////////////
6624   // Placing Electronic Tubes
6625   /////////////////////////////////////////////////////////////
6626   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6627                                                                              - fgkEndCapInterfaceCardBThickness
6628                                                                              - 9.*fgkEndCapStripConnectionThickness
6629                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6630                                                                                fgkEndCapKaptonFoilWidth
6631                                                                              - fgkEndCapInterfaceCardBThickness
6632                                                                              - 9.*fgkEndCapStripConnectionThickness
6633                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6634                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6635   TGeoVolume* endcapeffectivecables[2];
6636   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6637                                                                                          fgkEndCapEffectiveCableRadiusMax,
6638                                                                                          endcapeffectivecableswidth[0],
6639                                                                                          10,"EndCapEffectiveCables1"); 
6640   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6641                                                                                          fgkEndCapEffectiveCableRadiusMax,
6642                                                                                          endcapeffectivecableswidth[1],
6643                                                                                          25,"EndCapEffectiveCables2"); 
6644   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6645   TGeoTranslation* endcapeffectivecablestrans[2];
6646   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6647                                           -                                                        0.5*endcapeffectivecableswidth[0]
6648                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6649                                           -                                                               fgkEndCapCoverPlateWidth[2]
6650                                           -                                             (kendcapcoverplatesmallholenumber-1)
6651                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6652                                           +                                             fgkEndCapSideCoverLength[2],
6653                                           -                     0.5*fgkEndCapCoverPlateThickness
6654                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6655                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6656                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6657   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6658                                           -                                                        0.5*endcapeffectivecableswidth[1]
6659                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6660                                           -                                                               fgkEndCapCoverPlateWidth[2]
6661                                           -                                             (kendcapcoverplatesmallholenumber-1)
6662                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6663                                           +                                         fgkEndCapSideCoverLength[2],
6664                                           -                     0.5*fgkEndCapCoverPlateThickness
6665                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6666                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6667                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6668   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6669   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6670   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6671                                                                                                                    *endcapeffectivecablesrot);
6672   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6673                                                                                                                    *endcapeffectivecablesrot);
6674 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6675 //                                                                                                        endcapeffectivecablescombitrans[0]);
6676   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6677                                                                                                           endcapeffectivecablescombitrans[1]);
6678   /////////////////////////////////////////////////////////////
6679   // Placing End Cap Cards
6680   /////////////////////////////////////////////////////////////
6681   TGeoVolume** endcapcards = GetEndCapCards();
6682   TGeoRotation* endcapcardsrot[2];
6683   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6684   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6685   TGeoTranslation* endcapcardstrans[2]; 
6686   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6687                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6688   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6689   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6690   TGeoHMatrix* endcapcardsmatrix[2];
6691   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6692   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6693                                                   - fgkEndCapCardJMDConnectorLength[0]
6694                                                   - fgkEndCapInterfaceCardBThickness
6695                                                   - 9.*fgkEndCapStripConnectionThickness
6696                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6697   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6698                                           -                                             fgkEndCapCoverPlateLength[0]
6699                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6700                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6701                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6702                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6703                                           -                                                               fgkEndCapInterfaceCardBThickness
6704                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6705                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6706                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6707                                           -                                                               fgkEndCapCoverPlateWidth[2]
6708                                           -                                             (kendcapcoverplatesmallholenumber-1)
6709                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6710                                           +                     fgkEndCapKaptonFoilWidth,
6711                                                                                           0.5*fgkEndCapCoverPlateThickness
6712                                           -                                                     fgkEndCapSideCoverWidth[1]);
6713   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6714   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6715    /////////////////////////////////////////////////////////////
6716   // Deallocating memory
6717   /////////////////////////////////////////////////////////////
6718   delete endcapcoverplaterot;
6719   delete endcapcoverplatecombitrans;
6720   delete endcapcoverplatetrans;
6721   for(Int_t i=0; i<3; i++){
6722    delete endcapsidecovercombitrans[i];
6723    if(i<2) delete endcapsidecoverot[i]; 
6724   }
6725   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6726   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6727   delete endcapcardsmatrix[0];
6728   return endcapassembly;
6729  } 
6730  ////////////////////////////////////////////////////////////////////////////////
6731  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6732                                                                                                                         Double_t radiusmax, 
6733                                                                                                                         Double_t width, 
6734                                                                                                                         Int_t ncables,
6735                                                                                                                         const char* volname){
6736   /////////////////////////////////////////////////////////////
6737   // Generating EndCap High Voltage Tubes 
6738   /////////////////////////////////////////////////////////////
6739   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6740   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
6741
6742   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6743   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6744                                                                                                    effectiveouteradius,0.5*width);
6745   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6746                                                                                                 effectiveinnertubeshape,
6747                                                                                                 fSSDStiffenerConnectorMedium);
6748   effectiveinnertube->SetLineColor(41);
6749   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6750                                                                                                 effectiveoutertubeshape,
6751                                                                                                 fSSDKaptonChipCableMedium);
6752   effectiveoutertube->SetLineColor(39);
6753   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6754   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6755   effectivemothertube->AddNode(effectiveinnertube,1);
6756   effectivemothertube->AddNode(effectiveoutertube,1);
6757   return effectivemothertube;
6758  } 
6759  ////////////////////////////////////////////////////////////////////////////////
6760  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6761   /////////////////////////////////////////////////////////////
6762   // Generating EndCap Support Layer 5 and Layer 6 
6763   /////////////////////////////////////////////////////////////
6764   const Int_t knedges = 5;
6765   ///////////////////////////////////////////////
6766   // Setting the vertices for TGeoXtru Up Volume
6767   ///////////////////////////////////////////////
6768   const Int_t klayernumber = 2;
6769   Double_t xupvertex[klayernumber][knedges+3];
6770   Double_t yupvertex[klayernumber][knedges+3];
6771   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6772   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6773   Double_t middlepsi[klayernumber] = {0.0,0.0};
6774   for(Int_t i=0; i<klayernumber; i++){
6775         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6776         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6777         xupvertex[i][2] = -xupvertex[i][1];
6778         xupvertex[i][3] = -xupvertex[i][0];
6779
6780         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6781         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6782         yupvertex[i][2] =  yupvertex[i][1];
6783         yupvertex[i][3] =  yupvertex[i][0];
6784         
6785     middledgeangle[i] = upedgeangle[i]/knedges;
6786     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6787     for(Int_t j=1; j<knedges; j++){
6788                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6789                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6790         }
6791   }
6792   ////////////////////////////////////
6793   // Generating Up TGeoXtru
6794   ////////////////////////////////////
6795   TGeoXtru* upendcapsupportshape[klayernumber];
6796   TGeoVolume* upendcapsupport[klayernumber]; 
6797   char upendcapsupportname[100]; 
6798   for(Int_t i=0; i<klayernumber; i++){
6799    upendcapsupportshape[i] = new TGeoXtru(2);
6800    snprintf(upendcapsupportname,100,"UpEndCapSupportPieceLayer%i",i+5);
6801    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6802    upendcapsupportshape[i]->DefineSection(0,0.);
6803    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6804    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6805                                                                         fSSDSupportRingAl);
6806    upendcapsupport[i]->SetLineColor(5);
6807   }
6808   ///////////////////////////////////////////////
6809   // Setting the vertices for TGeoXtru Down Volume
6810   ///////////////////////////////////////////////
6811   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6812   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6813   for(Int_t i=0; i<klayernumber; i++){
6814         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6815         xdownvertex[i][1] =  xupvertex[i][0];
6816         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6817         ydownvertex[i][1] =  yupvertex[i][0];
6818         for(Int_t j=0; j<knedges; j++){
6819                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6820                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6821         } 
6822         for(Int_t j=0; j<knedges; j++){
6823                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6824                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6825                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6826                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
6827         }
6828   }
6829   ////////////////////////////////////
6830   // Generating Down TGeoXtru
6831   ////////////////////////////////////  
6832   TGeoXtru* downendcapsupportshape[klayernumber];
6833   TGeoVolume* downendcapsupport[klayernumber]; 
6834   char downendcapsupportname[100]; 
6835   for(Int_t i=0; i<klayernumber; i++){
6836         downendcapsupportshape[i] = new TGeoXtru(2);
6837         snprintf(downendcapsupportname,100,"DownEndCapSupportPieceLayer%i",i+5);
6838         downendcapsupportshape[i] = new TGeoXtru(2);
6839         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
6840     if(i==0){
6841                 downendcapsupportshape[i]->DefineSection(0,0.);
6842                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
6843     }
6844         else{
6845                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
6846                                                                  -                 fgkEndCapSupportLowWidth[i]);
6847                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6848         }
6849     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
6850                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
6851         downendcapsupport[i]->SetLineColor(5);
6852   }
6853   ///////////////////////////////////////////////
6854   // Setting TGeoPgon Volume
6855   ///////////////////////////////////////////////
6856   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6857                                                                                                    fgkSSDLay6LadderNumber};
6858   TGeoPgon* endcapsupportmothershape[klayernumber];
6859   TGeoVolume** endcapsupportmother;
6860   endcapsupportmother = new TGeoVolume*[klayernumber];
6861   char endcapsupportmothername[100];
6862   for(Int_t i=0; i<klayernumber; i++){
6863         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6864         snprintf(endcapsupportmothername,100,"EndCapSupportMotherLayer%i",i+5);
6865         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
6866     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
6867                                                                                           ydownvertex[i][0],yupvertex[i][1]);
6868     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
6869                                                                                         fSSDAir);       
6870   }
6871   ////////////////////////////////////
6872   TGeoRotation** endcapsupportrot[klayernumber];
6873   for(Int_t i=0; i<2; i++){
6874         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
6875         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6876            endcapsupportrot[i][j] = new TGeoRotation();
6877            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
6878        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
6879        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
6880         }
6881   }
6882   return endcapsupportmother;
6883  } 
6884  ////////////////////////////////////////////////////////////////////////////////
6885  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
6886   /////////////////////////////////////////////////////////////
6887   // Setting End Cap Support Layer 5 and 6. 
6888   /////////////////////////////////////////////////////////////
6889   const Int_t kendcapcoverplatesmallholenumber = 9;
6890   const Int_t klayernumber = 2;
6891   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6892                                                                                                    fgkSSDLay6LadderNumber};
6893   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
6894                                                                                 360.0/kssdlayladdernumber[1]};
6895   TGeoVolume** endcapsupport = EndCapSupport();
6896   TGeoVolume** endcapassembly = GetEndCapAssembly();
6897   TGeoPgon* endcapsupportshape[klayernumber];
6898   Double_t* radiusmin[klayernumber];
6899   Double_t* radiusmax[klayernumber];
6900   for(Int_t i=0; i<klayernumber; i++){
6901     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
6902         radiusmin[i] = endcapsupportshape[i]->GetRmin();
6903         radiusmax[i] = endcapsupportshape[i]->GetRmax();
6904   }  
6905   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
6906   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
6907                                                                           endcapassemblyshape->GetDY(),
6908                                                                           endcapassemblyshape->GetDZ()};
6909   ///////////////////////////////////////////////
6910   // Setting TGeoPgon Volume for Mother Container
6911   ///////////////////////////////////////////////
6912   TGeoPgon* endcapsupportsystemshape[klayernumber];
6913   char endcapsupportsystemothername[100];
6914   for(Int_t i=0; i<klayernumber; i++){
6915         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6916         snprintf(endcapsupportsystemothername,100,"EndCapSupportSystemLayer%i",i+5);
6917         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
6918                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
6919                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6920                                                                                            +2.*endcapassemblycenter[2])
6921                                                                                            /CosD(0.5*upedgeangle[i]));  
6922     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
6923                                                                                                  -(fgkEndCapCoverPlateWidth[1]
6924                                                                                              - fgkEndCapCoverPlateWidth[0]),
6925                                                                                            *radiusmin[i],
6926                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6927                                                                                            +2.*endcapassemblycenter[2])
6928                                                                                            /CosD(0.5*upedgeangle[i]));
6929   }
6930   fgkEndCapSupportSystem = new TGeoVolume*[4];
6931   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
6932                                                                           endcapsupportsystemshape[0],fSSDAir); 
6933   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
6934                                                                           endcapsupportsystemshape[0],fSSDAir); 
6935   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
6936                                                                           endcapsupportsystemshape[1],fSSDAir); 
6937   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
6938                                                                           endcapsupportsystemshape[1],fSSDAir); 
6939   ///////////////////////////////////////////////
6940   TGeoTranslation* endcapassemblytrans[klayernumber];
6941   for(Int_t i=0; i<klayernumber; i++)
6942         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
6943                                                                            -  fgkEndCapSideCoverThickness
6944                                                                            +  endcapassemblycenter[0],
6945                                                                            -  0.5*fgkEndCapCoverPlateThickness
6946                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
6947                                                                            +  2.0*endcapassemblycenter[2]
6948                                                                            +  0.5*fgkEndCapSupportLength[i]
6949                                                                            /  TanD(0.5*upedgeangle[i]),
6950                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
6951                                                                            -  fgkEndCapCoverPlateWidth[2]
6952                                                                            - (kendcapcoverplatesmallholenumber-1)
6953                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
6954   TGeoRotation** endcapassemblyrot[klayernumber];
6955   TGeoHMatrix** endcapassemblymatrix[klayernumber];
6956   for(Int_t i=0; i<klayernumber; i++){
6957    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
6958    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
6959    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
6960    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
6961    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
6962    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
6963    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
6964    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6965         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
6966         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
6967    }
6968   }
6969   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
6970                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
6971   for(Int_t i=0; i<2*klayernumber; i++){
6972         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
6973                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
6974                                                                                                                                            endcapassemblymatrix[1][j+2]);
6975         }
6976         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
6977   }
6978    /////////////////////////////////////////////////////////////
6979   // Deallocating memory
6980   /////////////////////////////////////////////////////////////
6981   for(Int_t i=0; i<klayernumber; i++){
6982         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
6983                 delete endcapassemblyrot[i][j];
6984         }
6985         delete [] endcapassemblyrot[i];
6986         delete endcapassemblymatrix[i][0];
6987         delete endcapassemblymatrix[i][1];
6988   }
6989   /////////////////////////////////////////////////////////////
6990   }
6991   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
6992   /////////////////////////////////////////////////////////////
6993   // Setting End Cap Support + End Cap Assembly of Layer 5. 
6994   /////////////////////////////////////////////////////////////
6995   if (! moth) {
6996     AliError("Can't insert end cap support of layer5, mother is null!\n");
6997     return;
6998   };
6999   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7000   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7001   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7002                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7003                                                                            +            fgkEndCapSupportCenterLay5Position
7004                                                                            -            fgkEndCapSideCoverLength[2]);
7005   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7006                                                                                                 fgkEndCapSideCoverLength[2]
7007                                                                            -        fgkEndCapSupportCenterLay5Position
7008                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7009   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7010   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7011   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7012         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7013   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7014   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7015    /////////////////////////////////////////////////////////////
7016   // Deallocating memory
7017   /////////////////////////////////////////////////////////////
7018   delete endcapsupportsystemrot;
7019   delete endcapsupportsystemITSCentertrans[1];
7020  }
7021   /////////////////////////////////////////////////////////////
7022   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7023   /////////////////////////////////////////////////////////////
7024   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7025   /////////////////////////////////////////////////////////////
7026   if (! moth) {
7027     AliError("Can't insert end cap support of layer6, mother is null!\n");
7028     return;
7029   };
7030   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7031   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7032   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7033                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7034                                                                            +            fgkEndCapSupportCenterLay6Position
7035                                                                            -            fgkEndCapSideCoverLength[2]);
7036   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7037                                                                                                 fgkEndCapSideCoverLength[2]
7038                                                                            -        fgkEndCapSupportCenterLay6Position
7039                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7040   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7041   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7042   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7043         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7044   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7045   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7046    /////////////////////////////////////////////////////////////
7047   // Deallocating memory
7048   /////////////////////////////////////////////////////////////
7049   delete endcapsupportsystemrot;
7050   delete endcapsupportsystemITSCentertrans[1];
7051  }
7052  ////////////////////////////////////////////////////////////////////////////////
7053  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7054   /////////////////////////////////////////////////////////////
7055   // Setting Ladder Support of Layer 5. 
7056   /////////////////////////////////////////////////////////////
7057   if (! moth) {
7058     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7059     return;
7060   };
7061   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7062   fMotherVol = moth;
7063   TGeoTranslation* centerITSRingSupportLay5trans[2];
7064   for(Int_t i=0; i<2; i++){
7065         centerITSRingSupportLay5trans[i] = 
7066                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7067     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7068   }
7069  }
7070  ////////////////////////////////////////////////////////////////////////////////
7071  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7072   /////////////////////////////////////////////////////////////
7073   // Setting Ladder Support of Layer 6. 
7074   /////////////////////////////////////////////////////////////
7075   if (! moth) {
7076     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7077     return;
7078   };
7079   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7080   fMotherVol = moth;
7081   TGeoTranslation* centerITSRingSupportLay6trans[2];
7082   for(Int_t i=0; i<2; i++){
7083         centerITSRingSupportLay6trans[i] = 
7084                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7085     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7086   }
7087  }
7088  ////////////////////////////////////////////////////////////////////////////////
7089  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7090   /////////////////////////////////////////////////////////////
7091   // Setting Ladder Support of Layer 6. 
7092   /////////////////////////////////////////////////////////////
7093   if (! moth) {
7094     AliError("Can't insert SSD Cone, mother is null!\n");
7095     return;
7096   };
7097   if(!fSSDCone) SetSSDCone();
7098   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7099                                                                 +                                         fgkSSDCentralAL3SupportLength);
7100     moth->AddNode(fSSDCone,1,ssdconetrans);
7101 }
7102  ////////////////////////////////////////////////////////////////////////////////
7103  void AliITSv11GeometrySSD::SetSSDCone(){
7104   /////////////////////////////////////////////////////////////
7105   // Method generating SSDCone 
7106   /////////////////////////////////////////////////////////////
7107   if(!fCreateMaterials) CreateMaterials();
7108   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7109   Double_t ssdpconesectionradiusmax[16];
7110   Double_t ssdpconesectionradiusmin[16];
7111   Double_t ssdpconezsection[16];
7112   TGeoPcon* ssdpconelittleholeshape[8];
7113   TGeoVolume* ssdpconelittlehole[8];
7114   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7115   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7116   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7117                                                       / SinD(fgkSSDPConeAngle)
7118                                                           + ssdpconesectionradiusmin[0];
7119   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7120                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7121                                                           / SinD(fgkSSDPConeAngle);
7122   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7123   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7124                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7125   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7126   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7127                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7128   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7129   ssdpconelittlehole[0]->SetLineColor(4);
7130   /////////////////////////////////////////////////////////////
7131   ssdpconezsection[2] = ssdpconezsection[1];  
7132   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7133   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7134   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7135                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7136                                                           / SinD(fgkSSDPConeAngle);
7137   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7138                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7139   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7140                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7141   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7142                                                                    * TMath::RadToDeg();
7143   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7144                                                                                                           60.-ssdpconelittleholeangle,2);    
7145   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7146                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7147   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7148   ssdpconelittlehole[1]->SetLineColor(4);
7149   TGeoRotation* ssdconelittleholerot[6];
7150   for(Int_t i=0; i<6; i++){
7151         ssdconelittleholerot[i] = new TGeoRotation();
7152     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7153   }
7154   /////////////////////////////////////////////////////////////
7155   ssdpconezsection[4] = ssdpconezsection[3];  
7156   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7157   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7158   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7159                                                           * CosD(fgkSSDPConeAngle)
7160                                                           / SinD(fgkSSDPConeAngle);
7161   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7162   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7163                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7164   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7165   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7166                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7167   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7168   ssdpconelittlehole[2]->SetLineColor(4);
7169   ///////////////////////////////////////////////////
7170   ssdpconezsection[6] = ssdpconezsection[5];  
7171   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7172   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7173   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7174                                                           -ssdpconezsection[0]
7175                                                           * CosD(fgkSSDPConeAngle)
7176                                                           / SinD(fgkSSDPConeAngle);
7177   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7178   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7179                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7180   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7181                                                                    * TMath::RadToDeg();
7182   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7183                                                                                                           45.-ssdpconemiddleholeangle,2);    
7184   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7185                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7186   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7187   ssdpconelittlehole[3]->SetLineColor(4);
7188   TGeoRotation* ssdconemiddleholerot[8];
7189   for(Int_t i=0; i<8; i++){
7190         ssdconemiddleholerot[i] = new TGeoRotation();
7191     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7192   }
7193   /////////////////////////////////////////////////////////////
7194   ssdpconezsection[8] = ssdpconezsection[7];  
7195   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7196   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7197   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7198                                                           * CosD(fgkSSDPConeAngle)
7199                                                           / SinD(fgkSSDPConeAngle);
7200   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7201   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7202                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7203   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7204   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7205                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7206   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7207   ssdpconelittlehole[4]->SetLineColor(4);
7208   /////////////////////////////////////////////////////////////
7209   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7210   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7211                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7212                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7213                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7214                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7215   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7216   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7217                                                                                  * TMath::RadToDeg();
7218   ssdpconezsection[10] = ssdpconezsection[9];
7219   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7220   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7221   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7222                                                           * CosD(fgkSSDPConeAngle)
7223                                                           / SinD(fgkSSDPConeAngle);
7224   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7225   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7226                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7227   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7228                                                                                         ssdpconetrapezoidsectionangle,2);    
7229   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7230                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7231   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7232   ssdpconelittlehole[5]->SetLineColor(4);
7233   TGeoRotation* ssdconeupradiusrot[8];
7234   for(Int_t i=0; i<8; i++){
7235         ssdconeupradiusrot[i] = new TGeoRotation();
7236     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7237   }
7238   /////////////////////////////////////////////////////////////
7239   ssdpconezsection[12] = ssdpconezsection[11];
7240   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7241   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7242   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7243   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7244   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7245   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7246   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7247                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7248   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7249   ssdpconelittlehole[6]->SetLineColor(4);
7250   /////////////////////////////////////////////////////////////
7251   ssdpconezsection[14] = 0.0;
7252   ssdpconezsection[15] = ssdpconezsection[0];
7253   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7254   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7255   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7256   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7257   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7258   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7259                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7260   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7261   ssdpconelittlehole[7]->SetLineColor(4);
7262   /////////////////////////////////////////////////////////////
7263   TGeoTube* ssdtubeconeshape[2];
7264   TGeoVolume* ssdtubecone[2];
7265   TGeoTranslation* ssdtubeconetrans[2];
7266   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7267                                                                            fgkSSDPConeExternalRadius,
7268                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7269   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7270                                                                            0.5*ssdpconezsection[0]); 
7271   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7272   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7273   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7274                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7275                                           + ssdpconezsection[13]);
7276   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7277   ssdtubecone[0]->SetLineColor(4);
7278   ssdtubecone[1]->SetLineColor(4);
7279   /////////////////////////////////////////////////////////////
7280   // Mother Volume Container
7281   /////////////////////////////////////////////////////////////
7282   Double_t ssdconemotherradiusmin[8];
7283   Double_t ssdconemotherradiusmax[8];
7284   Double_t ssdconemothersection[8]; 
7285   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7286   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7287   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7288   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7289   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7290   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7291   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7292   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7293   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7294   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7295   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7296   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7297   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7298   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7299   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7300   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7301   ssdconemothersection[0] = 0.0;
7302   ssdconemothersection[1] = ssdpconezsection[0];
7303   ssdconemothersection[2] = ssdpconezsection[0];
7304   ssdconemothersection[3] = ssdpconezsection[11];
7305   ssdconemothersection[4] = ssdpconezsection[11];
7306   ssdconemothersection[5] = ssdpconezsection[13];
7307   ssdconemothersection[6] = ssdpconezsection[13];
7308   ssdconemothersection[7] = fgkSSDPConeLength;
7309   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7310   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7311                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7312   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7313   /////////////////////////////////////////////////////////////
7314   //Placing the Volumes into Mother 
7315   /////////////////////////////////////////////////////////////
7316   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7317   for(Int_t i=0; i<6; i++){
7318         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7319   }
7320   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7321   for(Int_t i=0; i<8; i++){
7322     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7323   }
7324   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7325   for(Int_t i=0; i<8; i++){
7326     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7327   }
7328   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7329   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7330   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7331   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7332   /////////////////////////////////////////////////////////////
7333   // ITS General Support
7334   /////////////////////////////////////////////////////////////
7335   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7336                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7337   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7338   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7339                                                                              - fgkSSDCentralAL3SupportLength);
7340   ssdcentralsupport->SetLineColor(4);
7341   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7342   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7343                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7344   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7345   TGeoTranslation* ssdcentralal3supportrans[3]; 
7346   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7347   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7348                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7349   ssdcentralal3support->SetLineColor(4);
7350   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7351   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7352   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7353   Double_t ssdpconcentralradiusmin[2];
7354   Double_t ssdpconcentralradiusmax[2];
7355   Double_t ssdpconcentralsection[2];
7356   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7357   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7358   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7359   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7360   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7361   ssdpconcentralsection[1] = 0.;
7362   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7363                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7364   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7365   ssdpconcentralal3->SetLineColor(4);
7366   fSSDCone->AddNode(ssdpconcentralal3,1);
7367   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7368   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7369   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7370                                                                 -2.*fgkSSDCentralAL3SupportLength);
7371   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7372                                                                                                                      *ssdcentralal3supportrot);
7373   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7374   TGeoRotation* ssdconemotherot = new TGeoRotation();
7375   ssdconemotherot->SetAngles(90.,180.,-90.);
7376   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7377                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7378   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7379   fSSDCone->AddNode(ssdconemother,1);
7380   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7381   /////////////////////////////////////////////////////////////
7382   // Deallocating memory
7383   /////////////////////////////////////////////////////////////
7384   delete ssdcentralal3supportrot;
7385   delete ssdcentralal3supportrans[2];
7386   delete ssdconemotherot;
7387   delete ssdconemothertrans;
7388   /////////////////////////////////////////////////////////////
7389  }
7390  ////////////////////////////////////////////////////////////////////////////////
7391  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7392   /////////////////////////////////////////////////////////////
7393   // Setting SSD Cables
7394   /////////////////////////////////////////////////////////////
7395   if (! moth) {
7396     AliError("Can't insert SSD Cables, mother is null!\n");
7397     return;
7398   };
7399   TGeoVolume* ssdcables = SetSSDCables();
7400   moth->AddNode(ssdcables,1);
7401 }
7402  ////////////////////////////////////////////////////////////////////////////////
7403  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7404   /////////////////////////////////////////////////////////////
7405   // Method generating SSDCables
7406   /////////////////////////////////////////////////////////////
7407   // SSD Layer 5 Cables
7408   //////////////////////////////////////////////////////////////////////////////////////////////////
7409   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7410   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7411   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7412   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7413   //////////////////////////////////////////////////////////////////////////////////////////////////
7414   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7415   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7416                                                                             -  fgkSSDLowerPConeRadius)
7417                                                                             * TanD(fgkSSDPConeAngle);
7418   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7419                                                                               + fgkEndCapSupportCenterLay5Position
7420                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7421   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7422                                                                            - ssdcableslay5startconedistance; 
7423   ssdcablelay5rightsidelength *= ssdcablesfactor;
7424   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7425   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7426                                                                                                 ssdcableslay5rightsideradiusmax,
7427                                                                                                 0.5*ssdcablelay5rightsidelength); 
7428   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7429                                                                                                          ssdcablelay5rightubeshape,
7430                                                                                                          fSSDCopper);
7431   ssdcablelay5righttube->SetLineColor(9);
7432   TGeoTranslation* ssdcablelay5rightrans = 
7433                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7434                                                                                  +              fgkEndCapSupportCenterLay5Position
7435                                                                                  +      0.5*ssdcablelay5rightsidelength);
7436   ////////////////////////////////////
7437   //  Double_t cablescapacity[20];
7438   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7439   ////////////////////////////////////
7440   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7441   ////////////////////////////////////
7442   // TGeoPCone Volumes
7443   ///////////////////////////////////
7444   TGeoPcon* ssdcableslay5pconshape[3];
7445   TGeoVolume* ssdcableslay5pcon[3]; 
7446   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7447   Double_t ssdcableslay5pconzsection[6];
7448   Double_t ssdcableslay5pconrmin[6];
7449   Double_t ssdcableslay5pconrmax[6];
7450   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7451   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7452   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7453   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7454   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7455                                                            + fgkEndCapSupportCenterLay5Position
7456                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7457   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7458                                                            + fgkSSDCentralAL3SupportLength
7459                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7460                                                            * TanD(fgkSSDPConeAngle);      
7461   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7462                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7463   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7464                                                            ssdcableslay5pconshape[0],fSSDCopper);
7465   ssdcableslay5pcon[0]->SetLineColor(9);
7466   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7467 ////////////////////////////////////
7468 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7469 ////////////////////////////////////
7470   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7471   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7472                                                            + fgkSSDCentralAL3SupportLength
7473                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7474                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7475   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7476                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7477                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7478   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7479                                                                                    ssdcableangle,2);   
7480   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7481   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7482   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7483                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7484   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7485   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7486   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7487                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7488   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7489   ssdcableslay5pcon[1]->SetLineColor(9);
7490   ////////////////////////////////////
7491   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7492                                                                                    ssdcableangle,2);   
7493   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7494   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7495   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7496   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7497   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7498   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7499                                                            * TanD(fgkSSDPConeAngle)
7500                                                            + 0.5*fgkSSDCentralSupportLength
7501                                                            + fgkSSDCentralAL3SupportLength;
7502   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7503   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7504                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7505   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7506   ssdcableslay5pcon[2]->SetLineColor(9);
7507 ////////////////////////////////////
7508   TGeoRotation* ssdcableslay5pconrot[4];        
7509   for(Int_t i=0; i<4; i++){
7510    ssdcableslay5pconrot[i] = new TGeoRotation();
7511    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7512    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7513    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7514   }
7515   ////////////////////////////////////
7516   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7517   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7518   ////////////////////////////////////
7519   // Positioning Left SSD Cables Part
7520   ////////////////////////////////////
7521   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7522                                                                                                         - 0.5*ssdcablelay5rightsidelength
7523                                                                                                         - fgkEndCapSupportCenterLay5Position
7524                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7525   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7526   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7527   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7528   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7529   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7530   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7531         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7532         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7533     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7534   }
7535   ////////////////////////////////////
7536   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7537   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7538   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7539   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7540   /////////////////////////////////////////////////////////////
7541   // Water Tubes Layer 5
7542   /////////////////////////
7543   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7544                                                                                      ssdcableslay5rightsideradiusmax
7545                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7546                                                                                      0.5*ssdcablelay5rightsidelength); 
7547   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7548                                                                                                          ssdcablelay5rightubewatershape,
7549                                                                                                          fSSDCoolingTubeWater);
7550   ssdcablelay5rightwatertube->SetLineColor(7);
7551   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7552   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7553   ////////////////////////////////////
7554   // TGeoPCone Water Volumes Layer 
7555   ///////////////////////////////////
7556   TGeoPcon* ssdcableslay5pconwatershape[3];
7557   TGeoVolume* ssdcableslay5pconwater[3]; 
7558   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7559   Double_t ssdcableslay5pconwaterzsection[6];
7560   Double_t ssdcableslay5pcwateronrmin[6];
7561   Double_t ssdcableslay5pconwaterrmax[6];
7562   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7563   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7564                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7565   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7566   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7567                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7568   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7569   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7570   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7571                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7572   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7573                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7574   ssdcableslay5pconwater[0]->SetLineColor(7);
7575   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7576   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7577 ////////////////////////////////////
7578   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7579   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7580   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7581                                                                                                 ssdcableangle,2);   
7582   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7583   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7584                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7585   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7586   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7587                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7588   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7589                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7590   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7591                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7592   ssdcableslay5pconwater[1]->SetLineColor(7);
7593 ////////////////////////////////////
7594   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7595                                                                                                 ssdcableangle,2);   
7596   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7597   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7598                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7599   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7600   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7601                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7602   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7603   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7604   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7605                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7606   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7607                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7608   ssdcableslay5pconwater[2]->SetLineColor(7);
7609 ////////////////////////////////////
7610   TGeoRotation* ssdcableslay5pconwaterot[4];    
7611   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7612   for(Int_t i=0; i<4; i++){
7613    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7614    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7615    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7616         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7617         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7618         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7619         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7620         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7621   }
7622   /////////////////////////
7623   // SSD Layer 6 Cables
7624   /////////////////////////
7625   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7626   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7627   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7628   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7629                                                                                                 ssdcableslay6rightsideradiusmax,
7630                                                                                                 0.5*ssdcablelay6rightsidelength); 
7631   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7632                                                                                                          ssdcablelay6rightubeshape,
7633                                                                                                          fSSDCopper);
7634   ssdcablelay6righttube->SetLineColor(9);
7635   TGeoTranslation* ssdcablelay6rightrans = 
7636                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7637                                                                                  +              fgkEndCapSupportCenterLay6Position
7638                                                                                  +      0.5*ssdcablelay6rightsidelength);
7639   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7640                                                                                                         - 0.5*ssdcablelay6rightsidelength
7641                                                                                                         - fgkEndCapSupportCenterLay6Position
7642                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7643   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7644   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7645   ////////////////////////////////////
7646   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7647   ////////////////////////////////////
7648   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7649                                                                                    ssdcableangle,2);   
7650   TGeoVolume* ssdcableslay6pcon;
7651   Double_t ssdcableslay6pconrmin[2];
7652   Double_t ssdcableslay6pconrmax[2];
7653   Double_t ssdcableslay6pconzsection[2];
7654   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7655   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7656   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7657   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7658   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7659                                                            + fgkEndCapSupportCenterLay6Position
7660                                                            + ssdcablelay6rightsidelength;
7661   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7662   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7663                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7664   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7665                                                            ssdcableslay6pconshape,fSSDCopper);
7666   ssdcableslay6pcon->SetLineColor(9);
7667   for(Int_t i=0; i<4; i++){
7668    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7669    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7670   }
7671   ////////////////////////////////////
7672   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7673   /////////////////////////
7674   // Water Tubes Layer 6
7675   /////////////////////////
7676   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7677                                                                                                                   ssdcableslay6rightsideradiusmax
7678                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7679                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7680   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7681                                                                                                          ssdcablelay6righwatertubeshape,
7682                                                                                                          fSSDCoolingTubeWater);
7683   ssdcablelay6rightwatertube->SetLineColor(7);
7684   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7685   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7686   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7687                                                                                    ssdcableangle,2);   
7688   TGeoVolume* ssdcableslay6waterpcon;
7689   Double_t ssdcableslay6waterpconrmin[2];
7690   Double_t ssdcableslay6waterpconrmax[2];
7691   Double_t ssdcableslay6waterpconzsection[2];
7692   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7693   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7694                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7695   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7696   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7697   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7698                                                            + fgkEndCapSupportCenterLay6Position
7699                                                            + ssdcablelay6rightsidelength;
7700   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7701   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7702                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7703   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7704                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7705   ssdcableslay6waterpcon->SetLineColor(7);
7706   TGeoRotation* ssdcableslay6pconwaterot[4];    
7707   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7708   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7709   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7710   for(Int_t i=0; i<4; i++){
7711    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7712    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7713    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7714                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7715    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7716    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7717   }
7718   ////////////////////////////////////////
7719   // From ITS Ring to Patch Panel3-RB26
7720   ////////////////////////////////////////
7721   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7722   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7723   Double_t ssdcablepatchpanel3RB26zsection[2];
7724   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeight+2.8+0.003;//Avoid small overlap with SPDshieldring;
7725   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7726                                                                           + fgkSSDCablesLay5RightSideHeight
7727                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7728   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7729   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7730                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7731                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7732   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7733                                                                                  + fgkSSDCentralAL3SupportLength
7734                                                                                  + fgkSSDPConeZLength[0];
7735   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7736   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7737                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7738                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7739   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7740                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7741   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7742                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7743   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7744   TGeoRotation* ssdcablepatchpanel3B26rot[4];
7745   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7746   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7747   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7748                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7749   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7750   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7751                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7752   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7753   ////////////////////////////////////
7754   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7755   ////////////////////////////////////////
7756   //  ITS Ring Cables RB26 Part
7757   ////////////////////////////////////////
7758   Double_t ssdcableitsring3BB26pconzsection[2];
7759   Double_t ssdcableitsring3BB26pconrmin[2];
7760   Double_t ssdcableitsring3BB26pconrmax[2];
7761   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7762                                                                           + fgkSSDCentralAL3SupportLength
7763                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7764   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7765   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7766   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7767                                                                   + fgkSSDCablesLay5RightSideHeight
7768                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7769   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7770   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7771   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7772   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7773                                                                    -              0.5*ssdcableangle,ssdcableangle
7774                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7775                                                                    -                             fgkSSDCableAngle),2);
7776   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7777                                                                    -              0.5*ssdcableangle,ssdcableangle
7778                                                                    +                      3.0*fgkSSDCableAngle
7779                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7780   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7781                                                                    -              0.5*ssdcableangle,ssdcableangle
7782                                                                    -                      fgkSSDCableAngle
7783                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7784   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7785                                                                    -              0.5*ssdcableangle,ssdcableangle
7786                                                                    +                      3.0*fgkSSDCableAngle
7787                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7788   for(Int_t i=0;i<4;i++)
7789         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7790                                                          ssdcableitsring3BB26pconrmin[j],
7791                                                          ssdcableitsring3BB26pconrmax[j]); 
7792   TGeoVolume* ssdcableitsring3BB26pcon[4];
7793   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7794                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7795   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7796                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7797   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7798                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7799   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7800                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7801   for(Int_t i=0;i<4;i++){
7802         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7803         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7804 }
7805   ////////////////////////////////////
7806   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7807   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7808   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7809   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7810   ////////////////////////////////////////
7811   // From ITS Ring to Patch Panel2-RB24
7812   ////////////////////////////////////////
7813   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7814   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7815   Double_t ssdcablepatchpanel3RB24zsection[2];
7816   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7817   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7818   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7819   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7820                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7821                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7822                                                                           + 0.5*fgkSSDPatchPanelHeight;
7823   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7824                                                                          -  fgkSSDCentralAL3SupportLength
7825                                                                          -  fgkSSDPConeZLength[0];
7826   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
7827   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
7828                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7829                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7830   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
7831                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
7832   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
7833                                                                                                 ssdcablepatchpanel3RB24pconshape,
7834                                                                                                 fSSDCopper);
7835   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
7836   TGeoRotation* ssdcablepatchpanel3B24rot[4];
7837   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
7838   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
7839   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
7840                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7841   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
7842   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
7843                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7844   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
7845   ////////////////////////////////////
7846   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
7847   ////////////////////////////////////////
7848   //  ITS Ring Cables RB24 Part
7849   ////////////////////////////////////////
7850   Double_t ssdcableitsring3BB24pconzsection[2];
7851   Double_t ssdcableitsring3BB24pconrmin[2];
7852   Double_t ssdcableitsring3BB24pconrmax[2];
7853   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
7854   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
7855   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7856   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
7857                                                                   + fgkSSDCablesLay5RightSideHeight
7858                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7859   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
7860   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
7861   TGeoPcon* ssdcableitsring3BB24pconshape[4];
7862   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7863                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7864                                                                    -                             fgkSSDCableAngle),2);
7865   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
7866                                                                      ssdcableangle-fgkSSDCableAngle
7867                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7868   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7869                                                                    -                      fgkSSDCableAngle
7870                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
7871   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
7872                                                                                                   ssdcableangle-fgkSSDCableAngle
7873                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7874   for(Int_t i=0;i<4;i++)
7875         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
7876                                                          ssdcableitsring3BB24pconrmin[j],
7877                                                          ssdcableitsring3BB24pconrmax[j]); 
7878   TGeoVolume* ssdcableitsring3BB24pcon[4];
7879   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
7880                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
7881   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
7882                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
7883   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
7884                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
7885   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
7886                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
7887   for(Int_t i=0;i<4;i++){
7888         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
7889         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
7890 }
7891   ////////////////////////////////////
7892   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
7893   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
7894   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
7895   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
7896   ////////////////////////////////////
7897   // Volumes for Material Budget 
7898   ////////////////////////////////////
7899   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
7900                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
7901                                                                                                          ssdcableslay6rightsideradiusmax
7902                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
7903                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
7904   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
7905                                                                                                          ssdcablelay6materialbudgetubeshape,
7906                                                                                                          fSSDCopper);
7907   ssdcablelay6materialbudgetube->SetLineColor(9);
7908   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
7909   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
7910
7911   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
7912                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
7913   TGeoVolume* ssdcablelay6materialbudgetpcon;
7914   Double_t ssdcablelay6materialbudgetpconrmin[2];
7915   Double_t ssdcablelay6materialbudgetpconrmax[2];
7916   Double_t ssdcablelay6materialbudgetpconzsection[2];
7917   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
7918                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7919   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
7920                                                                                 + fgkSSDCableMaterialBudgetHeight;
7921   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
7922   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
7923   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7924                                                                                         + fgkEndCapSupportCenterLay6Position
7925                                                                                         + ssdcablelay6rightsidelength;
7926   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7927   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
7928                                                   ssdcablelay6materialbudgetpconzsection[i],
7929                                                   ssdcablelay6materialbudgetpconrmin[i],
7930                                                   ssdcablelay6materialbudgetpconrmax[i]); 
7931   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
7932                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
7933   ssdcablelay6materialbudgetpcon->SetLineColor(9);
7934   for(Int_t i=0; i<4; i++){
7935    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
7936    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7937   }
7938 ////////////////////////////////////
7939  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
7940   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
7941   Double_t ssdcablesvolume = 0.0;
7942   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
7943   std::cout << ssdcablesvolume << std::endl;*/
7944   return ssdcablesmother;
7945  }
7946  ////////////////////////////////////////////////////////////////////////////////
7947 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3 const * const vertexpos[4] , const Double_t* width, 
7948                                             Double_t height, const char* shapename, Int_t isign) const{
7949   /////////////////////////////////////////////////////////////
7950   // Method generating an Arb shape 
7951   /////////////////////////////////////////////////////////////
7952   const Int_t kvertexnumber = 8;
7953   const Int_t ktransvectnumber = 2;
7954   TVector3 vertex[kvertexnumber];
7955   TVector3 transvector[2];
7956   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
7957   /////////////////////////////////////////////////////////////
7958   //Setting the vertices for TGeoArb8
7959   /////////////////////////////////////////////////////////////
7960   vertex[0] = *vertexpos[0];
7961   vertex[1] = *vertexpos[1];
7962   vertex[2] = vertex[1]; 
7963   vertex[3] = vertex[0]; 
7964   vertex[4] = *vertexpos[2];
7965   vertex[5] = *vertexpos[3];
7966   vertex[6] = vertex[5];
7967   vertex[7] = vertex[4];
7968
7969   // NB: order of points is clockwise
7970   if (isign < 0) {
7971     vertex[2] -= transvector[0];
7972     vertex[3] -= transvector[0];
7973     vertex[6] -= transvector[1];
7974     vertex[7] -= transvector[1];
7975   }
7976   else {
7977     vertex[0] += transvector[0];
7978     vertex[1] += transvector[0];
7979     vertex[4] += transvector[1];
7980     vertex[5] += transvector[1];
7981   }
7982
7983   /////////////////////////////////////////////////////////////
7984   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
7985   for(Int_t i = 0; i<kvertexnumber;i++) {
7986     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
7987   }
7988
7989   return arbshape;
7990
7991 ///////////////////////////////////////////////////////////////////////////////
7992 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
7993                                                                 Double_t rmax, Int_t nedges, Double_t height){
7994   /////////////////////////////////////////////////////////////
7995   // Method generating Arc shape 
7996   /////////////////////////////////////////////////////////////
7997         const Int_t kvertexnumber = 2*nedges+2;
7998         TGeoXtru* arcshape = new TGeoXtru(2);   
7999         TVector3** vertexposition[2];
8000         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8001         Double_t angle = 0.;
8002     for(Int_t i=0; i<nedges+1; i++){ 
8003                 angle = 90.+0.5*phi-i*(phi/nedges);
8004                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8005                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8006         }
8007         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8008         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8009         for(Int_t i=0; i<kvertexnumber; i++){ 
8010                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8011                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8012                 }
8013                 else if(i>=1&&i<nedges+2)
8014                 {
8015                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8016                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8017                 }
8018         else
8019                 {
8020                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8021                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8022                 }
8023     }
8024   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8025   arcshape->DefineSection(0,-0.5*height);
8026   arcshape->DefineSection(1,0.5*height);
8027   /////////////////////////////////////////////////////////////
8028   // Deallocating memory
8029   /////////////////////////////////////////////////////////////
8030   for(Int_t i=0; i<2; i++){
8031         for(Int_t j=0; j<nedges+1; j++)
8032                 delete vertexposition[i][j];
8033         delete [] vertexposition[i];
8034   }
8035   delete [] xvertexpoints;
8036   delete [] yvertexpoints;
8037   /////////////////////////////////////////////////////////////
8038         return arcshape;
8039 }
8040 ////////////////////////////////////////////////////////////////////////////////
8041 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(const Double_t* radius,const Int_t* edgesnumber,const Double_t* section) const {
8042   ///////////////////////////////////////////////////////////////////////
8043   // Method Generating the Screw Shape  
8044   // radius[0]: outer radius
8045   // radius[1]: inner radius
8046   // edgesnumber[0]: outer number of edges
8047   // edgesnumber[1]: inner number of edges
8048   // section[0]: lower section position
8049   // section[1]: higher section position
8050   ///////////////////////////////////////////////////////////////////////
8051   Double_t outradius = radius[0];
8052   Double_t inradius = radius[1];
8053   Int_t outvertexnumber = edgesnumber[0];
8054   Int_t invertexnumber = edgesnumber[1];
8055   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8056   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8057   for(Int_t i=0; i<outvertexnumber; i++){
8058         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8059         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8060   }
8061   for(Int_t i=0; i<invertexnumber; i++){
8062         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8063         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8064   }
8065   TGeoXtru* screwshapeout = new TGeoXtru(2);
8066   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8067   screwshapeout->DefineSection(0,section[0]);
8068   screwshapeout->DefineSection(1,section[1]);
8069   TGeoXtru* screwshapein = new TGeoXtru(2);
8070   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8071   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8072   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8073   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8074   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8075   
8076   delete [] xscrewvertex;
8077   delete [] yscrewvertex;
8078   return screwshape;
8079 }
8080 ////////////////////////////////////////////////////////////////////////////////
8081 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, const Double_t *section) const {
8082   ///////////////////////////////////////////////////////////////////////
8083   // Method Generating the Hole Shape  
8084   // radius of the Hole
8085   // nedges: number of edges to approximate the circle
8086   ///////////////////////////////////////////////////////////////////////
8087   Double_t* xholevertex = new Double_t[nedges];
8088   Double_t* yholevertex = new Double_t[nedges];
8089   Double_t z  = 0.5*(section[0]+section[1]);
8090   Double_t dz = 0.5*(section[1]-section[0]);
8091   TGeoTranslation *tr = 0;
8092   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8093      tr = new TGeoTranslation(0.,0.,z);
8094      tr->RegisterYourself();
8095   }   
8096   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8097   for(Int_t i=0; i<nedges; i++){
8098         xholevertex[i] = radius*CosD(i*360./nedges);
8099         yholevertex[i] = radius*SinD(i*360./nedges);
8100   }
8101   TGeoXtru* holeshapeout = new TGeoXtru(2);
8102   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8103   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8104   holeshapeout->DefineSection(1,section[1]+0.01);
8105   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8106   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8107   
8108   delete [] xholevertex;
8109   delete [] yholevertex;
8110   return holeshape;
8111 }
8112 ////////////////////////////////////////////////////////////////////////////////
8113 TVector3* AliITSv11GeometrySSD::GetReflection(const TVector3* vector,const Double_t* param) const{
8114   /////////////////////////////////////////////////////////////
8115   // Given an axis specified by param, it gives the reflection of the point
8116   // respect to the axis
8117   /////////////////////////////////////////////////////////////
8118   TVector3* n = new TVector3(param[0],param[1],param[2]);
8119   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8120   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8121   /////////////////////////////////////////////////////////////
8122   // Deallocating memory
8123   /////////////////////////////////////////////////////////////
8124   delete n;
8125   /////////////////////////////////////////////////////////////
8126   return reflectedvector;
8127 }
8128 ////////////////////////////////////////////////////////////////////////////////
8129 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(const TGeoHMatrix* ct,
8130                                                        Double_t dx,
8131                                                        Double_t dy,
8132                                                        Double_t dz) const{
8133   /////////////////////////////////////////////////////////////
8134   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8135   /////////////////////////////////////////////////////////////
8136   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8137   const Double_t *vect = hmatrix->GetTranslation();
8138   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8139   hmatrix->SetTranslation(newvect);
8140   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8141   delete hmatrix;
8142   return matrix;
8143 }
8144 ////////////////////////////////////////////////////////////////////////////////
8145 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8146   /////////////////////////////////////////////////////////////
8147   // Method returning the Medium type 
8148   /////////////////////////////////////////////////////////////
8149   char ch[100];
8150   snprintf(ch,100, "ITS_%s",mediumName);
8151   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8152   if (! medium)
8153     AliError(Form("medium %s not found !\n", mediumName));
8154   return medium;
8155 }
8156 ////////////////////////////////////////////////////////////////////////////////
8157 void AliITSv11GeometrySSD::CreateMaterials(){
8158 ///////////////////////////////////
8159 // This part has to be modified
8160 ///////////////////////////////////
8161   ///////////////////////////////////
8162   // Silicon for Sensor
8163   /////////////////////////////////// 
8164   fSSDSensorMedium = GetMedium("SI$");
8165   ///////////////////////////////////
8166   // Silicon Mixture for Sensor
8167   /////////////////////////////////// 
8168   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8169   fSSDChipGlueMedium = GetMedium("EPOXY$");
8170   ///////////////////////////////////
8171   // Stiffener Components Materials
8172   /////////////////////////////////// 
8173   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8174   ///////////////////////////  
8175   // Stiffener Connectors 
8176   ///////////////////////////  
8177   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8178   ////////////////////////////////  
8179   // Stiffener 0603-1812 Capacitor
8180   ////////////////////////////////  
8181   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8182   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8183   fSSDStiffenerCapacitorCapMedium = GetMedium("NiSn$");
8184   ///////////////////////////  
8185   // Stiffener Hybrid Wire 
8186   ///////////////////////////  
8187   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8188   ///////////////////////////  
8189   // Al for Cooling Block
8190   ///////////////////////////  
8191   fSSDAlCoolBlockMedium = GetMedium("AL$");
8192   //////////////////////////////////////////////////////  
8193   // Kapton and Al for Chip Cable Flex and Ladder Cables
8194   //////////////////////////////////////////////////////  
8195   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8196   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8197   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8198   fSSDAlTraceFlexMedium = GetMedium("AL$");
8199   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8200   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8201   /////////////////////////////////////////////////////////////////  
8202   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8203   //////////////////////////////////////////////////////////////////  
8204   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8205   /////////////////////////////////////////////////////////////////  
8206   // G10 for Detector Leg, TubeHolder
8207   //////////////////////////////////////////////////////////////////  
8208   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8209   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8210   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8211   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8212   /////////////////////////////////////////////////////////////////  
8213   // Water and Phynox for Cooling Tube
8214   //////////////////////////////////////////////////////////////////  
8215   fSSDCoolingTubeWater = GetMedium("WATER$");
8216   fSSDCoolingTubePhynox = GetMedium("INOX$");
8217   /////////////////////////////////////////////////////////////////////
8218   // Material for Support Rings
8219   /////////////////////////////////////////////////////////////////////
8220   fSSDSupportRingAl = GetMedium("AL$");
8221   fSSDRohaCellCone = GetMedium("ROHACELL$");
8222   /////////////////////////////////////////////////////////////////////
8223   fSSDAir = GetMedium("SDD AIR$");
8224   fSSDCopper = GetMedium("COPPER$");
8225   fSSDSn = GetMedium("Sn$");
8226   fCreateMaterials = kTRUE;
8227 }
8228 /////////////////////////////////////////////////////////////////////
8229