]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Fixes for Coverity warnings - M. van Leeuwen
[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::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "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 = 625.0*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
500 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
501 /////////////////////////////////////////////////////////////////////////////////
502 // SSD Cone Parameters (lengths are in mm and angles in degrees)
503 /////////////////////////////////////////////////////////////////////////////////
504 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
509 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
526 /////////////////////////////////////////////////////////////////////////////////
527 // SSD Cables Parameters (lengths are in mm and angles in degrees)
528 /////////////////////////////////////////////////////////////////////////////////
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
533 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
536 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
541 const Double_t AliITSv11GeometrySSD::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
617   for (Int_t i=0; i < fgkcarbonfibersupportnumber; i++) {
618     fcarbonfibersupport[i] = 0;
619     fcarbonfibersupportmatrix[i] = 0;
620   }
621   for (Int_t i=0; i < fgkcarbonfiberjunctionumber; i++) {
622     fcarbonfiberjunctionmatrix[i] = 0;
623   }
624   for (Int_t i=0; i < fgkcarbonfiberlowersupportnumber; i++) {
625     fcarbonfiberlowersupport[i] = 0;
626     fcarbonfiberlowersupportrans[0] = 0;
627   }
628   for (Int_t i=0; i < fgkvolumekind; i++) {
629     fssdsensorsupport[i] = 0;
630   }
631   for (Int_t i=0; i < fgkssdsensorsupportnumber; i++) {
632     fssdsensorsupportmatrix[i] = 0;
633   }
634   for (Int_t i=0; i < fgkcoolingtubesupportnumber; i++) {
635     fcoolingtubesupportmatrix[i] = 0;
636   }
637   for (Int_t i=0; i < fgkhybridcompnumber; i++) {
638     fssdhybridcomponent[i] = 0;
639   }
640   for (Int_t i=0; i < fgkcoolingblocknumber; i++) {
641     fcoolingblockmatrix[i] = 0;
642   }
643   for (Int_t i=0; i < fgkflexnumber; i++) {
644     fstiffenerflexmatrix[i] = 0;
645     fendflexmatrix[i] = 0;
646   }
647   for (Int_t i=0; i < fgkendladdercoolingtubenumber; i++) {
648     fendladdercoolingtube[i] = 0;
649     for (Int_t j = 0; j < 2; j++) 
650       fendladdercoolingtubematrix[i][j] = 0;
651   }
652   for (Int_t i=0; i < fgkendlabbercarbonfiberjunctionumber; i++) {
653     fendladdercarbonfiberjunction[i] = 0;
654   }
655   for (Int_t i=0; i < fgkendladdercabonfiberjunctionmatrixnumber; i++) {
656     fendladdercarbonfiberjunctionmatrix[i] = 0;
657   }
658   for (Int_t i=0; i < fgkendladdercarbonfibermatrixnumber; i++) {
659     fendladdercarbonfibermatrix[i] = 0;
660   }
661   for (Int_t i=0; i < fgkendladdermountingblocknumber; i++) {
662     fendladdermountingblockclipmatrix[i] = 0;
663   }
664   for (Int_t i = 0; i < fgkendladderlowersuppnumber+1; i++) {
665     fendladderlowersupptrans[i] = 0;
666   }
667   for (Int_t i = 0; i < fgkladdercablesnumber; i++) {
668     fladdercablematrix[i] = 0;
669   }
670   for (Int_t i = 0; i < fgkladdersegmentnumber; i++) {
671     fladdersegment[i] = 0;
672   }
673   for (Int_t i = 0; i < fgkladdernumber; i++) {
674     fladder[i] = 0;
675     fladdermatrix[i] = 0;
676     fssdsensormatrix[i] = 0;
677     flayermatrix[i] = 0;
678   }
679   for (Int_t i = 0; i < 2; i++) {
680     fLay5LadderSupport[i] = 0;
681     fLay6LadderSupport[i] = 0;
682   }
683 }
684 /////////////////////////////////////////////////////////////////////////////////
685 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
686   AliITSv11Geometry(s.GetDebug()),
687   fSSDChipMedium(s.fSSDChipMedium),
688   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
689   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
690   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
691   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
692   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
693   fSSDStiffenerCapacitorCapMedium(s.fSSDStiffenerCapacitorCapMedium),
694   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
695   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
696   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
697   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
698   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
699   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
700   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
701   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
702   fSSDSensorMedium(s.fSSDSensorMedium),
703   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
704   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
705   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
706   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
707   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
708   fSSDSupportRingAl(s.fSSDSupportRingAl),
709   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
710   fSSDRohaCellCone(s.fSSDRohaCellCone),
711   fSSDAir(s.fSSDAir),
712   fSSDCopper(s.fSSDCopper),  
713   fSSDSn(s.fSSDSn),
714   fCreateMaterials(s.fCreateMaterials),
715   fTransformationMatrices(s.fTransformationMatrices),
716   fBasicObjects(s.fBasicObjects),
717   fcarbonfiberjunction(s.fcarbonfiberjunction),
718   fcoolingtubesupport(s.fcoolingtubesupport),
719   fhybridmatrix(s.fhybridmatrix),
720   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
721   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
722   fssdstiffenerflex(s.fssdstiffenerflex),
723   fssdendflex(s.fssdendflex),
724   fcoolingtube(s.fcoolingtube),
725   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
726   fendladdermountingblock(s.fendladdermountingblock),
727   fendladdermountingblockclip(s.fendladdermountingblockclip),
728   fSSDSensor5(s.fSSDSensor5),
729   fSSDSensor6(s.fSSDSensor6),
730   fSSDLayer5(s.fSSDLayer5),     
731   fSSDLayer6(s.fSSDLayer6),
732   fMotherVol(s.fMotherVol),
733   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
734   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
735   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
736   fSSDCone(s.fSSDCone),
737   fColorCarbonFiber(s.fColorCarbonFiber),
738   fColorRyton(s.fColorRyton),
739   fColorPhynox(s.fColorPhynox),
740   fColorSilicon(s.fColorSilicon),
741   fColorAl(s.fColorAl),
742   fColorNiSn(s.fColorNiSn),
743   fColorKapton(s.fColorKapton),
744   fColorPolyhamide(s.fColorPolyhamide),
745   fColorStiffener(s.fColorStiffener),
746   fColorEpoxy(s.fColorEpoxy),
747   fColorWater(s.fColorWater),
748   fColorG10(s.fColorG10)
749 {
750   ////////////////////////
751   // Copy Constructor
752   ////////////////////////
753 }
754 /////////////////////////////////////////////////////////////////////////////////
755 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
756 operator=(const AliITSv11GeometrySSD &s){
757   ////////////////////////
758   // Assignment operator
759   ////////////////////////
760   this->~AliITSv11GeometrySSD();
761   new(this) AliITSv11GeometrySSD(s); 
762   return *this;
763 /*      
764   if(&s == this) return *this;
765   fMotherVol = s.fMotherVol;
766   return *this;
767  */
768 }
769 ///////////////////////////////////////////////////////////////////////////////
770 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
771   ///////////////////////////////////////////////////////////////////////  
772   // Method generating the trasformation matrix for the whole SSD Geometry   
773   ///////////////////////////////////////////////////////////////////////  
774   // Setting some variables for Carbon Fiber Supportmatrix creation
775   //////////////////////////////////////////////////////////////////////
776   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
777                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
778   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
779                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
780                                                                  +      fgkCarbonFiberSupportWidth);
781   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
782                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
783   TGeoRotation* carbonfiberot[3];
784   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
785   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
786   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
787   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
788   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
789                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
790                                                   -  fgkCarbonFiberTriangleLength
791                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
792   ///////////////////////////////////////////
793   //Setting Local Translations and Rotations: 
794   ///////////////////////////////////////////
795   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
796   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
797                                                                          0.5*carbonfibersupportheight,NULL);    
798   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
799                                                                          2.*symmetryplaneposition+transvector[1],
800                                                                          transvector[2], carbonfiberot[2]);
801   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
802   /////////////////////////////////////////////////////////////
803   // Carbon Fiber Support Transformations
804   /////////////////////////////////////////////////////////////
805   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
806   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
807                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
808                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
809                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
810   }             
811   /////////////////////////////////////////////////////////////
812   // Carbon Fiber Junction Transformation
813   /////////////////////////////////////////////////////////////
814   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
815   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
816   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
817   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
818   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
819         localcarbonfiberjunctionmatrix[i] = 
820                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
821         localcarbonfiberjunctionrot[i] = 
822                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
823         localcarbonfiberjunctiontrans[i] = 
824                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
825   }
826   ///////////////////////
827   // Setting Translations
828   ///////////////////////
829   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
830   localcarbonfiberjunctiontrans[1][0] = 
831                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
832   localcarbonfiberjunctiontrans[2][0] = 
833                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
834                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
835                                  fgkCarbonFiberTriangleLength
836                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
837   localcarbonfiberjunctiontrans[0][1] = 
838                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
839   localcarbonfiberjunctiontrans[1][1] = 
840                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
841   localcarbonfiberjunctiontrans[2][1] = 
842                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
843   ////////////////////
844   // Setting Rotations
845   ////////////////////
846   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
847                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
848                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
849   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
850         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
851   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
852   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
853   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
854   ////////////////////////////////////////
855   // Setting Carbon Fiber Junction matrix 
856   ////////////////////////////////////////
857   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
858                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
859                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
860                         localcarbonfiberjunctionmatrix[i][j] = 
861                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
862                                                            *localcarbonfiberjunctionrot[i][j]);
863                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
864          }
865   }
866   /////////////////////////////////////////////////////////////
867   // Carbon Fiber Lower Support Transformations
868   /////////////////////////////////////////////////////////////
869   TGeoTranslation* localcarbonfiberlowersupportrans[2];
870   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
871                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
872                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
873                                                                          0.0);
874   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
875                                                                          fgkCarbonFiberJunctionWidth
876                                                                 -    fgkCarbonFiberLowerSupportWidth
877                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
878                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
879                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
880    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
881    fcarbonfiberlowersupportrans[0] = 
882                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
883    fcarbonfiberlowersupportrans[1] = 
884                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
885   /////////////////////////////////////////////////////////////
886   // SSD Sensor Support Transformations
887   /////////////////////////////////////////////////////////////
888   const Int_t kssdsensorsupportmatrixnumber = 3;
889   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
890   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
891   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
892   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
893         localssdsensorsupportmatrix[i] = 
894                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
895         localssdsensorsupportrot[i] = 
896                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
897         localssdsensorsupportrans[i] = 
898                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
899   }
900   ///////////////////////
901   // Setting Translations
902   ///////////////////////
903   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
904                                                                           0.5*fgkSSDSensorSideSupportWidth,
905                                                                           0.0);
906   localssdsensorsupportrans[1][0] = 
907                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
908   localssdsensorsupportrans[2][0] = 
909                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
910   localssdsensorsupportrans[0][1] = 
911                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
912                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
913                                                                                 0.0);
914   localssdsensorsupportrans[1][1] = 
915                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
916                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
917                                                                     -   fgkSSDModuleSensorSupportDistance,
918                                                                                 0.0);
919   localssdsensorsupportrans[2][1] = 
920                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
921                                                                         -    fgkSSDSensorCenterSupportPosition,
922                                                                                  0.5*fgkSSDSensorCenterSupportWidth
923                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
924                                                                                  fgkSSDSensorCenterSupportThickness[0]);
925   localssdsensorsupportrans[0][2] = 
926                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
927                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
928                                                                                  fgkCarbonFiberJunctionWidth
929                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
930                                                                         +    fgkSSDSensorCenterSupportLength
931                                                                         -    fgkSSDSensorCenterSupportThickness[0])
932                                                                         -    fgkSSDSensorCenterSupportPosition,
933                                                                              0.0);
934   localssdsensorsupportrans[1][2] = 
935                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
936   localssdsensorsupportrans[2][2] = 
937                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
938   ////////////////////
939   // Setting Rotations
940   ////////////////////
941   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
942                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
943                         localssdsensorsupportrot[i][j] = new TGeoRotation();
944   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
945         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
946         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
947   }
948   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
949   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
950   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
951   ////////////////////////////////////////
952   // SSD Sensor Support matrix 
953   ////////////////////////////////////////
954   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
955                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
956                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
957                         localssdsensorsupportmatrix[i][j] = 
958                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
959                                                            *localssdsensorsupportrot[i][j]);
960                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
961          }
962   }
963   /////////////////////////////////////////////////////////////
964   // SSD Cooling Tube Support Transformations
965   /////////////////////////////////////////////////////////////
966   const Int_t kcoolingtubesupportmatrixnumber = 2;
967   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
968   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
969   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
970   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
971                                                                                                         /fgkCoolingTubeSupportRmax);
972   localcoolingtubesupportrans[0] = 
973                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
974                                                 +  2.*(fgkCoolingTubeSupportLength
975                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
976                                                 +  fgkCarbonFiberTriangleLength
977                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
978   localcoolingtubesupportrans[1] = 
979                         new TGeoTranslation(fgkCarbonFiberJunctionLength
980                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
981                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
982                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
983                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
984                     -  0.5*(fgkCarbonFiberLowerSupportWidth
985                                         +          fgkSSDSensorCenterSupportLength
986                     -      fgkSSDSensorCenterSupportThickness[0])
987                                         +  0.5*fgkSSDSensorLength,
988                                         -  0.5*fgkCoolingTubeSupportHeight);  
989   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
990   localcoolingtubesupportrot[i] = new TGeoRotation();
991   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
992   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
993   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
994         localcoolingtubesupportmatrix[i] = 
995                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
996                                                    *localcoolingtubesupportrot[i]);
997   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
998   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
999                                                                 (*localcoolingtubesupportmatrix[0]));
1000   /////////////////////////////////////////////////////////////
1001   // End Ladder SSD Cooling Tube Support Transformations
1002   /////////////////////////////////////////////////////////////
1003   TGeoTranslation** localendladdercooltubetrans[2];
1004   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
1005   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
1006   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
1007   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
1008                                                                                         -          (fgkCoolingTubeSupportLength
1009                                                                                         -               fgkCoolingTubeSupportRmax),
1010                                                                                                         fgkEndLadderMountingBlockPosition[0]
1011                                                                                         -               fgkendladdercoolingsupportdistance[0]
1012                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
1013                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1014   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
1015                                                                                         -          (fgkCoolingTubeSupportLength
1016                                                                                         -               fgkCoolingTubeSupportRmax),
1017                                                                                                         fgkEndLadderMountingBlockPosition[0]
1018                                                                                         +               fgkendladdercoolingsupportdistance[1]
1019                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
1020                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1021   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
1022                                                                                         -       fgkCoolingTubeSupportRmax)
1023                                                                                         +               fgkCarbonFiberTriangleLength
1024                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
1025                                                                                                 0.0,
1026                                                                                                 0.0);
1027   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
1028                                                                                                         fgkendladdercoolingsupportdistance[0]
1029                                                                                         +               fgkendladdercoolingsupportdistance[1],
1030                                                                                                         0.0);
1031   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
1032   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
1033                                                                                         +               fgkCarbonFiberJunctionLength
1034                                                                                         -               fgkCoolingTubeSupportLength,
1035                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
1036                                                                                         -       0.5*fgkCoolingTubeSupportWidth
1037                                                                                                    -fgkendladdercoolingsupportdistance[2],
1038                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1039   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
1040                                                                                         +               fgkCoolingTubeSupportLength
1041                                                                                         -               fgkCoolingTubeSupportRmax
1042                                                                                         -               fgkCarbonFiberJunctionLength,
1043                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
1044                                                                                         -       0.5*fgkCoolingTubeSupportWidth
1045                                                                                         -               fgkendladdercoolingsupportdistance[2],
1046                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1047   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
1048   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
1049   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
1050   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
1051   (*localcoolingtubesupportrot[1]));
1052   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
1053   (*localcoolingtubesupportrot[1]));
1054   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
1055   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
1056   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
1057   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
1058   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
1059
1060   fendladdercoolingtubesupportmatrix[1][0] =    
1061                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
1062                                                                                    *(*localcoolingtubesupportrot[1]));
1063   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
1064   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
1065   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
1066   /////////////////////////////////////////////////////////////
1067   // SSD Cooling Tube Transformations
1068   /////////////////////////////////////////////////////////////
1069   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
1070   localcoolingtuberot->SetAngles(0.,90.,0.);
1071   TGeoTranslation* localcoolingtubetrans[2];
1072   TVector3* localcoolingtubevect[2];
1073
1074   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1075                                                   -fgkCarbonFiberTriangleLength),
1076                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
1077                                             - fgkCarbonFiberLowerSupportWidth 
1078                                             - fgkLowerSupportToSensorZ ,
1079                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1080   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
1081                                               localcoolingtubevect[0]->Y(),
1082                                               localcoolingtubevect[0]->Z());
1083   for(Int_t j=0; j<2; j++){
1084     localcoolingtubetrans[j] = 
1085         new TGeoTranslation(localcoolingtubevect[j]->X(),
1086                             localcoolingtubevect[j]->Y(),
1087                             localcoolingtubevect[j]->Z());
1088      fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
1089                                              *(*localcoolingtuberot));
1090   }
1091   /////////////////////////////////////////////////////////////
1092   // SSD End Ladder Cooling Tube Transformations
1093   /////////////////////////////////////////////////////////////
1094   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1095   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1096   TGeoTranslation** localendlladdercoolingtubetrans[2];
1097   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
1098   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
1099   for(Int_t i=0; i<2; i++)      
1100         for(Int_t j=0; j<2; j++)        
1101                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1102
1103   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
1104   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1105                                                                         -        fgkCoolingTubeSupportRmax)
1106                                                                         +        fgkCarbonFiberJunctionLength,
1107                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1108                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1109   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1110                                                                         -        fgkCoolingTubeSupportRmax)
1111                                                                         -        fgkCarbonFiberJunctionLength
1112                                                                         +    fgkCarbonFiberTriangleLength,
1113                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1114                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1115
1116   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1117                                                           -   fgkCoolingTubeSupportRmax)
1118                                                         +       fgkCarbonFiberJunctionLength,
1119                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1120                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1121   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1122                                                   -      fgkCoolingTubeSupportRmax)
1123                                                   -      fgkCarbonFiberJunctionLength
1124                                                   +    fgkCarbonFiberTriangleLength,
1125                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1126                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1127   for(Int_t i=0; i<2; i++)
1128         for(Int_t j=0; j<2; j++){
1129                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1130                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1131         }
1132   /////////////////////////////////////////////////////////////
1133   // SSD Hybrid Components Transformations
1134   /////////////////////////////////////////////////////////////
1135   const Int_t khybridmatrixnumber = 3;
1136   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1137   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1138                                             0.5*fgkSSDStiffenerWidth,
1139                                             0.5*fgkSSDStiffenerHeight);
1140   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1141                                             fgkSSDModuleStiffenerPosition[1],0.0);
1142
1143   localhybridtrans[2] = new TGeoTranslation(
1144                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1145                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1146                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1147                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1148                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1149                       -       fgkSSDSensorCenterSupportThickness[0]),
1150                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1151                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1152                                           -       fgkSSDModuleVerticalDisalignment)); 
1153   fhybridmatrix = new TGeoHMatrix();
1154   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1155   /////////////////////////////////////////////////////////////
1156   // SSD Cooling Block Transformations
1157   /////////////////////////////////////////////////////////////
1158   TGeoTranslation localcoolingblocktrans (fcoolingtubematrix[0]->GetTranslation()[0] 
1159                                           - 0.5*fgkSSDCoolingBlockLength,
1160                                           fhybridmatrix->GetTranslation()[1]-0.5*fgkSSDStiffenerWidth,
1161                                           fhybridmatrix->GetTranslation()[2]+0.5*fgkSSDStiffenerHeight+
1162                                           0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1163   fcoolingblocksystematrix = new TGeoHMatrix(localcoolingblocktrans);
1164   /////////////////////////////////////////////////////////////
1165   // SSD Stiffener Flex Transformations
1166   /////////////////////////////////////////////////////////////
1167   const Int_t klocalflexmatrixnumber = 4;
1168   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1169   for(Int_t i=0; i<fgkflexnumber; i++)    
1170       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1171   for(Int_t i=0; i<fgkflexnumber; i++)
1172       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1173             localflexmatrix[i][j] = new TGeoCombiTrans();
1174   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1175                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1176                                                                   -    fgkSSDStiffenerWidth;
1177   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1178                                         +0.5*fgkSSDStiffenerLength,
1179                                          0.5*fgkSSDStiffenerWidth,
1180                                         -0.5*fgkSSDStiffenerHeight
1181                                         -0.5*fgkSSDFlexHeight[0]);
1182   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1183                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1184                                         -0.5*fgkSSDStiffenerWidth,
1185                                         -0.5*fgkSSDStiffenerHeight
1186                                         -0.5*fgkSSDFlexHeight[0]);
1187   TGeoRotation* localflexrot = new TGeoRotation();
1188   localflexrot->SetAngles(180.,0.,0.);    
1189   localflexmatrix[1][0]->SetRotation(localflexrot);
1190   for(Int_t i=0; i<fgkflexnumber; i++)
1191       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1192             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1193   for(Int_t i=0; i<fgkflexnumber; i++){
1194       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1195       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1196             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1197   }
1198   /////////////////////////////////////////////////////////////
1199   // SSD End Flex Transformations
1200   /////////////////////////////////////////////////////////////
1201   TGeoRotation* localendflexrot = new TGeoRotation();
1202   localendflexrot->SetAngles(0.0,90.0,0.0);
1203   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1204   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1205                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1206   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1207                             * TMath::DegToRad()*ssdflexradiusmax
1208                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1209                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1210                                                                                    - 0.1*fgkSSDFlexFullLength;
1211   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1212                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1213                             +      fgkSSDFlexLength[2];
1214   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1215                               0.5*fgkSSDFlexWidth[0],
1216                               2.*fgkSSDStiffenerHeight
1217                             + 0.5*fgkSSDFlexHeight[0]);      
1218   localendflexmatrix->SetRotation(localendflexrot);
1219   for(Int_t i=0; i<fgkflexnumber; i++) 
1220       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1221   /////////////////////////////////////////////////////////////
1222   // End Ladder Carbon Fiber Junction
1223   /////////////////////////////////////////////////////////////
1224   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1225   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1226   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1227   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1228       localendladdercarbonfiberjunctionmatrix[i] 
1229             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1230       localendladdercarbonfiberjunctionrot[i] 
1231             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1232       localendladdercarbonfiberjunctiontrans[i] 
1233             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1234       fendladdercarbonfiberjunctionmatrix[i]
1235             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1236   }
1237   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1238       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1239             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1240             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1241       }
1242   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1243       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1244           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1245   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1246       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1247                               0.0,0.0);
1248       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1249                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1250                 *                     SinD(fgkCarbonFiberTriangleAngle),
1251                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1252   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1253   }
1254   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1255   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1256   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1257   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1258       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1259       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1260       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1261       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1262             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1263       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1264             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1265                                *localendladdercarbonfiberjunctionglobalrot[i]);
1266   }
1267   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1268       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1269             localendladdercarbonfiberjunctionmatrix[i][j] = 
1270                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1271                                      *localendladdercarbonfiberjunctionrot[i][j]);
1272            fendladdercarbonfiberjunctionmatrix[i][j] =
1273             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1274             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1275       }  
1276   /////////////////////////////////////////////////////////////
1277   // End Ladder Carbon Fiber Support
1278   /////////////////////////////////////////////////////////////
1279   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1280   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1281       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1282       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1283             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1284       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1285   }
1286   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1287       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1288             fendladdercarbonfibermatrix[i][j] = 
1289             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1290             *(*fcarbonfibersupportmatrix[j]));
1291   /////////////////////////////////////////////////////////////
1292   // End Ladder SSD Mounting Block
1293   /////////////////////////////////////////////////////////////
1294   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1295       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1296   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1297       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1298                                 +        fgkSSDMountingBlockLength[1])
1299                                 +  0.5*fgkCarbonFiberTriangleLength,
1300                                 fgkEndLadderMountingBlockPosition[i],
1301                                 -  fgkSSDMountingBlockHeight[1]
1302                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1303   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1304   endladdermountingblockrot->SetAngles(0.,90.,0.);
1305   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1306         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1307   /////////////////////////////////////////////////////////////
1308   // End Ladder SSD Mounting Block Clip Matrix 
1309   /////////////////////////////////////////////////////////////
1310   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1311         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1312   
1313   TGeoRotation* localendladdercliprot = new TGeoRotation();
1314   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1315   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1316                                                                                   -     fgkSSDMountingBlockLength[1])
1317                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1318   localendladdercliprot->SetAngles(90.,180.,-90.);
1319   TGeoCombiTrans* localendladderclipcombitrans = 
1320                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1321   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1322         for(Int_t j=0; j<2; j++){
1323                 fendladdermountingblockclipmatrix[i][j] = 
1324                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1325                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1326         }
1327   /////////////////////////////////////////////////////////////
1328   // End Ladder Carbon Fiber Lower Support
1329   /////////////////////////////////////////////////////////////
1330   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1331       fendladderlowersupptrans[i] = 
1332             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1333                         +  0.5*fgkSSDMountingBlockWidth),
1334                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1335   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1336                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1337                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1338                                                                          0.0);
1339   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1340  /////////////////////////////////////////////////////////////
1341   // Matrix for positioning Ladder into mother volume
1342   /////////////////////////////////////////////////////////////
1343   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1344   for(Int_t i=0; i<fgkladdernumber; i++) 
1345         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1346   TGeoRotation* localladdermotherrot = new TGeoRotation();
1347   localladdermotherrot->SetAngles(0.,90.,0.);  
1348   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1349   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1350   for(Int_t i=0; i<fgkladdernumber; i++){
1351         localladdermothertrans[i] = new TGeoTranslation(0.,
1352                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1353                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1354                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1355                                                           * fgkCarbonFiberJunctionWidth,0.);
1356         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1357                                                                                                                 *localladdermotherrot);
1358         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1359         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1360   }
1361   /////////////////////////////////////////////////////////////
1362   // Ladder Cables Matrices
1363   /////////////////////////////////////////////////////////////
1364   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1365                                              + fgkSSDFlexHeight[1];  
1366   Double_t ssdladdercabletransx[3];
1367   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1368                                                   *   SinD(2.*fgkSSDFlexAngle)
1369                                                   *       CosD(2.*fgkSSDFlexAngle);
1370   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1371                                                   -     ssdladdercabletransx[0]
1372                                                   /     SinD(2.*fgkSSDFlexAngle))
1373                                                   *     CosD(fgkSSDFlexAngle);                                          
1374   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1375                                                   *       TMath::DegToRad()*ssdflexradiusmax
1376                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1377                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1378                                                   -       fgkSSDLadderCableWidth)
1379                                                   *       CosD(2.*fgkSSDFlexAngle);
1380   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1381                                                   *     TanD(2.*fgkSSDFlexAngle),
1382                                                         ssdladdercabletransx[1]
1383                                                   *     TanD(fgkSSDFlexAngle),
1384                                                         ssdladdercabletransx[2]
1385                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1386   TGeoRotation* localladdercablerot[3]; 
1387   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1388   localladdercablerot[0]->SetAngles(90.,0.,0.);
1389   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1390   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1391                                                  *                        (*localladdercablerot[0]));
1392   //TGeoRotation* localladdercablerot = new TGeoRotation();     
1393   //localladdercablerot->SetAngles(90.,0.,0.);
1394   ////////////////////////////////////////////
1395   // LocalLadderCableCombiTransMatrix
1396   ////////////////////////////////////////////
1397   const Int_t klocalladdersidecablesnumber = 2;
1398   const Int_t klocalladdercombitransnumber = 5;
1399   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1400   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1401          localladdercablecombitransmatrix[i] = 
1402                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1403   ///////////////////////////////////////////
1404   // Left Side Ladder Cables Transformations
1405   ///////////////////////////////////////////
1406   localladdercablecombitransmatrix[0][0]  =
1407                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1408                                                 0.,0.,NULL);
1409   localladdercablecombitransmatrix[0][1] = 
1410         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1411                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1412                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1413                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1414                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1415                                            + fgkSSDSensorCenterSupportLength
1416                                            - fgkSSDSensorCenterSupportThickness[0]),
1417                                            - (fgkSSDModuleCoolingBlockToSensor
1418                                            + 0.5*fgkCoolingTubeSupportHeight
1419                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1420                                            - fgkSSDChipHeight),NULL);
1421   localladdercablecombitransmatrix[0][2] = 
1422                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1423                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1424   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1425                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1426                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1427                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1428                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1429                                                                                                 new TGeoRotation("",180.,0.,0.));
1430   localladdercablecombitransmatrix[0][4] = 
1431                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1432                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1433                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1434                                                           0.,
1435                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1436                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1437                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1438                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1439   ///////////////////////////////////////////
1440   // Rigth Side Ladder Cables Transformations
1441   ///////////////////////////////////////////
1442   TGeoCombiTrans* localladdercablessdmodulematrix = 
1443         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1444                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1445                                                                          fgkSSDStiffenerWidth,
1446                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1447   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1448    localladdercablecombitransmatrix[1][i] = 
1449                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1450                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1451   ///////////////////////////////////////////
1452   // Setting LadderCableHMatrix
1453   ///////////////////////////////////////////
1454   Int_t beamaxistrans[2][3];
1455   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1456   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1457   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1458   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1459   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1460   beamaxistrans[1][2] = beamaxistrans[1][0];
1461   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1462   TGeoRotation* laddercablerot = new TGeoRotation();
1463   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1464   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1465   Double_t* laddercabletransvector;     
1466   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1467         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1468         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1469   }
1470   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1471         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1472                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1473                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1474                         localladdercablehmatrix[i][j]->MultiplyLeft(
1475                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1476         }
1477                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1478                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1479                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1480                                                                          laddercabletransvector[1]
1481                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1482                                         *                                fgkCarbonFiberJunctionWidth,
1483                                                                          laddercabletransvector[2]);
1484                 laddercablecombitrans->SetRotation(*laddercablerot);
1485                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1486                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1487         }
1488     fladdercablematrix[i][2] = 
1489                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1490                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1491         fladdercablematrix[i][3] = 
1492                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1493                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1494   }
1495   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1496     for(Int_t j=0; j<klocalladdercombitransnumber-1; j++) 
1497       fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1498   
1499   ///////////////////////////////////////////
1500   // Setting Ladder HMatrix
1501   ///////////////////////////////////////////
1502   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1503                                                                                                 fgkSSDLay6SensorsNumber};
1504   for(Int_t i=0; i<fgkladdernumber; i++){
1505         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1506         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1507                 fladdermatrix[i][j] = new TGeoHMatrix();
1508                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1509                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1510                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1511         }
1512   }
1513   ///////////////////////////////////////////
1514   // Setting SSD Sensor Matrix 
1515   ///////////////////////////////////////////
1516   TGeoCombiTrans* localssdsensorcombitrans[2];
1517   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1518   localssdsensorrot->SetAngles(0.,90.,0.);      
1519   TGeoTranslation* localssdsensortrans[2];
1520   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1521   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1522                                          fgkCarbonFiberJunctionWidth 
1523                                          - fgkCarbonFiberLowerSupportWidth 
1524                                          - fgkLowerSupportToSensorZ,
1525                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1526                                           -             fgkSSDModuleCoolingBlockToSensor
1527                                           +    (fgkSSDSensorSideSupportHeight[1]
1528                                           -             fgkSSDSensorSideSupportHeight[0]));
1529   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1530                                          fgkCarbonFiberJunctionWidth 
1531                                          - fgkCarbonFiberLowerSupportWidth 
1532                                          - fgkLowerSupportToSensorZ,
1533                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1534                                                         -fgkSSDModuleCoolingBlockToSensor);
1535
1536   for(Int_t i=0; i<2; i++) 
1537         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1538                                                                                                          *localssdsensorrot);   
1539     for(Int_t i=0; i<fgkladdernumber; i++){
1540         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1541         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1542                 switch(i){
1543                         case 0: //Ladder of Layer5  
1544                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1545                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1546                                                                                                 *localssdsensorcombitrans[1])));
1547                         break;
1548                         case 1: //Ladder of Layer6 
1549                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1550                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1551                                                                                                 *localssdsensorcombitrans[0])));
1552                 break;
1553                 }
1554           }
1555   }     
1556   //////////////////////////
1557   // Setting SSD End Ladder  
1558   //////////////////////////
1559   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1560   for(Int_t i=0; i<2; i++){
1561         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1562         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1563         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1564         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1565         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1566         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1567         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1568         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1569    }
1570   /////////////////////////////////////////////////////
1571   // Setting the CombiTransformation to pass ITS center 
1572   /////////////////////////////////////////////////////
1573   Double_t itscentertransz[fgklayernumber];
1574   itscentertransz[0] = fgkSSDLay5LadderLength
1575                                          - fgkLay5CenterITSPosition;
1576   itscentertransz[1] = fgkSSDLay6LadderLength
1577                                          - fgkLay6CenterITSPosition;
1578   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1579                                                    + 0.5*fgkCoolingTubeSupportHeight;
1580   TGeoRotation* itscenterrot[3];
1581   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1582   itscenterrot[0]->SetAngles(90.,180.,-90.);
1583   itscenterrot[1]->SetAngles(0.,90.,0.);
1584   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1585   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1586   for(Int_t i=0; i<fgklayernumber; i++) 
1587         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1588                                                          itssensortransy,
1589                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1590                                                    - itscentertransz[i],itscenterrot[2]);
1591   TGeoRotation** locallayerrot[fgklayernumber];
1592   TGeoTranslation** locallayertrans[fgklayernumber];    
1593   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1594   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1595   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1596                                          - fgkLay5CenterITSPosition);
1597   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1598                                          - fgkLay6CenterITSPosition);
1599   const Int_t kssdlayladdernumber[fgklayernumber] = 
1600                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1601   for(Int_t i=0; i<fgklayernumber; i++){
1602     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1603     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1604         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1605         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1606   }
1607   Double_t layerladderangleposition[fgklayernumber] = 
1608                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1609   Double_t layerradius = 0.;
1610   for(Int_t i=0; i<fgklayernumber; i++){        
1611         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1612                 switch(i){
1613                         case 0: //Ladder of Layer5  
1614                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1615                         break;
1616                         case 1: //Ladder of Layer6 
1617                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1618                 break;
1619                 }
1620                 locallayerrot[i][j] = new TGeoRotation();
1621                 locallayertrans[i][j] = new TGeoTranslation();
1622                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1623                 locallayertrans[i][j]->SetTranslation(layerradius 
1624                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1625                                                             layerradius 
1626                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1627                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1628                                                                          *locallayerrot[i][j]);
1629                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1630                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1631                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1632         }
1633   }
1634   /////////////////////////////////////////////////////////////
1635   // Deallocating memory
1636   /////////////////////////////////////////////////////////////
1637   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1638         delete carbonfiberot[i];
1639         delete localcarbonfibersupportmatrix[i];
1640   }
1641   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1642      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1643        delete localcarbonfiberjunctionmatrix[i][j];
1644            delete localcarbonfiberjunctionrot[i][j];
1645            delete localcarbonfiberjunctiontrans[i][j];
1646            }
1647        delete [] localcarbonfiberjunctionmatrix[i];
1648        delete [] localcarbonfiberjunctionrot[i];
1649        delete [] localcarbonfiberjunctiontrans[i];
1650   }
1651   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1652            delete localcarbonfiberlowersupportrans[i];
1653   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1654      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1655        delete localssdsensorsupportmatrix[i][j];
1656            delete localssdsensorsupportrot[i][j];
1657            delete localssdsensorsupportrans[i][j];
1658            }
1659        delete [] localssdsensorsupportmatrix[i];
1660        delete [] localssdsensorsupportrot[i];
1661        delete [] localssdsensorsupportrans[i];
1662   }
1663   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1664         delete localcoolingtubesupportmatrix[i];
1665         delete localcoolingtubesupportrot[i];
1666         delete localcoolingtubesupportrans[i];
1667   }
1668   for(Int_t j=0; j<2; j++){
1669     delete localcoolingtubevect[j];
1670     delete localcoolingtubetrans[j];
1671   }
1672  delete endladdermountingblockrot;
1673  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1674  for(Int_t i=0; i<fgkflexnumber; i++){
1675       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1676             delete localflexmatrix[i][j];
1677       delete [] localflexmatrix[i];
1678  }
1679  delete localendlladdercoolingtuberot;
1680  for(Int_t i=0; i<2; i++){
1681         for(Int_t j=0; j<2; j++)
1682           delete localendlladdercoolingtubetrans[i][j];
1683         delete [] localendlladdercoolingtubetrans[i];
1684   }
1685
1686  delete localflexrot;
1687  delete localendflexrot;
1688  delete localendflexmatrix;
1689  for(Int_t i=0; i<fgkladdernumber; i++){ 
1690         delete localladdermothertrans[i];
1691         delete localladdermothercombitrans[i];
1692   }
1693  delete localladdermotherrot;
1694  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1695       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1696             delete localendladdercarbonfiberjunctionmatrix[i][j];
1697             delete localendladdercarbonfiberjunctionrot[i][j];
1698             delete localendladdercarbonfiberjunctiontrans[i][j];
1699       }
1700       delete [] localendladdercarbonfiberjunctionmatrix[i];
1701       delete [] localendladdercarbonfiberjunctionrot[i];
1702       delete [] localendladdercarbonfiberjunctiontrans[i];
1703       delete localendladdercarbonfiberjunctionglobalrot[i];
1704       delete localendladdercarbonfiberjunctionglobaltrans[i];
1705       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1706  }
1707   for(Int_t i=0; i<2; i++){
1708         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1709         delete [] localendladdercooltubetrans[i];
1710   }
1711   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1712       delete localendladdercarbonfibertrans[i];
1713   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1714   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1715         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1716                 delete localladdercablecombitransmatrix[i][j];
1717                 delete []localladdercablecombitransmatrix[i];
1718   }
1719   delete localendladdercliprot;
1720   delete localendladdercliptrans;
1721   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1722         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1723                 delete localladdercablehmatrix[i][j];
1724         delete []localladdercablehmatrix[i];
1725   }
1726   delete laddercablerot;
1727   delete laddercabletrans;
1728   delete laddercablecombitrans;
1729   delete localladdercablessdmodulematrix;
1730   delete localssdsensorrot;     
1731   for(Int_t i=0; i<2; i++){
1732         delete localssdsensortrans[i];
1733         delete localssdsensorcombitrans[i];
1734   }
1735   for(Int_t i=0; i<fgklayernumber; i++){
1736         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1737                 delete locallayerrot[i][j];
1738                 delete locallayertrans[i][j];
1739                 delete locallayercombitrans[i][j];
1740     }
1741         delete [] locallayerrot[i];
1742         delete [] locallayertrans[i];
1743         delete [] locallayercombitrans[i];
1744         delete localbeamaxistrans[i];
1745   }
1746   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1747   for(Int_t i=0; i<fgkladdernumber; i++){
1748         for(Int_t j=0; j<fgkladdernumber; j++)
1749                 delete ladderglobalmatrix[i][j];
1750         delete [] ladderglobalmatrix[i];
1751   }
1752   /////////////////////////////////////////////////////////////
1753   fTransformationMatrices = kTRUE;      
1754 }
1755 ///////////////////////////////////////////////////////////////////////////////
1756 void AliITSv11GeometrySSD::CreateBasicObjects(){
1757   /////////////////////////////////////////////////////////////  
1758   // Method generating the Objects of SSD Geometry    
1759   /////////////////////////////////////////////////////////////
1760   // SSD Sensor
1761   ///////////////////////////////////
1762   SetSSDSensor();
1763   /////////////////////////////////////////////////////////////  
1764   // Carbon Fiber Support    
1765   /////////////////////////////////////////////////////////////  
1766   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1767   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1768       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1769   /////////////////////////////////////////////////////////////
1770   // Carbon Fiber Junction 
1771   /////////////////////////////////////////////////////////////
1772   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1773   /////////////////////////////////////////////////////////////
1774   // Carbon Fiber Lower Support
1775   /////////////////////////////////////////////////////////////
1776   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1777   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1778         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1779   /////////////////////////////
1780   // SSD Sensor Support
1781   /////////////////////////////
1782   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1783                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1784   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1785                                                                          fgkSSDSensorSideSupportThickness[1]};
1786   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1787         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1788                                                                                            fgkSSDSensorSideSupportHeight[i],
1789                                                                                            fgkSSDSensorSideSupportWidth,
1790                                                                                            sidesupporthickness);  
1791         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1792                                                                                            fgkSSDSensorCenterSupportHeight[i],
1793                                                                                            fgkSSDSensorCenterSupportWidth,
1794                                                                                            sidesupporthickness);
1795   }
1796   /////////////////////////////////////////////////////////////
1797   // SSD Cooling Tube Support
1798   /////////////////////////////////////////////////////////////
1799   Int_t edgesnumber = 3;
1800   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1801   /////////////////////////////////////////////////////////////
1802   // SSD Hybrid
1803   /////////////////////////////////////////////////////////////
1804   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1805   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1806         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1807   /////////////////////////////////////////////////////////////
1808   // SSD Cooling Block System
1809   /////////////////////////////////////////////////////////////
1810   fssdcoolingblocksystem = GetCoolingBlockSystem();
1811    /////////////////////////////////////////////////////////////
1812   // SSD Cooling Tube
1813   /////////////////////////////////////////////////////////////
1814   CreateCoolingTubes();
1815   /////////////////////////////////////////////////////////////
1816   // SSD Flex  
1817   /////////////////////////////////////////////////////////////
1818   fssdstiffenerflex = GetSSDStiffenerFlex();
1819   fssdendflex = GetSSDEndFlex();
1820   ///////////////////////////////////
1821   // End Ladder Carbon Fiber Junction
1822   ///////////////////////////////////
1823   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1824                                                    fendladdercarbonfiberjunction[i] = 
1825                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1826   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1827     fendladdercarbonfiberjunction[i][0] = 
1828                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1829     fendladdercarbonfiberjunction[i][1] = 
1830                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1831   }
1832   ///////////////////////////////////
1833   // End Ladder Mounting Block
1834   ///////////////////////////////////
1835   fendladdermountingblock = GetSSDMountingBlock();
1836   ///////////////////////////////////
1837   // End Ladder Mounting Block
1838   ///////////////////////////////////
1839   fendladdermountingblockclip = GetMountingBlockClip();
1840   ///////////////////////////////////
1841   // Ladder Support 
1842   ///////////////////////////////////
1843   TList* laddersupportlist = GetMountingBlockSupport(20);
1844   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1845   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1846   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1847   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1848   /////////////////////////////////////////////////////////////
1849   // Deallocating memory
1850   /////////////////////////////////////////////////////////////
1851   delete carbonfibersupportlist;
1852   delete carbonfiberlowersupportlist;
1853   delete ssdhybridcomponentslist;
1854   delete laddersupportlist;
1855   /////////////////////////////////////////////////////////////
1856   fBasicObjects = kTRUE;
1857 }
1858 /////////////////////////////////////////////////////////////////////////////////
1859 void AliITSv11GeometrySSD::SetSSDSensor(){
1860   ////////////////////////////////////////////////////////////////
1861   // Method generating SSD Sensors: it sets the private variables
1862   // fSSDSensor5, fSSDSensor6  
1863   ////////////////////////////////////////////////////////////////
1864   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1865   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1866   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1867                                                 0.5*ssdsensitivewidth,
1868                                                 0.5*fgkSSDSensorHeight,
1869                                                 0.5*ssdsensitivelength);
1870   TGeoVolume* ssdsensorsensitiveLay5 = 
1871         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1872   TGeoVolume* ssdsensorsensitiveLay6 = 
1873         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1874   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1875   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1876   TGeoBBox* ssdsensorinsensitiveshape[2];
1877   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1878                                                 0.5*fgkSSDSensorInsensitiveWidth,
1879                                                 0.5*fgkSSDSensorHeight,
1880                                                 0.5*fgkSSDSensorLength);
1881   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1882                                                 0.5*ssdsensitivewidth,
1883                                                 0.5*fgkSSDSensorHeight,
1884                                                 0.5*fgkSSDSensorInsensitiveWidth);
1885   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1886                                              "SSDSensorInsensitive2"};
1887   TGeoVolume* ssdsensorinsensitive[2];
1888   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1889       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1890                      fSSDSensorMedium);
1891       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1892   }
1893   /////////////////////////////////////////////////////////////
1894   // Virtual Volume containing SSD Sensor  
1895   /////////////////////////////////////////////////////////////
1896   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1897                                                                                              0.5*fgkSSDSensorWidth,
1898                                                                                              0.5*fgkSSDSensorHeight,
1899                                                                                              0.5*fgkSSDSensorLength);
1900   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1901                                                                                  fSSDAir);      
1902   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1903                                                                                  fSSDAir);      
1904   /////////////////////////////////////////////////////////////
1905   for(Int_t i=0; i<4; i++){ 
1906             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1907             ssdsensorinsensitive[1],i<2?1:2,
1908                         new TGeoTranslation(
1909                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1910       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1911                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1912       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1913             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1914             ssdsensorinsensitive[1],i<2?1:2,
1915                         new TGeoTranslation(
1916                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1917       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1918                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1919       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1920   }
1921     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1922     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1923 }
1924 ///////////////////////////////////////////////////////////////////////////////
1925 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1926   /////////////////////////////////////////////////////////////  
1927   // Method generating the Carbon Fiber Support   
1928   /////////////////////////////////////////////////////////////  
1929   const Int_t kvertexnumber = 4;
1930   const Int_t kshapesnumber = 2;
1931   TVector3** vertexposition[kshapesnumber];
1932   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1933   Double_t carbonfibersupportxaxisEdgeproj = 
1934                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1935         *       TMath::DegToRad());
1936   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1937                                  /                         fgkCarbonFiberSupportXAxisLength);
1938   /////////////////////
1939   //Vertex Positioning
1940   ////////////////////
1941   vertexposition[0][0] = new TVector3();
1942   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1943                                                                           fgkCarbonFiberSupportYAxisLength);
1944   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1945                                                                           carbonfibersupportxaxisEdgeproj
1946                                            *                      TMath::Tan(theta));
1947   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1948                                            -                      carbonfibersupportxaxisEdgeproj,
1949                                                                           fgkCarbonFiberSupportYAxisLength
1950                                            -                      vertexposition[0][2]->Y());
1951   ////////////////////////////////////////////////////
1952   //Setting the parameters for Isometry Transformation
1953   ////////////////////////////////////////////////////
1954   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1955                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1956                                                                  +      fgkCarbonFiberSupportWidth);
1957   Double_t* param = new Double_t[4]; 
1958   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1959   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1960     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1961                  (GetReflection(vertexposition[0][j],param))->Y());
1962   const char* carbonfibersupportshapename[kshapesnumber] = 
1963                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1964   const char* carbonfibersupportname[kshapesnumber] = 
1965                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1966   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1967   TGeoVolume* carbonfibersupport[kshapesnumber];
1968   TList* carbonfibersupportlist = new TList();
1969   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1970   Double_t carbonfibersupportheight = 
1971           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1972           *TMath::DegToRad());
1973   for(Int_t i = 0; i< kshapesnumber; i++){
1974    carbonfibersupportshape[i] = 
1975                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1976                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1977    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1978                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1979    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1980    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1981    }
1982   /////////////////////////////////////////////////////////////
1983   // Deallocating memory
1984   /////////////////////////////////////////////////////////////
1985   for(Int_t i=0; i< kshapesnumber; i++){
1986      for(Int_t j=0; j< kvertexnumber; j++)
1987            delete vertexposition[i][j];
1988        delete [] vertexposition[i];
1989   }
1990   delete [] param;
1991   /////////////////////////////////////////////////////////////
1992    return carbonfibersupportlist;
1993 }
1994 /////////////////////////////////////////////////////////////////////////////////
1995 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1996   /////////////////////////////////////////////////////////////
1997   // Method generating SSD Carbon Fiber Junction
1998   /////////////////////////////////////////////////////////////
1999   const Int_t kvertexnumber = 6;
2000   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2001   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2002                                             *  TMath::DegToRad()),-1.,0.,0.};
2003   TVector3* vertex[kvertexnumber];
2004   vertex[0] = new TVector3();
2005   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2006                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2007                         *                         TMath::DegToRad()),
2008                                                   fgkCarbonFiberJunctionEdge[0]
2009                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2010                         *                         TMath::DegToRad()));
2011   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2012                                                    fgkCarbonFiberJunctionEdge[1]);
2013   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2014   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2015   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2016   Double_t xvertexpoints[6], yvertexpoints[6];
2017   for(Int_t i=0; i<kvertexnumber; i++) 
2018           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2019   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2020   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2021   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2022   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2023                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2024   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2025   /////////////////////////////////////////////////////////////
2026   // Deallocating memory
2027   /////////////////////////////////////////////////////////////
2028   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2029   ///////////////////////////////////////////////////////////// 
2030   return carbonfiberjunction;
2031 }
2032 ////////////////////////////////////////////////////////////////////////////////
2033 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2034   /////////////////////////////////////////////////////////////
2035   // Method generating the Carbon Fiber Lower Support   
2036   /////////////////////////////////////////////////////////////  
2037   const Int_t kvertexnumber = 4;
2038   const Int_t kshapesnumber = 2;
2039   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2040                                                                 fgkCarbonFiberLowerSupportWidth};
2041   TVector3** vertexposition[kshapesnumber];
2042   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2043                                                  new TVector3*[kvertexnumber];
2044   //First Shape Vertex Positioning
2045   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2046   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2047                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2048   vertexposition[0][2] = new TVector3();
2049   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2050   //Second Shape Vertex Positioning
2051   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2052                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2053                                  /                              fgkCarbonFiberTriangleLength);
2054   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2055                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2056                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2057   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2058                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2059                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2060   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2061   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2062                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2063   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
2064                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2065   const char* carbonfiberlowersupportname[kshapesnumber] = 
2066                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2067   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2068   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2069   TList* carbonfiberlowersupportlist = new TList();
2070   for(Int_t i = 0; i< kshapesnumber; i++){ 
2071         carbonfiberlowersupportshape[i] = 
2072                                                                 GetArbShape(vertexposition[i],width,
2073                                                                                         fgkCarbonFiberLowerSupportHeight,
2074                                                                                         carbonfiberlowersupportshapename[i]);
2075     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2076                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2077         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2078     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2079   }
2080   /////////////////////////////////////////////////////////////
2081   // Deallocating memory
2082   /////////////////////////////////////////////////////////////
2083   for(Int_t i=0; i< kshapesnumber; i++){
2084      for(Int_t j=0; j< kvertexnumber; j++)
2085            delete vertexposition[i][j];
2086        delete [] vertexposition[i];
2087   }
2088   /////////////////////////////////////////////////////////////
2089   return carbonfiberlowersupportlist;
2090 }
2091 ///////////////////////////////////////////////////////////////////////////////
2092 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2093                                                                  Double_t width, Double_t* thickness)const{
2094   /////////////////////////////////////////////////////////////
2095   // Method generating the Sensor Support   
2096   /////////////////////////////////////////////////////////////  
2097         const Int_t kvertexnumber = 6;
2098         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2099     TVector3* vertexposition[kvertexnumber];
2100         vertexposition[0] = new TVector3();     
2101         vertexposition[1] = new TVector3(0.0,length);   
2102         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2103         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2104         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2105         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2106         Double_t xvertexpoints[6], yvertexpoints[6];
2107         for(Int_t i=0; i<kvertexnumber; i++) 
2108                 xvertexpoints[i] = vertexposition[i]->X(), 
2109                 yvertexpoints[i] = vertexposition[i]->Y();
2110     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2111     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2112     ssdsensorsupportshape->DefineSection(1,0.5*width);
2113     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2114                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2115   /////////////////////////////////////////////////////////////
2116   // Deallocating memory
2117   /////////////////////////////////////////////////////////////
2118         for (Int_t i=0; i<kvertexnumber; i++)
2119                 delete vertexposition[i];
2120   /////////////////////////////////////////////////////////////
2121     return ssdsensorsupport;
2122 }
2123 ////////////////////////////////////////////////////////////////////////////////
2124 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2125   /////////////////////////////////////////////////////////////
2126   // Method generating the Cooling Tube Support
2127   /////////////////////////////////////////////////////////////
2128   if(nedges%2!=0) nedges--;     
2129   const Int_t kvertexnumber = nedges+5;
2130   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2131                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2132   Double_t angle = 90.+phi;
2133   Double_t psi = 90.-phi;
2134   ///////////////////////////////////////
2135   // Vertex Positioning for TGeoXTru
2136   ///////////////////////////////////////
2137   TVector3** vertexposition = new TVector3*[kvertexnumber];
2138
2139   Double_t Router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
2140   vertexposition[0] = new TVector3(Router*CosD(angle),
2141                                                                    Router*SinD(angle));
2142   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2143                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2144   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2145                                                                    fgkCoolingTubeSupportRmax);
2146   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2147                                                                    fgkCoolingTubeSupportRmax);
2148   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2149                                                                     vertexposition[1]->Y());
2150
2151   for(Int_t i=0; i<nedges; i++)
2152         vertexposition[i+5] = 
2153                 new TVector3(Router*CosD(psi+i*(2.*phi/nedges)),
2154                              Router*SinD(psi+i*(2.*phi/nedges)));
2155   ///////////////////////////////////////////////////////////////////////
2156   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2157   ///////////////////////////////////////////////////////////////////////
2158   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2159   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2160   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2161   for(Int_t i=0; i<kvertexnumber; i++){
2162         xvertexpoints[i] = vertexposition[i]->X();
2163         yvertexpoints[i] = vertexposition[i]->Y();
2164   } 
2165   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2166                                                                                         yvertexpoints);
2167   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2168   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2169   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2170                                                                           coolingtubesupportarcshape,
2171                                                                                   fSSDTubeHolderMedium);
2172   coolingtubesupportarc->SetLineColor(fColorG10);
2173   //////////////////////////////////////////////////////////////////////////
2174   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2175   //////////////////////////////////////////////////////////////////////////
2176   TGeoTubeSeg* coolingtubesupportsegshape = 
2177                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2178                                                                                         fgkCoolingTubeSupportRmax,
2179                                                                                         0.5*fgkCoolingTubeSupportWidth,
2180                                                                                         phi,360-phi);
2181   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2182                                                                                         coolingtubesupportsegshape,
2183                                                                                         fSSDTubeHolderMedium);
2184   coolingtubesupportseg->SetLineColor(fColorG10);
2185   //////////////////////////////////////////////////////////////////////////
2186   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2187   //////////////////////////////////////////////////////////////////////////
2188   Double_t* boxorigin = new Double_t[3];
2189   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2190   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2191   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2192                                                                                  0.5*fgkCoolingTubeSupportHeight,
2193                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2194   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2195                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2196   coolingtubesupportbox->SetLineColor(fColorG10);
2197   //////////////////////////////////////////////////////////////////////////
2198   // Cooling Tube for Cooling Tube Support 
2199   //////////////////////////////////////////////////////////////////////////
2200   TGeoXtru* coolingtubearcshape[2];
2201   coolingtubearcshape[0] = new TGeoXtru(2);     
2202   Double_t* xvert = new Double_t[nedges+2];
2203   Double_t* yvert = new Double_t[nedges+2];
2204   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2205   ////////////////////////////////////////
2206   // Positioning the vertices for TGeoXTru
2207   ////////////////////////////////////////
2208   xvert[0] = 0., yvert[0] = 0.;
2209   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2210   for(Int_t i=0; i< nedges; i++)
2211                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2212                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2213   ////////////////////////////////////////
2214   // Defining TGeoXTru PolyGone
2215   ////////////////////////////////////////
2216   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2217   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2218   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2219   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2220                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2221   TGeoVolume* coolingtubearc[2];
2222   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2223                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2224   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2225                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2226   coolingtubearc[0]->SetLineColor(fColorWater);
2227   coolingtubearc[1]->SetLineColor(fColorPhynox);
2228   ////////////////////////////////////////////
2229   // Defining TGeoTubeSeg Part of Cooling Tube
2230   ////////////////////////////////////////////
2231   TGeoTubeSeg* coolingtubesegshape[2];
2232   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2233                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2234   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2235                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2236   TGeoVolume* coolingtubeseg[2];
2237   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2238                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2239   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2240                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2241   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2242   coolingtubeseg[1]->SetLineColor(fColorWater);
2243   /////////////////////////////////////////////////////////////
2244   // Virtual Volume containing Cooling Tube Support  
2245   /////////////////////////////////////////////////////////////
2246   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2247   const Int_t kvirtualvertexnumber = 8;
2248   TVector3* virtualvertex[kvirtualvertexnumber];
2249    ////////////////////////////////////////
2250   // Positioning the vertices for TGeoXTru
2251   ////////////////////////////////////////
2252   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2253   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2254   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2255   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2256   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2257   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2258   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2259   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2260   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2261   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2262         xmothervertex[i] = virtualvertex[i]->X(),
2263         ymothervertex[i] = virtualvertex[i]->Y();
2264   ////////////////////////////////////////
2265   // Defining TGeoXTru PolyGone
2266   ////////////////////////////////////////
2267   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2268                                                                                                                                          ymothervertex);
2269   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2270   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2271   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2272     virtualCoolingTubeSupportShape,fSSDAir); */
2273   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
2274
2275   ////////////////////////////////////////
2276   // Positioning Volumes in Virtual Volume
2277   ////////////////////////////////////////
2278   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2279   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2280   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2281   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2282   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2283   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2284   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2285   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2286   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2287   /////////////////////////////////////////////////////////////
2288   // Deallocating memory
2289   /////////////////////////////////////////////////////////////
2290   delete [] vertexposition;
2291   delete [] xvertexpoints;
2292   delete [] yvertexpoints;
2293   delete [] xvert;
2294   delete [] yvert;
2295   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2296         delete virtualvertex[i];
2297   /////////////////////////////////////////////////////////////
2298         return virtualcoolingtubesupport;
2299 }
2300 /////////////////////////////////////////////////////////////////////////////////
2301 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2302   /////////////////////////////////////////////////////////////
2303   // Method generating List containing SSD Hybrid Components   
2304   /////////////////////////////////////////////////////////////
2305   TList* ssdhybridlist = new TList();
2306   const Int_t kssdstiffenernumber = 2;
2307   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2308                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2309                                                                   -    fgkSSDStiffenerWidth;
2310   Double_t ssdchipcablesradius[kssdstiffenernumber];
2311   for(Int_t i=0; i<kssdstiffenernumber; i++)
2312           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2313                                -  fgkSSDChipCablesHeight[0]
2314                                -  fgkSSDChipCablesHeight[1]);
2315   /////////////////////////////////////////////////////////////
2316   // Mother Volumes Containers 
2317   /////////////////////////////////////////////////////////////
2318   const Int_t kmothernumber = 2;
2319   const Int_t kmothervertexnumber = 8;
2320   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2321   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2322
2323   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
2324   TGeoVolume* ssdhybridmother[kmothernumber][2];
2325
2326   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
2327   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
2328   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
2329
2330   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2331   for(Int_t i=0; i<kmothernumber; i++){
2332     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
2333     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
2334     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
2335     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2336       -fgkSSDChipCablesHeight[i+2];
2337     
2338     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
2339     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
2340     xmothervertex[i][3] = xmothervertex[i][2];
2341     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1];
2342
2343     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
2344     ymothervertex[i][4] = ymothervertex[i][3];
2345     xmothervertex[i][5] = xmothervertex[i][4];
2346     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i];
2347
2348     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
2349     ymothervertex[i][6] = ymothervertex[i][5];
2350     
2351     xmothervertex[i][7] = xmothervertex[i][6];
2352     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
2353     TGeoXtru *shape = new TGeoXtru(2);
2354     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
2355     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
2356     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
2357     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
2358     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
2359     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2360    }   
2361   /////////////////////////////////////////////////////////////
2362   // SSD Stiffener   
2363   /////////////////////////////////////////////////////////////
2364   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2365                                              0.5*fgkSSDStiffenerLength,
2366                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2367                                              0.5*fgkSSDStiffenerHeight);
2368   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2369                                             fSSDStiffenerMedium);  
2370   ssdstiffener->SetLineColor(fColorStiffener); 
2371
2372 ////////////////////////////
2373 // Capacitor 0603-2200 nF
2374 ///////////////////////////
2375   const Int_t knapacitor0603number = 5;
2376   TGeoBBox* capacitor0603mothershape =  new TGeoBBox("Capacitor0603MotherShape",
2377                                                0.5*fgkSSDCapacitor0603Length + fgkSSDCapacitor0603CapLength,
2378                                                0.5*fgkSSDCapacitor0603Width,
2379                                                0.5*fgkSSDCapacitor0603Height);
2380   TGeoVolume* capacitor0603mother = new TGeoVolume("Capacitor0603Mother",capacitor0603mothershape,
2381                                              fSSDAir); 
2382
2383   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2384                                                0.5*fgkSSDCapacitor0603Length,
2385                                                0.5*fgkSSDCapacitor0603Width,
2386                                                0.5*fgkSSDCapacitor0603Height);
2387   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2388                                              fSSDStiffener0603CapacitorMedium); 
2389   capacitor0603->SetLineColor(fColorAl);
2390   TGeoTranslation *cap0603trans = new TGeoTranslation(0.,0.,0.);
2391   capacitor0603mother->AddNode(capacitor0603,1,cap0603trans);
2392
2393   TGeoBBox* capacitor0603capshape =  new TGeoBBox("Capacitor0603CapShape",
2394                                                0.5*fgkSSDCapacitor0603CapLength,
2395                                                0.5*fgkSSDCapacitor0603Width,
2396                                                0.5*fgkSSDCapacitor0603Height);
2397   TGeoVolume* capacitor0603cap = new TGeoVolume("Capacitor0603Cap",capacitor0603capshape,
2398                                              fSSDStiffenerCapacitorCapMedium); 
2399   capacitor0603cap->SetLineColor(fColorNiSn);
2400   TGeoTranslation *cap0603captrans1 = new TGeoTranslation(- capacitor0603shape->GetDX() - capacitor0603capshape->GetDX(),0.,0.);
2401   capacitor0603mother->AddNode(capacitor0603cap,1,cap0603captrans1);
2402   TGeoTranslation *cap0603captrans2 = new TGeoTranslation(capacitor0603shape->GetDX() + capacitor0603capshape->GetDX(),0.,0.);
2403   capacitor0603mother->AddNode(capacitor0603cap,2,cap0603captrans2);
2404
2405
2406   TGeoVolume* ssdchip = GetSSDChip();
2407
2408   const Int_t knedges = 5;
2409   TGeoVolume *ssdchipcables[2];
2410
2411   for(Int_t i=0; i<kmothernumber; i++){
2412     for(Int_t j=0; j<kssdstiffenernumber; j++){
2413       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
2414       for(Int_t k=1; k<knapacitor0603number+1; k++){
2415         ssdhybridmother[i][j]->AddNode(capacitor0603mother,k,
2416                                        new TGeoCombiTrans("",
2417                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
2418                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
2419                                                           (k-3.)/6*fgkSSDStiffenerLength,
2420                                                           hybridmotherrotInv));
2421       }
2422     }
2423     
2424     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
2425     for(Int_t k=0; k<fgkSSDChipNumber; k++){
2426       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
2427                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
2428                                                             - fgkSSDChipCablesHeight[i+2],
2429                                                             (k+0.5-fgkSSDChipNumber/2)*
2430                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
2431       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
2432                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
2433                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
2434                                                      hybridmotherrotInv);
2435       for(Int_t j=0; j<kssdstiffenernumber; j++){
2436         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
2437         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
2438       }
2439     }  
2440     // Final placement by assembly
2441     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
2442     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
2443     ssdhybridlist->Add(ssdhybridassembly[i]);
2444   }    
2445   /////////////////////////////////////////////////////////////
2446   // Mother Volume Containing Capacitor Part 
2447   /////////////////////////////////////////////////////////////
2448   const Int_t kcapacitormothernumber = 8;
2449   Double_t xcapacitorvertex[kcapacitormothernumber];
2450   Double_t ycapacitorvertex[kcapacitormothernumber];  
2451   ///////////////////////
2452   // Setting the vertices 
2453   ///////////////////////
2454   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2455   xcapacitorvertex[1] = xcapacitorvertex[0];   
2456   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2457   xcapacitorvertex[3] = xcapacitorvertex[2];   
2458   xcapacitorvertex[4] = xcapacitorvertex[0];   
2459   xcapacitorvertex[5] = xcapacitorvertex[0];   
2460   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2461   xcapacitorvertex[7] = xcapacitorvertex[6];   
2462   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2463   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2464   ycapacitorvertex[2] = ycapacitorvertex[1];   
2465   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2466   ycapacitorvertex[4] = ycapacitorvertex[3];   
2467   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2468   ycapacitorvertex[6] = ycapacitorvertex[5];   
2469   ycapacitorvertex[7] = ycapacitorvertex[0];   
2470   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2471   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2472                                               ycapacitorvertex);
2473   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2474   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2475 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2476 //                                          fSSDAir);
2477   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2478 ////////////////////////////
2479 // Connector 
2480 ///////////////////////////
2481   const Int_t kssdconnectorlayernumber = 3;
2482   TGeoBBox* ssdconnectorshape[kssdconnectorlayernumber];
2483   Double_t ssdConnectorThickness[kssdconnectorlayernumber]={fgkSSDConnectorAlHeight,fgkSSDConnectorNiHeight,fgkSSDConnectorSnHeight};
2484   /*
2485   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2486   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2487                                    +  fgkSSDConnectorAlHeight};  
2488   */
2489   Double_t ssdconnectororigin[3] = {0,0,0.5*fgkSSDStiffenerHeight};
2490   const char* ssdconnectorname[kssdconnectorlayernumber] = {"SSDConnectorAl","SSDConnectorNi","SSDConnectorSn"};
2491   TGeoMedium *ssdConnectorMedium[kssdconnectorlayernumber]={fSSDAlTraceFlexMedium,fSSDStiffenerConnectorMedium,fSSDSn};
2492   TGeoVolume* ssdconnector[kssdconnectorlayernumber];
2493   for(Int_t i=0; i<kssdconnectorlayernumber; i++){
2494     ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2495       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2496                                           0.5*fgkSSDConnectorWidth,
2497                                           0.5*ssdConnectorThickness[i],
2498                                           ssdconnectororigin);
2499       ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2500       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2501                                        ssdConnectorMedium[i]);      
2502       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorNiSn);
2503   }
2504   const Int_t kssdconnectornumber = 4;
2505   TGeoTranslation* ssdconnectortrans[kssdconnectornumber];
2506   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2507                        +  fgkSSDConnectorPosition[0]
2508                        -  fgkSSDConnectorSeparation
2509                        -  1.5*fgkSSDConnectorLength,
2510                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2511                        -  fgkSSDConnectorPosition[1]
2512                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2513   ssdconnectortrans[1] = new TGeoTranslation(
2514                        -  ssdstiffenershape->GetDX()
2515                        +  fgkSSDConnectorPosition[0]
2516                        -  0.5*fgkSSDConnectorLength,
2517                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2518                        -  fgkSSDConnectorPosition[1]
2519                        -  ssdconnectorshape[0]->GetDY(),0.0);
2520   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2521                        -  fgkSSDConnectorPosition[0]
2522                        +  fgkSSDConnectorSeparation
2523                        +  1.5*fgkSSDConnectorLength,
2524                           -(ssdstiffenershape->GetDY()
2525                        -  fgkSSDConnectorPosition[1]
2526                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2527   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2528                        -  fgkSSDConnectorPosition[0]
2529                        +  0.5*fgkSSDConnectorLength,
2530                           -(ssdstiffenershape->GetDY()
2531                        -  fgkSSDConnectorPosition[1]
2532                        -  ssdconnectorshape[0]->GetDY()),0.0);
2533   for(Int_t i=0; i<kssdconnectornumber; i++) {
2534     Int_t nlay = kssdconnectorlayernumber - 1;
2535     if (i == 1 || i == 2)
2536       nlay++;
2537     for(Int_t j=0; j<nlay; j++)
2538       ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2539   }
2540 ////////////////////////////
2541 // Capacitor 1812-330 nF
2542 /////////////////////////// 
2543 //  Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2544   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2545                                                                                          0.5*fgkSSDCapacitor1812Length,
2546                                                                                          0.5*fgkSSDCapacitor1812Width,
2547                                                0.5*fgkSSDCapacitor1812Height);
2548   //            ssdcapacitor1812origin);
2549   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2550                                              fSSDStiffener1812CapacitorMedium); 
2551   capacitor1812->SetLineColor(fColorAl);
2552   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2553                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2554                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2555   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2556
2557   TGeoBBox* capacitor1812capshape =  new TGeoBBox("Capacitor1812CapShape",
2558     0.5*fgkSSDCapacitor1812CapLength, 0.5*fgkSSDCapacitor1812Width,
2559     0.5*fgkSSDCapacitor1812Height);
2560   TGeoVolume* capacitor1812cap = new TGeoVolume("Capacitor1812Cap",capacitor1812capshape,
2561                                              fSSDStiffenerCapacitorCapMedium);
2562   capacitor1812cap->SetLineColor(fColorNiSn);
2563   TGeoTranslation* capacitor1812captrans1 = new TGeoTranslation(
2564         - capacitor1812shape->GetDX() - capacitor1812capshape->GetDX(),
2565         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2566         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2567         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2568   ssdhybridcapacitormother->AddNode(capacitor1812cap,1,capacitor1812captrans1);
2569   TGeoTranslation* capacitor1812captrans2 = new TGeoTranslation(
2570         capacitor1812shape->GetDX() + capacitor1812capshape->GetDX(),
2571         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2572         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2573         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2574   ssdhybridcapacitormother->AddNode(capacitor1812cap,2,capacitor1812captrans2);
2575
2576 ////////////////////////////
2577 //Hybrid Wire
2578 ////////////////////////////
2579   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2580                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2581                                  - fgkSSDConnectorSeparation;
2582   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2583                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2584   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2585
2586   Double_t wireangle = TMath::ATan(wirex/wirey);
2587   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2588                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2589   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2590                                              fSSDStiffenerHybridWireMedium); 
2591   hybridwire->SetLineColor(fColorPhynox);
2592   TGeoCombiTrans* hybridwirecombitrans[2];
2593   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2594                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2595                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2596                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2597                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2598                                    ssdstiffenershape->GetDZ()
2599                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight+fgkSSDConnectorSnHeight,
2600                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2601   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2602                             0.0,
2603                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2604                             0.0,        
2605                             new TGeoRotation("HybridWireRot2",
2606                           - wireangle*TMath::RadToDeg(),0.,0.));
2607   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2608   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2609   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2610   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2611   ssdhybridlist->Add(ssdhybridcapacitormother);
2612   /////////////////////////////////////////////////////////////
2613   // Deallocating memory
2614   /////////////////////////////////////////////////////////////
2615   delete hybridwirecombitrans[0];
2616   delete hybridwirecombitrans[1];
2617   return ssdhybridlist;
2618   /////////////////////////////////////////////////////////////
2619 }
2620 ///////////////////////////////////////////////////////////////////////////////
2621 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2622   /////////////////////////////////////////////////////////////
2623   // SSD Cooling Block System
2624   /////////////////////////////////////////////////////////////
2625   // SSD Cooling Block and Cooling Tube Transformations
2626   /////////////////////////////////////////////////////////////
2627   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2628   localcoolingblockrot->SetAngles(0.,90.,0.);
2629   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2630   TVector3* coolingblocktransvector;
2631   coolingblocktransvector = new TVector3(fgkCoolingTubeSeparation,
2632                                                                   fgkSSDSensorLength
2633                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2634                                                                 - fgkSSDCoolingBlockWidth);
2635   const Int_t kcoolingblocktransnumber = 2;
2636   const Int_t kcoolingblocknumber = 4;
2637   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2638   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2639   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2640   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2641     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2642       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X(),//+2*coolingtubedistance,
2643                                              j*coolingblocktransvector->Y(),
2644                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2645                                                     + fgkCoolingTubeRmax));
2646       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2647     }
2648   }
2649   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2650   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2651   /////////////////////////////////////////////////////////////
2652   // Adding Cooling block to mother volume
2653   /////////////////////////////////////////////////////////////
2654   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2655     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2656   }
2657   /////////////////////////////////////////////////////////////
2658   // Deallocating memory
2659   /////////////////////////////////////////////////////////////
2660   delete coolingblocktransvector;
2661   delete localcoolingblockrot;
2662
2663   return coolingsystemother;
2664 }
2665 /////////////////////////////////////////////////////////////////////////////////
2666 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2667   /////////////////////////////////////////////////////////////
2668   // SSD Flex
2669   /////////////////////////////////////////////////////////////
2670   const Int_t kssdflexlayernumber = 2;
2671   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2672   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2673   const Int_t kmothervertexnumber = 17; 
2674   Double_t xmothervertex[kmothervertexnumber];
2675   Double_t ymothervertex[kmothervertexnumber];
2676   /////////////////////////////////////////////
2677   // Auxiliary variables for vertex positioning
2678   /////////////////////////////////////////////
2679   const Int_t kssdflexboxnumber = 5;
2680   Double_t ssdflexboxlength[kssdflexboxnumber];
2681   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2682                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2683                                           *     fgkSSDChipSeparationLength
2684                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2685                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2686   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2687   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2688                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2689   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2690   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2691                                           -     ssdflexboxlength[1];
2692   Double_t ssdflexboxwidth[kssdflexboxnumber];
2693   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2694   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2695   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2696   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2697   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2698   ///////////////////////
2699   // Setting the vertices 
2700   ///////////////////////
2701   xmothervertex[0]  = 0.0;
2702   xmothervertex[1]  = xmothervertex[0];
2703   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2704   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2705                                         + ssdflexboxlength[4];
2706   xmothervertex[4]  = xmothervertex[3];
2707   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2708   xmothervertex[6]  = xmothervertex[5];
2709   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2710   xmothervertex[8]  = xmothervertex[7];
2711   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2712   xmothervertex[10] = xmothervertex[9]; 
2713   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2714   xmothervertex[12] = xmothervertex[11];
2715   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2716   xmothervertex[14] = xmothervertex[13];
2717   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2718   xmothervertex[16] = xmothervertex[15];
2719   ymothervertex[0]  = 0.0;
2720   ymothervertex[1]  = fgkSSDFlexWidth[1];
2721   ymothervertex[2]  = fgkSSDFlexWidth[0];
2722   ymothervertex[3]  = ymothervertex[2];
2723   ymothervertex[4]  = ymothervertex[0];
2724   ymothervertex[5]  = ymothervertex[4];
2725   ymothervertex[6]  = ssdflexboxwidth[2];
2726   ymothervertex[7]  = ymothervertex[6];
2727   ymothervertex[8]  = ymothervertex[0];
2728   ymothervertex[9]  = ymothervertex[8];
2729   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2730   ymothervertex[11] = ymothervertex[10];
2731   ymothervertex[12] = ymothervertex[0];
2732   ymothervertex[13] = ymothervertex[12];
2733   ymothervertex[14] = ymothervertex[7];
2734   ymothervertex[15] = ymothervertex[14];
2735   ymothervertex[16] = ymothervertex[0];
2736   /////////////////////////////////////////////////////////////
2737   // First Mother Volume containing SSDFlex
2738   /////////////////////////////////////////////////////////////
2739   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2740   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2741                                                                     ymothervertex);
2742   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2743   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2744   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2745 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2746 //                                                                                       fSSDAir);
2747   /////////////////////////////////////////////////////////////
2748   // SSDFlex Layer Shapes
2749   /////////////////////////////////////////////////////////////
2750   for(Int_t i=0; i<kssdflexlayernumber; i++){
2751         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2752                                                                    ymothervertex);
2753     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2754         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2755   }
2756   /////////////////////////////////////
2757   // Setting Layers into Mother Volume
2758   /////////////////////////////////////
2759   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2760   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2761                                                                                                  fSSDKaptonFlexMedium};
2762   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2763                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2764   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2765   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2766   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2767         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2768                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2769                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2770         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2771     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2772                                          +                                         fgkSSDFlexHeight[1])); 
2773     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2774   }
2775   return ssdflexmother;
2776 }
2777 /////////////////////////////////////////////////////////////////////////////////
2778 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2779   /////////////////////////////////////////////////////////////
2780   // Method generating SSD End Flex   
2781   /////////////////////////////////////////
2782   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2783                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2784   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2785                                                 * TMath::DegToRad()*ssdflexradiusmax
2786                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2787                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2788                                                         - 0.1*fgkSSDFlexFullLength;
2789   const Int_t knedges = 20;  
2790   const Int_t karcnumber = 2;
2791   TVector3* vertexposition[karcnumber*(knedges+1)];
2792   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2793   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2794   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2795   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2796                                                                                  - 90.0*TMath::DegToRad()};
2797   TVector3* referencetrans[karcnumber];
2798   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2799                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2800                                                                    radius[0]);
2801   referencetrans[1] = new TVector3(referencetrans[0]->X()
2802                                         +              fgkSSDFlexLength[2],
2803      -              fgkSSDStiffenerHeight);
2804 for(Int_t i=0; i<karcnumber; i++){
2805         for(Int_t j=0; j<knedges+1; j++){
2806                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2807                                                                                                radius[i]*SinD(angle[i]));
2808                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2809         }       
2810   }
2811   ///////////////////////
2812   // Setting the vertices 
2813   ///////////////////////
2814   const Int_t kendflexlayernumber = 4;
2815   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2816   TVector3** vertex[kendflexlayernumber];
2817   for(Int_t i=0; i<kendflexlayernumber; i++) 
2818                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2819   TVector3* transvector[kendflexlayernumber+1];
2820   TVector3* deltatransvector = new TVector3();  
2821   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2822   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2823                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2824   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2825         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2826                                         *                 CosD(fgkSSDFlexAngle),
2827                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2828                                         *         SinD(fgkSSDFlexAngle),0.0);   
2829         *transvector[i] = *transvector[i-1]+*deltatransvector;
2830   }
2831   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2832   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2833   for(Int_t i=0; i<karcnumber; i++){
2834         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2835                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2836                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2837                                               /radius[i];
2838         }
2839   }
2840   for(Int_t i=0; i<kendflexlayernumber; i++){
2841         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2842         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2843         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2844                 if(j<(knedges+1)){
2845                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2846                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2847                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2848                         *vertex[i][j+2] += *referencetrans[0];
2849                         vertex[i][4*(knedges+1)-j+1] = 
2850                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2851                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2852                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2853                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2854                 }
2855                 else{
2856                 
2857                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2858                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2859                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2860                         *vertex[i][j+2] += *referencetrans[1];
2861                         vertex[i][4*(knedges+1)-j+1] = 
2862                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2863                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2864                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2865                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2866            }
2867         }
2868   }
2869   /////////////////////////////////////////////////////////////
2870   // First Mother Volume containing SSDEndFlex
2871   /////////////////////////////////////////////////////////////
2872   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2873   Double_t xmothervertex[kendflexvertexnumber];
2874   Double_t ymothervertex[kendflexvertexnumber];
2875   xmothervertex[0] = vertex[0][0]->X(); 
2876   ymothervertex[0] = vertex[0][0]->Y();
2877   for(Int_t i=1; i<kendflexvertexnumber; i++){
2878         if(i<2*(knedges+1)+2){
2879                 xmothervertex[i] = vertex[3][i]->X();
2880                 ymothervertex[i] = vertex[3][i]->Y();
2881         }
2882         else{
2883                 xmothervertex[i] = vertex[0][i]->X();
2884                 ymothervertex[i] = vertex[0][i]->Y();
2885         }
2886   }
2887   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2888                                                                            xmothervertex,ymothervertex);
2889   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2890   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2891 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2892 //                                                               ssdendflexmothershape,fSSDAir);        
2893   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2894   //////////////////////////////////////
2895   // End Flex TGeoXtru Layer Definition 
2896   //////////////////////////////////////
2897   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2898   TGeoVolume* ssdendflex[kendflexlayernumber];
2899   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2900   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2901   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2902   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2903   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2904                                                                                                         fSSDKaptonFlexMedium};
2905   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2906                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2907   for(Int_t i=0; i<kendflexlayernumber; i++){
2908         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2909                 xvertex[i][j] = vertex[i][j]->X();
2910                 yvertex[i][j] = vertex[i][j]->Y();
2911         }
2912   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2913   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2914   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2915   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2916                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2917   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2918   ssdendflexmother->AddNode(ssdendflex[i],1);
2919   }
2920   /////////////////////////////////////////////////////////////
2921   // Deallocating memory
2922   /////////////////////////////////////////////////////////////
2923   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2924   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2925   for(Int_t i=0; i<kendflexlayernumber; i++){
2926         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2927         delete [] vertex[i];
2928   }
2929   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2930   delete deltatransvector;
2931   /////////////////////////////////////////////////////////////
2932   //ssdendflexmother->CheckOverlaps(0.01);
2933   return ssdendflexmother;
2934 }
2935 ///////////////////////////////////////////////////////////////////////////////
2936 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
2937   /////////////////////////////////////////////////////////////
2938   // Method generating the Mounting Block
2939   /////////////////////////////////////////////////////////////  
2940   const Int_t kvertexnumber = 8;
2941   Double_t xvertex[kvertexnumber];
2942   Double_t yvertex[kvertexnumber];
2943   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
2944   xvertex[1] = xvertex[0];
2945   xvertex[2] = -xvertex[0];
2946   xvertex[3] = xvertex[2];
2947   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
2948                          -                                 fgkSSDMountingBlockLength[2]);
2949   xvertex[5] = xvertex[4];
2950   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
2951                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
2952                          -     fgkSSDMountingBlockScrewHoleRadius[0];
2953   xvertex[7] = xvertex[6];
2954   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
2955                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
2956   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
2957   yvertex[2] = yvertex[1]; 
2958   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
2959   yvertex[4] = yvertex[3];
2960   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
2961                          - fgkSSDMountingBlockHeight[0];
2962   yvertex[6] = yvertex[5];
2963   yvertex[7] = yvertex[0];
2964
2965   ///////////////////////////////////////////////////////////////////////
2966   // TGeoXTru Volume definition for Mounting Block Part
2967   ///////////////////////////////////////////////////////////////////////
2968   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
2969   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
2970   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
2971   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
2972   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
2973                                                                           ssdmountingblockshape,
2974                                                                                   fSSDMountingBlockMedium);
2975   ssdmountingblock->SetLineColor(fColorG10);
2976   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
2977   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
2978   TGeoRotation* mountingblockrot = new TGeoRotation();
2979   mountingblockrot->SetAngles(90.,180.,-90.);
2980   mountingblockcombitrans->SetRotation(*mountingblockrot);
2981   /////////////////////////////////////////////////////////////
2982   // Generating the Mounting Block Screw Vertices 
2983   /////////////////////////////////////////////////////////////  
2984   const Int_t kscrewvertexnumber = 15;
2985   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
2986                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
2987                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
2988                                  * TMath::RadToDeg();
2989   Double_t phi0 = 90.+alpha;
2990   Double_t phi = 270.-2*alpha;
2991   Double_t deltaphi = phi/kscrewvertexnumber;   
2992   TVector3* screwvertex[kscrewvertexnumber+1];
2993   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
2994         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
2995                                    *CosD(phi0+i*deltaphi),
2996                                    fgkSSDMountingBlockScrewHoleRadius[0]
2997                                    *SinD(phi0+i*deltaphi));
2998   Double_t xscrewvertex[kscrewvertexnumber+6];
2999   Double_t yscrewvertex[kscrewvertexnumber+6];
3000   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3001   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3002                                   -               fgkSSDMountingBlockScrewHoleEdge);
3003   xscrewvertex[1] = xscrewvertex[0];
3004   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3005   xscrewvertex[2] = screwvertex[0]->X();
3006   yscrewvertex[2] = yscrewvertex[1];
3007   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3008         xscrewvertex[i+3] = screwvertex[i]->X();        
3009         yscrewvertex[i+3] = screwvertex[i]->Y();        
3010   } 
3011   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3012   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3013   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3014   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3015   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3016   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3017   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3018   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3019                                                         +                                  fgkSSDMountingBlockHeight[2]);
3020   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3021                                                                                 ssdmountingblockscrewshape,
3022                                                                                             fSSDMountingBlockMedium);
3023   ssdmountingblockscrew->SetLineColor(fColorG10);
3024   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3025   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3026   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3027                                                                         -                                yscrewvertex[1],
3028                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3029                                                                         -                                fgkSSDMountingBlockHeight[2]
3030                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3031                                                                         +                                fgkSSDMountingBlockHeight[2]
3032                                                                         -                                yvertex[0]));
3033   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3034                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3035                                                                                                                  yscrewvertex[1]
3036                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3037                                                                                                          +fgkSSDMountingBlockHeight[2]
3038                                                                                                          -yvertex[0]));
3039   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3040                                                                                                           yscrewvertex[1],
3041                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3042                                                                         +                                 fgkSSDMountingBlockHeight[2]
3043                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3044                                                                         +                                 fgkSSDMountingBlockHeight[2]
3045                                                                         -                                 yvertex[0]));
3046   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3047                                                                                                          yscrewvertex[1],
3048                                                                         -                                yscrewvertex[1]
3049                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3050                                                                         +                                fgkSSDMountingBlockHeight[2]
3051                                                                         -                                yvertex[0]));
3052   TGeoRotation* ssdmountingblockscrewrot[4];
3053   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3054         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3055     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3056     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3057   for(Int_t i=1; i<4; i++) 
3058         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3059   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3060   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3061   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3062   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3063                                                          +                                xvertex[0],yscrewvertex[1]
3064                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3065                                                          +                                fgkSSDMountingBlockHeight[2]
3066                                                          -                                yvertex[0]),0.);      
3067   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3068   for(Int_t i=0; i<4; i++){
3069         ssdmountingblockscrewmatrix[i] = 
3070                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3071         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3072   }
3073   ///////////////////////////////////////////////////////////////////////
3074   // TGeoXtru for Mother Volume 
3075   ///////////////////////////////////////////////////////////////////////
3076   const Int_t kvertexmothernumber = 12;
3077   Double_t xmothervertex[kvertexmothernumber];
3078   Double_t ymothervertex[kvertexmothernumber];
3079   for(Int_t i=0; i<6; i++){
3080         xmothervertex[i] = xvertex[i];
3081         ymothervertex[i] = yvertex[i];
3082   } 
3083   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3084   ymothervertex[6]  = ymothervertex[5];
3085   xmothervertex[7]  = xmothervertex[6];
3086   ymothervertex[7]  = ymothervertex[4];
3087   xmothervertex[8]  = xmothervertex[7]
3088                                         + 0.5*(fgkSSDMountingBlockLength[1]
3089                                         -          fgkSSDMountingBlockLength[2]);
3090   ymothervertex[8]  = ymothervertex[4];
3091   xmothervertex[9]  = xmothervertex[8];
3092   ymothervertex[9]  = ymothervertex[2];
3093   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3094   ymothervertex[10] = ymothervertex[1];
3095   xmothervertex[11] = xmothervertex[10];
3096   ymothervertex[11] = ymothervertex[0];  
3097   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3098   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3099   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3100   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3101   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3102                                                                           ssdmountingblockmothershape,
3103                                                                                   fSSDAir);
3104   /////////////////////////////////////////////////////////////
3105   // Placing the Volumes into Mother Volume 
3106   /////////////////////////////////////////////////////////////
3107   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3108   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3109   for(Int_t i=0; i<4; i++) 
3110         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3111                                                                         ssdmountingblockscrewmatrix[i]);
3112   /////////////////////////////////////////////////////////////
3113   // Deallocating memory
3114   /////////////////////////////////////////////////////////////
3115   delete mountingblockrot;
3116   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3117   delete ssdmountingblockglobalrot; 
3118   delete ssdmountingblockglobaltrans; 
3119   /////////////////////////////////////////////////////////////
3120   return ssdmountingblockmother;
3121 }
3122 ///////////////////////////////////////////////////////////////////////////////
3123  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3124   /////////////////////////////////////////////////////////////
3125   // Method generating the Mounting Block Clip 
3126   /////////////////////////////////////////////////////////////  
3127   const Int_t kmothervertexnumber = 10;
3128   Double_t xmothervertex[kmothervertexnumber];
3129   Double_t ymothervertex[kmothervertexnumber];
3130   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3131                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3132   xmothervertex[1] = xmothervertex[0];
3133   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3134                                    - fgkMountingBlockClibScrewRadius);
3135   xmothervertex[3] = xmothervertex[2]; 
3136   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3137   xmothervertex[5] = xmothervertex[4]; 
3138   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3139   xmothervertex[7] = xmothervertex[6]; 
3140   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3141   xmothervertex[9] = xmothervertex[8]; 
3142   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3143                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3144   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3145   ymothervertex[2] = ymothervertex[1];
3146   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3147                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3148                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3149   ymothervertex[4] = ymothervertex[3];
3150   ymothervertex[5] = ymothervertex[2];
3151   ymothervertex[6] = ymothervertex[5];
3152   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3153   ymothervertex[8] = ymothervertex[7];
3154   ymothervertex[9] = ymothervertex[0];
3155
3156   ///////////////////////////////////////////////////////////////////////
3157   // TGeoXTru Volume definition for Mounting Block Clip Part
3158   ///////////////////////////////////////////////////////////////////////
3159   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3160   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3161   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3162   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3163   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3164                                                                           ssdmountingblockclipshape,fSSDAir);
3165   ssdmountingblockclip->SetLineColor(4);
3166   ///////////////////////////////////////////////////////////////////////
3167   // TGeoXTru Volume definition for Clip 
3168   ///////////////////////////////////////////////////////////////////////
3169   const Int_t kclipvertexnumber = 6;
3170   Double_t xclipvertex[kclipvertexnumber];
3171   Double_t yclipvertex[kclipvertexnumber];
3172   xclipvertex[0] = xmothervertex[0];
3173   xclipvertex[1] = xclipvertex[0];
3174   xclipvertex[2] = xmothervertex[6];
3175   xclipvertex[3] = xclipvertex[2];
3176   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3177   xclipvertex[5] = xclipvertex[4];
3178   yclipvertex[0] = ymothervertex[0];
3179   yclipvertex[1] = ymothervertex[1];
3180   yclipvertex[2] = yclipvertex[1];
3181   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3182   yclipvertex[4] = yclipvertex[3];
3183   yclipvertex[5] = yclipvertex[0];
3184   TGeoXtru* clipshape = new TGeoXtru(2);
3185   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3186   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3187   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3188                                                          +   fgkMountingBlockClibWidth);
3189   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3190   clip->SetLineColor(18);
3191   ///////////////////////////////////////////////////////////////////////
3192   // Ladder Support Piece  
3193   ///////////////////////////////////////////////////////////////////////
3194   const Int_t ksupportvertexnumber = 4;
3195   Double_t xsupportvertex[ksupportvertexnumber];
3196   Double_t ysupportvertex[ksupportvertexnumber];
3197   xsupportvertex[0] = xclipvertex[5];
3198   xsupportvertex[1] = xsupportvertex[0];
3199   xsupportvertex[2] = xmothervertex[9];
3200   xsupportvertex[3] = xsupportvertex[2];
3201   ysupportvertex[0] = yclipvertex[0];
3202   ysupportvertex[1] = yclipvertex[3];
3203   ysupportvertex[2] = ysupportvertex[1];
3204   ysupportvertex[3] = ysupportvertex[0];
3205   TGeoXtru* supportshape = new TGeoXtru(2);
3206   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3207   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3208   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3209   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3210   support->SetLineColor(9);
3211   ///////////////////////////////////////////////////////////////////////
3212   // TGeoXTru Volume definition for Screw   
3213   ///////////////////////////////////////////////////////////////////////
3214   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3215                                                 0.5*fgkMountingBlockClibScrewRadius};
3216   Int_t edgesnumber[2] = {50,6};
3217   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3218                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3219   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3220   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3221   clipscrew->SetLineColor(12);
3222   TGeoRotation* screwrot = new TGeoRotation();
3223   screwrot->SetAngles(0.,90.,0.);
3224   TGeoTranslation* screwtrans = new TGeoTranslation();
3225   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3226                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3227                                                          0.5*fgkSSDMountingBlockWidth+
3228                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3229   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3230   ///////////////////////////////////////////////////////////////////////
3231   // Placing the Volumes
3232   ///////////////////////////////////////////////////////////////////////
3233   ssdmountingblockclip->AddNode(clip,1);
3234   ssdmountingblockclip->AddNode(support,1);
3235   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3236   /////////////////////////////////////////////////////////////
3237   // Deallocating memory
3238   /////////////////////////////////////////////////////////////  
3239   delete screwtrans;
3240   delete screwrot;
3241   /////////////////////////////////////////////////////////////
3242   return ssdmountingblockclip;
3243 }
3244 ///////////////////////////////////////////////////////////////////////////////
3245 void AliITSv11GeometrySSD::CreateCoolingTubes() {
3246   /////////////////////////////////////////////////////////////
3247   // Method generating the Cooling Tube 
3248   // sets fcoolingtube and returns list for endladdercoolingtube
3249   /////////////////////////////////////////////////////////////  
3250   TGeoTube *coolingtubeshape[2];
3251   // Ladder Cooling Tubes
3252
3253   // MvL: Simplified cooling tubes
3254   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,0.5*fgkCoolingTubeLength);
3255   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,coolingtubeshape[0]->GetDz());
3256
3257   // End Ladder Cooling Tubes   
3258   TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3259   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3260     endladdercoolingtubeshape[i] = new  TGeoTube*[2];
3261
3262   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
3263   endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3264                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0] - sensZshift));
3265   endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3266                                                  endladdercoolingtubeshape[0][0]->GetDz());
3267   endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3268                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1] + sensZshift));
3269   endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3270                                                  endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3271   // Ladder Cooling Tubes
3272   TGeoVolume* coolingtube[2];
3273   coolingtube[0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0], fSSDCoolingTubePhynox);
3274   coolingtube[1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[1], fSSDCoolingTubeWater);
3275   coolingtube[0]->SetLineColor(fColorPhynox);
3276   coolingtube[1]->SetLineColor(fColorWater);
3277
3278   // End Ladder Cooling Tubes   
3279   TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3280   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3281     endladdercoolingtube[i] = new TGeoVolume*[2];
3282   endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3283                                               endladdercoolingtubeshape[0][0],
3284                                               fSSDCoolingTubePhynox);
3285   endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3286                                               endladdercoolingtubeshape[0][1],
3287                                               fSSDCoolingTubeWater);
3288   endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3289                                               endladdercoolingtubeshape[1][0],
3290                                               fSSDCoolingTubePhynox);
3291   endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3292                                               endladdercoolingtubeshape[1][1],
3293                                               fSSDCoolingTubeWater);
3294   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3295     endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3296     endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3297   }
3298   
3299   /////////////////////////////////////////////////////////////
3300   // Virtual Volume containing Cooling Tubes
3301   /////////////////////////////////////////////////////////////
3302   // Ladder Cooling Tubes
3303   TGeoTube* virtualcoolingtubeshape = new TGeoTube(coolingtubeshape[1]->GetRmin(),
3304                                                    coolingtubeshape[0]->GetRmax(),
3305                                                    coolingtubeshape[0]->GetDz());
3306   fcoolingtube = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape, fSSDAir);
3307   fcoolingtube->AddNode(coolingtube[0],1);
3308   fcoolingtube->AddNode(coolingtube[1],1);
3309
3310   // End Ladder Cooling Tubes
3311   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3312   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3313     endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3314                                                        endladdercoolingtubeshape[i][0]->GetRmax(),
3315                                                        endladdercoolingtubeshape[i][0]->GetDz());
3316   fendladdercoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3317                                             endladdervirtualcoolingtubeshape[0],
3318                                             fSSDAir);
3319   fendladdercoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3320                                             endladdervirtualcoolingtubeshape[1],
3321                                             fSSDAir);
3322   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3323   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3324   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3325   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);  
3326 }
3327 ///////////////////////////////////////////////////////////////////////////////
3328 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3329   /////////////////////////////////////////////////////////////
3330   // Method generating SSD Cooling Block    
3331   /////////////////////////////////////////////////////////////
3332   const Int_t kvertexnumber = 8;
3333   ///////////////////////////////////////
3334   // Vertex Positioning for TGeoXTru
3335   ///////////////////////////////////////
3336   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3337   vertexposition[0] = new TVector3(0.0,0.0);
3338   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3339   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3340                                           vertexposition[1]->Y());
3341   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3342                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3343   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3344   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3345                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3346   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3347                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3348                                         - fgkSSDCoolingBlockHoleLength[0]
3349                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3350                                           fgkSSDCoolingBlockHeight[0]
3351                                         - fgkSSDCoolingBlockHoleRadius[1],
3352                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3353   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3354                                         - fgkSSDCoolingBlockHoleLength[0]),
3355                                           vertexposition[6]->Y());
3356   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3357                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3358   Double_t phi = 180.-alpha;
3359   Double_t psi = 180.+2.*alpha;
3360   Double_t deltapsi = psi/nedges;
3361   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3362   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3363                                                   fgkSSDCoolingBlockHoleCenter);
3364   for(Int_t i=0; i<nedges+1; i++){
3365         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3366                                                                                                radius*SinD(phi+i*deltapsi));
3367    *vertexposition[kvertexnumber+i] += (*transvector);
3368   }
3369   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3370   for(Int_t i=0; i<kvertexnumber; i++)
3371     vertexposition[kvertexnumber+nedges+1+i] = 
3372                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3373   ///////////////////////////////////////////////////////////////////////
3374   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3375   ///////////////////////////////////////////////////////////////////////
3376   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3377   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3378   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3379   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3380         xvertexpoints[i] = vertexposition[i]->X();
3381         yvertexpoints[i] = vertexposition[i]->Y();
3382   } 
3383   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3384                                                                                         yvertexpoints);
3385   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3386   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3387   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3388                                                                           ssdcoolingblockshape,
3389                                                                                   fSSDAlCoolBlockMedium);
3390   ssdcoolingblock->SetLineColor(fColorAl);
3391   /////////////////////////////////////////////////////////////
3392   // Deallocating memory
3393   /////////////////////////////////////////////////////////////
3394   delete [] vertexposition;
3395   delete [] xvertexpoints;
3396   delete [] yvertexpoints;
3397   /////////////////////////////////////////////////////////////
3398   return ssdcoolingblock;
3399 }
3400 /////////////////////////////////////////////////////////////////////////////////
3401 void AliITSv11GeometrySSD::GetSSDChipCables(TGeoVolume *&cableL, TGeoVolume *&cableR, Double_t SSDChipCablesHeight, Int_t nedges){
3402   ///////////////////////////////////////////////////////
3403   static const Int_t kssdchipcablesnumber    = 2;  // Number of cables: left and right
3404   static const Int_t kssdchipcableslaynumber = 2;  // Number of layers: Al and Kapton
3405   static const Int_t kvertexnumber                        = 4*(nedges+1)+4;
3406   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3407   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3408   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeight
3409                                                  -  fgkSSDChipCablesHeight[0]
3410                                                  -  fgkSSDChipCablesHeight[1]);
3411   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3412   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3413   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3414                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3415                                                           - ssdchipcablesradius[0]
3416                                                           - fgkSSDChipCablesWidth[1]
3417                                                           - fgkSSDChipCablesWidth[2]);
3418   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3419                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3420                                                           +      fgkSSDChipCablesHeight[1]
3421                                                           +      fgkSSDSensorHeight);
3422   ///////////////////////////////////////////////////////
3423   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3424   ///////////////////////////////////////////////////////
3425   TVector3** vertexposition[kssdchipcableslaynumber];
3426   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3427                                                                                                   new TVector3*[4*(nedges+1)+4];
3428   Double_t ratio[4];
3429   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3430   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3431                    /  ssdchipcablesradius[0]; 
3432   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3433                    /  ssdchipcablesradius[0];
3434   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3435                    +  fgkSSDChipCablesHeight[1])
3436                    /  ssdchipcablesradius[0];
3437   Double_t phi = 180.;
3438   Double_t deltaphi = 180./nedges;
3439   Double_t angle = 0.0;
3440
3441   Double_t xvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3442   Double_t yvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3443
3444   TVector3* vertex = new TVector3();
3445   TVector3* transvector[kssdchipcableslaynumber];
3446   transvector[0] = new TVector3(fgkSSDChipWidth,
3447                                                                 SSDChipCablesHeight-ssdchipcablesradius[0]);
3448   transvector[1] = new TVector3();
3449   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcablesnumber];
3450   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcablesnumber];
3451   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcablesnumber] = 
3452                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3453                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3454   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3455         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3456         transvector[1]->SetY(ssdchipcablesradius[0]
3457                                  +               fgkSSDChipCablesHeight[0]
3458                                  +               fgkSSDChipCablesHeight[1]);  
3459         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3460                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeight
3461                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3462                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeight
3463                                                          - i*fgkSSDChipCablesHeight[0]);
3464                 vertexposition[i][2*(nedges+1)+2] = 
3465                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3466                                 +                                fgkSSDChipCablesWidth[1]
3467                                 +                                fgkSSDChipCablesWidth[2],
3468                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3469                                 +                                fgkSSDChipCablesHeight[1]));
3470         vertexposition[i][2*(nedges+1)+3] = 
3471                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3472                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3473                                 -                                fgkSSDChipCablesHeight[i]);
3474             for(Int_t j=0; j<nedges+1; j++){            
3475                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3476                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3477                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3478                         vertexposition[0][(nedges+1)*i+j+2] = 
3479                                                 new TVector3(*vertex+*transvector[i]);
3480                         vertexposition[1][(nedges+1)*i+j+2] = 
3481                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3482                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3483                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3484                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3485                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3486                                                 new TVector3(vertex->X()*ratio[2*i+1]
3487                                                         +                        transvector[i]->X(),
3488                                                                                  vertex->Y()*ratio[2*i+1]
3489                                                         +                transvector[i]->Y());
3490                 }
3491         }
3492         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3493                 for(Int_t j=0; j<kvertexnumber; j++){   
3494                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3495                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3496                 }
3497                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3498                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3499                                                                                 xvertexpoints[i],yvertexpoints[i]);
3500                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3501                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3502                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3503                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3504                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3505                                                           (kssdchipcablesnumber*k+i)%2==0?
3506                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3507                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3508         }
3509         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3510                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3511   }
3512   /////////////////////////////////////////////////////////////
3513   // Mother Volume definition 
3514   /////////////////////////////////////////////////////////////
3515   static const Int_t kmothervertexnumber = 8;
3516   Double_t xmothervertex[kmothervertexnumber];
3517   Double_t ymothervertex[kmothervertexnumber];
3518   xmothervertex[0] = xvertexpoints[0][1];
3519   ymothervertex[0] = yvertexpoints[0][1];
3520   xmothervertex[1] = xvertexpoints[0][2+nedges/2];
3521   ymothervertex[1] = yvertexpoints[0][1];
3522   xmothervertex[2] = xvertexpoints[0][2+nedges/2];
3523   ymothervertex[2] = yvertexpoints[0][2+nedges];
3524   xmothervertex[3] = xvertexpoints[0][3+nedges];
3525   ymothervertex[3] = yvertexpoints[0][3+nedges];
3526   xmothervertex[4] = xvertexpoints[0][3+2*nedges];
3527   ymothervertex[4] = yvertexpoints[0][3+2*nedges];
3528   xmothervertex[5] = xvertexpoints[0][4+2*nedges];
3529   ymothervertex[5] = yvertexpoints[0][4+2*nedges];
3530   xmothervertex[6] = xvertexpoints[1][5+2*nedges];
3531   ymothervertex[6] = yvertexpoints[1][5+2*nedges];
3532   xmothervertex[7] = xvertexpoints[0][1];
3533   ymothervertex[7] = yvertexpoints[1][5+2*nedges];
3534   TGeoXtru *ssdchipcablemothershape = new TGeoXtru(2);
3535   ssdchipcablemothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3536   ssdchipcablemothershape->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3537   ssdchipcablemothershape->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3538
3539   cableL = new TGeoVolume("SSDChipCableMotherLeft",ssdchipcablemothershape,fSSDAir);
3540   cableR = new TGeoVolume("SSDChipCableMotherRight",ssdchipcablemothershape,fSSDAir);
3541
3542   cableL->AddNode(ssdchipcable[0],1);
3543   cableL->AddNode(ssdchipcable[1],1);
3544   cableR->AddNode(ssdchipcable[2],1);
3545   cableR->AddNode(ssdchipcable[3],1);  
3546
3547   /////////////////////////////////////////////////////////////
3548   // Deallocating memory
3549   /////////////////////////////////////////////////////////////
3550   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3551   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3552   delete vertex; 
3553   /////////////////////////////////////////////////////////////
3554 }
3555 //_____________________________________________________________________________
3556 TGeoVolume* AliITSv11GeometrySSD::GetSSDChip() const{
3557   /////////////////////////////////////////////////////////////
3558   // SSD Chip Assembly Generation    
3559   /////////////////////////////////////////////////////////////
3560   TGeoBBox* ssdchipcompshape[2];
3561   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3562                                                                                 0.5*fgkSSDChipLength,
3563                                                                                 0.5*fgkSSDChipWidth,
3564                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3565   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3566                                                                                 0.5*fgkSSDChipLength,
3567                                                                                 0.5*fgkSSDChipWidth,
3568                                                                                 0.5*fgkSSDChipGlueHeight);
3569   TGeoVolume* ssdchipcomp[2];
3570   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3571   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3572                                                                   fSSDChipGlueMedium);
3573   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3574   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3575   TGeoTranslation* ssdchipcomptrans[2];
3576   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3577   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3578   /////////////////////////////////////////////////////////////
3579   // Virtual Volume containing SSDChip   
3580   /////////////////////////////////////////////////////////////
3581   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3582                                                                                                                  0.5*fgkSSDChipWidth,
3583                                                                                                                  0.5*fgkSSDChipHeight);
3584   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3585   /////////////////////////////////////////////////////////////
3586   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3587   return ssdchip;
3588 }
3589 /////////////////////////////////////////////////////////////////////////////////
3590 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3591   /////////////////////////////////////////////////////////////
3592   // Method returning a List containing pointers to Ladder Cable Volumes    
3593   //
3594   // Return list contains 3 assemblies: cable box, cable arb shape and the end part of the cable
3595   //                                    each contains 2 volumes, one for polyamide and one for aluminium
3596   /////////////////////////////////////////////////////////////
3597   const Int_t kladdercablesegmentnumber = 2;
3598   /////////////////////////////////////////
3599   // LadderSegmentBBox Volume
3600   /////////////////////////////////////////
3601   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3602   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3603                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3604
3605
3606   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3607                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3608   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3609
3610   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3611                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3612                                                                                            0.5*fgkSSDFlexWidth[0],
3613                                                                                            0.5*fgkSSDLadderCableWidth,
3614                                                                        0.5*fgkSSDLadderCableHeight[0]),
3615                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3616                                                                                            0.5*fgkSSDFlexWidth[0],
3617                                                                                            0.5*fgkSSDLadderCableWidth,
3618                                                                                            fgkSSDLadderCableHeight[0]
3619                                                                                            +0.5*fgkSSDLadderCableHeight[1])
3620                                                                                    };
3621   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3622   static TGeoVolume* laddercablesegmentarbassembly = 
3623                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3624
3625   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3626   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3627
3628   if (laddercablesegmentbboxshape[0] == 0) { 
3629     // Initialise static shapes and volumes 
3630   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3631                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3632                                                                            0.5*fgkSSDFlexWidth[0],
3633                                                                            0.5*fgkSSDLadderCableWidth,
3634                                                                            0.5*fgkSSDLadderCableHeight[i]); 
3635
3636   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3637                         laddercablesegmentbbox[i] =
3638                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3639                                                                                  laddercablesegmentbboxshape[i],
3640                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3641             fSSDKaptonLadderCableMedium));
3642                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3643                                                                                                                    fColorPolyhamide);
3644   }
3645   
3646   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3647                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3648                                                                                             laddercablesegmentbboxtrans[i]);
3649 /////////////////////////////////////////
3650 // LadderSegmentArb8 Volume
3651 /////////////////////////////////////////
3652   const Int_t kvertexnumber = 4;
3653   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3654   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3655                                                                                                   new TVector3*[kvertexnumber];
3656 //Shape Vertex Positioning
3657   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3658         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3659         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3660                                                                                                                   i*fgkSSDFlexHeight[0]);
3661         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3662                                                                                    +                         fgkSSDFlexHeight[1]
3663                                                                                    +                      i*fgkSSDFlexHeight[0]);
3664         laddercablesegmentvertexposition[i][3] = 
3665                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3666                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3667   }
3668   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3669                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3670   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3671                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3672
3673   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3674                                         GetArbShape(laddercablesegmentvertexposition[i],
3675                                                                 laddercablesegmentwidth[i],
3676                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3677                                                                 laddercablesegmentarbshapename[i]);
3678   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3679                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3680
3681   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3682                          laddercablesegmentarb[i] =
3683                                                    new TGeoVolume(laddercablesegmentarbname[i],
3684                                                                                   laddercablesegmentarbshape[i],
3685                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3686             fSSDKaptonLadderCableMedium)); 
3687                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3688                                                                                                                    fColorPolyhamide);
3689 }
3690   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3691   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3692                                                                                                  90.,90,-90.);   
3693   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3694                                                                                                   0.,90.,0.);    
3695   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3696                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3697                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3698                                                          + fgkSSDFlexWidth[0],0.,0.,
3699                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3700                                                      *(*laddercablesegmentarbrot[0])));
3701   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3702   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3703                                                                                    laddercablesegmentarbcombitrans);
3704   }  // End of static initialisations
3705 /////////////////////////////////////////
3706 // End Ladder Cable Volume
3707 // Note: this part depends explicitly on the length passed as an argument to the function
3708 /////////////////////////////////////////
3709   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
3710   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
3711                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
3712   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
3713                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
3714                                                                            0.5*ssdendladdercablelength,
3715                                                                            0.5*fgkSSDLadderCableWidth,
3716                                                                            0.5*fgkSSDLadderCableHeight[i]);
3717   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
3718                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
3719   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
3720   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3721                         ladderendcablesegmentbbox[i] =
3722                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
3723                                                                                  ladderendcablesegmentbboxshape[i],
3724                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3725             fSSDKaptonLadderCableMedium));
3726                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3727                                                                                                                    fColorPolyhamide);
3728   }
3729   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
3730   ladderendcablesegmentbboxtrans[0] = 
3731                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
3732                                                                                            0.5*ssdendladdercablelength,
3733                                                                                            0.5*fgkSSDLadderCableWidth,
3734                                                                                            0.5*fgkSSDLadderCableHeight[0]);
3735   ladderendcablesegmentbboxtrans[1] = 
3736                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
3737                                                                                            0.5*ssdendladdercablelength,
3738                                                                                            0.5*fgkSSDLadderCableWidth,
3739                                                                                            fgkSSDLadderCableHeight[0]
3740                                                                                            +0.5*fgkSSDLadderCableHeight[1]);
3741   TGeoVolume* ladderendcablesegmentbboxassembly = 
3742                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
3743   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3744                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
3745                                                                                             ladderendcablesegmentbboxtrans[i]);
3746 /////////////////////////////////////////
3747   TList* laddercablesegmentlist = new TList();
3748   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
3749   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
3750   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
3751   return laddercablesegmentlist;
3752 }
3753
3754 /////////////////////////////////////////////////////////////////////////////////
3755 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
3756   /////////////////////////////////////////////////////////////
3757   // Method generating Ladder Cable of given length (n modules + end)
3758   // Called by GetLadderCableAssembly
3759   /////////////////////////////////////////////////////////////
3760   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
3761   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
3762   for(Int_t i=0; i<n; i++){
3763          TGeoTranslation* laddercabletrans = new TGeoTranslation(
3764                                                         i*(fgkCarbonFiberJunctionWidth),
3765                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3766                                                         i*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3767     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
3768     if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
3769  
3770   }
3771   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
3772                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3773                                                              fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3774                                                              (n-1)*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3775   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
3776   return laddercable;
3777 }
3778 /////////////////////////////////////////////////////////////////////////////////
3779 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
3780   ///////////////////////////////////////////////////////////////////
3781   // Main method generating Ladder Cable bundles containing n cables
3782   ///////////////////////////////////////////////////////////////////
3783   Double_t totalLength = ssdendladdercablelength+(n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0];
3784   Double_t cableOrig[3] = {0.5*totalLength,1.5*fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1])};
3785   TGeoBBox *laddercableshape = new TGeoBBox(0.5*totalLength,0.5*fgkSSDLadderCableWidth,0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]),cableOrig);
3786   TGeoVolume* laddercable = new TGeoVolume("LadderCableMother", laddercableshape, fSSDAir);
3787   char laddercabletransname[100];
3788   for(Int_t i=0; i<n; i++){ 
3789     snprintf(laddercabletransname,100,"LadderCableTrans%i",i+1);
3790     laddercable->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
3791                          new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0,0));
3792   }
3793   return laddercable;
3794 }
3795 /////////////////////////////////////////////////////////////////////////////////
3796 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
3797   /////////////////////////////////////////////////////////////
3798   // Method generating Ladder Cable List Assemblies  
3799   // containing two cables bundles, i.e. P+N readout for one endcap
3800   /////////////////////////////////////////////////////////////  
3801   const Int_t kladdercableassemblynumber = 2; 
3802   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
3803   TGeoVolume* ladderCable[kladdercableassemblynumber];
3804   char laddercableassemblyname[100];
3805   TList* laddercableassemblylist = new TList();
3806   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
3807     snprintf(laddercableassemblyname,100,"LadderCableAssembly%i",i+1);
3808         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
3809         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
3810                                          new TGeoCombiTrans((n-1)
3811                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3812                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
3813                                                                                         0.,new TGeoRotation("",180,0.,0.)));
3814         laddercableassemblylist->Add(ladderCable[i]);
3815 }
3816   return laddercableassemblylist;
3817 }
3818 ///////////////////////////////////////////////////////////////////////////////
3819 void AliITSv11GeometrySSD::SetLadderSegment(){
3820   /////////////////////////////////////////////////////////////
3821   // Method Generating Ladder Segment Array
3822   /////////////////////////////////////////////////////////////
3823   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
3824   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
3825
3826   /* MvL: tried to create mother volume. Requires changes in all rotations, bc xtru is always along z-axis
3827   TGeoXtru *laddersegmentshape = new TGeoXtru(2);
3828   static const Int_t ntrianglevtx = 3;
3829   Double_t xtrianglevtx[ntrianglevtx]={-0.5*fgkCarbonFiberTriangleLength,fgkCarbonFiberTriangleLength, 0};
3830   Double_t ytrianglevtx[ntrianglevtx]={0, 0, fgkCarbonFiberTriangleLength * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad())};
3831   laddersegmentshape->DefinePolygon(ntrianglevtx,xtrianglevtx,ytrianglevtx);
3832   laddersegmentshape->DefineSection(0,0);
3833   laddersegmentshape->DefineSection(1,fgkCarbonFiberJunctionWidth);  // MVL
3834   fladdersegment[0] = new TGeoVolume("LadderSegment1",laddersegmentshape,fSSDAir);      
3835   fladdersegment[1] = new TGeoVolume("LadderSegment2",laddersegmentshape,fSSDAir);      
3836   */
3837
3838   if(!fCreateMaterials) CreateMaterials();
3839   if(!fTransformationMatrices) CreateTransformationMatrices();
3840   if(!fBasicObjects) CreateBasicObjects();
3841   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
3842   // Placing Carbon Fiber Support       
3843         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
3844                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3845                                                                                         fcarbonfibersupportmatrix[j]);  
3846                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3847                                                                                         fcarbonfibersupportmatrix[j]);
3848   }
3849   // Placing Carbon Fiber Junction
3850         for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++) {
3851         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
3852                                                                    fcarbonfiberjunctionmatrix[j]);
3853   }
3854   // Placing Carbon Fiber Lower Support
3855     for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++) {
3856                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
3857                                                            fcarbonfiberlowersupportrans[j]);    
3858     }
3859   // Placing SSD Sensor Support
3860     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
3861         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
3862                                                                      fssdsensorsupport[1][i],
3863                                                            j+1,fssdsensorsupportmatrix[j]);
3864   // Placing SSD Cooling Tube Support 
3865         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
3866                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3867                                                                    fcoolingtubesupportmatrix[j]);
3868   // Placing SSD Cooling Tube  
3869         fladdersegment[i]->AddNode(fcoolingtube,1,fcoolingtubematrix[0]);
3870         fladdersegment[i]->AddNode(fcoolingtube,2,fcoolingtubematrix[1]);
3871   // Placing SSD Hybrid
3872     switch(i){
3873         case 0: 
3874                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
3875                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3876                 break;
3877     case 1:
3878                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
3879                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3880                 break;
3881         }
3882         // Placing Cooling Block System
3883       fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
3884         // Placing SSD Flex
3885       for(Int_t j=0; j<fgkflexnumber; j++){
3886         fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
3887         fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
3888       }
3889    }
3890 }
3891 ///////////////////////////////////////////////////////////////////////////////
3892 void AliITSv11GeometrySSD::SetEndLadderSegment(){
3893   /////////////////////////////////////////////////////////////
3894   // Method Generating End Ladder
3895   /////////////////////////////////////////////////////////////
3896   // End Ladder Carbon Fiber Junction 
3897   /////////////////////////////////////////////////////////////
3898   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
3899   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
3900   if(!fCreateMaterials) CreateMaterials();
3901   if(!fTransformationMatrices) CreateTransformationMatrices();
3902   if(!fBasicObjects) CreateBasicObjects();
3903   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
3904         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
3905                 fendladdersegment[i]->AddNode(j==2 ? 
3906                                                         fendladdercarbonfiberjunction[i][1] : 
3907                                                         fendladdercarbonfiberjunction[i][0],
3908                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
3909   }
3910   /////////////////////////////////////////////////////////////
3911   // End Ladder Carbon Fiber Support 
3912   /////////////////////////////////////////////////////////////
3913   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
3914       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
3915                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3916                   fendladdercarbonfibermatrix[i][j]);   
3917           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3918                   fendladdercarbonfibermatrix[i][j]);   
3919       }
3920   /////////////////////////////////////////////////////////////
3921   // End Ladder Mounting Block
3922   /////////////////////////////////////////////////////////////
3923   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3924        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
3925                                      fendladdermountingblockcombitrans[i]);
3926   /////////////////////////////////////////////////////////////
3927   // End Ladder Mounting Block Clip
3928   /////////////////////////////////////////////////////////////
3929   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3930         for(Int_t j=0; j<2; j++)
3931                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
3932                                               fendladdermountingblockclipmatrix[i][j]);
3933   /////////////////////////////////////////////////////////////
3934   // End Ladder Lower Supports
3935   /////////////////////////////////////////////////////////////
3936   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
3937                                 fendladderlowersupptrans[0]);
3938   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
3939                                 fendladderlowersupptrans[1]);
3940   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
3941                                 fendladderlowersupptrans[2]);
3942   /////////////////////////////////////////////////////////////
3943   // End Ladder Cooling Tube Support
3944   /////////////////////////////////////////////////////////////
3945   for(Int_t i=0; i<2; i++) 
3946         for(Int_t j=0; j<(i==0?4:2); j++)   
3947                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3948                                               fendladdercoolingtubesupportmatrix[i][j]);
3949   /////////////////////////////////////////////////////////////
3950   // End Ladder Cooling Tube Support
3951   /////////////////////////////////////////////////////////////
3952   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]); 
3953   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);
3954   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[1][0]);
3955   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[1][1]); 
3956 }
3957 ///////////////////////////////////////////////////////////////////////////////
3958 void AliITSv11GeometrySSD::SetLadder(){
3959   /////////////////////////////////////////////////////////////
3960   // Method Generating Ladder of Layer 5 and 6
3961   /////////////////////////////////////////////////////////////  
3962   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
3963                                                                                                 fgkSSDLay6SensorsNumber};
3964   /////////////////////////////////////////////////////////////////////////////                                         
3965   /// Generating Ladder Mother Volume Containing Ladder 
3966   /////////////////////////////////////////////////////////////////////////////          
3967   TGeoXtru* laddershape[fgkladdernumber];       
3968   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
3969   const Int_t kmothervertexnumber = 8;  
3970   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
3971   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
3972   ///////////////////////
3973   // Setting the vertices 
3974   ///////////////////////
3975   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
3976                                                                 * (fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]);
3977   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
3978   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
3979   xmothervertex[0][1] = xmothervertex[0][0];
3980   ymothervertex[0][1] = -0.5*fgkCoolingTubeSupportHeight; // 0.0; MvL 20-apr-2010
3981   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
3982                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
3983   ymothervertex[0][2] = ymothervertex[0][1];
3984   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
3985   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
3986   xmothervertex[0][4] = -xmothervertex[0][3];
3987   ymothervertex[0][4] = ymothervertex[0][3];
3988   xmothervertex[0][5] = -xmothervertex[0][2];
3989   ymothervertex[0][5] = ymothervertex[0][2];
3990   xmothervertex[0][6] = -xmothervertex[0][1];
3991   ymothervertex[0][6] = ymothervertex[0][1];
3992   xmothervertex[0][7] = -xmothervertex[0][0];
3993   ymothervertex[0][7] = ymothervertex[0][0];
3994   for(Int_t i=0; i<kmothervertexnumber; i++){
3995         xmothervertex[1][i] = xmothervertex[0][i];
3996         ymothervertex[1][i] = ymothervertex[0][i];
3997   }
3998 ///////////////////////////////////////////////////////////////////////////
3999 // Disalignement Mother Volume corrections 25/08/08
4000 ///////////////////////////////////////////////////////////////////////////
4001   TGeoXtru* leftladdershape1[fgkladdernumber];  
4002   TGeoXtru* leftladdershape2[fgkladdernumber];  
4003   TGeoXtru* centersensorladdershape[fgkladdernumber];   
4004   TGeoXtru* rightladdershape1[fgkladdernumber]; 
4005   TGeoXtru* rightladdershape2[fgkladdernumber]; 
4006   for(Int_t i=0; i<fgkladdernumber; i++){
4007     leftladdershape1[i] = new TGeoXtru(2);
4008     leftladdershape2[i] = new TGeoXtru(2);
4009     centersensorladdershape[i] = new TGeoXtru(2);
4010     rightladdershape1[i] = new TGeoXtru(2);
4011     rightladdershape2[i] = new TGeoXtru(2);
4012   }
4013   //////////////////////////////////////
4014   // Setting the names for shapes  
4015   //////////////////////////////////////
4016   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
4017   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
4018   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
4019   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
4020   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
4021   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
4022   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
4023   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
4024   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
4025   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
4026   //////////////////////////////////////
4027   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
4028   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
4029   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
4030   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
4031   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
4032   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
4033   for(Int_t i=0; i<fgkladdernumber; i++) {
4034     for(Int_t j=0; j<kmothervertexnumber; j++){
4035       xcentersensorvertex[i][j] = xmothervertex[i][j];
4036       ycentersensorvertex[i][j] = ymothervertex[i][j];
4037       xend1laddervertex[i][j] = xmothervertex[i][j];
4038       yend1laddervertex[i][j] = ymothervertex[i][j];
4039       xend2laddervertex[i][j] = xmothervertex[i][j];
4040       yend2laddervertex[i][j] = ymothervertex[i][j];
4041     }
4042     // Add some space around sensors to accommodate misalignments
4043     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
4044     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
4045     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
4046     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
4047     
4048     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
4049     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
4050     
4051     // Center Ladder Piece
4052     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
4053                                               ycentersensorvertex[i]);
4054     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4055                                                  + 1.45*fgkSSDMountingBlockWidth);
4056     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
4057                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4058                                                  - 2.4*fgkSSDMountingBlockWidth);
4059
4060     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
4061
4062     // Cuts off first corner (neg x)
4063     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
4064     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
4065     // Cuts off last part (pos x)
4066     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
4067     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
4068
4069     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
4070                                        yend1laddervertex[i]);
4071     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4072     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4073                                          - fgkEndLadderMountingBlockPosition[0]);
4074     
4075     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
4076                                        yend2laddervertex[i]);
4077     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4078                                          - fgkEndLadderMountingBlockPosition[0]); 
4079     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4080                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4081
4082     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4083                                         yend1laddervertex[i]);
4084     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4085                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4086                                         -2.4*fgkSSDMountingBlockWidth);
4087     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4088                                         + fgkEndLadderMountingBlockPosition[1]);
4089
4090     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4091                                         yend2laddervertex[i]);
4092     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4093                                            + fgkEndLadderMountingBlockPosition[1]);
4094     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4095                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4096   }
4097   TGeoCompositeShape* laddershapecontainer[2];
4098   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4099                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4100                                                    "+Lay5CenterSensorContainer"
4101                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4102   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4103                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4104                                                    "+Lay6CenterSensorContainer"
4105                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4106   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4107   for(Int_t i=0; i<fgkladdernumber; i++){
4108     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4109     fladder[i]->SetLineColor(4);
4110   }
4111 ///////////////////////////////////////////////////////////////////////////
4112  if(!fCreateMaterials) CreateMaterials();
4113  if(!fTransformationMatrices) CreateTransformationMatrices();
4114  if(!fBasicObjects) CreateBasicObjects();
4115  SetLadderSegment(); 
4116  SetEndLadderSegment();
4117   for(Int_t i=0; i<fgkladdernumber; i++){
4118         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4119         //////////////////////////                                              
4120         /// Placing Ladder Segment
4121         //////////////////////////              
4122                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4123                                                                      fladdersegment[i==0 ? 1 : 0],
4124                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4125         //////////////////////////                                              
4126         /// Placing SSD Sensor
4127         //////////////////////////              
4128         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4129                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4130                                                         fssdsensormatrix[i][j]);
4131         }
4132         ///////////////////////////////                                         
4133         /// Placing End Ladder Segment
4134         ///////////////////////////////         
4135         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4136         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4137    }
4138 /////////////////////////////////////////////////////////////////////////////                                           
4139 /// Placing Ladder Cables
4140 /////////////////////////////////////////////////////////////////////////////           
4141   Int_t sidecablenumber[2][2];
4142   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4143   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4144   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4145   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4146   Double_t carbonfibertomoduleposition[3];
4147   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4148   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4149                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4150          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4151          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4152          -            fgkSSDSensorCenterSupportThickness[0]);
4153   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4154                                                                  +   0.5*fgkCoolingTubeSupportHeight
4155          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4156   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4157   Double_t ssdendladdercablelength[4];
4158   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4159                                                          + fgkSSDSensorLength
4160                                                          - fgkSSDModuleStiffenerPosition[1]
4161                                                          - fgkSSDStiffenerWidth 
4162                                                          - fgkSSDFlexWidth[0]
4163                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4164   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4165                                                          + fgkSSDModuleStiffenerPosition[1]
4166                                                          + fgkSSDStiffenerWidth
4167                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4168   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4169                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4170                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4171                                                          - kendladdercablecorrection;
4172   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4173                                                          + carbonfibertomoduleposition[1]
4174                                                          - fgkSSDModuleStiffenerPosition[1]
4175                                                          - fgkSSDStiffenerWidth)
4176                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4177
4178   TList* laddercableassemblylist[4];
4179   const Int_t kendladdercablesnumber = 4;
4180   TGeoRotation *laddercablerot = new TGeoRotation();
4181   laddercablerot->SetAngles(90.,60.,-90.);
4182   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4183         for(Int_t j=0; j<kendladdercablesnumber; j++){
4184                 laddercableassemblylist[j] = 
4185                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4186                                                                    ssdendladdercablelength[j]);
4187                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4188                                                                         j<2?1:2,fladdercablematrix[i][j]);
4189   }
4190 }
4191 ////////////////////////////////////////////////////////////////////////////////
4192 void AliITSv11GeometrySSD::SetLayer(){
4193 ////////////////////////////////////////////////////////////////////////////////
4194   // Creating Ladder of Layer 5 and Layer 6
4195   /////////////////////////////////////////////////////////////
4196   if(!fCreateMaterials) CreateMaterials();
4197   if(!fTransformationMatrices) CreateTransformationMatrices();
4198   if(!fBasicObjects) CreateBasicObjects();
4199   SetLadder(); // Generating the ladder of Layer5 and Layer6
4200   const Int_t kssdlayladdernumber[fgklayernumber] = 
4201                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4202   /////////////////////////////////////////////////////////////
4203   // Generating mother volumes for Layer5 and Layer6
4204   /////////////////////////////////////////////////////////////
4205   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4206   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4207   Int_t *ladderindex[fgklayernumber];
4208   Int_t index[fgklayernumber] = {8,9};
4209   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4210   for(Int_t i=0; i<fgklayernumber; i++) 
4211         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4212                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4213                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4214                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4215                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4216         }
4217   /////////////////////////////////////////////////////////////
4218   // Deallocating memory
4219   /////////////////////////////////////////////////////////////
4220   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
4221 }
4222 ////////////////////////////////////////////////////////////////////////////////
4223 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4224   /////////////////////////////////////////////////////////////
4225   // Insert the layer 5 in the mother volume. 
4226   /////////////////////////////////////////////////////////////
4227   if (! moth) {
4228     AliError("Can't insert layer5, mother is null!\n");
4229     return;
4230   };
4231   if(!fSSDLayer5) SetLayer();
4232   fMotherVol = moth;
4233   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4234                                                                                 + fgkLay5CenterITSPosition);
4235   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4236  }
4237 ////////////////////////////////////////////////////////////////////////////////
4238 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4239   /////////////////////////////////////////////////////////////
4240   // Insert the layer 6 in the mother volume. 
4241   /////////////////////////////////////////////////////////////
4242   if (! moth) {
4243     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4244     return;
4245   };
4246   if(!fSSDLayer6) SetLayer();
4247   fMotherVol = moth;
4248   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4249                                                                                 + fgkLay6CenterITSPosition);
4250   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4251  }
4252  ////////////////////////////////////////////////////////////////////////////////
4253  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4254   /////////////////////////////////////////////////////////////
4255   // Method generating the Arc structure of Ladder Support 
4256   /////////////////////////////////////////////////////////////
4257   const Int_t kssdlayladdernumber[fgklayernumber] = 
4258                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4259   Double_t mountingsupportedge[fgklayernumber];
4260   Double_t mountingblockratio[fgklayernumber];
4261   Double_t theta[fgklayernumber];
4262   Double_t phi[fgklayernumber];
4263   Double_t psi0[fgklayernumber];
4264   Double_t deltapsi[fgklayernumber];
4265   TVector3* mountingsupportedgevector[fgklayernumber];
4266   for(Int_t i=0; i<fgklayernumber; i++){
4267         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4268     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4269                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4270                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4271                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4272                                                           / kssdlayladdernumber[i])));
4273     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4274     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4275         mountingsupportedgevector[i] = new TVector3();
4276         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4277         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4278                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4279                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4280     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4281     deltapsi[i] = (theta[i]+phi[i])/nedges;
4282   }
4283   TVector3** vertex[fgklayernumber];
4284   TList* vertexlist[fgklayernumber];
4285   Int_t indexedge[fgklayernumber] = {0,0};
4286   for(Int_t i=0; i<fgklayernumber; i++){
4287         vertex[i] = new TVector3*[nedges+1];
4288         vertexlist[i] = new TList();
4289   } 
4290   for(Int_t i=0; i<fgklayernumber; i++){
4291         for(Int_t j=0; j<nedges+1; j++){
4292                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4293                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4294                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4295                 vertexlist[i]->Add(vertex[i][j]);
4296         }
4297         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4298   }
4299   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4300   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4301   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4302   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4303   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4304   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4305   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4306   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4307   for(Int_t i=0; i<fgklayernumber; i++){
4308     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4309     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4310     xcentervertex[i] = new Double_t[indexedge[i]+3];
4311     ycentervertex[i] = new Double_t[indexedge[i]+3];
4312         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4313         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4314         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4315         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4316         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4317                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4318                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4319                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4320                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4321                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4322                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4323                 if(j<indexedge[i]+1){
4324                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4325                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4326                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4327                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4328                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4329                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4330                 }
4331         }
4332         xsidevertex[i][1] = xsidevertex[i][0]; 
4333         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4334         xsidevertex[i][2] = xsidevertex[i][3]; 
4335         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4336         xcentervertex[i][1] = xcentervertex[i][0]; 
4337         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4338         xcentervertex[i][2] = xcentervertex[i][3]; 
4339         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4340         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4341         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4342         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4343         ycenterlowervertex[i][0] = ysidevertex[i][0];
4344         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4345         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4346   }
4347   /////////////////////////////////////////////////////////////
4348   // Building the Arc Structure of Ladder Supports 
4349   /////////////////////////////////////////////////////////////
4350   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4351   TGeoXtru* centermountingsupportshape[fgklayernumber];
4352   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4353   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4354   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4355   TGeoVolume* centermountingblocksupport[fgklayernumber];
4356   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4357   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4358   char sidemountingblockname[100];
4359   char centermountingblockname[100];
4360   char sideladdersupportpiecename[100];
4361   char centerladdersupportpiecename[100];
4362   for(Int_t i=0; i<fgklayernumber; i++){ 
4363     snprintf(sidemountingblockname,100,"MountingBlockSupportSideLay%dArc",i+5);
4364     snprintf(centermountingblockname,100,"MountingBlockSupportCenterLay%dArc",i+5);
4365     snprintf(sideladdersupportpiecename,100,"SideLadderSupportPieceLay%d",i+5);
4366     snprintf(centerladdersupportpiecename,100,"CenterLadderSupportPieceLay%d",i+5);
4367     sidemountingblocksupportshape[i] = new TGeoXtru(2);
4368     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4369                                                                                                 xsidevertex[i],ysidevertex[i]);
4370     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4371                                                                                                          -fgkMountingBlockSupportWidth[0]);
4372     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4373     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4374                                                                           sidemountingblocksupportshape[i],
4375                                                                                   fSSDAlCoolBlockMedium);
4376         sidemountingblocksupport[i]->SetLineColor(9);
4377         centermountingsupportshape[i] = new TGeoXtru(2);
4378     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4379                                                                                                 xcentervertex[i],ycentervertex[i]);
4380         centermountingsupportshape[i]->DefineSection(0,0.);
4381     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4382                                                                                                   -fgkMountingBlockSupportWidth[0]);
4383
4384     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4385                                                                           centermountingsupportshape[i],
4386                                                                                   fSSDAlCoolBlockMedium);
4387         centermountingblocksupport[i]->SetLineColor(9);
4388         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4389     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4390                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4391         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4392                                                                                                          -fgkMountingBlockSupportWidth[0]);
4393     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4394     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4395                                                                           sideladdersupportpieceshape[i],
4396                                                                                   fSSDCarbonFiberMedium);
4397         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4398         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4399     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4400                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4401         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4402     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4403                                                                                                   -fgkMountingBlockSupportWidth[0]);
4404     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4405                                                                           centerladdersupportpieceshape[i],
4406                                                                                   fSSDCarbonFiberMedium);
4407         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4408   }
4409   /////////////////////////////////////////////////////////////
4410   // Building the Up Structure of Ladder Supports 
4411   /////////////////////////////////////////////////////////////
4412   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4413   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4414   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4415   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4416   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4417   //////////////////////////////////////////////////////////
4418   // Setting the volume for TGeoXtru Mounting Block Piece  
4419   //////////////////////////////////////////////////////////
4420   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4421   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4422   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4423   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4424   TGeoVolume* mountingblockpieceup[fgklayernumber];
4425   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4426   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4427   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4428   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4429   char mountingblockpiecedownname[100];
4430   char mountingblockpieceupname[100];
4431   for(Int_t i=0; i<fgklayernumber; i++){
4432     ///////////////////////////
4433     // Mounting Block Down Vertex
4434     ///////////////////////////
4435         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4436         snprintf(mountingblockpiecedownname,100,"MountingBlockPieceDownLay%d",i+5);
4437         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4438         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4439                                               + fgkMountingBlockSupportDownHeight 
4440                                               - fgkSSDLadderVerticalDisalignment;
4441         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4442         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4443                                                                                 + fgkSSDMountingBlockHeight[1]
4444                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4445                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4446         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4447         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4448         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4449         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4450         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4451         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4452         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4453         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4454                                                                                 + fgkSSDMountingBlockHeight[2]
4455                                                                                 - fgkSSDMountingBlockHeight[0];
4456         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4457         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4458         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4459         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4460         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4461                                                                                                          mountingblockpiecedownyvertex[i]);
4462         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4463         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4464         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4465                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4466         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4467
4468     ///////////////////////////
4469     // Mounting Block Up Vertex
4470     ///////////////////////////
4471         mountingblockpieceupshape[i] = new TGeoXtru(2);
4472         snprintf(mountingblockpieceupname,100,"MountingBlockPieceUpLay%d",i+5);
4473         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4474         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4475                                                                                 + fgkMountingBlockSupportUpHeight[i]
4476                                               - fgkSSDLadderVerticalDisalignment;
4477         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4478         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4479                                                                                 + fgkSSDMountingBlockHeight[1]
4480                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4481                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4482         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4483         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4484         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4485         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4486         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4487         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4488         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4489         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4490                                                                                 + fgkSSDMountingBlockHeight[2]
4491                                                                                 - fgkSSDMountingBlockHeight[0];
4492         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4493         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4494         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4495         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4496
4497         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4498                                                                                                          mountingblockpieceupyvertex[i]);
4499         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4500         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4501         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4502                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4503         mountingblockpieceup[i]->SetLineColor(fColorG10);
4504  }
4505   ///////////////////////////////////////////////////////////////////
4506   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4507   ///////////////////////////////////////////////////////////////////
4508   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4509   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4510   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4511   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4512   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4513   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4514   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4515   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4516   char mountingblocksupportrapezoidowname[100];
4517   char mountingblocksupportrapezoidupname[100];
4518   Double_t scalefactor = 3./4.;
4519   for(Int_t i=0; i<fgklayernumber; i++){
4520   ////////////////////////////////////////////
4521   // Mounting Block Support Down Trapezoid Vertex 
4522   ////////////////////////////////////////////
4523         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4524         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4525                                                                                                  - mountingsupportedge[i];
4526         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4527         mountingblocksupportrapezoidownxvertex[i][1] = 
4528                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4529         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4530                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4531                                                                                              - mountingblockpiecedownyvertex[i][0]);
4532         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4533         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4534         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4535         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4536         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4537         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4538
4539         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4540                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4541         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4542                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4543         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4544         snprintf(mountingblocksupportrapezoidowname,100,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4545         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4546                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4547         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4548   ////////////////////////////////////////////
4549   // Mounting Block Support Up Trapezoid Vertex 
4550   ////////////////////////////////////////////
4551         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4552         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4553                                                                                                  - mountingsupportedge[i];
4554         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4555         mountingblocksupportrapezoidupxvertex[i][1] = 
4556                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4557         mountingblocksupportrapezoidupyvertex[i][1] = 
4558                                                                                                mountingblockpieceupyvertex[i][0]
4559                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4560                                                                                              - mountingblockpieceupyvertex[i][0]);
4561         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4562         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4563         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4564         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4565         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4566         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4567
4568         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4569                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4570         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4571                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4572         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4573         snprintf(mountingblocksupportrapezoidupname,100,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4574         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4575                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4576         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4577   }
4578   ///////////////////////////////////////////////////////////////////
4579   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4580   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4581   Double_t boxoriginup[fgklayernumber][2][3];
4582   Double_t boxorigindown[fgklayernumber][2][3];
4583   char mountingblocksupportboxdownname[100];
4584   char mountingblocksupportboxupname[100];
4585   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4586   mountingblocksupportrot->SetAngles(90.,180.,-90);
4587   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4588   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4589   TGeoHMatrix* laddersupportmatrix[2];
4590   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4591   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4592   /////////////////////////////////////////////////////////////
4593   // Creating Mother Volume for Containment
4594   /////////////////////////////////////////////////////////////
4595   Double_t *xmothervertex[fgklayernumber];
4596   Double_t *ymothervertex[fgklayernumber];
4597   for(Int_t i=0; i<fgklayernumber; i++){
4598         xmothervertex[i] = new Double_t[8];
4599         ymothervertex[i] = new Double_t[8];
4600   }  
4601   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4602   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4603   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4604   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4605   char upmotheladdersupportname[100];
4606   char downmotheladdersupportname[100];
4607   for(Int_t i=0; i<fgklayernumber; i++){
4608         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4609                                                     -  mountingsupportedge[i];
4610         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4611         xmothervertex[i][1] = xmothervertex[i][0];
4612         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4613                                                         + fgkMountingBlockSupportWidth[0];
4614         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4615         ymothervertex[i][2] = ymothervertex[i][1];
4616         xmothervertex[i][3] = xmothervertex[i][2];
4617         ymothervertex[i][3] = -ymothervertex[i][0];
4618         xmothervertex[i][4] = -xmothervertex[i][0];
4619         ymothervertex[i][4] = ymothervertex[i][3];
4620         xmothervertex[i][5] = xmothervertex[i][4];
4621         ymothervertex[i][5] = -ymothervertex[i][1];
4622         xmothervertex[i][6] = -xmothervertex[i][2];
4623         ymothervertex[i][6] = ymothervertex[i][5];
4624         xmothervertex[i][7] = xmothervertex[i][6];
4625         ymothervertex[i][7] = ymothervertex[i][0];
4626
4627         snprintf(downmotheladdersupportname,100,"LadderSupportDownLay%d",i+5);
4628         snprintf(upmotheladdersupportname,100,"LadderSupportUpLay%d",i+5);
4629
4630         downmotherladdersupportshape[i] = new TGeoXtru(2);
4631         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4632         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4633         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4634                                                                    +                       fgkMountingBlockSupportDownHeight
4635                                                                    +                       fgkSSDMountingBlockHeight[1]
4636                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4637                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4638                                                        - fgkSSDLadderVerticalDisalignment);
4639         
4640 //                                                 - fgkSSDModuleVerticalDisalignment);
4641         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4642
4643         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4644                                                                           downmotherladdersupportshape[i],fSSDAir);
4645     upmotherladdersupportshape[i] = new TGeoXtru(2);
4646         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4647         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4648     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4649                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4650                                                                    +                       fgkSSDMountingBlockHeight[1]
4651                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4652                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4653                                                  - fgkSSDLadderVerticalDisalignment);
4654
4655      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4656                                                                                           upmotherladdersupportshape[i],fSSDAir);
4657   }
4658   for(Int_t i=0; i<fgklayernumber; i++){
4659         /////////////////////////
4660         // Setting the box origin
4661         /////////////////////////
4662         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4663         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4664                                                    +  0.5*fgkMountingBlockSupportDownHeight
4665                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4666         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4667                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4668   
4669         boxorigindown[i][1][0] = 0.0;
4670         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4671         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4672                                                    -      fgkMountingBlockSupportWidth[0]);
4673                                                    
4674         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4675         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4676                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4677                                - 0.5*fgkSSDLadderVerticalDisalignment;
4678         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4679                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4680   
4681         boxoriginup[i][1][0] = 0.0;
4682         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4683         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4684                                                  - fgkMountingBlockSupportWidth[0]);
4685   
4686         /////////////////////////
4687     // Setting the boxes    
4688         /////////////////////////
4689         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4690                                                                                  +  fgkSSDMountingBlockLength[0]),
4691                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4692                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4693                                                                                         boxorigindown[i][0]);
4694         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4695                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4696                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4697                                                                                  -  fgkMountingBlockSupportWidth[0]),
4698                                                                                         boxorigindown[i][1]);
4699                                                                                         
4700         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4701                                                                                  +  fgkSSDMountingBlockLength[0]),
4702                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4703                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4704                                                                                         boxoriginup[i][0]);
4705
4706         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4707                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4708                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4709                                                                      -  fgkMountingBlockSupportWidth[0]),
4710                                                                                         boxoriginup[i][1]);
4711         ///////////////////////////////////////
4712         // Adding the Volumes to Mother Volume    
4713         ///////////////////////////////////////
4714         for(Int_t j=0; j<2; j++){
4715           snprintf(mountingblocksupportboxdownname,100,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4716           snprintf(mountingblocksupportboxupname,100,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4717           mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4718                                                              mountingblocksupportboxdownshape[i][j],
4719                                                              fSSDCarbonFiberMedium);
4720           mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4721                                                            mountingblocksupportboxupshape[i][j],
4722                                                            fSSDCarbonFiberMedium);
4723                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4724                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4725                 for(Int_t k=0; k<2; k++){
4726                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4727                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4728                 }
4729         }
4730         for(Int_t k=0; k<2; k++){
4731                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4732                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4733                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4734                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4735                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4736                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4737                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4738                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4739                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4740                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4741                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4742                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4743         }
4744   }
4745   TList* laddersupportlist = new TList();
4746   laddersupportlist->Add(downmotherladdersupport[0]); 
4747   laddersupportlist->Add(upmotherladdersupport[0]); 
4748   laddersupportlist->Add(downmotherladdersupport[1]); 
4749   laddersupportlist->Add(upmotherladdersupport[1]); 
4750   /////////////////////////////////////////////////////////////
4751   // Deallocating memory
4752   /////////////////////////////////////////////////////////////
4753   for(Int_t i=0; i<fgklayernumber; i++){
4754         for(Int_t j=0; j<nedges+1; j++)
4755                 delete vertex[i][j];
4756         delete mountingsupportedgevector[i];
4757         delete [] vertex[i];
4758         delete vertexlist[i];
4759         delete [] xsidevertex[i];
4760         delete [] ysidevertex[i];
4761         delete [] xcentervertex[i];
4762         delete [] ycentervertex[i];
4763         delete [] xsidelowervertex[i];
4764         delete [] ysidelowervertex[i];
4765         delete [] xcenterlowervertex[i];
4766         delete [] ycenterlowervertex[i];
4767         delete [] xmothervertex[i];
4768         delete [] ymothervertex[i];
4769   }
4770   delete [] xsidevertex;
4771   delete [] ysidevertex;
4772   delete [] xcentervertex;
4773   delete [] ycentervertex;
4774   delete [] xsidelowervertex;
4775   delete [] ysidelowervertex;
4776   delete [] xcenterlowervertex;
4777   delete [] ycenterlowervertex;
4778   delete globalrefladdersupportrot;
4779   delete mountingblocksupportrot;
4780   /////////////////////
4781   return laddersupportlist;     
4782 }
4783  ////////////////////////////////////////////////////////////////////////////////
4784 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4785 //////////////////////////////////////////
4786 // Method Generating Ladder Support Ring
4787 //////////////////////////////////////////
4788   if(!fCreateMaterials) CreateMaterials();
4789   if(!fTransformationMatrices) CreateTransformationMatrices();
4790   if(!fBasicObjects) CreateBasicObjects();
4791   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4792   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4793     const Int_t kssdlayladdernumber[fgklayernumber] = 
4794                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4795   Double_t mountingsupportedge[fgklayernumber];
4796   Double_t mountingblockratio[fgklayernumber];
4797   Double_t theta[fgklayernumber];
4798   Double_t phi[fgklayernumber];
4799   for(Int_t i=0; i<fgklayernumber; i++){
4800         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4801     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4802                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4803                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4804                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4805                                                           / kssdlayladdernumber[i])));
4806     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4807                          / fgkMountingBlockSupportRadius[i]);
4808     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4809   }
4810   TGeoRotation* globalrot = new TGeoRotation();
4811   globalrot->SetAngles(0.,-90.,0.); 
4812   TGeoRotation** laddersupportrot[fgklayernumber];
4813   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
4814   for(Int_t i=0; i<fgklayernumber; i++){                
4815         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
4816         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
4817         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4818                 laddersupportrot[i][j] = new TGeoRotation();
4819                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
4820                 switch(i){
4821                         case 0: //Ladder of Layer5  
4822                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4823                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
4824                                                                             laddersupportmatrix[i][j]); 
4825                         break;
4826                         case 1: //Ladder of Layer6 
4827                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4828                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
4829                                                                               laddersupportmatrix[i][j]); 
4830                         break;
4831                 }
4832     }
4833   }
4834   /////////////////////////////////////////////////////////////
4835   // Creating Lower Ladder Support 
4836   /////////////////////////////////////////////////////////////
4837   TVector3** ringsupportvertex[fgklayernumber];         
4838   Double_t angle = 360./nedges;
4839   for(Int_t i=0; i<fgklayernumber; i++){
4840     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
4841         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
4842                                                         *                          TMath::Cos(theta[i]));
4843         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
4844                                                         -                          mountingsupportedge[i],
4845                                                                                    ringsupportvertex[i][0]->Y());
4846         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
4847                                                                                    ringsupportvertex[i][1]->Y());                                                                               
4848     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
4849         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
4850            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
4851            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
4852            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
4853            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
4854         }
4855         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
4856     for(Int_t j=0; j<nedges+1; j++){
4857                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
4858                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*CosD(90.0-j*angle),
4859                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*SinD(90.0-j*angle));
4860         }
4861   }
4862   Double_t **xmothervertex = new Double_t*[fgklayernumber];
4863   Double_t **ymothervertex = new Double_t*[fgklayernumber];
4864   for(Int_t i=0; i<fgklayernumber; i++){
4865         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4866         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4867         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
4868                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
4869                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
4870         }
4871   }
4872 ////////////////////////////////////////////////////////////////////////////////
4873 // Start Corrections 13/06/08
4874 ////////////////////////////////////////////////////////////////////////////////
4875   char lowerladderpconsupportname[100];
4876   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
4877   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
4878   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
4879   Double_t lowerladderpconradiusmax[fgklayernumber];
4880   Double_t lowerladderpconradiusmin[fgklayernumber];
4881   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4882   lowerladdersupportrot->SetAngles(90.,180.,-90);
4883   for(Int_t i=0; i<fgklayernumber; i++){
4884         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
4885                                                                 *                          TMath::Cos(theta[i]);
4886     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeight;
4887   } 
4888   for(Int_t i=0; i<fgklayernumber; i++){
4889 ///////////////////////////  Modified Version ?///////////////////
4890     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
4891         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
4892                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
4893                                                          lowerladderpconradiusmax[i]);
4894         snprintf(lowerladderpconsupportname,100,"LowerLadderPConSupportNameLay%d",i+5);
4895         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
4896     lowerladderpconsupport[i]->SetLineColor(fColorAl);
4897         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
4898         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
4899  }
4900 ////////////////////////////////////////////////////////////////////////////////
4901 // End Corrections 13/06/08
4902 ////////////////////////////////////////////////////////////////////////////////
4903   /*char lowerladdersupportname[30];
4904   TGeoXtru* lowerladdersupportshape[fgklayernumber];
4905   TGeoVolume* lowerladdersupport[fgklayernumber];
4906   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4907   lowerladdersupportrot->SetAngles(90.,180.,-90);
4908   for(Int_t i=0; i<fgklayernumber; i++){
4909         lowerladdersupportshape[i] = new TGeoXtru(2);
4910         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
4911                                                                                           xmothervertex[i],ymothervertex[i]);
4912         lowerladdersupportshape[i]->DefineSection(0,0.);
4913     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4914         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
4915     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
4916                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
4917         lowerladdersupport[i]->SetLineColor(fColorAl);
4918         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
4919         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
4920   }*/
4921   /////////////////////////////////////////////////////////////
4922   // Deallocating memory
4923   /////////////////////////////////////////////////////////////
4924   for(Int_t i=0; i<fgklayernumber; i++){
4925         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
4926                 delete ringsupportvertex[i][j];
4927         delete [] ringsupportvertex[i];
4928   }
4929   for(Int_t i=0; i<fgklayernumber; i++){
4930         delete [] xmothervertex[i];
4931         delete [] ymothervertex[i];
4932   }
4933   delete [] xmothervertex;
4934   delete [] ymothervertex; 
4935   delete globalrot;
4936   for(Int_t i=0; i<fgklayernumber; i++){
4937         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
4938                 delete laddersupportrot[i][j];
4939         delete [] laddersupportrot[i];
4940   }
4941  }  
4942  ////////////////////////////////////////////////////////////////////////////////
4943  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
4944   /////////////////////////////////////////////////////////////
4945   // Method generating Endcap CoverPlate
4946   /////////////////////////////////////////////////////////////
4947   // Holes Definition 
4948   ///////////////////
4949   Int_t nendcapcoverplateholedges = 30;
4950   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
4951   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
4952                                                           0.5*fgkEndCapCoverPlateThickness};
4953   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
4954                                                                                                               nendcapcoverplateholedges,holesection);
4955   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
4956                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
4957   endcapcoverplatesmallhole->SetLineColor(6);
4958   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
4959                                                                                                               nendcapcoverplateholedges,holesection);
4960   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
4961                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
4962   endcapcoverplatebighole->SetLineColor(6);
4963   //////////////////////////
4964   // Screw Piece Definition 
4965   //////////////////////////
4966   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
4967   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
4968                                                                                                       CosD(0.5*smallscrewangle),
4969                                                                                                       0.5*fgkEndCapCoverPlateThickness);
4970   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
4971                                                                                                 endcapsmallscrewpieceshape,
4972                                                                                                 fSSDCoolingTubePhynox);
4973   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
4974   ///////////////////
4975   // Box Definition 
4976   ///////////////////
4977   TGeoBBox* endcapcoverplateboxshape[4];
4978   TGeoVolume* endcapcoverplatebox[4];
4979   Double_t boxorigin[5][3];
4980   boxorigin[0][0] = 0.;
4981   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
4982   boxorigin[0][2] = 0.;
4983
4984   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
4985   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
4986   boxorigin[1][2] = 0.;
4987
4988   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
4989                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
4990   boxorigin[2][1] = boxorigin[1][1];
4991   boxorigin[2][2] = 0.;
4992
4993   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
4994                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
4995   boxorigin[3][1] = boxorigin[1][1];
4996   boxorigin[3][2] = 0.;
4997
4998   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4999                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5000                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5001                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5002
5003   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5004                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5005                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5006                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5007                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5008
5009   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5010                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5011                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5012                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5013                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5014
5015   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5016                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5017                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5018                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5019                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5020   
5021   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5022                                                                            fSSDAlCoolBlockMedium);
5023   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5024                                                                            fSSDAlCoolBlockMedium);
5025   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5026                                                                            fSSDAlCoolBlockMedium);
5027   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5028                                                                            fSSDAlCoolBlockMedium);
5029   endcapcoverplatebox[0]->SetLineColor(6);
5030   endcapcoverplatebox[1]->SetLineColor(6);
5031   endcapcoverplatebox[2]->SetLineColor(6);
5032   endcapcoverplatebox[3]->SetLineColor(6);
5033   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5034   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5035                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5036                                                                                         0.5*fgkEndCapCoverPlateThickness,
5037                                                                                         endcapfillingboxorigin);
5038   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5039                                                                            fSSDAlCoolBlockMedium);
5040   endcapfillingbox->SetLineColor(6);
5041   ////////////////////////////
5042   // Contour shape Definition 
5043   ////////////////////////////
5044   const Int_t kcontourvertexnumber = 10;
5045   Double_t xcontourvertex[kcontourvertexnumber];
5046   Double_t ycontourvertex[kcontourvertexnumber];
5047   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5048   xcontourvertex[1] = xcontourvertex[0];
5049   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5050   xcontourvertex[3] = xcontourvertex[2];
5051   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5052   xcontourvertex[5] = xcontourvertex[4];
5053   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5054   xcontourvertex[7] = xcontourvertex[6];
5055   xcontourvertex[8] = xcontourvertex[4];
5056   xcontourvertex[9] = xcontourvertex[8];
5057   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5058                                         - (kendcapcoverplatesmallholenumber[1]-1)
5059                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5060   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5061                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5062   ycontourvertex[2] = ycontourvertex[1];
5063   ycontourvertex[3] = ycontourvertex[0];
5064   ycontourvertex[4] = ycontourvertex[3];
5065   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5066   ycontourvertex[6] = ycontourvertex[5];
5067   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5068                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5069                                         + fgkEndCapCoverPlateSmallHoleRadius;
5070   ycontourvertex[8] = ycontourvertex[7];
5071   ycontourvertex[9] = ycontourvertex[0];
5072
5073   Double_t xboxin, dxboxin, yboxin, dyboxin;
5074   Double_t xboxout, dxboxout, yboxout, dyboxout;
5075   Double_t coordmin, coordmax;
5076   coordmin = -fgkEndCapCoverPlateLength[0];
5077   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5078   xboxout = 0.5*(coordmin+coordmax);
5079   dxboxout = 0.5*(coordmax-coordmin);
5080   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5081                                         - (kendcapcoverplatesmallholenumber[1]-1)
5082                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5083   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5084                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5085   yboxout = 0.5*(coordmin+coordmax);
5086   dyboxout = 0.5*(coordmax-coordmin);
5087   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5088   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5089   xboxin = 0.5*(coordmin+coordmax);
5090   dxboxin = 0.5*(coordmax-coordmin);
5091   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5092   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5093                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5094                                         + fgkEndCapCoverPlateSmallHoleRadius;
5095   yboxin = 0.5*(coordmin+coordmax);
5096   dyboxin = 0.5*(coordmax-coordmin);
5097   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5098   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5099                                                          xboxout, yboxout, 0.);
5100   trendCapCoverPlateContourboxout->RegisterYourself();
5101   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5102   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5103                                                          xboxin, yboxin, 0.);
5104   trendCapCoverPlateContourboxin->RegisterYourself();
5105   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5106         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5107
5108   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5109                                                                            fSSDAlCoolBlockMedium);
5110   contour->SetLineColor(6);
5111   /////////////////////////////
5112   // Hole Contour Shape Definition 
5113   ////////////////////////////
5114   coordmin = xcontourvertex[0];
5115   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5116   xboxout = 0.5*(coordmin+coordmax);
5117   dxboxout = 0.5*(coordmax-coordmin);
5118   coordmin = ycontourvertex[1];
5119   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5120   yboxout = 0.5*(coordmin+coordmax);
5121   dyboxout = 0.5*(coordmax-coordmin);
5122   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5123                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5124   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5125   xboxin = 0.5*(coordmin+coordmax);
5126   dxboxin = 0.5*(coordmax-coordmin);
5127   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5128                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5129   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5130   yboxin = 0.5*(coordmin+coordmax);
5131   dyboxin = 0.5*(coordmax-coordmin);
5132   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5133   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5134                                                          xboxout, yboxout, 0.);
5135   trendCapCoverPlateContourboxout1->RegisterYourself();
5136   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5137   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5138                                                          xboxin, yboxin, 0.);
5139   trendCapCoverPlateContourboxin1->RegisterYourself();
5140   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5141         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5142
5143
5144   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5145   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5146   xboxout = 0.5*(coordmin+coordmax);
5147   dxboxout = 0.5*(coordmax-coordmin);
5148   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5149                                                    - fgkEndCapCoverPlateWidth[0]);
5150   coordmax = ycontourvertex[0];
5151   yboxout = 0.5*(coordmin+coordmax);
5152   dyboxout = 0.5*(coordmax-coordmin);
5153   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5154                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5155   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5156   xboxin = 0.5*(coordmin+coordmax);
5157   dxboxin = 0.5*(coordmax-coordmin);
5158   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5159                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5160                                                    - fgkEndCapCoverPlateWidth[0]
5161                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5162   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5163   yboxin = 0.5*(coordmin+coordmax);
5164   dyboxin = 0.5*(coordmax-coordmin);
5165   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5166   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5167                                                          xboxout, yboxout, 0.);
5168   trendCapCoverPlateContourboxout2->RegisterYourself();
5169   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5170   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5171                                                          xboxin, yboxin, 0.);
5172   trendCapCoverPlateContourboxin2->RegisterYourself();
5173   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5174         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5175   
5176 //  const Int_t kholecontourvertexnumber = 10;
5177
5178   Double_t xholecontourvertex[2][kcontourvertexnumber];
5179   Double_t yholecontourvertex[2][kcontourvertexnumber];
5180   xholecontourvertex[0][0] = xcontourvertex[0];
5181   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5182   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5183   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5184   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5185                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5186                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5187   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5188   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5189                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5190   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5191   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5192   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5193   
5194   yholecontourvertex[0][0] = ycontourvertex[1];
5195   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5196   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5197   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5198   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5199   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5200                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5201   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5202   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5203   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5204   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5205
5206   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5207   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5208   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5209   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5210   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5211                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5212                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5213   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5214   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5215                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5216   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5217   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5218   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5219   
5220   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5221                                                    - fgkEndCapCoverPlateWidth[0]);
5222   yholecontourvertex[1][1] = ycontourvertex[0];
5223   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5224   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5225   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5226   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5227                                                    - fgkEndCapCoverPlateWidth[0]
5228                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5229   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5230   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5231   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5232   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5233
5234   TGeoVolume* holecontour[2];
5235   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5236                                                                   fSSDAlCoolBlockMedium);
5237   holecontour[0]->SetLineColor(6);
5238   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5239                                                                   fSSDAlCoolBlockMedium);
5240   holecontour[1]->SetLineColor(6);
5241   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5242                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5243   TGeoTranslation*  bigholetrans[3];
5244   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5245                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5246   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5247                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5248                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5249   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5250                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5251   /////////////////////////////////
5252   // Mother Volume Xtru Definition 
5253   /////////////////////////////////
5254   const Int_t kmothervertexnumber = 12;
5255   Double_t xmothervertex[kmothervertexnumber];  
5256   Double_t ymothervertex[kmothervertexnumber];  
5257   xmothervertex[0]  = xcontourvertex[0];
5258   xmothervertex[1]  = xmothervertex[0];
5259   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5260   xmothervertex[3]  = xmothervertex[2];
5261   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5262   xmothervertex[5]  = xmothervertex[4];
5263   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5264   xmothervertex[7]  = xmothervertex[6];
5265   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5266                                         + fgkEndCapCoverPlateLength[2]; 
5267   xmothervertex[9]  = xmothervertex[8];
5268   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5269   xmothervertex[11] = xmothervertex[10];
5270   
5271   ymothervertex[0]  = ycontourvertex[0];
5272   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5273   ymothervertex[2]  = ymothervertex[1];
5274   ymothervertex[3]  = ycontourvertex[1];
5275   ymothervertex[4]  = ymothervertex[3];
5276   ymothervertex[5]  = ymothervertex[1];
5277   ymothervertex[6]  = ymothervertex[5];
5278   ymothervertex[7]  = ymothervertex[0];
5279   ymothervertex[8]  = ymothervertex[7];
5280   ymothervertex[9]  = ymothervertex[8]
5281                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5282   ymothervertex[10] = ymothervertex[9];
5283   ymothervertex[11] = ymothervertex[8];
5284   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5285   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5286   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5287   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5288   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5289   ////////////////////////////////////////
5290   // Adding Nodes
5291   ////////////////////////////////////////
5292 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5293   TGeoTranslation*** endcapcoverplatesmallholetrans;
5294   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5295   Double_t transx[4] = {0,
5296                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5297                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5298                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5299                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5300                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5301   Int_t index = 0;
5302   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5303         endcapcoverplatesmallholetrans[i] = 
5304                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5305     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5306                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5307             endcapcoverplatesmallholetrans[i][j] = 
5308                 new TGeoTranslation(transx[i],
5309                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5310             if(index!=10){ 
5311                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5312                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5313                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5314                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5315                 }
5316                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5317                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5318                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5319     }
5320   }
5321   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5322   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5323   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5324   mothercoverplate->AddNode(endcapfillingbox,1);
5325   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5326   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5327   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5328   mothercoverplate->AddNode(holecontour[0],1);
5329   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5330   mothercoverplate->AddNode(holecontour[1],1);  
5331   mothercoverplate->AddNode(contour,1);
5332   
5333   for (Int_t i = 0; i < kendcapcoverplatesmallholenumber[0]; i++) 
5334     delete [] endcapcoverplatesmallholetrans[i];
5335   delete [] endcapcoverplatesmallholetrans;
5336   /////////////////////////////////
5337   return mothercoverplate;      
5338  }
5339  ////////////////////////////////////////////////////////////////////////////////
5340  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5341   /////////////////////////////////////////////////////////////
5342   // Getting EndCap Cooling Tube 
5343   /////////////////////////////////////////////////////////////
5344   TGeoTorus* endcapcoolingtubetorushape[5];
5345   TGeoVolume* endcapcoolingtubetorus[5];
5346   TGeoTube* endcapcoolingtubeshape[4];
5347   TGeoVolume* endcapcoolingtube[4];
5348   char endcapcoolingtubetorusname[100];
5349   char endcapcoolingtubename[100];
5350   TGeoTorus* endcapcoolingwatertubetorushape[5];
5351   TGeoVolume* endcapcoolingwatertubetorus[5];
5352   TGeoTube* endcapcoolingwatertubeshape[4];
5353   TGeoVolume* endcapcoolingwatertube[4];
5354   char endcapcoolingwatertubetorusname[100];
5355   char endcapcoolingwatertubename[100];
5356   for(Int_t i=0; i<5; i++){
5357     snprintf(endcapcoolingtubetorusname,100,"EndCapCoolingTubeTorus%d",i+1);
5358     snprintf(endcapcoolingtubename,100,"EndCapCoolingTube%d",i+1);
5359     snprintf(endcapcoolingwatertubetorusname,100,"EndCapCoolingWaterTubeTorus%d",i+1);
5360     snprintf(endcapcoolingwatertubename,100,"EndCapCoolingWaterTube%d",i+1);
5361     if(i==3){
5362       endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5363                                                     fgkEndCapCoolingTubeRadiusMin,
5364                                                     fgkEndCapCoolingTubeRadiusMax,
5365                                                     90.0,fgkEndCapCoolingTubeAngle[3]);
5366       endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5367                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5368                                                          90.0,fgkEndCapCoolingTubeAngle[3]);
5369     }
5370     else{
5371       endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5372                                                     :fgkEndCapCoolingTubeAxialRadius[1],
5373                                                     fgkEndCapCoolingTubeRadiusMin,
5374                                                     fgkEndCapCoolingTubeRadiusMax,
5375                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5376       endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5377                                                          :fgkEndCapCoolingTubeAxialRadius[1],
5378                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5379                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5380     }
5381         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5382                                                                                            endcapcoolingtubetorushape[i],
5383                                                                                            fSSDCoolingTubePhynox);
5384         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5385                                                                                                         endcapcoolingwatertubetorushape[i],
5386                                                                                                         fSSDCoolingTubeWater);
5387     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5388     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5389     if(i<4){
5390                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5391                                                                   fgkEndCapCoolingTubeRadiusMax,
5392                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5393                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5394                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5395         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5396                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5397         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5398                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5399                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5400                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5401         }
5402   }
5403   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5404   /////////////////////////////////////////
5405   // Transformation for Volume Positioning 
5406   /////////////////////////////////////////
5407   TGeoCombiTrans* coolingtubecombitrans[6];
5408   TGeoRotation* coolingtuberot[8];
5409   TGeoTranslation* coolingtubetrans[6];
5410   TGeoHMatrix* coolingtubematrix[4];
5411   TGeoCombiTrans* torustubecombitrans[4];
5412   TGeoRotation* torustuberot[7];
5413   TGeoTranslation* torustubetrans[4];
5414   TGeoHMatrix* torustubematrix[5];
5415   TGeoCombiTrans* coolingwatertubecombitrans[6];
5416   TGeoRotation* coolingwatertuberot[8];
5417   TGeoTranslation* coolingwatertubetrans[6];
5418   TGeoHMatrix* coolingwatertubematrix[4];
5419   TGeoCombiTrans* toruswatertubecombitrans[4];
5420   TGeoRotation* toruswatertuberot[7];
5421   TGeoTranslation* toruswatertubetrans[4];
5422   TGeoHMatrix* toruswatertubematrix[5];
5423   for(Int_t i=0; i<8; i++){
5424     if(i<6){
5425          coolingtubetrans[i] = new TGeoTranslation();
5426          coolingwatertubetrans[i] = new TGeoTranslation();
5427     }
5428     if(i<8){
5429          coolingtuberot[i] = new TGeoRotation();
5430          coolingwatertuberot[i] = new TGeoRotation();
5431     }
5432     if(i<4){
5433          torustubetrans[i] = new TGeoTranslation();
5434          toruswatertubetrans[i] = new TGeoTranslation();
5435     }
5436     if(i<7){
5437          torustuberot[i] = new TGeoRotation();
5438          toruswatertuberot[i] = new TGeoRotation();
5439         }
5440   }
5441   /////////////////////////////////////////
5442   // Transformation for Inox Volume Positioning 
5443   /////////////////////////////////////////
5444   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5445                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5446   coolingtuberot[0]->SetAngles(0.,90.,0.);
5447   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5448                                                                                                 *coolingtuberot[0]);
5449                                                                                                 
5450   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5451   coolingtuberot[1]->SetAngles(0.,90.,0.);
5452   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5453                                                                                                 *coolingtuberot[1]);
5454
5455   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5456                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5457                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5458                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5459                                                                           0.);
5460   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5461   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5462                                                                                                 *coolingtuberot[2]);
5463
5464   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5465                                            *                             (*coolingtubecombitrans[1]));
5466
5467   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5468                                                                          endcapcoolingtubeshape[1]->GetDz());
5469   torustuberot[0]->SetAngles(0.,90.,0.); 
5470   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5471
5472   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5473
5474   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5475                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5476   coolingtuberot[3]->SetAngles(0.,90.,0.);
5477   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5478                                                                                                 *coolingtuberot[3]);
5479   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5480   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5481   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5482   
5483   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5484                                                                         endcapcoolingtubeshape[2]->GetDz());
5485   torustuberot[1]->SetAngles(0.,90.,0.); 
5486   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5487   torustuberot[2]->SetAngles(180.,0.,0.); 
5488   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5489   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5490
5491   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5492                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5493   torustuberot[3]->SetAngles(0.,90.,0.); 
5494   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5495   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5496   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5497   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5498
5499   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5500                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5501   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5502   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5503                                                                                                 *coolingtuberot[5]);
5504   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5505   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5506   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5507   
5508   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5509                                                                         endcapcoolingtubeshape[0]->GetDz());
5510   torustuberot[5]->SetAngles(0.,90.,0.); 
5511   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5512   torustuberot[6]->SetAngles(-90.,0.,0.); 
5513   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5514   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5515   
5516   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5517                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5518   coolingtuberot[6]->SetAngles(0.,90.,0.);
5519   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5520                                                                                                 *coolingtuberot[6]);
5521   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5522   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5523   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5524     /////////////////////////////////////////
5525   // Transformation for Water Volume Positioning 
5526   /////////////////////////////////////////
5527   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5528                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5529   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5530   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5531                                                                                                      *coolingwatertuberot[0]);
5532
5533   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5534   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5535   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5536                                                                                                      *coolingwatertuberot[1]);
5537
5538   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5539                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5540                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5541                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5542                                                                               0.);
5543   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5544   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5545                                                                                                     *coolingwatertuberot[2]);
5546
5547   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5548                                            *                                 (*coolingwatertubecombitrans[1]));
5549                                            
5550   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5551                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5552   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5553   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5554                                                                                                    *toruswatertuberot[0]);
5555
5556   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5557                                                   *                                     (*toruswatertubecombitrans[0]));
5558
5559   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5560                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5561   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5562   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5563                                                                                                      *coolingwatertuberot[3]);
5564   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5565   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5566                                                         *                                 (*coolingwatertubecombitrans[3]));
5567   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5568
5569   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5570                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5571   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5572   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5573                                                                                                    *toruswatertuberot[1]);
5574   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5575   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5576                                                   *                 (*toruswatertubecombitrans[1]));
5577   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5578   
5579   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5580                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5581   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5582   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5583                                                                                                    *toruswatertuberot[3]);
5584   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5585   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5586                                                   *                                     (*toruswatertubecombitrans[2]));
5587   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5588
5589   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5590                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5591   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5592   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5593                                                                                                      *coolingwatertuberot[5]);
5594   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5595   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5596                                                         *                                 (*coolingwatertubecombitrans[4]));
5597   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5598   
5599   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5600                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5601   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5602   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5603                                                                                                    *toruswatertuberot[5]);
5604   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5605   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5606                                                   *                 (*toruswatertubecombitrans[3]));
5607   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5608   
5609   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5610                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5611   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5612   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5613                                                                                                      *coolingwatertuberot[6]);
5614   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5615   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5616                                                         *                                 (*coolingwatertubecombitrans[5]));
5617   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5618   /////////////////////////////////////////
5619   // Positioning Volumes
5620   /////////////////////////////////////////
5621   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5622   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5623   
5624   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5625   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5626
5627   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5628   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5629  
5630   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5631   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5632
5633   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5634   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5635
5636   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5637   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5638
5639   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5640   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5641
5642   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5643   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5644   
5645   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5646   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5647  
5648   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5649   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5650   /////////////////////////////////////////////////////////////
5651   // Deallocating memory
5652   /////////////////////////////////////////////////////////////
5653   for(Int_t i=0; i<8; i++){
5654     if(i<6){
5655          delete coolingtubetrans[i];
5656          delete coolingwatertubetrans[i];
5657          if(i!=0){
5658           delete coolingtubecombitrans[i];
5659           delete coolingwatertubecombitrans[i];
5660          }
5661         }
5662     if(i<8){
5663           delete coolingtuberot[i];
5664           delete coolingwatertuberot[i];
5665     }
5666     if(i<4){
5667                 delete torustubetrans[i];
5668                 delete toruswatertubetrans[i];
5669                 delete torustubecombitrans[i];
5670                 delete toruswatertubecombitrans[i];
5671         } 
5672     if(i<7){
5673          delete torustuberot[i];
5674          delete toruswatertuberot[i];
5675         }
5676   }
5677   /////////////////////////////////////////////////////////////
5678   return endcapcoolingtubemother;
5679  }
5680  ////////////////////////////////////////////////////////////////////////////////
5681  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5682   /////////////////////////////////////////////////////////////
5683   // Getting EndCap Cover Side 
5684   /////////////////////////////////////////////////////////////
5685   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5686   const Int_t kvertexnumber = 15; 
5687   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5688   xvertex[0]  = 0.0;
5689   xvertex[1]  = xvertex[0];
5690   xvertex[2]  = fgkEndCapSideCoverLength[0];
5691   xvertex[3]  = fgkEndCapSideCoverLength[1];
5692   xvertex[4]  = xvertex[3];
5693   xvertex[5]  = fgkEndCapSideCoverLength[2];
5694   xvertex[6]  = xvertex[5];
5695   xvertex[7]  = xvertex[2];
5696   xvertex[8]  = xvertex[7];
5697   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5698   xvertex[10] = xvertex[9];
5699   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5700                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5701                           * fgkEndCapSideCoverLength[4];
5702   xvertex[12] = xvertex[11];
5703   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5704                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5705                           * fgkEndCapSideCoverLength[4];
5706   xvertex[14] = xvertex[13];
5707   yvertex[0]  = 0.0;
5708   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5709   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5710   yvertex[3]  = yvertex[2];
5711   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5712   yvertex[5]  = yvertex[4];
5713   yvertex[6]  = yvertex[0];
5714   yvertex[7]  = yvertex[6];
5715   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5716   yvertex[9]  = yvertex[8];
5717   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5718   yvertex[11] = yvertex[10];
5719   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5720   yvertex[13] = yvertex[12];
5721   yvertex[14] = yvertex[6];
5722   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5723   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5724   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5725   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5726   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5727   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5728   endcapsidecovershapein->SetName("endcapsidecovershapein");
5729   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5730   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5731   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5732
5733
5734   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5735   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5736                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5737   endcapsidecover->SetLineColor(fColorPhynox);
5738   ////////////////////////////////////////////
5739   // Defininition of Mother Volume
5740   ////////////////////////////////////////////
5741   const Int_t kmothervertexnumber = 7;
5742   Double_t xmothervertex[kmothervertexnumber]; 
5743   Double_t ymothervertex[kmothervertexnumber]; 
5744   for(Int_t i=0; i<kmothervertexnumber; i++){
5745         xmothervertex[i] = xvertex[i];
5746         ymothervertex[i] = yvertex[i];
5747   }
5748   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5749   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5750   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5751   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5752   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5753                                                                 endcapsidecovermothershape,fSSDAir);
5754   ////////////////////////////////////////////
5755   endcapsidecovermother->AddNode(endcapsidecover,1);
5756   TGeoBBox* endcapsidecoverboxshape[4];
5757   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5758                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5759                                                                0.5*fgkEndCapSideCoverLength[4],
5760                                                                    0.5*fgkEndCapSideCoverThickness); 
5761   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5762                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5763                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5764                                                          -     fgkEndCapSideCoverLength[4]),
5765                                                                    0.5*fgkEndCapSideCoverThickness); 
5766   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5767                                                                0.5*fgkEndCapSideCoverLength[4],
5768                                                                    0.5*fgkEndCapSideCoverThickness); 
5769   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5770                                                                0.5*fgkEndCapSideCoverWidth[5],
5771                                                                    0.5*fgkEndCapSideCoverThickness); 
5772   TGeoVolume* endcapsidecoverbox[4];
5773   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5774   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5775   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5776   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5777   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5778 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5779   TGeoTranslation** endcapsidecoverboxtrans;
5780   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5781   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5782                                                          +                                         fgkEndCapSideCoverLength[0],
5783                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5784                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5785   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5786                                                          +                     xvertex[11],
5787                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5788                                                          +                     yvertex[12],0.);
5789   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5790                                                          +                     xvertex[11],
5791                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5792                                                          +                     yvertex[12]
5793                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5794                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5795   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5796   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5797   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5798   for(Int_t i=0; i<2; i++)
5799         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5800                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5801                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5802                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5803                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5804                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5805                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5806                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5807         }
5808   for(Int_t i=0; i<2; i++)
5809         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5810                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5811                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5812                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5813                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5814                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5815                                                         +fgkEndCapSideCoverLength[4]),0.0);
5816                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5817                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5818                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5819                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5820         }
5821         return endcapsidecovermother;
5822  } 
5823  ////////////////////////////////////////////////////////////////////////////////
5824  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5825  ////////////////////////////////////////////////////////////////////////////////
5826  // Method returning Interface Card A, Interface Card B, Supply Card 
5827  ////////////////////////////////////////////////////////////////////////////////
5828  /////////////////////
5829  // Supply Card
5830  /////////////////////
5831  // Electronic Board Back Al Plane
5832  const Int_t kelectboardbackvertexnumber = 8;
5833  Double_t xelectboardback[kelectboardbackvertexnumber];
5834  Double_t yelectboardback[kelectboardbackvertexnumber];
5835  xelectboardback[0] = 0.0;
5836  xelectboardback[1] = xelectboardback[0];
5837  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5838  xelectboardback[3] = xelectboardback[2];
5839  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5840  xelectboardback[5] = xelectboardback[4];
5841  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5842  xelectboardback[7] = xelectboardback[6];
5843  
5844  yelectboardback[0] = 0.0;
5845  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5846  yelectboardback[2] = yelectboardback[1];
5847  yelectboardback[3] = yelectboardback[0];
5848  yelectboardback[4] = yelectboardback[3];
5849  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5850  yelectboardback[6] = yelectboardback[5];
5851  yelectboardback[7] = yelectboardback[4];
5852  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5853  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5854                                                                         xelectboardback,yelectboardback); 
5855  electboardbackshape->DefineSection(0,0.0);
5856  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5857  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5858                                                                                          electboardbackshape,fSSDSupportRingAl);
5859  electboardback->SetLineColor(fColorAl);
5860  // Electronic Board Kapton Layer
5861  const Int_t kelectlayervertexnumber = 8;
5862  Double_t xelectlayer[kelectlayervertexnumber];
5863  Double_t yelectlayer[kelectlayervertexnumber];
5864  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5865  xelectlayer[1] = xelectlayer[0];
5866  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5867  xelectlayer[3] = xelectlayer[2];
5868  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5869      
5870  yelectlayer[0] = 0.0;
5871  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5872  yelectlayer[2] = yelectlayer[1];
5873  yelectlayer[3] = yelectlayer[0];
5874  yelectlayer[4] = yelectlayer[3];
5875  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5876  yelectlayer[6] = yelectlayer[5];
5877  yelectlayer[7] = yelectlayer[4];
5878  TGeoXtru* electlayershape = new TGeoXtru(2);
5879  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5880  electlayershape->DefineSection(0,0.0);
5881  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5882  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5883                                                                                          electlayershape,fSSDKaptonFlexMedium);
5884  electlayer->SetLineColor(fColorKapton);
5885  // JMD Connector Female
5886  const Int_t kjmdconnectorvertexnumber = 6;
5887  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5888  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5889  xjmdconnectorvertex[0] = 0.0; 
5890  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5891  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5892  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5893  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5894  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5895
5896  yjmdconnectorvertex[0] = 0.0; 
5897  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5898  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5899  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5900  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5901  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5902  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5903  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5904                                                                   yjmdconnectorvertex); 
5905  jmdconnectorshape->DefineSection(0,0.0);
5906  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
5907  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
5908                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
5909  jmdconnector->SetLineColor(fColorG10);
5910  // Top Cable Connector
5911  const Int_t kcableconnectorvertexnumber = 8;
5912  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
5913  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
5914  xconnectorvertex[0] = 0.0;
5915  xconnectorvertex[1] = xconnectorvertex[0];
5916  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
5917  xconnectorvertex[3] = xconnectorvertex[2];
5918  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
5919                                          - fgkEndCapCardCableConnectorLength[2];
5920  xconnectorvertex[5] = xconnectorvertex[4];
5921  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
5922  xconnectorvertex[7] = xconnectorvertex[6];
5923
5924  yconnectorvertex[0] = 0.0;
5925  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
5926  yconnectorvertex[2] = yconnectorvertex[1];
5927  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
5928  yconnectorvertex[4] = yconnectorvertex[3];
5929  yconnectorvertex[5] = yconnectorvertex[1];
5930  yconnectorvertex[6] = yconnectorvertex[5];
5931  yconnectorvertex[7] = yconnectorvertex[0];
5932  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
5933  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
5934                                                                     yconnectorvertex); 
5935  cableconnectorshape->DefineSection(0,0.0);
5936  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
5937  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
5938                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
5939  cableconnector->SetLineColor(fColorG10);
5940  // Strip Connection
5941  TGeoBBox* endcapstripconnectionshape = 
5942                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
5943                                                                                          0.5*fgkEndCapStripConnectionThickness,
5944                                                                                          0.5*fgkEndCapStripConnectionWidth);
5945  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
5946                                                                                                         endcapstripconnectionshape,
5947                                                                                                         fSSDSupportRingAl);
5948  endcapstripconnection->SetLineColor(fColorAl);
5949  // Interface Card B
5950  const Int_t kcardBvertexnumber = 12; 
5951  Double_t xcardBvertexnumber[kcardBvertexnumber];
5952  Double_t ycardBvertexnumber[kcardBvertexnumber];
5953
5954  xcardBvertexnumber[0]  = 0.0;
5955  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
5956  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
5957  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
5958  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
5959  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
5960  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
5961  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
5962  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
5963  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
5964  xcardBvertexnumber[10] = xcardBvertexnumber[7];
5965  xcardBvertexnumber[11] = xcardBvertexnumber[10];
5966  
5967  ycardBvertexnumber[0]  = 0.0;
5968  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
5969  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
5970  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
5971  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
5972  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
5973  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
5974  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
5975  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
5976  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
5977  ycardBvertexnumber[10] = ycardBvertexnumber[9];
5978  ycardBvertexnumber[11] = ycardBvertexnumber[0];
5979
5980  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
5981  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
5982  interfacecardBshape->DefineSection(0,0.);
5983  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
5984  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
5985                                                                                          fSSDMountingBlockMedium);
5986  interfacecardB->SetLineColor(46);
5987  // Interface Card B Electronic Board
5988  const Int_t kelectboardcardBvertexnumber = 14; 
5989  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
5990  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
5991
5992  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
5993  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
5994  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
5995  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
5996  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
5997  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
5998  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
5999  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6000  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6001  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6002  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6003  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6004  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6005  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6006
6007  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6008  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6009  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6010  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6011  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6012  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6013  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6014  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6015  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6016  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6017  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6018  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6019  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6020  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6021
6022  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6023  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6024                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6025  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6026  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6027                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6028  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6029                                                                                           fSSDSupportRingAl);
6030  electboardcardB->SetLineColor(fColorAl);
6031  // Generating Stiffener 2
6032  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6033                                                                                            0.5*fgkEndCapStiffenerThickness,
6034                                                                                            0.5*fgkEndCapStiffenerLength);
6035  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6036  endcapstiffener->SetLineColor(fColorAl);   
6037  // Generating Mother Interface Card B Container
6038  const Int_t kinterfacecardBmothervertexnumber = 10;
6039  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6040  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6041
6042  xinterfacecardBmothervertex[0] = 0.0;
6043  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6044  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6045                                                                 + fgkEndCapInterfaceCardBThickness;
6046  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6047  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6048                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6049  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6050  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6051  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6052  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6053                                                                 + fgkEndCapCardJMDConnectorLength[0];
6054  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6055
6056  yinterfacecardBmothervertex[0] = 0.0;
6057  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6058                                                                 + fgkEndCapInterfaceCardBWidth[1]
6059                                                                 + fgkEndCapInterfaceCardBWidth[2];
6060  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6061  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6062  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6063  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6064  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6065  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6066                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6067                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6068  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6069  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6070  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6071  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6072                                                                                   xinterfacecardBmothervertex,
6073                                                                                   yinterfacecardBmothervertex);
6074  interfacecardBmothershape->DefineSection(0,-1.e-15);
6075  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6076  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6077                                                                                                    interfacecardBmothershape,fSSDAir);
6078  electboardcardB->SetLineColor(fColorAl);
6079  // Positioning Volumes Mother Interface Card B Container 
6080  TGeoRotation* interfacecardBrot = new TGeoRotation();
6081  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6082  interfacecardBrot->SetAngles(90.,-90.,-90.);
6083  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6084  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6085  TGeoRotation* electboardcardBrot = new TGeoRotation();
6086  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6087  electboardcardBrot->SetAngles(90.,90.,-90.);
6088  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6089  TGeoCombiTrans* electboardcardBcombitrans = 
6090                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6091  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6092  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6093  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6094  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6095  TGeoTranslation* jmdconnectorcardBtrans[3];
6096  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6097  for(Int_t i=0; i<3; i++){
6098    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6099                                                          + fgkEndCapCardJMDConnectorLength[0], 
6100                                                            fgkEndCapCardElectBoardLayerWidth[1],
6101                                                            0.5*fgkEndCapCardJMDConnectorThickness
6102                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6103                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6104                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6105    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6106                                                                                                            *jmdconnectorcardBrot);
6107    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6108  }
6109  // Mother Supply Card Container 
6110  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6111  // Interface Card Container
6112  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6113  // Placing Volumes in Mother Supply Card Container
6114  // JMD Connector Positioning
6115  TGeoTranslation* jmdconnectortrans[2];
6116  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6117  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6118                                                                                         fgkEndCapCardElectBoardBackLength[0]
6119                                           -                                             fgkEndCapCardJMDConnectorThickness
6120                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6121  TGeoRotation* jmdconnectorot = new TGeoRotation();
6122  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6123                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6124                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6125                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6126                                                                       fgkEndCapCardJMDConnectorThickness
6127                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6128  jmdconnectorot->SetAngles(90.,180.,-90);
6129  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6130                                                                                 * jmdconnectorot);
6131  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6132  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6133  // Top Cable Connector Placing
6134  TGeoRotation* cableconnectorot[2];
6135  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6136  TGeoTranslation* cableconnectortrans[3];
6137  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6138  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6139  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6140  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6141  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6142                                                                                                                            *cableconnectorot[0]);
6143  TGeoHMatrix* cableconnectormatrix[2];
6144  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6145                                                         new TGeoHMatrix((*cableconnectorot[1])
6146                                                                                    *(*cableconnectorcombitrans));
6147  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6148                                            -                               fgkEndCapCardCableConnectorThickness,
6149                                                                                 fgkEndCapCardCableConnectorLength[0]
6150                                            +                            fgkEndCapCardCableConnectorToLayer);
6151  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6152                                            -                2.*fgkEndCapCardCableConnectorThickness
6153                                            -                            fgkEndCapCardCableConnectorDistance,
6154                                                                                 fgkEndCapCardCableConnectorLength[0]
6155                                            +                            fgkEndCapCardCableConnectorToLayer);
6156  for(Int_t i=0; i<2; i++){
6157         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6158     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6159  }
6160  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6161  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6162  electboardbackrot->SetAngles(90.,-90.,-90.);
6163  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6164                                                         +                fgkEndCapCardJMDConnectorLength[0]
6165                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6166  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6167                                                                                                                            *electboardbackrot);
6168  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6169  // Electronic Board Kapton Layer Positioning
6170  TGeoRotation* electlayerrot = new TGeoRotation();
6171  TGeoTranslation* electlayertrans[2];
6172  TGeoCombiTrans* electlayercombitrans[2];
6173  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6174  electlayerrot->SetAngles(90.,-90.,-90.);
6175  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6176                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6177  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6178                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6179                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6180  for(Int_t i=0; i<2; i++){
6181         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6182         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6183  }
6184  // Placing Volumes in Mother Interface Card Container
6185  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6186  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6187  for(Int_t i=0; i<2; i++){
6188         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6189  }
6190  /////////////////////////////////////////////////////////////
6191  // Generation of Card Interface Container
6192  /////////////////////////////////////////////////////////////
6193  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6194                                                   - fgkEndCapCardJMDConnectorLength[0]
6195                                                   - fgkEndCapInterfaceCardBThickness
6196                                                   - 9.*fgkEndCapStripConnectionThickness
6197                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6198  const Int_t kcardinterfacecontainervertexnumber = 14;
6199  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6200  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6201  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6202                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6203  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6204  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6205                                                                    + fgkEndCapStripConnectionThickness
6206                                                                    - fgkEndCapCardElectBoardLayerThickness
6207                                                                    - fgkEndCapCardCableConnectorWidth[0];
6208  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6209  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6210  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6211  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6212                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6213  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6214  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6215                                                                    + fgkEndCapInterfaceCardBThickness;
6216  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6217  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6218                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6219  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6220  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6221                                    - fgkEndCapInterfaceElectBoardCardBThickness
6222                                                                    + fgkEndCapCardJMDConnectorLength[0]
6223                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6224  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6225
6226  ycardinterfacecontainervertex[0]  = 0.;
6227  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6228                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6229                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6230  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6231  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6232                                                                    - fgkEndCapStripConnectionWidth;
6233  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6234  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6235  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6236  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6237                                                                    + fgkEndCapInterfaceCardBWidth[1]
6238                                                                    + fgkEndCapInterfaceCardBWidth[2];
6239  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6240  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6241  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6242  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6243  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6244  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6245  
6246  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6247  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6248                                                                                   xcardinterfacecontainervertex,
6249                                                                                   ycardinterfacecontainervertex);
6250  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6251                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6252  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6253                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6254  TGeoVolume** cardinterfacecontainer;
6255  cardinterfacecontainer = new TGeoVolume*[4];
6256  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6257                                                                                         interfacecardmothershape,fSSDAir); 
6258  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6259                                                                                         interfacecardmothershape,fSSDAir); 
6260  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6261                                                                                         interfacecardmothershape,fSSDAir); 
6262  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6263                                                                                         interfacecardmothershape,fSSDAir); 
6264  /////////////////////////////////
6265  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6266  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6267  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6268  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6269  /////////////////////////////////
6270  TGeoRotation* endcapstripconnectionrot[2];
6271  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6272  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6273  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6274  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6275                                                                         *                                 (*endcapstripconnectionrot[0]));
6276  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6277  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6278                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6279                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6280                                                                                         -endcapstripconnectionshape->GetDZ(),
6281                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6282  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6283  TGeoTranslation* cardinterfacetrans[9];
6284  TGeoHMatrix* cardinterfacematrix[9]; 
6285  for(Int_t i=0; i<7; i++){ 
6286         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6287                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6288                                                                                                 0.0,0.0);  
6289         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6290                                                    *                             (*endcapstripconnectionmatrix));
6291  }
6292  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6293                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6294                                                                                                 0.0,0.0);  
6295  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6296                                                 *                                 (*endcapstripconnectionmatrix));
6297  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6298                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6299                                                                                                 0.0,0.0);  
6300  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6301                                                 *                                 (*endcapstripconnectionmatrix));
6302
6303  for(Int_t i=0; i<4; i++){
6304         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6305                                                                            cardinterfacematrix[7]);                             
6306         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6307                                                                            cardinterfacematrix[8]);                             
6308  }
6309  TGeoTranslation* mothersupplycardtrans = 
6310                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6311                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6312                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6313  TGeoHMatrix* mothersupplycardmatrix[7];
6314  Int_t index[4] = {1,1,1,1};
6315  for(Int_t i=0; i<7; i++){
6316         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6317                                                         *                                 (*mothersupplycardtrans));
6318         for(Int_t j=0; j<4; j++){
6319                 switch(j){
6320                         case 0: //Layer5 EndCap Left Side  
6321                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6322                                                                                                    cardinterfacematrix[i]);                             
6323                                 if(i!=0){
6324                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6325                                                                                                            mothersupplycardmatrix[i]);                  
6326                                         index[j]++;
6327
6328                                 }
6329                         break;
6330                         case 1: //Layer5 EndCap Rigth Side  
6331                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6332                                                                                                    cardinterfacematrix[i]);                     
6333                                 if(i>0&&i<6){
6334                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6335                                                                                                            mothersupplycardmatrix[i]);                  
6336                                         index[j]++;
6337                                 }
6338                         break;
6339                         case 2: //Layer6 EndCap Left Side  
6340                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6341                                                                                                    cardinterfacematrix[i]);                             
6342                                 if(i!=6){
6343                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6344                                                                                                            mothersupplycardmatrix[i]);                  
6345                                         index[j]++;
6346                                 }
6347                         break;
6348                         case 3: //Layer6 EndCap Right Side  
6349                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6350                                                                                                    cardinterfacematrix[i]);                             
6351                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6352                                                                                                    mothersupplycardmatrix[i]);                  
6353                                 index[j]++;
6354                         break;
6355                 }
6356         }
6357  }
6358  // Positioning Interface 
6359  TGeoTranslation* motherinterfacecardtrans = 
6360                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6361                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6362                                                          -fgkEndCapCardElectBoardLayerThickness
6363                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6364  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6365                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6366  // Positioning Interface Card B 
6367  TGeoTranslation* interfacecardBmothertrans = 
6368                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6369                                                                                 + 2.*fgkEndCapStripConnectionThickness
6370                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6371                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6372                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6373  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6374                                                                                                                          interfacecardBmothertrans);
6375  // Positioning Stiffener 
6376  TGeoTranslation* endcapstiffenertrans = 
6377                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6378                                                                            +    2.0*fgkEndCapStripConnectionThickness
6379                                                                            +    fgkEndCapInterfaceCardBThickness
6380                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6381                                                                            +    stiffenertransx
6382                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6383                                                                                         endcapstiffenershape->GetDZ()
6384                                                                            -    0.5*(fgkEndCapStiffenerLength
6385                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6386  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6387  /////////////////////////////////////////////////////////////
6388  // Deallocating memory
6389  /////////////////////////////////////////////////////////////
6390  delete interfacecardBrot;
6391  delete interfacecardBtrans;
6392  delete electboardcardBtrans;
6393  delete electboardcardBrot; 
6394  delete jmdconnectorcardBrot;
6395  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6396  delete jmdconnectorot;
6397  delete jmdconnectortrans[1];
6398  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6399  delete cableconnectorcombitrans;
6400  delete electboardbacktrans;
6401  delete electboardbackrot;
6402  delete electlayerrot;
6403  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6404  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6405  delete mothersupplycardtrans;
6406  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6407  /////////////////////////////////////////////////////////////
6408  return cardinterfacecontainer;
6409  }
6410  ////////////////////////////////////////////////////////////////////////////////
6411  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6412   /////////////////////////////////////////////////////////////
6413   // Method returning EndCap Mother Volume
6414   /////////////////////////////////////////////////////////////
6415   const Int_t kendcapcoverplatesmallholenumber = 9;
6416   Double_t endcapmotherorigin[3];
6417   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6418                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6419                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6420   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6421                                           -                      fgkEndCapCoverPlateWidth[2]
6422                                           -       (kendcapcoverplatesmallholenumber-1)
6423                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6424                                           +  0.5*(fgkEndCapSideCoverLength[2]
6425                                           +               fgkEndCapCoverPlateWidth[1]
6426                                           -       fgkEndCapCoverPlateWidth[0])
6427                                           -      (fgkEndCapCoverPlateWidth[1]
6428                                           -       fgkEndCapCoverPlateWidth[0]);
6429   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6430                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6431                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6432                                                 +      fgkEndCapSideCoverWidth[1]
6433                                                 +      fgkEndCapSideCoverThickness
6434                                                 +      fgkEndCapKaptonFoilThickness);
6435   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6436                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6437                                                           +              2.0* fgkEndCapSideCoverThickness),
6438                                                                          0.5* (fgkEndCapSideCoverLength[2]
6439                                                           +                    fgkEndCapCoverPlateWidth[1]
6440                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6441                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6442                                                       +                                    fgkEndCapSideCoverWidth[1]
6443                                                           +                                       fgkEndCapSideCoverThickness
6444                                                       +                                   fgkEndCapKaptonFoilThickness),
6445                                                                                          endcapmotherorigin);
6446   TGeoVolume** endcapassembly;  
6447   endcapassembly = new TGeoVolume*[4];
6448   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6449                                                                                         endcapmothershape,fSSDAir); 
6450   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6451                                                                                         endcapmothershape,fSSDAir); 
6452   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6453                                                                                         endcapmothershape,fSSDAir); 
6454   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6455                                                                                         endcapmothershape,fSSDAir); 
6456  /////////////////////////////////
6457  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6458  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6459  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6460  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6461  /////////////////////////////////
6462   /////////////////////////////////////////////////////
6463   // Placing Endcap Cover Plate
6464   /////////////////////////////////////////////////////
6465   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6466   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6467   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6468   TGeoCombiTrans* endcapcoverplatecombitrans = 
6469                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6470                                                                                          endcapcoverplaterot);
6471   TGeoTranslation* endcapcoverplatetrans = 
6472                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6473   TGeoHMatrix* endcapcoverplatematrix = 
6474                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6475                                                                           *       (*endcapcoverplatecombitrans));
6476   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6477   /////////////////////////////////////////////////////
6478   // Placing Endcap Side Cover
6479   /////////////////////////////////////////////////////
6480   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6481   TGeoRotation* endcapsidecoverot[2];
6482   TGeoCombiTrans* endcapsidecovercombitrans[3];
6483   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6484   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6485   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6486                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6487                                                                                         - fgkEndCapCoverPlateWidth[2]
6488                                                                                     - (kendcapcoverplatesmallholenumber-1)
6489                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6490                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6491                                                                                         + fgkEndCapSideCoverLength[2],
6492                                                                                           0.5*(fgkEndCapSideCoverThickness
6493                                                                                         + fgkEndCapCoverPlateThickness)
6494                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6495                                                                                           endcapsidecoverot[0]);
6496   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6497   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6498                                                                                                         0.5*fgkEndCapCoverPlateThickness
6499                                                                                                         -fgkEndCapSideCoverWidth[1],
6500                                                                                                         endcapsidecoverot[1]);
6501   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6502                                                                                                         +fgkEndCapCoverPlateLength[3]
6503                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6504                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6505                                                                                                         0.5*fgkEndCapCoverPlateThickness
6506                                                                                                         -fgkEndCapSideCoverWidth[1],
6507                                                                                                         endcapsidecoverot[1]);
6508   TGeoHMatrix* endcapsidecovermatrix[2];
6509   for(Int_t i=0; i<2; i++){
6510    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6511                                                         *                                 (*endcapsidecovercombitrans[0]));
6512         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6513                                                                                                                 endcapsidecovermatrix[i]);
6514   }
6515   /////////////////////////////////////////////////////
6516   // Placing Endcap Cooling Tube
6517   /////////////////////////////////////////////////////
6518   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6519   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6520   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6521   TGeoCombiTrans* endcapccolingtubecombitrans 
6522                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6523                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6524                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6525                                                 - fgkEndCapCoolingTubeToCoverSide,
6526                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6527                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6528   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6529                                                                                                           endcapccolingtubecombitrans);
6530   /////////////////////////////////////////////////////
6531   // Placing Screws 
6532   /////////////////////////////////////////////////////
6533   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6534                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6535   Int_t screwcoverplatedgesnumber[2] = {20,20};
6536   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6537                                                                                 fgkEndCapCoverPlateThickness
6538                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6539   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6540                                                                                                  screwcoverplatedgesnumber,
6541                                                                                                  screwcoverplatesection);
6542   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6543                                                                                            screwcoverplateshape,
6544                                                                                            fSSDCoolingTubePhynox); 
6545   screwcoverplate->SetLineColor(12);
6546   Double_t transx[4] = {0,
6547                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6548                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6549                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6550                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6551                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6552   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6553 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6554   TGeoTranslation*** endcapcoverplatescrewtrans;
6555   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6556   Int_t index = 0;
6557   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6558         endcapcoverplatescrewtrans[i] = 
6559                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6560     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6561                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6562         if(index==1||index==9||index==28||index==36){
6563                         endcapcoverplatescrewtrans[i][j] = 
6564                                 new TGeoTranslation(transx[i],
6565                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6566                                                                         fgkEndCapSideCoverThickness);
6567                 }
6568                 else{
6569                         endcapcoverplatescrewtrans[i][j] = 
6570                                 new TGeoTranslation(transx[i],
6571                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6572                                                                         0.);
6573                 }
6574             if(index!=19) 
6575                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6576                                                                                           endcapcoverplatescrewtrans[i][j]);
6577         }
6578   }
6579   /////////////////////////////////////////////////////
6580   // Placing Cover Plate Clips 
6581   /////////////////////////////////////////////////////
6582   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6583                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6584                                                                                                          0.5*fgkEndCapSideCoverThickness);
6585   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6586                                                                                                         endcapcoverplateclipshape,
6587                                                                                                         fSSDCoolingTubePhynox);
6588   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6589                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6590                                                                                                          0.5*fgkEndCapSideCoverThickness);
6591   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6592                                                                                                         endcapcoverplatedownclipshape,
6593                                                                                                         fSSDCoolingTubePhynox);
6594   TGeoTranslation* endcapcoverplatecliptrans[4];
6595   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6596                                                            -                     fgkEndCapCoverPlateLength[0]
6597                                                            -                     fgkEndCapSideCoverThickness,
6598                                                                                                          0.0,
6599                                                                                                  0.5*(fgkEndCapSideCoverThickness
6600                                                            +                                              fgkEndCapCoverPlateThickness));
6601   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6602                                                            -                     fgkEndCapCoverPlateLength[0]
6603                                                            -                     fgkEndCapSideCoverThickness,
6604                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6605                                                            *                                     fgkEndCapSideCoverWidth[5],
6606                                                                                                  0.5*(fgkEndCapSideCoverThickness
6607                                                            +                                              fgkEndCapCoverPlateThickness));
6608   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6609                                                            -                     fgkEndCapCoverPlateLength[0]
6610                                                            +                                     fgkEndCapCoverPlateLength[1]
6611                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6612                                                            -                                     fgkEndCapCoverPlateClipLength
6613                                                            +                                 fgkEndCapSideCoverThickness,
6614                                                                                                          0.0,
6615                                                                                                  0.5*(fgkEndCapSideCoverThickness
6616                                                            +                                              fgkEndCapCoverPlateThickness));
6617   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6618                                                            -                     fgkEndCapCoverPlateLength[0]
6619                                                            +                                     fgkEndCapCoverPlateLength[1]
6620                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6621                                                            -                                     fgkEndCapCoverPlateClipLength
6622                                                            +                                 fgkEndCapSideCoverThickness,
6623                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6624                                                            *                                     fgkEndCapSideCoverWidth[5],
6625                                                                                                  0.5*(fgkEndCapSideCoverThickness
6626                                                            +                                              fgkEndCapCoverPlateThickness));
6627   endcapcoverplateclip->SetLineColor(fColorPhynox);
6628   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6629   for(Int_t i=0; i<4; i++) 
6630         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6631                                                                                                    endcapcoverplatecliptrans[i]);  
6632   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6633   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6634                                                                    -                     fgkEndCapCoverPlateLength[0]
6635                                                                    -                     fgkEndCapSideCoverThickness,
6636                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6637                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6638                                                                                                         0.5*(fgkEndCapSideCoverThickness
6639                                                                +                                         fgkEndCapCoverPlateThickness)
6640                                                                    -                     fgkEndCapSideCoverWidth[1]
6641                                                                    -                                     fgkEndCapSideCoverThickness);
6642   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6643                                                                    -                     fgkEndCapCoverPlateLength[0]
6644                                                                    -                     fgkEndCapSideCoverThickness,
6645                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6646                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6647                                                                    +                            fgkEndCapSideCoverLength[2]
6648                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6649                                                                                                         0.5*(fgkEndCapSideCoverThickness
6650                                                                +                                         fgkEndCapCoverPlateThickness)
6651                                                                    -                     fgkEndCapSideCoverWidth[1]
6652                                                                    -                                     fgkEndCapSideCoverThickness);
6653   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6654                                                                    -                     fgkEndCapCoverPlateLength[0]
6655                                                                    +                     fgkEndCapSideCoverThickness
6656                                                                    +                     fgkEndCapCoverPlateLength[1]
6657                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6658                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6659                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6660                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6661                                                                                                         0.5*(fgkEndCapSideCoverThickness
6662                                                                +                                         fgkEndCapCoverPlateThickness)
6663                                                                    -                     fgkEndCapSideCoverWidth[1]
6664                                                                    -                                     fgkEndCapSideCoverThickness);
6665   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6666                                                                    -                     fgkEndCapCoverPlateLength[0]
6667                                                                    +                     fgkEndCapSideCoverThickness
6668                                                                    +                     fgkEndCapCoverPlateLength[1]
6669                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6670                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6671                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6672                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6673                                                                    +                                 fgkEndCapSideCoverLength[2]
6674                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6675                                                                                                         0.5*(fgkEndCapSideCoverThickness
6676                                                                +                                         fgkEndCapCoverPlateThickness)
6677                                                                    -                     fgkEndCapSideCoverWidth[1]
6678                                                                    -                                     fgkEndCapSideCoverThickness);
6679   for(Int_t i=0; i<4; i++)
6680         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6681                                                                                                    endcapcoverplatedowncliptrans[i]);
6682   /////////////////////////////////////////////////////
6683   // Placing Kapton Foil
6684   /////////////////////////////////////////////////////
6685   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6686                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6687                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6688   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6689                                                                                                 endcapkaptonfoilshape,
6690                                                                                                 fSSDKaptonFlexMedium);
6691   endcapkaptonfoil->SetLineColor(8);
6692   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6693                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6694                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6695                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6696                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6697                                                                              -                     fgkEndCapSideCoverWidth[1]
6698                                                                                  -                     fgkEndCapSideCoverThickness);
6699   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6700   /////////////////////////////////////////////////////////////
6701   // Placing Electronic Tubes
6702   /////////////////////////////////////////////////////////////
6703   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6704                                                                              - fgkEndCapInterfaceCardBThickness
6705                                                                              - 9.*fgkEndCapStripConnectionThickness
6706                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6707                                                                                fgkEndCapKaptonFoilWidth
6708                                                                              - fgkEndCapInterfaceCardBThickness
6709                                                                              - 9.*fgkEndCapStripConnectionThickness
6710                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6711                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6712   TGeoVolume* endcapeffectivecables[2];
6713   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6714                                                                                          fgkEndCapEffectiveCableRadiusMax,
6715                                                                                          endcapeffectivecableswidth[0],
6716                                                                                          10,"EndCapEffectiveCables1"); 
6717   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6718                                                                                          fgkEndCapEffectiveCableRadiusMax,
6719                                                                                          endcapeffectivecableswidth[1],
6720                                                                                          25,"EndCapEffectiveCables2"); 
6721   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6722   TGeoTranslation* endcapeffectivecablestrans[2];
6723   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6724                                           -                                                        0.5*endcapeffectivecableswidth[0]
6725                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6726                                           -                                                               fgkEndCapCoverPlateWidth[2]
6727                                           -                                             (kendcapcoverplatesmallholenumber-1)
6728                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6729                                           +                                             fgkEndCapSideCoverLength[2],
6730                                           -                     0.5*fgkEndCapCoverPlateThickness
6731                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6732                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6733                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6734   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6735                                           -                                                        0.5*endcapeffectivecableswidth[1]
6736                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6737                                           -                                                               fgkEndCapCoverPlateWidth[2]
6738                                           -                                             (kendcapcoverplatesmallholenumber-1)
6739                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6740                                           +                                         fgkEndCapSideCoverLength[2],
6741                                           -                     0.5*fgkEndCapCoverPlateThickness
6742                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6743                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6744                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6745   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6746   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6747   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6748                                                                                                                    *endcapeffectivecablesrot);
6749   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6750                                                                                                                    *endcapeffectivecablesrot);
6751 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6752 //                                                                                                        endcapeffectivecablescombitrans[0]);
6753   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6754                                                                                                           endcapeffectivecablescombitrans[1]);
6755   /////////////////////////////////////////////////////////////
6756   // Placing End Cap Cards
6757   /////////////////////////////////////////////////////////////
6758   TGeoVolume** endcapcards = GetEndCapCards();
6759   TGeoRotation* endcapcardsrot[2];
6760   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6761   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6762   TGeoTranslation* endcapcardstrans[2]; 
6763   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6764                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6765   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6766   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6767   TGeoHMatrix* endcapcardsmatrix[2];
6768   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6769   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6770                                                   - fgkEndCapCardJMDConnectorLength[0]
6771                                                   - fgkEndCapInterfaceCardBThickness
6772                                                   - 9.*fgkEndCapStripConnectionThickness
6773                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6774   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6775                                           -                                             fgkEndCapCoverPlateLength[0]
6776                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6777                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6778                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6779                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6780                                           -                                                               fgkEndCapInterfaceCardBThickness
6781                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6782                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6783                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6784                                           -                                                               fgkEndCapCoverPlateWidth[2]
6785                                           -                                             (kendcapcoverplatesmallholenumber-1)
6786                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6787                                           +                     fgkEndCapKaptonFoilWidth,
6788                                                                                           0.5*fgkEndCapCoverPlateThickness
6789                                           -                                                     fgkEndCapSideCoverWidth[1]);
6790   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6791   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6792    /////////////////////////////////////////////////////////////
6793   // Deallocating memory
6794   /////////////////////////////////////////////////////////////
6795   delete endcapcoverplaterot;
6796   delete endcapcoverplatecombitrans;
6797   delete endcapcoverplatetrans;
6798   for(Int_t i=0; i<3; i++){
6799    delete endcapsidecovercombitrans[i];
6800    if(i<2) delete endcapsidecoverot[i]; 
6801   }
6802   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6803   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6804   delete endcapcardsmatrix[0];
6805   return endcapassembly;
6806  } 
6807  ////////////////////////////////////////////////////////////////////////////////
6808  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6809                                                                                                                         Double_t radiusmax, 
6810                                                                                                                         Double_t width, 
6811                                                                                                                         Int_t ncables,
6812                                                                                                                         const char* volname){
6813   /////////////////////////////////////////////////////////////
6814   // Generating EndCap High Voltage Tubes 
6815   /////////////////////////////////////////////////////////////
6816   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6817   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
6818
6819   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6820   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6821                                                                                                    effectiveouteradius,0.5*width);
6822   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6823                                                                                                 effectiveinnertubeshape,
6824                                                                                                 fSSDStiffenerConnectorMedium);
6825   effectiveinnertube->SetLineColor(41);
6826   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6827                                                                                                 effectiveoutertubeshape,
6828                                                                                                 fSSDKaptonChipCableMedium);
6829   effectiveoutertube->SetLineColor(39);
6830   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6831   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6832   effectivemothertube->AddNode(effectiveinnertube,1);
6833   effectivemothertube->AddNode(effectiveoutertube,1);
6834   return effectivemothertube;
6835  } 
6836  ////////////////////////////////////////////////////////////////////////////////
6837  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6838   /////////////////////////////////////////////////////////////
6839   // Generating EndCap Support Layer 5 and Layer 6 
6840   /////////////////////////////////////////////////////////////
6841   const Int_t knedges = 5;
6842   ///////////////////////////////////////////////
6843   // Setting the vertices for TGeoXtru Up Volume
6844   ///////////////////////////////////////////////
6845   const Int_t klayernumber = 2;
6846   Double_t xupvertex[klayernumber][knedges+3];
6847   Double_t yupvertex[klayernumber][knedges+3];
6848   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6849   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6850   Double_t middlepsi[klayernumber] = {0.0,0.0};
6851   for(Int_t i=0; i<klayernumber; i++){
6852         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6853         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6854         xupvertex[i][2] = -xupvertex[i][1];
6855         xupvertex[i][3] = -xupvertex[i][0];
6856
6857         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6858         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6859         yupvertex[i][2] =  yupvertex[i][1];
6860         yupvertex[i][3] =  yupvertex[i][0];
6861         
6862     middledgeangle[i] = upedgeangle[i]/knedges;
6863     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6864     for(Int_t j=1; j<knedges; j++){
6865                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6866                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6867         }
6868   }
6869   ////////////////////////////////////
6870   // Generating Up TGeoXtru
6871   ////////////////////////////////////
6872   TGeoXtru* upendcapsupportshape[klayernumber];
6873   TGeoVolume* upendcapsupport[klayernumber]; 
6874   char upendcapsupportname[100]; 
6875   for(Int_t i=0; i<klayernumber; i++){
6876    upendcapsupportshape[i] = new TGeoXtru(2);
6877    snprintf(upendcapsupportname,100,"UpEndCapSupportPieceLayer%i",i+5);
6878    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6879    upendcapsupportshape[i]->DefineSection(0,0.);
6880    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6881    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6882                                                                         fSSDSupportRingAl);
6883    upendcapsupport[i]->SetLineColor(5);
6884   }
6885   ///////////////////////////////////////////////
6886   // Setting the vertices for TGeoXtru Down Volume
6887   ///////////////////////////////////////////////
6888   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6889   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6890   for(Int_t i=0; i<klayernumber; i++){
6891         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6892         xdownvertex[i][1] =  xupvertex[i][0];
6893         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6894         ydownvertex[i][1] =  yupvertex[i][0];
6895         for(Int_t j=0; j<knedges; j++){
6896                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6897                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6898         } 
6899         for(Int_t j=0; j<knedges; j++){
6900                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6901                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6902                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6903                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
6904         }
6905   }
6906   ////////////////////////////////////
6907   // Generating Down TGeoXtru
6908   ////////////////////////////////////  
6909   TGeoXtru* downendcapsupportshape[klayernumber];
6910   TGeoVolume* downendcapsupport[klayernumber]; 
6911   char downendcapsupportname[100]; 
6912   for(Int_t i=0; i<klayernumber; i++){
6913         downendcapsupportshape[i] = new TGeoXtru(2);
6914         snprintf(downendcapsupportname,100,"DownEndCapSupportPieceLayer%i",i+5);
6915         downendcapsupportshape[i] = new TGeoXtru(2);
6916         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
6917     if(i==0){
6918                 downendcapsupportshape[i]->DefineSection(0,0.);
6919                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
6920     }
6921         else{
6922                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
6923                                                                  -                 fgkEndCapSupportLowWidth[i]);
6924                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6925         }
6926     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
6927                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
6928         downendcapsupport[i]->SetLineColor(5);
6929   }
6930   ///////////////////////////////////////////////
6931   // Setting TGeoPgon Volume
6932   ///////////////////////////////////////////////
6933   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6934                                                                                                    fgkSSDLay6LadderNumber};
6935   TGeoPgon* endcapsupportmothershape[klayernumber];
6936   TGeoVolume** endcapsupportmother;
6937   endcapsupportmother = new TGeoVolume*[klayernumber];
6938   char endcapsupportmothername[100];
6939   for(Int_t i=0; i<klayernumber; i++){
6940         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6941         snprintf(endcapsupportmothername,100,"EndCapSupportMotherLayer%i",i+5);
6942         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
6943     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
6944                                                                                           ydownvertex[i][0],yupvertex[i][1]);
6945     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
6946                                                                                         fSSDAir);       
6947   }
6948   ////////////////////////////////////
6949   TGeoRotation** endcapsupportrot[klayernumber];
6950   for(Int_t i=0; i<2; i++){
6951         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
6952         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6953            endcapsupportrot[i][j] = new TGeoRotation();
6954            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
6955        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
6956        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
6957         }
6958   }
6959   return endcapsupportmother;
6960  } 
6961  ////////////////////////////////////////////////////////////////////////////////
6962  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
6963   /////////////////////////////////////////////////////////////
6964   // Setting End Cap Support Layer 5 and 6. 
6965   /////////////////////////////////////////////////////////////
6966   const Int_t kendcapcoverplatesmallholenumber = 9;
6967   const Int_t klayernumber = 2;
6968   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6969                                                                                                    fgkSSDLay6LadderNumber};
6970   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
6971                                                                                 360.0/kssdlayladdernumber[1]};
6972   TGeoVolume** endcapsupport = EndCapSupport();
6973   TGeoVolume** endcapassembly = GetEndCapAssembly();
6974   TGeoPgon* endcapsupportshape[klayernumber];
6975   Double_t* radiusmin[klayernumber];
6976   Double_t* radiusmax[klayernumber];
6977   for(Int_t i=0; i<klayernumber; i++){
6978     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
6979         radiusmin[i] = endcapsupportshape[i]->GetRmin();
6980         radiusmax[i] = endcapsupportshape[i]->GetRmax();
6981   }  
6982   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
6983   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
6984                                                                           endcapassemblyshape->GetDY(),
6985                                                                           endcapassemblyshape->GetDZ()};
6986   ///////////////////////////////////////////////
6987   // Setting TGeoPgon Volume for Mother Container
6988   ///////////////////////////////////////////////
6989   TGeoPgon* endcapsupportsystemshape[klayernumber];
6990   char endcapsupportsystemothername[100];
6991   for(Int_t i=0; i<klayernumber; i++){
6992         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6993         snprintf(endcapsupportsystemothername,100,"EndCapSupportSystemLayer%i",i+5);
6994         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
6995                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
6996                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6997                                                                                            +2.*endcapassemblycenter[2])
6998                                                                                            /CosD(0.5*upedgeangle[i]));  
6999     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7000                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7001                                                                                              - fgkEndCapCoverPlateWidth[0]),
7002                                                                                            *radiusmin[i],
7003                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7004                                                                                            +2.*endcapassemblycenter[2])
7005                                                                                            /CosD(0.5*upedgeangle[i]));
7006   }
7007   fgkEndCapSupportSystem = new TGeoVolume*[4];
7008   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7009                                                                           endcapsupportsystemshape[0],fSSDAir); 
7010   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7011                                                                           endcapsupportsystemshape[0],fSSDAir); 
7012   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7013                                                                           endcapsupportsystemshape[1],fSSDAir); 
7014   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7015                                                                           endcapsupportsystemshape[1],fSSDAir); 
7016   ///////////////////////////////////////////////
7017   TGeoTranslation* endcapassemblytrans[klayernumber];
7018   for(Int_t i=0; i<klayernumber; i++)
7019         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7020                                                                            -  fgkEndCapSideCoverThickness
7021                                                                            +  endcapassemblycenter[0],
7022                                                                            -  0.5*fgkEndCapCoverPlateThickness
7023                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7024                                                                            +  2.0*endcapassemblycenter[2]
7025                                                                            +  0.5*fgkEndCapSupportLength[i]
7026                                                                            /  TanD(0.5*upedgeangle[i]),
7027                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7028                                                                            -  fgkEndCapCoverPlateWidth[2]
7029                                                                            - (kendcapcoverplatesmallholenumber-1)
7030                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7031   TGeoRotation** endcapassemblyrot[klayernumber];
7032   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7033   for(Int_t i=0; i<klayernumber; i++){
7034    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7035    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7036    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7037    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7038    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7039    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7040    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7041    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7042         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7043         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7044    }
7045   }
7046   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7047                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7048   for(Int_t i=0; i<2*klayernumber; i++){
7049         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7050                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7051                                                                                                                                            endcapassemblymatrix[1][j+2]);
7052         }
7053         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7054   }
7055    /////////////////////////////////////////////////////////////
7056   // Deallocating memory
7057   /////////////////////////////////////////////////////////////
7058   for(Int_t i=0; i<klayernumber; i++){
7059         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7060                 delete endcapassemblyrot[i][j];
7061         }
7062         delete [] endcapassemblyrot[i];
7063         delete endcapassemblymatrix[i][0];
7064         delete endcapassemblymatrix[i][1];
7065   }
7066   /////////////////////////////////////////////////////////////
7067   }
7068   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7069   /////////////////////////////////////////////////////////////
7070   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7071   /////////////////////////////////////////////////////////////
7072   if (! moth) {
7073     AliError("Can't insert end cap support of layer5, mother is null!\n");
7074     return;
7075   };
7076   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7077   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7078   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7079                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7080                                                                            +            fgkEndCapSupportCenterLay5Position
7081                                                                            -            fgkEndCapSideCoverLength[2]);
7082   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7083                                                                                                 fgkEndCapSideCoverLength[2]
7084                                                                            -        fgkEndCapSupportCenterLay5Position
7085                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7086   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7087   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7088   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7089         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7090   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7091   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7092    /////////////////////////////////////////////////////////////
7093   // Deallocating memory
7094   /////////////////////////////////////////////////////////////
7095   delete endcapsupportsystemrot;
7096   delete endcapsupportsystemITSCentertrans[1];
7097  }
7098   /////////////////////////////////////////////////////////////
7099   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7100   /////////////////////////////////////////////////////////////
7101   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7102   /////////////////////////////////////////////////////////////
7103   if (! moth) {
7104     AliError("Can't insert end cap support of layer6, mother is null!\n");
7105     return;
7106   };
7107   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7108   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7109   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7110                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7111                                                                            +            fgkEndCapSupportCenterLay6Position
7112                                                                            -            fgkEndCapSideCoverLength[2]);
7113   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7114                                                                                                 fgkEndCapSideCoverLength[2]
7115                                                                            -        fgkEndCapSupportCenterLay6Position
7116                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7117   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7118   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7119   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7120         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7121   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7122   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7123    /////////////////////////////////////////////////////////////
7124   // Deallocating memory
7125   /////////////////////////////////////////////////////////////
7126   delete endcapsupportsystemrot;
7127   delete endcapsupportsystemITSCentertrans[1];
7128  }
7129  ////////////////////////////////////////////////////////////////////////////////
7130  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7131   /////////////////////////////////////////////////////////////
7132   // Setting Ladder Support of Layer 5. 
7133   /////////////////////////////////////////////////////////////
7134   if (! moth) {
7135     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7136     return;
7137   };
7138   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7139   fMotherVol = moth;
7140   TGeoTranslation* centerITSRingSupportLay5trans[2];
7141   for(Int_t i=0; i<2; i++){
7142         centerITSRingSupportLay5trans[i] = 
7143                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7144     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7145   }
7146  }
7147  ////////////////////////////////////////////////////////////////////////////////
7148  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7149   /////////////////////////////////////////////////////////////
7150   // Setting Ladder Support of Layer 6. 
7151   /////////////////////////////////////////////////////////////
7152   if (! moth) {
7153     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7154     return;
7155   };
7156   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7157   fMotherVol = moth;
7158   TGeoTranslation* centerITSRingSupportLay6trans[2];
7159   for(Int_t i=0; i<2; i++){
7160         centerITSRingSupportLay6trans[i] = 
7161                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7162     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7163   }
7164  }
7165  ////////////////////////////////////////////////////////////////////////////////
7166  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7167   /////////////////////////////////////////////////////////////
7168   // Setting Ladder Support of Layer 6. 
7169   /////////////////////////////////////////////////////////////
7170   if (! moth) {
7171     AliError("Can't insert SSD Cone, mother is null!\n");
7172     return;
7173   };
7174   if(!fSSDCone) SetSSDCone();
7175   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7176                                                                 +                                         fgkSSDCentralAL3SupportLength);
7177     moth->AddNode(fSSDCone,1,ssdconetrans);
7178 }
7179  ////////////////////////////////////////////////////////////////////////////////
7180  void AliITSv11GeometrySSD::SetSSDCone(){
7181   /////////////////////////////////////////////////////////////
7182   // Method generating SSDCone 
7183   /////////////////////////////////////////////////////////////
7184   if(!fCreateMaterials) CreateMaterials();
7185   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7186   Double_t ssdpconesectionradiusmax[16];
7187   Double_t ssdpconesectionradiusmin[16];
7188   Double_t ssdpconezsection[16];
7189   TGeoPcon* ssdpconelittleholeshape[8];
7190   TGeoVolume* ssdpconelittlehole[8];
7191   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7192   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7193   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7194                                                       / SinD(fgkSSDPConeAngle)
7195                                                           + ssdpconesectionradiusmin[0];
7196   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7197                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7198                                                           / SinD(fgkSSDPConeAngle);
7199   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7200   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7201                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7202   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7203   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7204                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7205   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7206   ssdpconelittlehole[0]->SetLineColor(4);
7207   /////////////////////////////////////////////////////////////
7208   ssdpconezsection[2] = ssdpconezsection[1];  
7209   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7210   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7211   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7212                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7213                                                           / SinD(fgkSSDPConeAngle);
7214   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7215                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7216   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7217                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7218   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7219                                                                    * TMath::RadToDeg();
7220   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7221                                                                                                           60.-ssdpconelittleholeangle,2);    
7222   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7223                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7224   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7225   ssdpconelittlehole[1]->SetLineColor(4);
7226   TGeoRotation* ssdconelittleholerot[6];
7227   for(Int_t i=0; i<6; i++){
7228         ssdconelittleholerot[i] = new TGeoRotation();
7229     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7230   }
7231   /////////////////////////////////////////////////////////////
7232   ssdpconezsection[4] = ssdpconezsection[3];  
7233   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7234   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7235   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7236                                                           * CosD(fgkSSDPConeAngle)
7237                                                           / SinD(fgkSSDPConeAngle);
7238   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7239   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7240                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7241   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7242   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7243                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7244   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7245   ssdpconelittlehole[2]->SetLineColor(4);
7246   ///////////////////////////////////////////////////
7247   ssdpconezsection[6] = ssdpconezsection[5];  
7248   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7249   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7250   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7251                                                           -ssdpconezsection[0]
7252                                                           * CosD(fgkSSDPConeAngle)
7253                                                           / SinD(fgkSSDPConeAngle);
7254   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7255   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7256                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7257   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7258                                                                    * TMath::RadToDeg();
7259   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7260                                                                                                           45.-ssdpconemiddleholeangle,2);    
7261   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7262                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7263   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7264   ssdpconelittlehole[3]->SetLineColor(4);
7265   TGeoRotation* ssdconemiddleholerot[8];
7266   for(Int_t i=0; i<8; i++){
7267         ssdconemiddleholerot[i] = new TGeoRotation();
7268     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7269   }
7270   /////////////////////////////////////////////////////////////
7271   ssdpconezsection[8] = ssdpconezsection[7];  
7272   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7273   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7274   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7275                                                           * CosD(fgkSSDPConeAngle)
7276                                                           / SinD(fgkSSDPConeAngle);
7277   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7278   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7279                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7280   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7281   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7282                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7283   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7284   ssdpconelittlehole[4]->SetLineColor(4);
7285   /////////////////////////////////////////////////////////////
7286   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7287   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7288                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7289                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7290                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7291                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7292   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7293   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7294                                                                                  * TMath::RadToDeg();
7295   ssdpconezsection[10] = ssdpconezsection[9];
7296   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7297   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7298   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7299                                                           * CosD(fgkSSDPConeAngle)
7300                                                           / SinD(fgkSSDPConeAngle);
7301   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7302   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7303                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7304   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7305                                                                                         ssdpconetrapezoidsectionangle,2);    
7306   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7307                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7308   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7309   ssdpconelittlehole[5]->SetLineColor(4);
7310   TGeoRotation* ssdconeupradiusrot[8];
7311   for(Int_t i=0; i<8; i++){
7312         ssdconeupradiusrot[i] = new TGeoRotation();
7313     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7314   }
7315   /////////////////////////////////////////////////////////////
7316   ssdpconezsection[12] = ssdpconezsection[11];
7317   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7318   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7319   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7320   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7321   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7322   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7323   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7324                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7325   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7326   ssdpconelittlehole[6]->SetLineColor(4);
7327   /////////////////////////////////////////////////////////////
7328   ssdpconezsection[14] = 0.0;
7329   ssdpconezsection[15] = ssdpconezsection[0];
7330   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7331   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7332   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7333   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7334   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7335   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7336                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7337   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7338   ssdpconelittlehole[7]->SetLineColor(4);
7339   /////////////////////////////////////////////////////////////
7340   TGeoTube* ssdtubeconeshape[2];
7341   TGeoVolume* ssdtubecone[2];
7342   TGeoTranslation* ssdtubeconetrans[2];
7343   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7344                                                                            fgkSSDPConeExternalRadius,
7345                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7346   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7347                                                                            0.5*ssdpconezsection[0]); 
7348   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7349   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7350   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7351                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7352                                           + ssdpconezsection[13]);
7353   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7354   ssdtubecone[0]->SetLineColor(4);
7355   ssdtubecone[1]->SetLineColor(4);
7356   /////////////////////////////////////////////////////////////
7357   // Mother Volume Container
7358   /////////////////////////////////////////////////////////////
7359   Double_t ssdconemotherradiusmin[8];
7360   Double_t ssdconemotherradiusmax[8];
7361   Double_t ssdconemothersection[8]; 
7362   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7363   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7364   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7365   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7366   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7367   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7368   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7369   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7370   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7371   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7372   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7373   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7374   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7375   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7376   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7377   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7378   ssdconemothersection[0] = 0.0;
7379   ssdconemothersection[1] = ssdpconezsection[0];
7380   ssdconemothersection[2] = ssdpconezsection[0];
7381   ssdconemothersection[3] = ssdpconezsection[11];
7382   ssdconemothersection[4] = ssdpconezsection[11];
7383   ssdconemothersection[5] = ssdpconezsection[13];
7384   ssdconemothersection[6] = ssdpconezsection[13];
7385   ssdconemothersection[7] = fgkSSDPConeLength;
7386   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7387   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7388                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7389   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7390   /////////////////////////////////////////////////////////////
7391   //Placing the Volumes into Mother 
7392   /////////////////////////////////////////////////////////////
7393   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7394   for(Int_t i=0; i<6; i++){
7395         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7396   }
7397   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7398   for(Int_t i=0; i<8; i++){
7399     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7400   }
7401   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7402   for(Int_t i=0; i<8; i++){
7403     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7404   }
7405   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7406   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7407   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7408   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7409   /////////////////////////////////////////////////////////////
7410   // ITS General Support
7411   /////////////////////////////////////////////////////////////
7412   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7413                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7414   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7415   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7416                                                                              - fgkSSDCentralAL3SupportLength);
7417   ssdcentralsupport->SetLineColor(4);
7418   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7419   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7420                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7421   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7422   TGeoTranslation* ssdcentralal3supportrans[3]; 
7423   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7424   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7425                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7426   ssdcentralal3support->SetLineColor(4);
7427   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7428   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7429   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7430   Double_t ssdpconcentralradiusmin[2];
7431   Double_t ssdpconcentralradiusmax[2];
7432   Double_t ssdpconcentralsection[2];
7433   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7434   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7435   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7436   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7437   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7438   ssdpconcentralsection[1] = 0.;
7439   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7440                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7441   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7442   ssdpconcentralal3->SetLineColor(4);
7443   fSSDCone->AddNode(ssdpconcentralal3,1);
7444   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7445   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7446   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7447                                                                 -2.*fgkSSDCentralAL3SupportLength);
7448   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7449                                                                                                                      *ssdcentralal3supportrot);
7450   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7451   TGeoRotation* ssdconemotherot = new TGeoRotation();
7452   ssdconemotherot->SetAngles(90.,180.,-90.);
7453   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7454                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7455   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7456   fSSDCone->AddNode(ssdconemother,1);
7457   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7458   /////////////////////////////////////////////////////////////
7459   // Deallocating memory
7460   /////////////////////////////////////////////////////////////
7461   delete ssdcentralal3supportrot;
7462   delete ssdcentralal3supportrans[2];
7463   delete ssdconemotherot;
7464   delete ssdconemothertrans;
7465   /////////////////////////////////////////////////////////////
7466  }
7467  ////////////////////////////////////////////////////////////////////////////////
7468  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7469   /////////////////////////////////////////////////////////////
7470   // Setting SSD Cables
7471   /////////////////////////////////////////////////////////////
7472   if (! moth) {
7473     AliError("Can't insert SSD Cables, mother is null!\n");
7474     return;
7475   };
7476   TGeoVolume* ssdcables = SetSSDCables();
7477   moth->AddNode(ssdcables,1);
7478 }
7479  ////////////////////////////////////////////////////////////////////////////////
7480  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7481   /////////////////////////////////////////////////////////////
7482   // Method generating SSDCables
7483   /////////////////////////////////////////////////////////////
7484   // SSD Layer 5 Cables
7485   //////////////////////////////////////////////////////////////////////////////////////////////////
7486   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7487   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7488   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7489   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7490   //////////////////////////////////////////////////////////////////////////////////////////////////
7491   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7492   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7493                                                                             -  fgkSSDLowerPConeRadius)
7494                                                                             * TanD(fgkSSDPConeAngle);
7495   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7496                                                                               + fgkEndCapSupportCenterLay5Position
7497                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7498   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7499                                                                            - ssdcableslay5startconedistance; 
7500   ssdcablelay5rightsidelength *= ssdcablesfactor;
7501   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7502   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7503                                                                                                 ssdcableslay5rightsideradiusmax,
7504                                                                                                 0.5*ssdcablelay5rightsidelength); 
7505   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7506                                                                                                          ssdcablelay5rightubeshape,
7507                                                                                                          fSSDCopper);
7508   ssdcablelay5righttube->SetLineColor(9);
7509   TGeoTranslation* ssdcablelay5rightrans = 
7510                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7511                                                                                  +              fgkEndCapSupportCenterLay5Position
7512                                                                                  +      0.5*ssdcablelay5rightsidelength);
7513   ////////////////////////////////////
7514   //  Double_t cablescapacity[20];
7515   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7516   ////////////////////////////////////
7517   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7518   ////////////////////////////////////
7519   // TGeoPCone Volumes
7520   ///////////////////////////////////
7521   TGeoPcon* ssdcableslay5pconshape[3];
7522   TGeoVolume* ssdcableslay5pcon[3]; 
7523   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7524   Double_t ssdcableslay5pconzsection[6];
7525   Double_t ssdcableslay5pconrmin[6];
7526   Double_t ssdcableslay5pconrmax[6];
7527   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7528   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7529   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7530   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7531   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7532                                                            + fgkEndCapSupportCenterLay5Position
7533                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7534   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7535                                                            + fgkSSDCentralAL3SupportLength
7536                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7537                                                            * TanD(fgkSSDPConeAngle);      
7538   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7539                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7540   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7541                                                            ssdcableslay5pconshape[0],fSSDCopper);
7542   ssdcableslay5pcon[0]->SetLineColor(9);
7543   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7544 ////////////////////////////////////
7545 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7546 ////////////////////////////////////
7547   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7548   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7549                                                            + fgkSSDCentralAL3SupportLength
7550                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7551                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7552   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7553                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7554                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7555   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7556                                                                                    ssdcableangle,2);   
7557   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7558   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7559   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7560                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7561   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7562   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7563   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7564                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7565   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7566   ssdcableslay5pcon[1]->SetLineColor(9);
7567   ////////////////////////////////////
7568   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7569                                                                                    ssdcableangle,2);   
7570   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7571   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7572   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7573   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7574   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7575   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7576                                                            * TanD(fgkSSDPConeAngle)
7577                                                            + 0.5*fgkSSDCentralSupportLength
7578                                                            + fgkSSDCentralAL3SupportLength;
7579   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7580   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7581                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7582   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7583   ssdcableslay5pcon[2]->SetLineColor(9);
7584 ////////////////////////////////////
7585   TGeoRotation* ssdcableslay5pconrot[4];        
7586   for(Int_t i=0; i<4; i++){
7587    ssdcableslay5pconrot[i] = new TGeoRotation();
7588    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7589    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7590    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7591   }
7592   ////////////////////////////////////
7593   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7594   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7595   ////////////////////////////////////
7596   // Positioning Left SSD Cables Part
7597   ////////////////////////////////////
7598   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7599                                                                                                         - 0.5*ssdcablelay5rightsidelength
7600                                                                                                         - fgkEndCapSupportCenterLay5Position
7601                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7602   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7603   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7604   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7605   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7606   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7607   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7608         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7609         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7610     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7611   }
7612   ////////////////////////////////////
7613   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7614   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7615   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7616   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7617   /////////////////////////////////////////////////////////////
7618   // Water Tubes Layer 5
7619   /////////////////////////
7620   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7621                                                                                      ssdcableslay5rightsideradiusmax
7622                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7623                                                                                      0.5*ssdcablelay5rightsidelength); 
7624   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7625                                                                                                          ssdcablelay5rightubewatershape,
7626                                                                                                          fSSDCoolingTubeWater);
7627   ssdcablelay5rightwatertube->SetLineColor(7);
7628   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7629   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7630   ////////////////////////////////////
7631   // TGeoPCone Water Volumes Layer 
7632   ///////////////////////////////////
7633   TGeoPcon* ssdcableslay5pconwatershape[3];
7634   TGeoVolume* ssdcableslay5pconwater[3]; 
7635   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7636   Double_t ssdcableslay5pconwaterzsection[6];
7637   Double_t ssdcableslay5pcwateronrmin[6];
7638   Double_t ssdcableslay5pconwaterrmax[6];
7639   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7640   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7641                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7642   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7643   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7644                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7645   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7646   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7647   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7648                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7649   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7650                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7651   ssdcableslay5pconwater[0]->SetLineColor(7);
7652   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7653   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7654 ////////////////////////////////////
7655   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7656   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7657   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7658                                                                                                 ssdcableangle,2);   
7659   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7660   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7661                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7662   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7663   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7664                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7665   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7666                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7667   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7668                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7669   ssdcableslay5pconwater[1]->SetLineColor(7);
7670 ////////////////////////////////////
7671   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7672                                                                                                 ssdcableangle,2);   
7673   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7674   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7675                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7676   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7677   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7678                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7679   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7680   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7681   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7682                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7683   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7684                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7685   ssdcableslay5pconwater[2]->SetLineColor(7);
7686 ////////////////////////////////////
7687   TGeoRotation* ssdcableslay5pconwaterot[4];    
7688   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7689   for(Int_t i=0; i<4; i++){
7690    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7691    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7692    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7693         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7694         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7695         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7696         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7697         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7698   }
7699   /////////////////////////
7700   // SSD Layer 6 Cables
7701   /////////////////////////
7702   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7703   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7704   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7705   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7706                                                                                                 ssdcableslay6rightsideradiusmax,
7707                                                                                                 0.5*ssdcablelay6rightsidelength); 
7708   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7709                                                                                                          ssdcablelay6rightubeshape,
7710                                                                                                          fSSDCopper);
7711   ssdcablelay6righttube->SetLineColor(9);
7712   TGeoTranslation* ssdcablelay6rightrans = 
7713                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7714                                                                                  +              fgkEndCapSupportCenterLay6Position
7715                                                                                  +      0.5*ssdcablelay6rightsidelength);
7716   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7717                                                                                                         - 0.5*ssdcablelay6rightsidelength
7718                                                                                                         - fgkEndCapSupportCenterLay6Position
7719                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7720   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7721   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7722   ////////////////////////////////////
7723   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7724   ////////////////////////////////////
7725   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7726                                                                                    ssdcableangle,2);   
7727   TGeoVolume* ssdcableslay6pcon;
7728   Double_t ssdcableslay6pconrmin[2];
7729   Double_t ssdcableslay6pconrmax[2];
7730   Double_t ssdcableslay6pconzsection[2];
7731   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7732   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7733   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7734   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7735   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7736                                                            + fgkEndCapSupportCenterLay6Position
7737                                                            + ssdcablelay6rightsidelength;
7738   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7739   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7740                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7741   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7742                                                            ssdcableslay6pconshape,fSSDCopper);
7743   ssdcableslay6pcon->SetLineColor(9);
7744   for(Int_t i=0; i<4; i++){
7745    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7746    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7747   }
7748   ////////////////////////////////////
7749   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7750   /////////////////////////
7751   // Water Tubes Layer 6
7752   /////////////////////////
7753   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7754                                                                                                                   ssdcableslay6rightsideradiusmax
7755                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7756                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7757   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7758                                                                                                          ssdcablelay6righwatertubeshape,
7759                                                                                                          fSSDCoolingTubeWater);
7760   ssdcablelay6rightwatertube->SetLineColor(7);
7761   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7762   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7763   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7764                                                                                    ssdcableangle,2);   
7765   TGeoVolume* ssdcableslay6waterpcon;
7766   Double_t ssdcableslay6waterpconrmin[2];
7767   Double_t ssdcableslay6waterpconrmax[2];
7768   Double_t ssdcableslay6waterpconzsection[2];
7769   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7770   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7771                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7772   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7773   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7774   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7775                                                            + fgkEndCapSupportCenterLay6Position
7776                                                            + ssdcablelay6rightsidelength;
7777   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7778   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7779                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7780   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7781                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7782   ssdcableslay6waterpcon->SetLineColor(7);
7783   TGeoRotation* ssdcableslay6pconwaterot[4];    
7784   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7785   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7786   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7787   for(Int_t i=0; i<4; i++){
7788    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7789    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7790    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7791                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7792    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7793    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7794   }
7795   ////////////////////////////////////////
7796   // From ITS Ring to Patch Panel3-RB26
7797   ////////////////////////////////////////
7798   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7799   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7800   Double_t ssdcablepatchpanel3RB26zsection[2];
7801   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeight+2.8;
7802   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7803                                                                           + fgkSSDCablesLay5RightSideHeight
7804                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7805   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7806   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7807                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7808                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7809   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7810                                                                                  + fgkSSDCentralAL3SupportLength
7811                                                                                  + fgkSSDPConeZLength[0];
7812   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7813   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7814                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7815                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7816   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7817                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7818   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7819                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7820   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7821   TGeoRotation* ssdcablepatchpanel3B26rot[4];
7822   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7823   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7824   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7825                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7826   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7827   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7828                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7829   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7830   ////////////////////////////////////
7831   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7832   ////////////////////////////////////////
7833   //  ITS Ring Cables RB26 Part
7834   ////////////////////////////////////////
7835   Double_t ssdcableitsring3BB26pconzsection[2];
7836   Double_t ssdcableitsring3BB26pconrmin[2];
7837   Double_t ssdcableitsring3BB26pconrmax[2];
7838   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7839                                                                           + fgkSSDCentralAL3SupportLength
7840                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7841   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7842   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7843   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7844                                                                   + fgkSSDCablesLay5RightSideHeight
7845                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7846   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7847   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7848   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7849   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7850                                                                    -              0.5*ssdcableangle,ssdcableangle
7851                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7852                                                                    -                             fgkSSDCableAngle),2);
7853   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7854                                                                    -              0.5*ssdcableangle,ssdcableangle
7855                                                                    +                      3.0*fgkSSDCableAngle
7856                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7857   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7858                                                                    -              0.5*ssdcableangle,ssdcableangle
7859                                                                    -                      fgkSSDCableAngle
7860                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7861   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7862                                                                    -              0.5*ssdcableangle,ssdcableangle
7863                                                                    +                      3.0*fgkSSDCableAngle
7864                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7865   for(Int_t i=0;i<4;i++)
7866         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7867                                                          ssdcableitsring3BB26pconrmin[j],
7868                                                          ssdcableitsring3BB26pconrmax[j]); 
7869   TGeoVolume* ssdcableitsring3BB26pcon[4];
7870   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7871                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7872   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7873                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7874   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7875                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7876   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7877                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7878   for(Int_t i=0;i<4;i++){
7879         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7880         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7881 }
7882   ////////////////////////////////////
7883   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7884   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7885   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7886   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7887   ////////////////////////////////////////
7888   // From ITS Ring to Patch Panel2-RB24
7889   ////////////////////////////////////////
7890   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7891   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7892   Double_t ssdcablepatchpanel3RB24zsection[2];
7893   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7894   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7895   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7896   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7897                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7898                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7899                                                                           + 0.5*fgkSSDPatchPanelHeight;
7900   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7901                                                                          -  fgkSSDCentralAL3SupportLength
7902                                                                          -  fgkSSDPConeZLength[0];
7903   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
7904   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
7905                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7906                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7907   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
7908                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
7909   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
7910                                                                                                 ssdcablepatchpanel3RB24pconshape,
7911                                                                                                 fSSDCopper);
7912   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
7913   TGeoRotation* ssdcablepatchpanel3B24rot[4];
7914   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
7915   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
7916   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
7917                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7918   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
7919   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
7920                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7921   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
7922   ////////////////////////////////////
7923   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
7924   ////////////////////////////////////////
7925   //  ITS Ring Cables RB24 Part
7926   ////////////////////////////////////////
7927   Double_t ssdcableitsring3BB24pconzsection[2];
7928   Double_t ssdcableitsring3BB24pconrmin[2];
7929   Double_t ssdcableitsring3BB24pconrmax[2];
7930   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
7931   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
7932   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7933   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
7934                                                                   + fgkSSDCablesLay5RightSideHeight
7935                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7936   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
7937   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
7938   TGeoPcon* ssdcableitsring3BB24pconshape[4];
7939   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7940                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7941                                                                    -                             fgkSSDCableAngle),2);
7942   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
7943                                                                      ssdcableangle-fgkSSDCableAngle
7944                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7945   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7946                                                                    -                      fgkSSDCableAngle
7947                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
7948   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
7949                                                                                                   ssdcableangle-fgkSSDCableAngle
7950                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7951   for(Int_t i=0;i<4;i++)
7952         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
7953                                                          ssdcableitsring3BB24pconrmin[j],
7954                                                          ssdcableitsring3BB24pconrmax[j]); 
7955   TGeoVolume* ssdcableitsring3BB24pcon[4];
7956   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
7957                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
7958   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
7959                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
7960   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
7961                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
7962   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
7963                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
7964   for(Int_t i=0;i<4;i++){
7965         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
7966         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
7967 }
7968   ////////////////////////////////////
7969   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
7970   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
7971   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
7972   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
7973   ////////////////////////////////////
7974   // Volumes for Material Budget 
7975   ////////////////////////////////////
7976   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
7977                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
7978                                                                                                          ssdcableslay6rightsideradiusmax
7979                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
7980                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
7981   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
7982                                                                                                          ssdcablelay6materialbudgetubeshape,
7983                                                                                                          fSSDCopper);
7984   ssdcablelay6materialbudgetube->SetLineColor(9);
7985   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
7986   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
7987
7988   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
7989                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
7990   TGeoVolume* ssdcablelay6materialbudgetpcon;
7991   Double_t ssdcablelay6materialbudgetpconrmin[2];
7992   Double_t ssdcablelay6materialbudgetpconrmax[2];
7993   Double_t ssdcablelay6materialbudgetpconzsection[2];
7994   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
7995                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7996   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
7997                                                                                 + fgkSSDCableMaterialBudgetHeight;
7998   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
7999   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8000   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8001                                                                                         + fgkEndCapSupportCenterLay6Position
8002                                                                                         + ssdcablelay6rightsidelength;
8003   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8004   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8005                                                   ssdcablelay6materialbudgetpconzsection[i],
8006                                                   ssdcablelay6materialbudgetpconrmin[i],
8007                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8008   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8009                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8010   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8011   for(Int_t i=0; i<4; i++){
8012    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8013    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8014   }
8015 ////////////////////////////////////
8016  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8017   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8018   Double_t ssdcablesvolume = 0.0;
8019   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8020   std::cout << ssdcablesvolume << std::endl;*/
8021   return ssdcablesmother;
8022  }
8023  ////////////////////////////////////////////////////////////////////////////////
8024 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8025                                             Double_t height, const char* shapename, Int_t isign) const{
8026   /////////////////////////////////////////////////////////////
8027   // Method generating an Arb shape 
8028   /////////////////////////////////////////////////////////////
8029   const Int_t kvertexnumber = 8;
8030   const Int_t ktransvectnumber = 2;
8031   TVector3 vertex[kvertexnumber];
8032   TVector3 transvector[2];
8033   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
8034   /////////////////////////////////////////////////////////////
8035   //Setting the vertices for TGeoArb8
8036   /////////////////////////////////////////////////////////////
8037   vertex[0] = *vertexpos[0];
8038   vertex[1] = *vertexpos[1];
8039   vertex[2] = vertex[1]; 
8040   vertex[3] = vertex[0]; 
8041   vertex[4] = *vertexpos[2];
8042   vertex[5] = *vertexpos[3];
8043   vertex[6] = vertex[5];
8044   vertex[7] = vertex[4];
8045
8046   // NB: order of points is clockwise
8047   if (isign < 0) {
8048     vertex[2] -= transvector[0];
8049     vertex[3] -= transvector[0];
8050     vertex[6] -= transvector[1];
8051     vertex[7] -= transvector[1];
8052   }
8053   else {
8054     vertex[0] += transvector[0];
8055     vertex[1] += transvector[0];
8056     vertex[4] += transvector[1];
8057     vertex[5] += transvector[1];
8058   }
8059
8060   /////////////////////////////////////////////////////////////
8061   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8062   for(Int_t i = 0; i<kvertexnumber;i++) {
8063     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
8064   }
8065
8066   return arbshape;
8067
8068 ///////////////////////////////////////////////////////////////////////////////
8069 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8070                                                                 Double_t rmax, Int_t nedges, Double_t height){
8071   /////////////////////////////////////////////////////////////
8072   // Method generating Arc shape 
8073   /////////////////////////////////////////////////////////////
8074         const Int_t kvertexnumber = 2*nedges+2;
8075         TGeoXtru* arcshape = new TGeoXtru(2);   
8076         TVector3** vertexposition[2];
8077         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8078         Double_t angle = 0.;
8079     for(Int_t i=0; i<nedges+1; i++){ 
8080                 angle = 90.+0.5*phi-i*(phi/nedges);
8081                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8082                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8083         }
8084         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8085         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8086         for(Int_t i=0; i<kvertexnumber; i++){ 
8087                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8088                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8089                 }
8090                 else if(i>=1&&i<nedges+2)
8091                 {
8092                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8093                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8094                 }
8095         else
8096                 {
8097                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8098                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8099                 }
8100     }
8101   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8102   arcshape->DefineSection(0,-0.5*height);
8103   arcshape->DefineSection(1,0.5*height);
8104   /////////////////////////////////////////////////////////////
8105   // Deallocating memory
8106   /////////////////////////////////////////////////////////////
8107   for(Int_t i=0; i<2; i++){
8108         for(Int_t j=0; j<nedges+1; j++)
8109                 delete vertexposition[i][j];
8110         delete [] vertexposition[i];
8111   }
8112   delete [] xvertexpoints;
8113   delete [] yvertexpoints;
8114   /////////////////////////////////////////////////////////////
8115         return arcshape;
8116 }
8117 ////////////////////////////////////////////////////////////////////////////////
8118 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8119   ///////////////////////////////////////////////////////////////////////
8120   // Method Generating the Screw Shape  
8121   // radius[0]: outer radius
8122   // radius[1]: inner radius
8123   // edgesnumber[0]: outer number of edges
8124   // edgesnumber[1]: inner number of edges
8125   // section[0]: lower section position
8126   // section[1]: higher section position
8127   ///////////////////////////////////////////////////////////////////////
8128   Double_t outradius = radius[0];
8129   Double_t inradius = radius[1];
8130   Int_t outvertexnumber = edgesnumber[0];
8131   Int_t invertexnumber = edgesnumber[1];
8132   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8133   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8134   for(Int_t i=0; i<outvertexnumber; i++){
8135         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8136         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8137   }
8138   for(Int_t i=0; i<invertexnumber; i++){
8139         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8140         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8141   }
8142   TGeoXtru* screwshapeout = new TGeoXtru(2);
8143   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8144   screwshapeout->DefineSection(0,section[0]);
8145   screwshapeout->DefineSection(1,section[1]);
8146   TGeoXtru* screwshapein = new TGeoXtru(2);
8147   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8148   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8149   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8150   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8151   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8152   
8153   delete [] xscrewvertex;
8154   delete [] yscrewvertex;
8155   return screwshape;
8156 }
8157 ////////////////////////////////////////////////////////////////////////////////
8158 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8159   ///////////////////////////////////////////////////////////////////////
8160   // Method Generating the Hole Shape  
8161   // radius of the Hole
8162   // nedges: number of edges to approximate the circle
8163   ///////////////////////////////////////////////////////////////////////
8164   Double_t* xholevertex = new Double_t[nedges];
8165   Double_t* yholevertex = new Double_t[nedges];
8166   Double_t z  = 0.5*(section[0]+section[1]);
8167   Double_t dz = 0.5*(section[1]-section[0]);
8168   TGeoTranslation *tr = 0;
8169   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8170      tr = new TGeoTranslation(0.,0.,z);
8171      tr->RegisterYourself();
8172   }   
8173   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8174   for(Int_t i=0; i<nedges; i++){
8175         xholevertex[i] = radius*CosD(i*360./nedges);
8176         yholevertex[i] = radius*SinD(i*360./nedges);
8177   }
8178   TGeoXtru* holeshapeout = new TGeoXtru(2);
8179   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8180   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8181   holeshapeout->DefineSection(1,section[1]+0.01);
8182   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8183   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8184   
8185   delete [] xholevertex;
8186   delete [] yholevertex;
8187   return holeshape;
8188 }
8189 ////////////////////////////////////////////////////////////////////////////////
8190 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8191   /////////////////////////////////////////////////////////////
8192   // Given an axis specified by param, it gives the reflection of the point
8193   // respect to the axis
8194   /////////////////////////////////////////////////////////////
8195   TVector3* n = new TVector3(param[0],param[1],param[2]);
8196   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8197   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8198   /////////////////////////////////////////////////////////////
8199   // Deallocating memory
8200   /////////////////////////////////////////////////////////////
8201   delete n;
8202   /////////////////////////////////////////////////////////////
8203   return reflectedvector;
8204 }
8205 ////////////////////////////////////////////////////////////////////////////////
8206 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8207                                                        Double_t dx,
8208                                                        Double_t dy,
8209                                                        Double_t dz) const{
8210   /////////////////////////////////////////////////////////////
8211   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8212   /////////////////////////////////////////////////////////////
8213   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8214   const Double_t *vect = hmatrix->GetTranslation();
8215   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8216   hmatrix->SetTranslation(newvect);
8217   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8218   delete hmatrix;
8219   return matrix;
8220 }
8221 ////////////////////////////////////////////////////////////////////////////////
8222 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8223   /////////////////////////////////////////////////////////////
8224   // Method returning the Medium type 
8225   /////////////////////////////////////////////////////////////
8226   char ch[100];
8227   snprintf(ch,100, "ITS_%s",mediumName);
8228   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8229   if (! medium)
8230     AliError(Form("medium %s not found !\n", mediumName));
8231   return medium;
8232 }
8233 ////////////////////////////////////////////////////////////////////////////////
8234 void AliITSv11GeometrySSD::CreateMaterials(){
8235 ///////////////////////////////////
8236 // This part has to be modified
8237 ///////////////////////////////////
8238   ///////////////////////////////////
8239   // Silicon for Sensor
8240   /////////////////////////////////// 
8241   fSSDSensorMedium = GetMedium("SI$");
8242   ///////////////////////////////////
8243   // Silicon Mixture for Sensor
8244   /////////////////////////////////// 
8245   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8246   fSSDChipGlueMedium = GetMedium("EPOXY$");
8247   ///////////////////////////////////
8248   // Stiffener Components Materials
8249   /////////////////////////////////// 
8250   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8251   ///////////////////////////  
8252   // Stiffener Connectors 
8253   ///////////////////////////  
8254   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8255   ////////////////////////////////  
8256   // Stiffener 0603-1812 Capacitor
8257   ////////////////////////////////  
8258   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8259   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8260   fSSDStiffenerCapacitorCapMedium = GetMedium("NiSn$");
8261   ///////////////////////////  
8262   // Stiffener Hybrid Wire 
8263   ///////////////////////////  
8264   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8265   ///////////////////////////  
8266   // Al for Cooling Block
8267   ///////////////////////////  
8268   fSSDAlCoolBlockMedium = GetMedium("AL$");
8269   //////////////////////////////////////////////////////  
8270   // Kapton and Al for Chip Cable Flex and Ladder Cables
8271   //////////////////////////////////////////////////////  
8272   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8273   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8274   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8275   fSSDAlTraceFlexMedium = GetMedium("AL$");
8276   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8277   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8278   /////////////////////////////////////////////////////////////////  
8279   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8280   //////////////////////////////////////////////////////////////////  
8281   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8282   /////////////////////////////////////////////////////////////////  
8283   // G10 for Detector Leg, TubeHolder
8284   //////////////////////////////////////////////////////////////////  
8285   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8286   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8287   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8288   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8289   /////////////////////////////////////////////////////////////////  
8290   // Water and Phynox for Cooling Tube
8291   //////////////////////////////////////////////////////////////////  
8292   fSSDCoolingTubeWater = GetMedium("WATER$");
8293   fSSDCoolingTubePhynox = GetMedium("INOX$");
8294   /////////////////////////////////////////////////////////////////////
8295   // Material for Support Rings
8296   /////////////////////////////////////////////////////////////////////
8297   fSSDSupportRingAl = GetMedium("AL$");
8298   fSSDRohaCellCone = GetMedium("ROHACELL$");
8299   /////////////////////////////////////////////////////////////////////
8300   fSSDAir = GetMedium("SDD AIR$");
8301   fSSDCopper = GetMedium("COPPER$");
8302   fSSDSn = GetMedium("Sn$");
8303   fCreateMaterials = kTRUE;
8304 }
8305 /////////////////////////////////////////////////////////////////////