]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Coding conventions
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41
42 /////////////////////////////////////////////////////////////////////////////////
43 // Names of the Sensitive Volumes of Layer 5 and Layer 6
44 /////////////////////////////////////////////////////////////////////////////////
45 const char* AliITSv11GeometrySSD::fgkSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgkSSDsensitiveVolName6 = "ITSssdSensitivL6";
47 /////////////////////////////////////////////////////////////////////////////////
48 //Parameters for SSD Geometry
49 /////////////////////////////////////////////////////////////////////////////////
50 // Variable for Vertical Disalignement of Modules
51 /////////////////////////////////////////////////////////////////////////////////
52 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
55 // For ladders:
56 const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.520*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.295*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603CapLength  =  0.900*fgkmm;  // Includes solder
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
97 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812CapLength  =  0.215*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   1.400*fgkmm;   
101 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = {44.32*fgkmm, 0.33*fgkmm};
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
105 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       =   0.25*fgkSSDStiffenerHeight;
108 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
109 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSnHeight     =   0.15*fgkmm;
111 /////////////////////////////////////////////////////////////////////////////////
112 // Cooling Block (lengths are in mm and angles in degrees)
113 /////////////////////////////////////////////////////////////////////////////////
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
117                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
119   {1.025*fgkmm, 0.120*fgkmm};  // Added 50 micron tolerance for thicker wall cooling pipe (March 2010)
120 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
121                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
122 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
123                                                                                                                                          1.500*fgkmm;
124 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
125                                                                                                                                          0.300*fgkmm;
126 /////////////////////////////////////////////////////////////////////////////////
127 // SSD Sensor (lengths are in mm and angles in degrees)
128 /////////////////////////////////////////////////////////////////////////////////
129 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
130                                                                                                                  "SSDSensorSensitiveVol";
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
132 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
135                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
136 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
137 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
138 /////////////////////////////////////////////////////////////////////////////////
139 // Flex (lengths are in mm and angles in degrees)
140 /////////////////////////////////////////////////////////////////////////////////
141 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
143                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
144                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
145                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
146                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
147                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
149                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
151                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
152 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
153 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
154 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
155 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
156                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
157 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
158                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
159 /////////////////////////////////////////////////////////////////////////////////
160 // SSD Ladder Cable (lengths are in mm and angles in degrees)
161 /////////////////////////////////////////////////////////////////////////////////
162 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
163 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableHeight[2] = {  0.030*fgkmm*17.5/23.5,  1.25 * 0.030*fgkmm};   // Al covers ~ 17.5/23.5 of surface, Kapton includes glue+foam   
164 /////////////////////////////////////////////////////////////////////////////////
165 // SSD Module (lengths are in mm and angles in degrees)
166 /////////////////////////////////////////////////////////////////////////////////
167 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
168                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
169 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
170                                                                                                                                         45.600*fgkmm;
171 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
172                                                                                                                                          5.075*fgkmm;
173 /////////////////////////////////////////////////////////////////////////////////
174 // Sensor Support (lengths are in mm and angles in degrees)
175 /////////////////////////////////////////////////////////////////////////////////
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
177                                                                                                                                          5.800*fgkmm;
178 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
179                                                                                                                                          2.000*fgkmm;
180 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
181                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
182                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
183 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
184 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
185 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
186                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
187 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
188                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
189                                                             +  fgkSSDSensorSideSupportThickness[0])
190                                                                 -  fgkSSDSensorSideSupportLength;
191 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
192                                                                                                                                     5.250*fgkmm;
193 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
194                                                                                                                                         1.680*fgkmm;
195 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
196                                                                   = {fgkSSDSensorSideSupportHeight[0]
197                                                                   +  fgkSSDSensorSideSupportThickness[0],
198                                                                          fgkSSDSensorSideSupportHeight[1]
199                                                                   +  fgkSSDSensorSideSupportThickness[1]};
200 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
201                                                                   =  {fgkSSDSensorSideSupportThickness[0],
202                                                                           fgkSSDSensorSideSupportThickness[1]};
203 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
204                                                                                                                                    19.000*fgkmm;
205 /////////////////////////////////////////////////////////////////////////////////
206 // Chip Cables (lengths are in mm and angles in degrees)
207 /////////////////////////////////////////////////////////////////////////////////
208 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
209                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
210 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
211                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
212                                                                   -  (fgkSSDSensorSideSupportHeight[1]
213                                                                   -   fgkSSDSensorSideSupportHeight[0])
214                                                                   -   fgkSSDModuleVerticalDisalignment
215                                                                   -   fgkSSDCoolingBlockHoleCenter
216                                                                   -   fgkSSDStiffenerHeight
217                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
218                                                                           fgkSSDModuleCoolingBlockToSensor
219                                                                   -   fgkSSDModuleVerticalDisalignment  
220                                                                   -   fgkSSDCoolingBlockHoleCenter
221                                                                   -       fgkSSDStiffenerHeight
222                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
223 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
224                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
225 /////////////////////////////////////////////////////////////////////////////////
226 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
227 /////////////////////////////////////////////////////////////////////////////////
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
229                                                                                                                                         3.820*fgkmm;
230 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
231 //                                                                                                                                         3.780;
232 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
233                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
235                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
236 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
237                                                                                                                                 { 30.00, 90.00};
238 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
239                                                                                                                                          1.78*fgkmm;
240 /////////////////////////////////////////////////////////////////////////////////
241 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
242 /////////////////////////////////////////////////////////////////////////////////
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
244                                                                    = fgkSSDModuleSensorSupportDistance
245                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
247 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
248                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
249 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
250                                                                                                                                         1.630*fgkmm;
251 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
252 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
253                                                                         = fgkCarbonFiberTriangleLength
254                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
255                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
256                                                                         * TMath::DegToRad());
257 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
258                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
259                                                                         - fgkCarbonFiberSupportWidth)
260                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
261                                                                         - fgkCarbonFiberSupportWidth;
262 /////////////////////////////////////////////////////////////////////////////////
263 // Carbon Fiber Lower Support Parameters (lengths are in mm)
264 /////////////////////////////////////////////////////////////////////////////////
265 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
266 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
267                                                                                                                                           =  0.950*fgkmm;
268 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
269                                                                                                                                           =  1.600*fgkmm;
270 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
271                                                                                                                                           =  0.830*fgkmm;
272 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
273                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
274 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
275                                                                         = fgkCarbonFiberJunctionWidth
276                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
277                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
278 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
279                                                                         = {fgkCarbonFiberLowerSupportWidth
280                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
281                                                                            fgkCarbonFiberLowerSupportWidth
282                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
283                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
284 /////////////////////////////////////////////////////////////////////////////////
285 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
286 /////////////////////////////////////////////////////////////////////////////////
287 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
288                                                            {0.5 * (fgkSSDLay5LadderLength
289                                                                         -  fgkSSDLay5SensorsNumber
290                                                                         *  fgkCarbonFiberJunctionWidth
291                                                                         -  fgkCarbonFiberLowerSupportWidth),
292                                                                 0.5 * (fgkSSDLay5LadderLength
293                                                                         -  fgkSSDLay5SensorsNumber
294                                                                         *  fgkCarbonFiberJunctionWidth
295                                                                         +  fgkCarbonFiberLowerSupportWidth)};
296 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
297                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
298                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
299 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
300                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
301                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
302 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
303                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
304 /////////////////////////////////////////////////////////////////////////////////
305 // Cooling Tube Support (lengths are in mm and angles in degrees)
306 /////////////////////////////////////////////////////////////////////////////////
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
309                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
312 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
313 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
314                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
315 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
316                                                                                                                                           11.70*fgkmm;
317 /////////////////////////////////////////////////////////////////////////////////
318 // Cooling Tube (lengths are in mm and angles in degrees)
319 /////////////////////////////////////////////////////////////////////////////////
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
321 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  1.915*fgkmm/2; // Nominal + 50 micron tolerance; real pipes are closer to 450 micron wall thickness
322 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
323                                                                                                         fgkCarbonFiberJunctionWidth;
324 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
325                                                                          fgkSSDModuleSensorSupportDistance
326                                                                   +      fgkSSDCoolingBlockLength;
327 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
328 /////////////////////////////////////////////////////////////////////////////////
329 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
330 /////////////////////////////////////////////////////////////////////////////////
331 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
332                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
333 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
334                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
335 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
336                                                                                                                                           20.0*fgkmm;
337 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
338                                                                                                                                                     40.0;
339 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
340                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
341 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
342                                                                                                                                           2.5*fgkmm;
343 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
344                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
345 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
346                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
347 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
348                                                                                                                                           1.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
350                                                                                                                                           6.0*fgkmm;
351 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeight      =  
352                                                                                                                                           4.0*fgkmm;
353 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
354                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
355 /////////////////////////////////////////////////////////////////////////////////
356 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
357 /////////////////////////////////////////////////////////////////////////////////
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
359 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
360 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
363 /////////////////////////////////////////////////////////////////////////////////
364 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
365 /////////////////////////////////////////////////////////////////////////////////
366 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
368 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
369                                                                                                   -  fgkSSDMountingBlockHeight[1]
370                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
371                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
372                                                                                                   -      fgkMountingBlockSupportDownHeight,
373                                                                                                          fgkSSDLay6RadiusMin
374                                                                                                   -  fgkSSDMountingBlockHeight[1]
375                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
376                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
377                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
378 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
379                                                                                                     -  fgkSSDMountingBlockHeight[1]
380                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
381                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
382                                                                                                         -  fgkMountingBlockSupportRadius[0],
383                                                                                                            fgkSSDLay6RadiusMax
384                                                                                                     -  fgkSSDMountingBlockHeight[1]
385                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
386                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
387                                                                                                         -  fgkMountingBlockSupportRadius[1]};
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeight = 10.0*fgkmm; // To be verified
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
390 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
391 /////////////////////////////////////////////////////////////////////////////////
392 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
393 /////////////////////////////////////////////////////////////////////////////////
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
398                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
400                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
401 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
402                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
408 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
409 /////////////////////////////////////////////////////////////////////////////////
410 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
411 /////////////////////////////////////////////////////////////////////////////////
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
414 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
415 /////////////////////////////////////////////////////////////////////////////////
416 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
417 /////////////////////////////////////////////////////////////////////////////////
418 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
419                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
423                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
424 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
425                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
426 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
427 /////////////////////////////////////////////////////////////////////////////////
428 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
429 /////////////////////////////////////////////////////////////////////////////////
430 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
431                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
432 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
433                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
434                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
435 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
436 /////////////////////////////////////////////////////////////////////////////////
437 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
438 /////////////////////////////////////////////////////////////////////////////////
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
440                                                                                                            {62.0*fgkmm,21.87*fgkmm};
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
442                                                                                                             {47.0*fgkmm,0.35*fgkmm};
443 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
444                                                                                                                                           1.0*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
447                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
448 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
449                                                                                                                                          0.15*fgkmm;
450 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
451                                                                                                                                          19.0*fgkmm;
452 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
453                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
454 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
455                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
456 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
457                                                                                                                                           2.1*fgkmm;
458 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
459                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
460 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
461                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
462 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
463                                                                                                                                            19*fgkmm; 
464 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
465                                                                                                                                           1.0*fgkmm;
466 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
467                                                                                                                                           3.6*fgkmm;
468 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
469                                                                                                                                          61.0*fgkmm; 
470 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
471                                                                                                                                          5.97*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
474                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
475                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
476 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
477                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
478 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
479                                                                                                                                           1.0*fgkmm; 
480 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
481                                                                                                                                    = 0.15*fgkmm; 
482 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
483                                                                                                                                          20.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
488 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
489 /////////////////////////////////////////////////////////////////////////////////
490 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
491 /////////////////////////////////////////////////////////////////////////////////
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 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   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++){
617     fendladdermountingblockcombitrans[i] = NULL;
618   }
619   for (Int_t i=0; i < fgkcarbonfibersupportnumber; i++) {
620     fcarbonfibersupport[i] = 0;
621     fcarbonfibersupportmatrix[i] = 0;
622   }
623   for (Int_t i=0; i < fgkcarbonfiberjunctionumber; i++) {
624     fcarbonfiberjunctionmatrix[i] = 0;
625   }
626   for (Int_t i=0; i < fgkcarbonfiberlowersupportnumber; i++) {
627     fcarbonfiberlowersupport[i] = 0;
628     fcarbonfiberlowersupportrans[0] = 0;
629   }
630   for (Int_t i=0; i < fgkvolumekind; i++) {
631     fssdsensorsupport[i] = 0;
632   }
633   for (Int_t i=0; i < fgkssdsensorsupportnumber; i++) {
634     fssdsensorsupportmatrix[i] = 0;
635   }
636   for (Int_t i=0; i < fgkcoolingtubesupportnumber; i++) {
637     fcoolingtubesupportmatrix[i] = 0;
638   }
639   for (Int_t i=0; i < fgkhybridcompnumber; i++) {
640     fssdhybridcomponent[i] = 0;
641   }
642   for (Int_t i=0; i < fgkcoolingblocknumber; i++) {
643     fcoolingblockmatrix[i] = 0;
644   }
645   for (Int_t i=0; i < fgkflexnumber; i++) {
646     fstiffenerflexmatrix[i] = 0;
647     fendflexmatrix[i] = 0;
648   }
649   for (Int_t i=0; i < fgkendladdercoolingtubenumber; i++) {
650     fendladdercoolingtube[i] = 0;
651     for (Int_t j = 0; j < 2; j++) 
652       fendladdercoolingtubematrix[i][j] = 0;
653   }
654   for (Int_t i=0; i < fgkendlabbercarbonfiberjunctionumber; i++) {
655     fendladdercarbonfiberjunction[i] = 0;
656   }
657   for (Int_t i=0; i < fgkendladdercarbonfiberjunctionmatrixnumber; i++) {
658     fendladdercarbonfiberjunctionmatrix[i] = 0;
659   }
660   for (Int_t i=0; i < fgkendladdercarbonfibermatrixnumber; i++) {
661     fendladdercarbonfibermatrix[i] = 0;
662   }
663   for (Int_t i=0; i < fgkendladdermountingblocknumber; i++) {
664     fendladdermountingblockclipmatrix[i] = 0;
665   }
666   for (Int_t i = 0; i < fgkendladderlowersuppnumber+1; i++) {
667     fendladderlowersupptrans[i] = 0;
668   }
669   for (Int_t i = 0; i < fgkladdercablesnumber; i++) {
670     fladdercablematrix[i] = 0;
671   }
672   for (Int_t i = 0; i < fgkladdersegmentnumber; i++) {
673     fladdersegment[i] = 0;
674   }
675   for (Int_t i = 0; i < fgkladdernumber; i++) {
676     fladder[i] = 0;
677     fladdermatrix[i] = 0;
678     fssdsensormatrix[i] = 0;
679     flayermatrix[i] = 0;
680   }
681   for (Int_t i = 0; i < 2; i++) {
682     fLay5LadderSupport[i] = 0;
683     fLay6LadderSupport[i] = 0;
684     fcoolingtubematrix[i] = NULL;
685     fendladdersegment[i] = NULL;
686     fendladdersegmentmatrix[i] = NULL;
687   }
688 }
689
690 ///////////////////////////////////////////////////////////////////////////////
691 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
692   ///////////////////////////////////////////////////////////////////////  
693   // Method generating the trasformation matrix for the whole SSD Geometry   
694   ///////////////////////////////////////////////////////////////////////  
695   // Setting some variables for Carbon Fiber Supportmatrix creation
696   //////////////////////////////////////////////////////////////////////
697   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
698                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
699   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
700                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
701                                                                  +      fgkCarbonFiberSupportWidth);
702   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
703                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
704   TGeoRotation* carbonfiberot[3];
705   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
706   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
707   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
708   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
709   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
710                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
711                                                   -  fgkCarbonFiberTriangleLength
712                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
713   ///////////////////////////////////////////
714   //Setting Local Translations and Rotations: 
715   ///////////////////////////////////////////
716   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
717   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
718                                                                          0.5*carbonfibersupportheight,NULL);    
719   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
720                                                                          2.*symmetryplaneposition+transvector[1],
721                                                                          transvector[2], carbonfiberot[2]);
722   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
723   /////////////////////////////////////////////////////////////
724   // Carbon Fiber Support Transformations
725   /////////////////////////////////////////////////////////////
726   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
727   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
728                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
729                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
730                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
731   }             
732   /////////////////////////////////////////////////////////////
733   // Carbon Fiber Junction Transformation
734   /////////////////////////////////////////////////////////////
735   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
736   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
737   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
738   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
739   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
740         localcarbonfiberjunctionmatrix[i] = 
741                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
742         localcarbonfiberjunctionrot[i] = 
743                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
744         localcarbonfiberjunctiontrans[i] = 
745                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
746   }
747   ///////////////////////
748   // Setting Translations
749   ///////////////////////
750   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
751   localcarbonfiberjunctiontrans[1][0] = 
752                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
753   localcarbonfiberjunctiontrans[2][0] = 
754                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
755                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
756                                  fgkCarbonFiberTriangleLength
757                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
758   localcarbonfiberjunctiontrans[0][1] = 
759                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
760   localcarbonfiberjunctiontrans[1][1] = 
761                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
762   localcarbonfiberjunctiontrans[2][1] = 
763                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
764   ////////////////////
765   // Setting Rotations
766   ////////////////////
767   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
768                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
769                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
772   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
773   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
774   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
775   ////////////////////////////////////////
776   // Setting Carbon Fiber Junction matrix 
777   ////////////////////////////////////////
778   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
779                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
780                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
781                         localcarbonfiberjunctionmatrix[i][j] = 
782                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
783                                                            *localcarbonfiberjunctionrot[i][j]);
784                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
785          }
786   }
787   /////////////////////////////////////////////////////////////
788   // Carbon Fiber Lower Support Transformations
789   /////////////////////////////////////////////////////////////
790   TGeoTranslation* localcarbonfiberlowersupportrans[2];
791   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
792                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
793                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
794                                                                          0.0);
795   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
796                                                                          fgkCarbonFiberJunctionWidth
797                                                                 -    fgkCarbonFiberLowerSupportWidth
798                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
799                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
800                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
801    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
802    fcarbonfiberlowersupportrans[0] = 
803                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
804    fcarbonfiberlowersupportrans[1] = 
805                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
806   /////////////////////////////////////////////////////////////
807   // SSD Sensor Support Transformations
808   /////////////////////////////////////////////////////////////
809   const Int_t kssdsensorsupportmatrixnumber = 3;
810   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
811   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
812   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
813   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
814         localssdsensorsupportmatrix[i] = 
815                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
816         localssdsensorsupportrot[i] = 
817                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
818         localssdsensorsupportrans[i] = 
819                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
820   }
821   ///////////////////////
822   // Setting Translations
823   ///////////////////////
824   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
825                                                                           0.5*fgkSSDSensorSideSupportWidth,
826                                                                           0.0);
827   localssdsensorsupportrans[1][0] = 
828                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
829   localssdsensorsupportrans[2][0] = 
830                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
831   localssdsensorsupportrans[0][1] = 
832                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
833                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
834                                                                                 0.0);
835   localssdsensorsupportrans[1][1] = 
836                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
837                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
838                                                                     -   fgkSSDModuleSensorSupportDistance,
839                                                                                 0.0);
840   localssdsensorsupportrans[2][1] = 
841                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
842                                                                         -    fgkSSDSensorCenterSupportPosition,
843                                                                                  0.5*fgkSSDSensorCenterSupportWidth
844                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
845                                                                                  fgkSSDSensorCenterSupportThickness[0]);
846   localssdsensorsupportrans[0][2] = 
847                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
848                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
849                                                                                  fgkCarbonFiberJunctionWidth
850                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
851                                                                         +    fgkSSDSensorCenterSupportLength
852                                                                         -    fgkSSDSensorCenterSupportThickness[0])
853                                                                         -    fgkSSDSensorCenterSupportPosition,
854                                                                              0.0);
855   localssdsensorsupportrans[1][2] = 
856                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
857   localssdsensorsupportrans[2][2] = 
858                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
859   ////////////////////
860   // Setting Rotations
861   ////////////////////
862   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
863                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
864                         localssdsensorsupportrot[i][j] = new TGeoRotation();
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
866         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
867         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
868   }
869   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
870   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
871   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
872   ////////////////////////////////////////
873   // SSD Sensor Support matrix 
874   ////////////////////////////////////////
875   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
876                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
877                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
878                         localssdsensorsupportmatrix[i][j] = 
879                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
880                                                            *localssdsensorsupportrot[i][j]);
881                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
882          }
883   }
884   /////////////////////////////////////////////////////////////
885   // SSD Cooling Tube Support Transformations
886   /////////////////////////////////////////////////////////////
887   const Int_t kcoolingtubesupportmatrixnumber = 2;
888   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
889   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
890   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
891   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
892                                                                                                         /fgkCoolingTubeSupportRmax);
893   localcoolingtubesupportrans[0] = 
894                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
895                                                 +  2.*(fgkCoolingTubeSupportLength
896                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
897                                                 +  fgkCarbonFiberTriangleLength
898                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
899   localcoolingtubesupportrans[1] = 
900                         new TGeoTranslation(fgkCarbonFiberJunctionLength
901                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
902                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
903                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
904                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
905                     -  0.5*(fgkCarbonFiberLowerSupportWidth
906                                         +          fgkSSDSensorCenterSupportLength
907                     -      fgkSSDSensorCenterSupportThickness[0])
908                                         +  0.5*fgkSSDSensorLength,
909                                         -  0.5*fgkCoolingTubeSupportHeight);  
910   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
911   localcoolingtubesupportrot[i] = new TGeoRotation();
912   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
913   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
914   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
915         localcoolingtubesupportmatrix[i] = 
916                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
917                                                    *localcoolingtubesupportrot[i]);
918   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
919   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
920                                                                 (*localcoolingtubesupportmatrix[0]));
921   /////////////////////////////////////////////////////////////
922   // End Ladder SSD Cooling Tube Support Transformations
923   /////////////////////////////////////////////////////////////
924   TGeoTranslation** localendladdercooltubetrans[2];
925   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
926   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
927   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
928   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
929                                                                                         -          (fgkCoolingTubeSupportLength
930                                                                                         -               fgkCoolingTubeSupportRmax),
931                                                                                                         fgkEndLadderMountingBlockPosition[0]
932                                                                                         -               fgkendladdercoolingsupportdistance[0]
933                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
934                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
935   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
936                                                                                         -          (fgkCoolingTubeSupportLength
937                                                                                         -               fgkCoolingTubeSupportRmax),
938                                                                                                         fgkEndLadderMountingBlockPosition[0]
939                                                                                         +               fgkendladdercoolingsupportdistance[1]
940                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
941                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
942   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
943                                                                                         -       fgkCoolingTubeSupportRmax)
944                                                                                         +               fgkCarbonFiberTriangleLength
945                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
946                                                                                                 0.0,
947                                                                                                 0.0);
948   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
949                                                                                                         fgkendladdercoolingsupportdistance[0]
950                                                                                         +               fgkendladdercoolingsupportdistance[1],
951                                                                                                         0.0);
952   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
953   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
954                                                                                         +               fgkCarbonFiberJunctionLength
955                                                                                         -               fgkCoolingTubeSupportLength,
956                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
957                                                                                         -       0.5*fgkCoolingTubeSupportWidth
958                                                                                                    -fgkendladdercoolingsupportdistance[2],
959                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
960   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
961                                                                                         +               fgkCoolingTubeSupportLength
962                                                                                         -               fgkCoolingTubeSupportRmax
963                                                                                         -               fgkCarbonFiberJunctionLength,
964                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
965                                                                                         -       0.5*fgkCoolingTubeSupportWidth
966                                                                                         -               fgkendladdercoolingsupportdistance[2],
967                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
968   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
969   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
970   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
971   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
972   (*localcoolingtubesupportrot[1]));
973   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
974   (*localcoolingtubesupportrot[1]));
975   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
976   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
977   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
978   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
979   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
980
981   fendladdercoolingtubesupportmatrix[1][0] =    
982                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
983                                                                                    *(*localcoolingtubesupportrot[1]));
984   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
985   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
986   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
987   /////////////////////////////////////////////////////////////
988   // SSD Cooling Tube Transformations
989   /////////////////////////////////////////////////////////////
990   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
991   localcoolingtuberot->SetAngles(0.,90.,0.);
992   TGeoTranslation* localcoolingtubetrans[2];
993   TVector3* localcoolingtubevect[2];
994
995   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
996                                                   -fgkCarbonFiberTriangleLength),
997                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
998                                             - fgkCarbonFiberLowerSupportWidth 
999                                             - fgkLowerSupportToSensorZ ,
1000                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1001   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
1002                                               localcoolingtubevect[0]->Y(),
1003                                               localcoolingtubevect[0]->Z());
1004   for(Int_t j=0; j<2; j++){
1005     localcoolingtubetrans[j] = 
1006         new TGeoTranslation(localcoolingtubevect[j]->X(),
1007                             localcoolingtubevect[j]->Y(),
1008                             localcoolingtubevect[j]->Z());
1009      fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
1010                                              *(*localcoolingtuberot));
1011   }
1012   /////////////////////////////////////////////////////////////
1013   // SSD End Ladder Cooling Tube Transformations
1014   /////////////////////////////////////////////////////////////
1015   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1016   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1017   TGeoTranslation** localendlladdercoolingtubetrans[2];
1018   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
1019   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
1020   for(Int_t i=0; i<2; i++)      
1021         for(Int_t j=0; j<2; j++)        
1022                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1023
1024   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
1025   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1026                                                                         -        fgkCoolingTubeSupportRmax)
1027                                                                         +        fgkCarbonFiberJunctionLength,
1028                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1029                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1030   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1031                                                                         -        fgkCoolingTubeSupportRmax)
1032                                                                         -        fgkCarbonFiberJunctionLength
1033                                                                         +    fgkCarbonFiberTriangleLength,
1034                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1035                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1036
1037   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1038                                                           -   fgkCoolingTubeSupportRmax)
1039                                                         +       fgkCarbonFiberJunctionLength,
1040                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1041                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1042   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1043                                                   -      fgkCoolingTubeSupportRmax)
1044                                                   -      fgkCarbonFiberJunctionLength
1045                                                   +    fgkCarbonFiberTriangleLength,
1046                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1047                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1048   for(Int_t i=0; i<2; i++)
1049         for(Int_t j=0; j<2; j++){
1050                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1051                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1052         }
1053   /////////////////////////////////////////////////////////////
1054   // SSD Hybrid Components Transformations
1055   /////////////////////////////////////////////////////////////
1056   const Int_t khybridmatrixnumber = 3;
1057   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1058   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1059                                             0.5*fgkSSDStiffenerWidth,
1060                                             0.5*fgkSSDStiffenerHeight);
1061   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1062                                             fgkSSDModuleStiffenerPosition[1],0.0);
1063
1064   localhybridtrans[2] = new TGeoTranslation(
1065                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1066                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1067                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1068                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1069                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1070                       -       fgkSSDSensorCenterSupportThickness[0]),
1071                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1072                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1073                                           -       fgkSSDModuleVerticalDisalignment)); 
1074   fhybridmatrix = new TGeoHMatrix();
1075   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1076   /////////////////////////////////////////////////////////////
1077   // SSD Cooling Block Transformations
1078   /////////////////////////////////////////////////////////////
1079   TGeoTranslation localcoolingblocktrans (fcoolingtubematrix[0]->GetTranslation()[0] 
1080                                           - 0.5*fgkSSDCoolingBlockLength,
1081                                           fhybridmatrix->GetTranslation()[1]-0.5*fgkSSDStiffenerWidth,
1082                                           fhybridmatrix->GetTranslation()[2]+0.5*fgkSSDStiffenerHeight+
1083                                           0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1084   fcoolingblocksystematrix = new TGeoHMatrix(localcoolingblocktrans);
1085   /////////////////////////////////////////////////////////////
1086   // SSD Stiffener Flex Transformations
1087   /////////////////////////////////////////////////////////////
1088   const Int_t klocalflexmatrixnumber = 4;
1089   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1090   for(Int_t i=0; i<fgkflexnumber; i++)    
1091       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1092   for(Int_t i=0; i<fgkflexnumber; i++)
1093       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1094             localflexmatrix[i][j] = new TGeoCombiTrans();
1095   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1096                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1097                                                                   -    fgkSSDStiffenerWidth;
1098   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1099                                         +0.5*fgkSSDStiffenerLength,
1100                                          0.5*fgkSSDStiffenerWidth,
1101                                         -0.5*fgkSSDStiffenerHeight
1102                                         -0.5*fgkSSDFlexHeight[0]);
1103   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1104                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1105                                         -0.5*fgkSSDStiffenerWidth,
1106                                         -0.5*fgkSSDStiffenerHeight
1107                                         -0.5*fgkSSDFlexHeight[0]);
1108   TGeoRotation* localflexrot = new TGeoRotation();
1109   localflexrot->SetAngles(180.,0.,0.);    
1110   localflexmatrix[1][0]->SetRotation(localflexrot);
1111   for(Int_t i=0; i<fgkflexnumber; i++)
1112       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1113             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1114   for(Int_t i=0; i<fgkflexnumber; i++){
1115       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1116       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1117             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1118   }
1119   /////////////////////////////////////////////////////////////
1120   // SSD End Flex Transformations
1121   /////////////////////////////////////////////////////////////
1122   TGeoRotation* localendflexrot = new TGeoRotation();
1123   localendflexrot->SetAngles(0.0,90.0,0.0);
1124   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1125   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1126                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1127   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1128                             * TMath::DegToRad()*ssdflexradiusmax
1129                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1130                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1131                                                                                    - 0.1*fgkSSDFlexFullLength;
1132   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1133                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1134                             +      fgkSSDFlexLength[2];
1135   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1136                               0.5*fgkSSDFlexWidth[0],
1137                               2.*fgkSSDStiffenerHeight
1138                             + 0.5*fgkSSDFlexHeight[0]);      
1139   localendflexmatrix->SetRotation(localendflexrot);
1140   for(Int_t i=0; i<fgkflexnumber; i++) 
1141       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1142   /////////////////////////////////////////////////////////////
1143   // End Ladder Carbon Fiber Junction
1144   /////////////////////////////////////////////////////////////
1145   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1146   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1147   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1148   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1149       localendladdercarbonfiberjunctionmatrix[i] 
1150             = new TGeoCombiTrans*[fgkendladdercarbonfiberjunctionmatrixnumber];
1151       localendladdercarbonfiberjunctionrot[i] 
1152             = new TGeoRotation*[fgkendladdercarbonfiberjunctionmatrixnumber];
1153       localendladdercarbonfiberjunctiontrans[i] 
1154             = new TGeoTranslation*[fgkendladdercarbonfiberjunctionmatrixnumber];
1155       fendladdercarbonfiberjunctionmatrix[i]
1156             = new TGeoHMatrix*[fgkendladdercarbonfiberjunctionmatrixnumber];
1157   }
1158   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1159       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1160             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1161             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1162       }
1163   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1164       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
1165           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1166   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1167       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1168                               0.0,0.0);
1169       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1170                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1171                 *                     SinD(fgkCarbonFiberTriangleAngle),
1172                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1173   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1174   }
1175   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1176   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1177   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1178   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1179       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1180       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1181       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1182       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1183             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1184       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1185             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1186                                *localendladdercarbonfiberjunctionglobalrot[i]);
1187   }
1188   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1189       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1190             localendladdercarbonfiberjunctionmatrix[i][j] = 
1191                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1192                                      *localendladdercarbonfiberjunctionrot[i][j]);
1193            fendladdercarbonfiberjunctionmatrix[i][j] =
1194             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1195             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1196       }  
1197   /////////////////////////////////////////////////////////////
1198   // End Ladder Carbon Fiber Support
1199   /////////////////////////////////////////////////////////////
1200   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1201   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1202       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1203       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1204             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1205       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1206   }
1207   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1208       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1209             fendladdercarbonfibermatrix[i][j] = 
1210             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1211             *(*fcarbonfibersupportmatrix[j]));
1212   /////////////////////////////////////////////////////////////
1213   // End Ladder SSD Mounting Block
1214   /////////////////////////////////////////////////////////////
1215   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1216       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1217   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1218       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1219                                 +        fgkSSDMountingBlockLength[1])
1220                                 +  0.5*fgkCarbonFiberTriangleLength,
1221                                 fgkEndLadderMountingBlockPosition[i],
1222                                 -  fgkSSDMountingBlockHeight[1]
1223                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1224   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1225   endladdermountingblockrot->SetAngles(0.,90.,0.);
1226   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1227         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1228   /////////////////////////////////////////////////////////////
1229   // End Ladder SSD Mounting Block Clip Matrix 
1230   /////////////////////////////////////////////////////////////
1231   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1232         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1233   
1234   TGeoRotation* localendladdercliprot = new TGeoRotation();
1235   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1236   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1237                                                                                   -     fgkSSDMountingBlockLength[1])
1238                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1239   localendladdercliprot->SetAngles(90.,180.,-90.);
1240   TGeoCombiTrans* localendladderclipcombitrans = 
1241                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1242   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1243         for(Int_t j=0; j<2; j++){
1244                 fendladdermountingblockclipmatrix[i][j] = 
1245                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1246                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1247         }
1248   /////////////////////////////////////////////////////////////
1249   // End Ladder Carbon Fiber Lower Support
1250   /////////////////////////////////////////////////////////////
1251   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1252       fendladderlowersupptrans[i] = 
1253             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1254                         +  0.5*fgkSSDMountingBlockWidth),
1255                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1256   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1257                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1258                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1259                                                                          0.0);
1260   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1261  /////////////////////////////////////////////////////////////
1262   // Matrix for positioning Ladder into mother volume
1263   /////////////////////////////////////////////////////////////
1264   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1265   for(Int_t i=0; i<fgkladdernumber; i++) 
1266         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1267   TGeoRotation* localladdermotherrot = new TGeoRotation();
1268   localladdermotherrot->SetAngles(0.,90.,0.);  
1269   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1270   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1271   for(Int_t i=0; i<fgkladdernumber; i++){
1272         localladdermothertrans[i] = new TGeoTranslation(0.,
1273                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1274                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1275                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1276                                                           * fgkCarbonFiberJunctionWidth,0.);
1277         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1278                                                                                                                 *localladdermotherrot);
1279         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1280         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1281   }
1282   /////////////////////////////////////////////////////////////
1283   // Ladder Cables Matrices
1284   /////////////////////////////////////////////////////////////
1285   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1286                                              + fgkSSDFlexHeight[1];  
1287   Double_t ssdladdercabletransx[3];
1288   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1289                                                   *   SinD(2.*fgkSSDFlexAngle)
1290                                                   *       CosD(2.*fgkSSDFlexAngle);
1291   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1292                                                   -     ssdladdercabletransx[0]
1293                                                   /     SinD(2.*fgkSSDFlexAngle))
1294                                                   *     CosD(fgkSSDFlexAngle);                                          
1295   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1296                                                   *       TMath::DegToRad()*ssdflexradiusmax
1297                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1298                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1299                                                   -       fgkSSDLadderCableWidth)
1300                                                   *       CosD(2.*fgkSSDFlexAngle);
1301   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1302                                                   *     TanD(2.*fgkSSDFlexAngle),
1303                                                         ssdladdercabletransx[1]
1304                                                   *     TanD(fgkSSDFlexAngle),
1305                                                         ssdladdercabletransx[2]
1306                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1307   TGeoRotation* localladdercablerot[3]; 
1308   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1309   localladdercablerot[0]->SetAngles(90.,0.,0.);
1310   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1311   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1312                                                  *                        (*localladdercablerot[0]));
1313   //TGeoRotation* localladdercablerot = new TGeoRotation();     
1314   //localladdercablerot->SetAngles(90.,0.,0.);
1315   ////////////////////////////////////////////
1316   // LocalLadderCableCombiTransMatrix
1317   ////////////////////////////////////////////
1318   const Int_t klocalladdersidecablesnumber = 2;
1319   const Int_t klocalladdercombitransnumber = 5;
1320   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1321   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1322          localladdercablecombitransmatrix[i] = 
1323                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1324   ///////////////////////////////////////////
1325   // Left Side Ladder Cables Transformations
1326   ///////////////////////////////////////////
1327   localladdercablecombitransmatrix[0][0]  =
1328                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1329                                                 0.,0.,NULL);
1330   localladdercablecombitransmatrix[0][1] = 
1331         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1332                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1333                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1334                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1335                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1336                                            + fgkSSDSensorCenterSupportLength
1337                                            - fgkSSDSensorCenterSupportThickness[0]),
1338                                            - (fgkSSDModuleCoolingBlockToSensor
1339                                            + 0.5*fgkCoolingTubeSupportHeight
1340                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1341                                            - fgkSSDChipHeight),NULL);
1342   localladdercablecombitransmatrix[0][2] = 
1343                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1344                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1345   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1346                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1347                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1348                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1349                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1350                                                                                                 new TGeoRotation("",180.,0.,0.));
1351   localladdercablecombitransmatrix[0][4] = 
1352                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1353                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1354                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1355                                                           0.,
1356                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1357                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1358                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1359                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1360   ///////////////////////////////////////////
1361   // Rigth Side Ladder Cables Transformations
1362   ///////////////////////////////////////////
1363   TGeoCombiTrans* localladdercablessdmodulematrix = 
1364         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1365                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1366                                                                          fgkSSDStiffenerWidth,
1367                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1368   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1369    localladdercablecombitransmatrix[1][i] = 
1370                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1371                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1372   ///////////////////////////////////////////
1373   // Setting LadderCableHMatrix
1374   ///////////////////////////////////////////
1375   Int_t beamaxistrans[2][3];
1376   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1377   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1378   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1379   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1380   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1381   beamaxistrans[1][2] = beamaxistrans[1][0];
1382   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1383   TGeoRotation* laddercablerot = new TGeoRotation();
1384   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1385   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1386   Double_t* laddercabletransvector;     
1387   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1388         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1389         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1390   }
1391   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1392         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1393                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1394                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1395                         localladdercablehmatrix[i][j]->MultiplyLeft(
1396                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1397         }
1398                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1399                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1400                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1401                                                                          laddercabletransvector[1]
1402                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1403                                         *                                fgkCarbonFiberJunctionWidth,
1404                                                                          laddercabletransvector[2]);
1405                 laddercablecombitrans->SetRotation(*laddercablerot);
1406                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1407                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1408         }
1409     fladdercablematrix[i][2] = 
1410                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1411                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1412         fladdercablematrix[i][3] = 
1413                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1414                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1415   }
1416   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1417     for(Int_t j=0; j<klocalladdercombitransnumber-1; j++) 
1418       fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1419   
1420   ///////////////////////////////////////////
1421   // Setting Ladder HMatrix
1422   ///////////////////////////////////////////
1423   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1424                                                                                                 fgkSSDLay6SensorsNumber};
1425   for(Int_t i=0; i<fgkladdernumber; i++){
1426         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1427         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1428                 fladdermatrix[i][j] = new TGeoHMatrix();
1429                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1430                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1431                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1432         }
1433   }
1434   ///////////////////////////////////////////
1435   // Setting SSD Sensor Matrix 
1436   ///////////////////////////////////////////
1437   TGeoCombiTrans* localssdsensorcombitrans[2];
1438   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1439   localssdsensorrot->SetAngles(0.,90.,0.);      
1440   TGeoTranslation* localssdsensortrans[2];
1441   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1442   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1443                                          fgkCarbonFiberJunctionWidth 
1444                                          - fgkCarbonFiberLowerSupportWidth 
1445                                          - fgkLowerSupportToSensorZ,
1446                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1447                                           -             fgkSSDModuleCoolingBlockToSensor
1448                                           +    (fgkSSDSensorSideSupportHeight[1]
1449                                           -             fgkSSDSensorSideSupportHeight[0]));
1450   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1451                                          fgkCarbonFiberJunctionWidth 
1452                                          - fgkCarbonFiberLowerSupportWidth 
1453                                          - fgkLowerSupportToSensorZ,
1454                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1455                                                         -fgkSSDModuleCoolingBlockToSensor);
1456
1457   for(Int_t i=0; i<2; i++) 
1458         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1459                                                                                                          *localssdsensorrot);   
1460     for(Int_t i=0; i<fgkladdernumber; i++){
1461         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1462         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1463                 switch(i){
1464                         case 0: //Ladder of Layer5  
1465                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1466                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1467                                                                                                 *localssdsensorcombitrans[1])));
1468                         break;
1469                         case 1: //Ladder of Layer6 
1470                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1471                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1472                                                                                                 *localssdsensorcombitrans[0])));
1473                 break;
1474                 }
1475           }
1476   }     
1477   //////////////////////////
1478   // Setting SSD End Ladder  
1479   //////////////////////////
1480   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1481   for(Int_t i=0; i<2; i++){
1482         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1483         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1484         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1485         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1486         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1487         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1488         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1489         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1490    }
1491   /////////////////////////////////////////////////////
1492   // Setting the CombiTransformation to pass ITS center 
1493   /////////////////////////////////////////////////////
1494   Double_t itscentertransz[fgklayernumber];
1495   itscentertransz[0] = fgkSSDLay5LadderLength
1496                                          - fgkLay5CenterITSPosition;
1497   itscentertransz[1] = fgkSSDLay6LadderLength
1498                                          - fgkLay6CenterITSPosition;
1499   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1500                                                    + 0.5*fgkCoolingTubeSupportHeight;
1501   TGeoRotation* itscenterrot[3];
1502   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1503   itscenterrot[0]->SetAngles(90.,180.,-90.);
1504   itscenterrot[1]->SetAngles(0.,90.,0.);
1505   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1506   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1507   for(Int_t i=0; i<fgklayernumber; i++) 
1508         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1509                                                          itssensortransy,
1510                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1511                                                    - itscentertransz[i],itscenterrot[2]);
1512   TGeoRotation** locallayerrot[fgklayernumber];
1513   TGeoTranslation** locallayertrans[fgklayernumber];    
1514   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1515   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1516   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1517                                          - fgkLay5CenterITSPosition);
1518   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1519                                          - fgkLay6CenterITSPosition);
1520   const Int_t kssdlayladdernumber[fgklayernumber] = 
1521                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1522   for(Int_t i=0; i<fgklayernumber; i++){
1523     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1524     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1525         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1526         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1527   }
1528   Double_t layerladderangleposition[fgklayernumber] = 
1529                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1530   Double_t layerradius = 0.;
1531   for(Int_t i=0; i<fgklayernumber; i++){        
1532         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1533                 switch(i){
1534                         case 0: //Ladder of Layer5  
1535                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1536                         break;
1537                         case 1: //Ladder of Layer6 
1538                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1539                 break;
1540                 }
1541                 locallayerrot[i][j] = new TGeoRotation();
1542                 locallayertrans[i][j] = new TGeoTranslation();
1543                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1544                 locallayertrans[i][j]->SetTranslation(layerradius 
1545                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1546                                                             layerradius 
1547                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1548                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1549                                                                          *locallayerrot[i][j]);
1550                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1551                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1552                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1553         }
1554   }
1555   /////////////////////////////////////////////////////////////
1556   // Deallocating memory
1557   /////////////////////////////////////////////////////////////
1558   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1559         delete carbonfiberot[i];
1560         delete localcarbonfibersupportmatrix[i];
1561   }
1562   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1563      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1564        delete localcarbonfiberjunctionmatrix[i][j];
1565            delete localcarbonfiberjunctionrot[i][j];
1566            delete localcarbonfiberjunctiontrans[i][j];
1567            }
1568        delete [] localcarbonfiberjunctionmatrix[i];
1569        delete [] localcarbonfiberjunctionrot[i];
1570        delete [] localcarbonfiberjunctiontrans[i];
1571   }
1572   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1573            delete localcarbonfiberlowersupportrans[i];
1574   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1575      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1576        delete localssdsensorsupportmatrix[i][j];
1577            delete localssdsensorsupportrot[i][j];
1578            delete localssdsensorsupportrans[i][j];
1579            }
1580        delete [] localssdsensorsupportmatrix[i];
1581        delete [] localssdsensorsupportrot[i];
1582        delete [] localssdsensorsupportrans[i];
1583   }
1584   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1585         delete localcoolingtubesupportmatrix[i];
1586         delete localcoolingtubesupportrot[i];
1587         delete localcoolingtubesupportrans[i];
1588   }
1589   for(Int_t j=0; j<2; j++){
1590     delete localcoolingtubevect[j];
1591     delete localcoolingtubetrans[j];
1592   }
1593  delete endladdermountingblockrot;
1594  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1595  for(Int_t i=0; i<fgkflexnumber; i++){
1596       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1597             delete localflexmatrix[i][j];
1598       delete [] localflexmatrix[i];
1599  }
1600  delete localendlladdercoolingtuberot;
1601  for(Int_t i=0; i<2; i++){
1602         for(Int_t j=0; j<2; j++)
1603           delete localendlladdercoolingtubetrans[i][j];
1604         delete [] localendlladdercoolingtubetrans[i];
1605   }
1606
1607  delete localflexrot;
1608  delete localendflexrot;
1609  delete localendflexmatrix;
1610  for(Int_t i=0; i<fgkladdernumber; i++){ 
1611         delete localladdermothertrans[i];
1612         delete localladdermothercombitrans[i];
1613   }
1614  delete localladdermotherrot;
1615  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1616       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1617             delete localendladdercarbonfiberjunctionmatrix[i][j];
1618             delete localendladdercarbonfiberjunctionrot[i][j];
1619             delete localendladdercarbonfiberjunctiontrans[i][j];
1620       }
1621       delete [] localendladdercarbonfiberjunctionmatrix[i];
1622       delete [] localendladdercarbonfiberjunctionrot[i];
1623       delete [] localendladdercarbonfiberjunctiontrans[i];
1624       delete localendladdercarbonfiberjunctionglobalrot[i];
1625       delete localendladdercarbonfiberjunctionglobaltrans[i];
1626       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1627  }
1628   for(Int_t i=0; i<2; i++){
1629         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1630         delete [] localendladdercooltubetrans[i];
1631   }
1632   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1633       delete localendladdercarbonfibertrans[i];
1634   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1635   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1636         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1637                 delete localladdercablecombitransmatrix[i][j];
1638                 delete []localladdercablecombitransmatrix[i];
1639   }
1640   delete localendladdercliprot;
1641   delete localendladdercliptrans;
1642   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1643         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1644                 delete localladdercablehmatrix[i][j];
1645         delete []localladdercablehmatrix[i];
1646   }
1647   delete laddercablerot;
1648   delete laddercabletrans;
1649   delete laddercablecombitrans;
1650   delete localladdercablessdmodulematrix;
1651   delete localssdsensorrot;     
1652   for(Int_t i=0; i<2; i++){
1653         delete localssdsensortrans[i];
1654         delete localssdsensorcombitrans[i];
1655   }
1656   for(Int_t i=0; i<fgklayernumber; i++){
1657         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1658                 delete locallayerrot[i][j];
1659                 delete locallayertrans[i][j];
1660                 delete locallayercombitrans[i][j];
1661     }
1662         delete [] locallayerrot[i];
1663         delete [] locallayertrans[i];
1664         delete [] locallayercombitrans[i];
1665         delete localbeamaxistrans[i];
1666   }
1667   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1668   for(Int_t i=0; i<fgkladdernumber; i++){
1669         for(Int_t j=0; j<fgkladdernumber; j++)
1670                 delete ladderglobalmatrix[i][j];
1671         delete [] ladderglobalmatrix[i];
1672   }
1673   /////////////////////////////////////////////////////////////
1674   fTransformationMatrices = kTRUE;      
1675 }
1676 ///////////////////////////////////////////////////////////////////////////////
1677 void AliITSv11GeometrySSD::CreateBasicObjects(){
1678   /////////////////////////////////////////////////////////////  
1679   // Method generating the Objects of SSD Geometry    
1680   /////////////////////////////////////////////////////////////
1681   // SSD Sensor
1682   ///////////////////////////////////
1683   SetSSDSensor();
1684   /////////////////////////////////////////////////////////////  
1685   // Carbon Fiber Support    
1686   /////////////////////////////////////////////////////////////  
1687   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1688   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1689       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1690   /////////////////////////////////////////////////////////////
1691   // Carbon Fiber Junction 
1692   /////////////////////////////////////////////////////////////
1693   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1694   /////////////////////////////////////////////////////////////
1695   // Carbon Fiber Lower Support
1696   /////////////////////////////////////////////////////////////
1697   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1698   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1699         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1700   /////////////////////////////
1701   // SSD Sensor Support
1702   /////////////////////////////
1703   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1704                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1705   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1706                                                                          fgkSSDSensorSideSupportThickness[1]};
1707   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1708         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1709                                                                                            fgkSSDSensorSideSupportHeight[i],
1710                                                                                            fgkSSDSensorSideSupportWidth,
1711                                                                                            sidesupporthickness);  
1712         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1713                                                                                            fgkSSDSensorCenterSupportHeight[i],
1714                                                                                            fgkSSDSensorCenterSupportWidth,
1715                                                                                            sidesupporthickness);
1716   }
1717   /////////////////////////////////////////////////////////////
1718   // SSD Cooling Tube Support
1719   /////////////////////////////////////////////////////////////
1720   Int_t edgesnumber = 3;
1721   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1722   /////////////////////////////////////////////////////////////
1723   // SSD Hybrid
1724   /////////////////////////////////////////////////////////////
1725   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1726   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1727         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1728   /////////////////////////////////////////////////////////////
1729   // SSD Cooling Block System
1730   /////////////////////////////////////////////////////////////
1731   fssdcoolingblocksystem = GetCoolingBlockSystem();
1732    /////////////////////////////////////////////////////////////
1733   // SSD Cooling Tube
1734   /////////////////////////////////////////////////////////////
1735   CreateCoolingTubes();
1736   /////////////////////////////////////////////////////////////
1737   // SSD Flex  
1738   /////////////////////////////////////////////////////////////
1739   fssdstiffenerflex = GetSSDStiffenerFlex();
1740   fssdendflex = GetSSDEndFlex();
1741   ///////////////////////////////////
1742   // End Ladder Carbon Fiber Junction
1743   ///////////////////////////////////
1744   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1745                                                    fendladdercarbonfiberjunction[i] = 
1746                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1747   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1748     fendladdercarbonfiberjunction[i][0] = 
1749                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1750     fendladdercarbonfiberjunction[i][1] = 
1751                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1752   }
1753   ///////////////////////////////////
1754   // End Ladder Mounting Block
1755   ///////////////////////////////////
1756   fendladdermountingblock = GetSSDMountingBlock();
1757   ///////////////////////////////////
1758   // End Ladder Mounting Block
1759   ///////////////////////////////////
1760   fendladdermountingblockclip = GetMountingBlockClip();
1761   ///////////////////////////////////
1762   // Ladder Support 
1763   ///////////////////////////////////
1764   TList* laddersupportlist = GetMountingBlockSupport(20);
1765   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1766   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1767   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1768   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1769   /////////////////////////////////////////////////////////////
1770   // Deallocating memory
1771   /////////////////////////////////////////////////////////////
1772   delete carbonfibersupportlist;
1773   delete carbonfiberlowersupportlist;
1774   delete ssdhybridcomponentslist;
1775   delete laddersupportlist;
1776   /////////////////////////////////////////////////////////////
1777   fBasicObjects = kTRUE;
1778 }
1779 /////////////////////////////////////////////////////////////////////////////////
1780 void AliITSv11GeometrySSD::SetSSDSensor(){
1781   ////////////////////////////////////////////////////////////////
1782   // Method generating SSD Sensors: it sets the private variables
1783   // fSSDSensor5, fSSDSensor6  
1784   ////////////////////////////////////////////////////////////////
1785   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1786   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1787   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1788                                                 0.5*ssdsensitivewidth,
1789                                                 0.5*fgkSSDSensorHeight,
1790                                                 0.5*ssdsensitivelength);
1791   TGeoVolume* ssdsensorsensitiveLay5 = 
1792         new TGeoVolume(fgkSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1793   TGeoVolume* ssdsensorsensitiveLay6 = 
1794         new TGeoVolume(fgkSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1795   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1796   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1797   TGeoBBox* ssdsensorinsensitiveshape[2];
1798   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1799                                                 0.5*fgkSSDSensorInsensitiveWidth,
1800                                                 0.5*fgkSSDSensorHeight,
1801                                                 0.5*fgkSSDSensorLength);
1802   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1803                                                 0.5*ssdsensitivewidth,
1804                                                 0.5*fgkSSDSensorHeight,
1805                                                 0.5*fgkSSDSensorInsensitiveWidth);
1806   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1807                                              "SSDSensorInsensitive2"};
1808   TGeoVolume* ssdsensorinsensitive[2];
1809   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1810       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1811                      fSSDSensorMedium);
1812       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1813   }
1814   /////////////////////////////////////////////////////////////
1815   // Virtual Volume containing SSD Sensor  
1816   /////////////////////////////////////////////////////////////
1817   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1818                                                                                              0.5*fgkSSDSensorWidth,
1819                                                                                              0.5*fgkSSDSensorHeight,
1820                                                                                              0.5*fgkSSDSensorLength);
1821   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1822                                                                                  fSSDAir);      
1823   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1824                                                                                  fSSDAir);      
1825   /////////////////////////////////////////////////////////////
1826   for(Int_t i=0; i<4; i++){ 
1827             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1828             ssdsensorinsensitive[1],i<2?1:2,
1829                         new TGeoTranslation(
1830                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1831       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1832                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1833       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1834             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1835             ssdsensorinsensitive[1],i<2?1:2,
1836                         new TGeoTranslation(
1837                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1838       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1839                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1840       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1841   }
1842     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1843     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1844 }
1845 ///////////////////////////////////////////////////////////////////////////////
1846 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1847   /////////////////////////////////////////////////////////////  
1848   // Method generating the Carbon Fiber Support   
1849   /////////////////////////////////////////////////////////////  
1850   const Int_t kvertexnumber = 4;
1851   const Int_t kshapesnumber = 2;
1852   TVector3** vertexposition[kshapesnumber];
1853   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1854   Double_t carbonfibersupportxaxisEdgeproj = 
1855                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1856         *       TMath::DegToRad());
1857   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1858                                  /                         fgkCarbonFiberSupportXAxisLength);
1859   /////////////////////
1860   //Vertex Positioning
1861   ////////////////////
1862   vertexposition[0][0] = new TVector3();
1863   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1864                                                                           fgkCarbonFiberSupportYAxisLength);
1865   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1866                                                                           carbonfibersupportxaxisEdgeproj
1867                                            *                      TMath::Tan(theta));
1868   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1869                                            -                      carbonfibersupportxaxisEdgeproj,
1870                                                                           fgkCarbonFiberSupportYAxisLength
1871                                            -                      vertexposition[0][2]->Y());
1872   ////////////////////////////////////////////////////
1873   //Setting the parameters for Isometry Transformation
1874   ////////////////////////////////////////////////////
1875   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1876                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1877                                                                  +      fgkCarbonFiberSupportWidth);
1878   Double_t* param = new Double_t[4]; 
1879   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1880   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1881     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1882                  (GetReflection(vertexposition[0][j],param))->Y());
1883   const char* carbonfibersupportshapename[kshapesnumber] = 
1884                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1885   const char* carbonfibersupportname[kshapesnumber] = 
1886                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1887   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1888   TGeoVolume* carbonfibersupport[kshapesnumber];
1889   TList* carbonfibersupportlist = new TList();
1890   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1891   Double_t carbonfibersupportheight = 
1892           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1893           *TMath::DegToRad());
1894   for(Int_t i = 0; i< kshapesnumber; i++){
1895    carbonfibersupportshape[i] = 
1896                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1897                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1898    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1899                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1900    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1901    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1902    }
1903   /////////////////////////////////////////////////////////////
1904   // Deallocating memory
1905   /////////////////////////////////////////////////////////////
1906   for(Int_t i=0; i< kshapesnumber; i++){
1907      for(Int_t j=0; j< kvertexnumber; j++)
1908            delete vertexposition[i][j];
1909        delete [] vertexposition[i];
1910   }
1911   delete [] param;
1912   /////////////////////////////////////////////////////////////
1913    return carbonfibersupportlist;
1914 }
1915 /////////////////////////////////////////////////////////////////////////////////
1916 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1917   /////////////////////////////////////////////////////////////
1918   // Method generating SSD Carbon Fiber Junction
1919   /////////////////////////////////////////////////////////////
1920   const Int_t kvertexnumber = 6;
1921   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
1922   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1923                                             *  TMath::DegToRad()),-1.,0.,0.};
1924   TVector3* vertex[kvertexnumber];
1925   vertex[0] = new TVector3();
1926   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
1927                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1928                         *                         TMath::DegToRad()),
1929                                                   fgkCarbonFiberJunctionEdge[0]
1930                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
1931                         *                         TMath::DegToRad()));
1932   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
1933                                                    fgkCarbonFiberJunctionEdge[1]);
1934   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
1935   vertex[1] = GetReflection(vertex[5],reflectionparam); 
1936   vertex[2] = GetReflection(vertex[4],reflectionparam); 
1937   Double_t xvertexpoints[6], yvertexpoints[6];
1938   for(Int_t i=0; i<kvertexnumber; i++) 
1939           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
1940   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
1941   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
1942   carbonfiberjunctionshape->DefineSection(1,0.5*width);
1943   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
1944                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
1945   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
1946   /////////////////////////////////////////////////////////////
1947   // Deallocating memory
1948   /////////////////////////////////////////////////////////////
1949   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
1950   ///////////////////////////////////////////////////////////// 
1951   return carbonfiberjunction;
1952 }
1953 ////////////////////////////////////////////////////////////////////////////////
1954 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
1955   /////////////////////////////////////////////////////////////
1956   // Method generating the Carbon Fiber Lower Support   
1957   /////////////////////////////////////////////////////////////  
1958   const Int_t kvertexnumber = 4;
1959   const Int_t kshapesnumber = 2;
1960   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
1961                                                                 fgkCarbonFiberLowerSupportWidth};
1962   TVector3** vertexposition[kshapesnumber];
1963   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
1964                                                  new TVector3*[kvertexnumber];
1965   //First Shape Vertex Positioning
1966   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
1967   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
1968                                            -            fgkCarbonFiberLowerSupportLowerLenght);
1969   vertexposition[0][2] = new TVector3();
1970   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
1971   //Second Shape Vertex Positioning
1972   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
1973                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
1974                                  /                              fgkCarbonFiberTriangleLength);
1975   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
1976                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
1977                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1978   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
1979                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
1980                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1981   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
1982   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
1983                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
1984   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
1985                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
1986   const char* carbonfiberlowersupportname[kshapesnumber] = 
1987                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
1988   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
1989   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
1990   TList* carbonfiberlowersupportlist = new TList();
1991   for(Int_t i = 0; i< kshapesnumber; i++){ 
1992         carbonfiberlowersupportshape[i] = 
1993                                                                 GetArbShape(vertexposition[i],width,
1994                                                                                         fgkCarbonFiberLowerSupportHeight,
1995                                                                                         carbonfiberlowersupportshapename[i]);
1996     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
1997                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
1998         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
1999     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2000   }
2001   /////////////////////////////////////////////////////////////
2002   // Deallocating memory
2003   /////////////////////////////////////////////////////////////
2004   for(Int_t i=0; i< kshapesnumber; i++){
2005      for(Int_t j=0; j< kvertexnumber; j++)
2006            delete vertexposition[i][j];
2007        delete [] vertexposition[i];
2008   }
2009   /////////////////////////////////////////////////////////////
2010   return carbonfiberlowersupportlist;
2011 }
2012 ///////////////////////////////////////////////////////////////////////////////
2013 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2014                                                                  Double_t width, const Double_t* thickness)const{
2015   /////////////////////////////////////////////////////////////
2016   // Method generating the Sensor Support   
2017   /////////////////////////////////////////////////////////////  
2018         const Int_t kvertexnumber = 6;
2019         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2020     TVector3* vertexposition[kvertexnumber];
2021         vertexposition[0] = new TVector3();     
2022         vertexposition[1] = new TVector3(0.0,length);   
2023         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2024         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2025         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2026         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2027         Double_t xvertexpoints[6], yvertexpoints[6];
2028         for(Int_t i=0; i<kvertexnumber; i++) 
2029                 xvertexpoints[i] = vertexposition[i]->X(), 
2030                 yvertexpoints[i] = vertexposition[i]->Y();
2031     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2032     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2033     ssdsensorsupportshape->DefineSection(1,0.5*width);
2034     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2035                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2036   /////////////////////////////////////////////////////////////
2037   // Deallocating memory
2038   /////////////////////////////////////////////////////////////
2039         for (Int_t i=0; i<kvertexnumber; i++)
2040                 delete vertexposition[i];
2041   /////////////////////////////////////////////////////////////
2042     return ssdsensorsupport;
2043 }
2044 ////////////////////////////////////////////////////////////////////////////////
2045 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2046   /////////////////////////////////////////////////////////////
2047   // Method generating the Cooling Tube Support
2048   /////////////////////////////////////////////////////////////
2049   if(nedges%2!=0) nedges--;     
2050   const Int_t kvertexnumber = nedges+5;
2051   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2052                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2053   Double_t angle = 90.+phi;
2054   Double_t psi = 90.-phi;
2055   ///////////////////////////////////////
2056   // Vertex Positioning for TGeoXTru
2057   ///////////////////////////////////////
2058   TVector3** vertexposition = new TVector3*[kvertexnumber];
2059
2060   Double_t router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
2061   vertexposition[0] = new TVector3(router*CosD(angle),
2062                                                                    router*SinD(angle));
2063   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2064                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2065   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2066                                                                    fgkCoolingTubeSupportRmax);
2067   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2068                                                                    fgkCoolingTubeSupportRmax);
2069   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2070                                                                     vertexposition[1]->Y());
2071
2072   for(Int_t i=0; i<nedges; i++)
2073         vertexposition[i+5] = 
2074                 new TVector3(router*CosD(psi+i*(2.*phi/nedges)),
2075                              router*SinD(psi+i*(2.*phi/nedges)));
2076   ///////////////////////////////////////////////////////////////////////
2077   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2078   ///////////////////////////////////////////////////////////////////////
2079   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2080   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2081   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2082   for(Int_t i=0; i<kvertexnumber; i++){
2083         xvertexpoints[i] = vertexposition[i]->X();
2084         yvertexpoints[i] = vertexposition[i]->Y();
2085   } 
2086   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2087                                                                                         yvertexpoints);
2088   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2089   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2090   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2091                                                                           coolingtubesupportarcshape,
2092                                                                                   fSSDTubeHolderMedium);
2093   coolingtubesupportarc->SetLineColor(fColorG10);
2094   //////////////////////////////////////////////////////////////////////////
2095   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2096   //////////////////////////////////////////////////////////////////////////
2097   TGeoTubeSeg* coolingtubesupportsegshape = 
2098                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2099                                                                                         fgkCoolingTubeSupportRmax,
2100                                                                                         0.5*fgkCoolingTubeSupportWidth,
2101                                                                                         phi,360-phi);
2102   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2103                                                                                         coolingtubesupportsegshape,
2104                                                                                         fSSDTubeHolderMedium);
2105   coolingtubesupportseg->SetLineColor(fColorG10);
2106   //////////////////////////////////////////////////////////////////////////
2107   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2108   //////////////////////////////////////////////////////////////////////////
2109   Double_t* boxorigin = new Double_t[3];
2110   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2111   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2112   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2113                                                                                  0.5*fgkCoolingTubeSupportHeight,
2114                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2115   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2116                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2117   coolingtubesupportbox->SetLineColor(fColorG10);
2118   //////////////////////////////////////////////////////////////////////////
2119   // Cooling Tube for Cooling Tube Support 
2120   //////////////////////////////////////////////////////////////////////////
2121   TGeoXtru* coolingtubearcshape[2];
2122   coolingtubearcshape[0] = new TGeoXtru(2);     
2123   Double_t* xvert = new Double_t[nedges+2];
2124   Double_t* yvert = new Double_t[nedges+2];
2125   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2126   ////////////////////////////////////////
2127   // Positioning the vertices for TGeoXTru
2128   ////////////////////////////////////////
2129   xvert[0] = 0., yvert[0] = 0.;
2130   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2131   for(Int_t i=0; i< nedges; i++)
2132                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2133                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2134   ////////////////////////////////////////
2135   // Defining TGeoXTru PolyGone
2136   ////////////////////////////////////////
2137   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2138   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2139   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2140   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2141                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2142   TGeoVolume* coolingtubearc[2];
2143   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2144                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2145   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2146                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2147   coolingtubearc[0]->SetLineColor(fColorWater);
2148   coolingtubearc[1]->SetLineColor(fColorPhynox);
2149   ////////////////////////////////////////////
2150   // Defining TGeoTubeSeg Part of Cooling Tube
2151   ////////////////////////////////////////////
2152   TGeoTubeSeg* coolingtubesegshape[2];
2153   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2154                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2155   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2156                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2157   TGeoVolume* coolingtubeseg[2];
2158   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2159                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2160   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2161                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2162   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2163   coolingtubeseg[1]->SetLineColor(fColorWater);
2164   /////////////////////////////////////////////////////////////
2165   // Virtual Volume containing Cooling Tube Support  
2166   /////////////////////////////////////////////////////////////
2167   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2168   const Int_t kvirtualvertexnumber = 8;
2169   TVector3* virtualvertex[kvirtualvertexnumber];
2170    ////////////////////////////////////////
2171   // Positioning the vertices for TGeoXTru
2172   ////////////////////////////////////////
2173   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2174   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2175   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2176   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2177   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2178   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2179   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2180   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2181   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2182   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2183         xmothervertex[i] = virtualvertex[i]->X(),
2184         ymothervertex[i] = virtualvertex[i]->Y();
2185   ////////////////////////////////////////
2186   // Defining TGeoXTru PolyGone
2187   ////////////////////////////////////////
2188   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2189                                                                                                                                          ymothervertex);
2190   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2191   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2192   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2193     virtualCoolingTubeSupportShape,fSSDAir); */
2194   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
2195
2196   ////////////////////////////////////////
2197   // Positioning Volumes in Virtual Volume
2198   ////////////////////////////////////////
2199   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2200   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2201   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2202   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2203   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2204   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2205   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2206   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2207   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2208   /////////////////////////////////////////////////////////////
2209   // Deallocating memory
2210   /////////////////////////////////////////////////////////////
2211   delete [] vertexposition;
2212   delete [] xvertexpoints;
2213   delete [] yvertexpoints;
2214   delete [] xvert;
2215   delete [] yvert;
2216   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2217         delete virtualvertex[i];
2218   /////////////////////////////////////////////////////////////
2219         return virtualcoolingtubesupport;
2220 }
2221 /////////////////////////////////////////////////////////////////////////////////
2222 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2223   /////////////////////////////////////////////////////////////
2224   // Method generating List containing SSD Hybrid Components   
2225   /////////////////////////////////////////////////////////////
2226   TList* ssdhybridlist = new TList();
2227   const Int_t kssdstiffenernumber = 2;
2228   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2229                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2230                                                                   -    fgkSSDStiffenerWidth;
2231   Double_t ssdchipcablesradius[kssdstiffenernumber];
2232   for(Int_t i=0; i<kssdstiffenernumber; i++)
2233           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2234                                -  fgkSSDChipCablesHeight[0]
2235                                -  fgkSSDChipCablesHeight[1]);
2236   /////////////////////////////////////////////////////////////
2237   // Mother Volumes Containers 
2238   /////////////////////////////////////////////////////////////
2239   const Int_t kmothernumber = 2;
2240   const Int_t kmothervertexnumber = 8;
2241   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2242   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2243
2244   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
2245   TGeoVolume* ssdhybridmother[kmothernumber][2];
2246
2247   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
2248   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
2249   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
2250
2251   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2252   for(Int_t i=0; i<kmothernumber; i++){
2253     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
2254     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
2255     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
2256     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2257       -fgkSSDChipCablesHeight[i+2];
2258     
2259     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
2260     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
2261     xmothervertex[i][3] = xmothervertex[i][2];
2262     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1];
2263
2264     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
2265     ymothervertex[i][4] = ymothervertex[i][3];
2266     xmothervertex[i][5] = xmothervertex[i][4];
2267     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i];
2268
2269     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
2270     ymothervertex[i][6] = ymothervertex[i][5];
2271     
2272     xmothervertex[i][7] = xmothervertex[i][6];
2273     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
2274     TGeoXtru *shape = new TGeoXtru(2);
2275     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
2276     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
2277     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
2278     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
2279     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
2280     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2281    }   
2282   /////////////////////////////////////////////////////////////
2283   // SSD Stiffener   
2284   /////////////////////////////////////////////////////////////
2285   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2286                                              0.5*fgkSSDStiffenerLength,
2287                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2288                                              0.5*fgkSSDStiffenerHeight);
2289   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2290                                             fSSDStiffenerMedium);  
2291   ssdstiffener->SetLineColor(fColorStiffener); 
2292
2293 ////////////////////////////
2294 // Capacitor 0603-2200 nF
2295 ///////////////////////////
2296   const Int_t knapacitor0603number = 5;
2297   TGeoBBox* capacitor0603mothershape =  new TGeoBBox("Capacitor0603MotherShape",
2298                                                0.5*fgkSSDCapacitor0603Length + fgkSSDCapacitor0603CapLength,
2299                                                0.5*fgkSSDCapacitor0603Width,
2300                                                0.5*fgkSSDCapacitor0603Height);
2301   TGeoVolume* capacitor0603mother = new TGeoVolume("Capacitor0603Mother",capacitor0603mothershape,
2302                                              fSSDAir); 
2303
2304   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2305                                                0.5*fgkSSDCapacitor0603Length,
2306                                                0.5*fgkSSDCapacitor0603Width,
2307                                                0.5*fgkSSDCapacitor0603Height);
2308   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2309                                              fSSDStiffener0603CapacitorMedium); 
2310   capacitor0603->SetLineColor(fColorAl);
2311   TGeoTranslation *cap0603trans = new TGeoTranslation(0.,0.,0.);
2312   capacitor0603mother->AddNode(capacitor0603,1,cap0603trans);
2313
2314   TGeoBBox* capacitor0603capshape =  new TGeoBBox("Capacitor0603CapShape",
2315                                                0.5*fgkSSDCapacitor0603CapLength,
2316                                                0.5*fgkSSDCapacitor0603Width,
2317                                                0.5*fgkSSDCapacitor0603Height);
2318   TGeoVolume* capacitor0603cap = new TGeoVolume("Capacitor0603Cap",capacitor0603capshape,
2319                                              fSSDStiffenerCapacitorCapMedium); 
2320   capacitor0603cap->SetLineColor(fColorNiSn);
2321   TGeoTranslation *cap0603captrans1 = new TGeoTranslation(- capacitor0603shape->GetDX() - capacitor0603capshape->GetDX(),0.,0.);
2322   capacitor0603mother->AddNode(capacitor0603cap,1,cap0603captrans1);
2323   TGeoTranslation *cap0603captrans2 = new TGeoTranslation(capacitor0603shape->GetDX() + capacitor0603capshape->GetDX(),0.,0.);
2324   capacitor0603mother->AddNode(capacitor0603cap,2,cap0603captrans2);
2325
2326
2327   TGeoVolume* ssdchip = GetSSDChip();
2328
2329   const Int_t knedges = 5;
2330   TGeoVolume *ssdchipcables[2];
2331
2332   for(Int_t i=0; i<kmothernumber; i++){
2333     for(Int_t j=0; j<kssdstiffenernumber; j++){
2334       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
2335       for(Int_t k=1; k<knapacitor0603number+1; k++){
2336         ssdhybridmother[i][j]->AddNode(capacitor0603mother,k,
2337                                        new TGeoCombiTrans("",
2338                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
2339                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
2340                                                           (k-3.)/6*fgkSSDStiffenerLength,
2341                                                           hybridmotherrotInv));
2342       }
2343     }
2344     
2345     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
2346     for(Int_t k=0; k<fgkSSDChipNumber; k++){
2347       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
2348                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
2349                                                             - fgkSSDChipCablesHeight[i+2],
2350                                                             (k+0.5-fgkSSDChipNumber/2)*
2351                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
2352       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
2353                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
2354                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
2355                                                      hybridmotherrotInv);
2356       for(Int_t j=0; j<kssdstiffenernumber; j++){
2357         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
2358         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
2359       }
2360     }  
2361     // Final placement by assembly
2362     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
2363     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
2364     ssdhybridlist->Add(ssdhybridassembly[i]);
2365   }    
2366   /////////////////////////////////////////////////////////////
2367   // Mother Volume Containing Capacitor Part 
2368   /////////////////////////////////////////////////////////////
2369   const Int_t kcapacitormothernumber = 8;
2370   Double_t xcapacitorvertex[kcapacitormothernumber];
2371   Double_t ycapacitorvertex[kcapacitormothernumber];  
2372   ///////////////////////
2373   // Setting the vertices 
2374   ///////////////////////
2375   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2376   xcapacitorvertex[1] = xcapacitorvertex[0];   
2377   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2378   xcapacitorvertex[3] = xcapacitorvertex[2];   
2379   xcapacitorvertex[4] = xcapacitorvertex[0];   
2380   xcapacitorvertex[5] = xcapacitorvertex[0];   
2381   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2382   xcapacitorvertex[7] = xcapacitorvertex[6];   
2383   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2384   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2385   ycapacitorvertex[2] = ycapacitorvertex[1];   
2386   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2387   ycapacitorvertex[4] = ycapacitorvertex[3];   
2388   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2389   ycapacitorvertex[6] = ycapacitorvertex[5];   
2390   ycapacitorvertex[7] = ycapacitorvertex[0];   
2391   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2392   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2393                                               ycapacitorvertex);
2394   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2395   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2396 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2397 //                                          fSSDAir);
2398   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2399 ////////////////////////////
2400 // Connector 
2401 ///////////////////////////
2402   const Int_t kssdconnectorlayernumber = 3;
2403   TGeoBBox* ssdconnectorshape[kssdconnectorlayernumber];
2404   Double_t ssdConnectorThickness[kssdconnectorlayernumber]={fgkSSDConnectorAlHeight,fgkSSDConnectorNiHeight,fgkSSDConnectorSnHeight};
2405   /*
2406   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2407   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2408                                    +  fgkSSDConnectorAlHeight};  
2409   */
2410   Double_t ssdconnectororigin[3] = {0,0,0.5*fgkSSDStiffenerHeight};
2411   const char* ssdconnectorname[kssdconnectorlayernumber] = {"SSDConnectorAl","SSDConnectorNi","SSDConnectorSn"};
2412   TGeoMedium *ssdConnectorMedium[kssdconnectorlayernumber]={fSSDAlTraceFlexMedium,fSSDStiffenerConnectorMedium,fSSDSn};
2413   TGeoVolume* ssdconnector[kssdconnectorlayernumber];
2414   for(Int_t i=0; i<kssdconnectorlayernumber; i++){
2415     ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2416       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2417                                           0.5*fgkSSDConnectorWidth,
2418                                           0.5*ssdConnectorThickness[i],
2419                                           ssdconnectororigin);
2420       ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2421       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2422                                        ssdConnectorMedium[i]);      
2423       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorNiSn);
2424   }
2425   const Int_t kssdconnectornumber = 4;
2426   TGeoTranslation* ssdconnectortrans[kssdconnectornumber];
2427   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2428                        +  fgkSSDConnectorPosition[0]
2429                        -  fgkSSDConnectorSeparation
2430                        -  1.5*fgkSSDConnectorLength,
2431                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2432                        -  fgkSSDConnectorPosition[1]
2433                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2434   ssdconnectortrans[1] = new TGeoTranslation(
2435                        -  ssdstiffenershape->GetDX()
2436                        +  fgkSSDConnectorPosition[0]
2437                        -  0.5*fgkSSDConnectorLength,
2438                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2439                        -  fgkSSDConnectorPosition[1]
2440                        -  ssdconnectorshape[0]->GetDY(),0.0);
2441   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2442                        -  fgkSSDConnectorPosition[0]
2443                        +  fgkSSDConnectorSeparation
2444                        +  1.5*fgkSSDConnectorLength,
2445                           -(ssdstiffenershape->GetDY()
2446                        -  fgkSSDConnectorPosition[1]
2447                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2448   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2449                        -  fgkSSDConnectorPosition[0]
2450                        +  0.5*fgkSSDConnectorLength,
2451                           -(ssdstiffenershape->GetDY()
2452                        -  fgkSSDConnectorPosition[1]
2453                        -  ssdconnectorshape[0]->GetDY()),0.0);
2454   for(Int_t i=0; i<kssdconnectornumber; i++) {
2455     Int_t nlay = kssdconnectorlayernumber - 1;
2456     if (i == 1 || i == 2)
2457       nlay++;
2458     for(Int_t j=0; j<nlay; j++)
2459       ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2460   }
2461 ////////////////////////////
2462 // Capacitor 1812-330 nF
2463 /////////////////////////// 
2464 //  Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2465   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2466                                                                                          0.5*fgkSSDCapacitor1812Length,
2467                                                                                          0.5*fgkSSDCapacitor1812Width,
2468                                                0.5*fgkSSDCapacitor1812Height);
2469   //            ssdcapacitor1812origin);
2470   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2471                                              fSSDStiffener1812CapacitorMedium); 
2472   capacitor1812->SetLineColor(fColorAl);
2473   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2474                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2475                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2476   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2477
2478   TGeoBBox* capacitor1812capshape =  new TGeoBBox("Capacitor1812CapShape",
2479     0.5*fgkSSDCapacitor1812CapLength, 0.5*fgkSSDCapacitor1812Width,
2480     0.5*fgkSSDCapacitor1812Height);
2481   TGeoVolume* capacitor1812cap = new TGeoVolume("Capacitor1812Cap",capacitor1812capshape,
2482                                              fSSDStiffenerCapacitorCapMedium);
2483   capacitor1812cap->SetLineColor(fColorNiSn);
2484   TGeoTranslation* capacitor1812captrans1 = new TGeoTranslation(
2485         - capacitor1812shape->GetDX() - capacitor1812capshape->GetDX(),
2486         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2487         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2488         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2489   ssdhybridcapacitormother->AddNode(capacitor1812cap,1,capacitor1812captrans1);
2490   TGeoTranslation* capacitor1812captrans2 = new TGeoTranslation(
2491         capacitor1812shape->GetDX() + capacitor1812capshape->GetDX(),
2492         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2493         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2494         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2495   ssdhybridcapacitormother->AddNode(capacitor1812cap,2,capacitor1812captrans2);
2496
2497 ////////////////////////////
2498 //Hybrid Wire
2499 ////////////////////////////
2500   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2501                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2502                                  - fgkSSDConnectorSeparation;
2503   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2504                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2505   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2506
2507   Double_t wireangle = TMath::ATan(wirex/wirey);
2508   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2509                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2510   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2511                                              fSSDStiffenerHybridWireMedium); 
2512   hybridwire->SetLineColor(fColorPhynox);
2513   TGeoCombiTrans* hybridwirecombitrans[2];
2514   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2515                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2516                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2517                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2518                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2519                                    ssdstiffenershape->GetDZ()
2520                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight+fgkSSDConnectorSnHeight,
2521                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2522   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2523                             0.0,
2524                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2525                             0.0,        
2526                             new TGeoRotation("HybridWireRot2",
2527                           - wireangle*TMath::RadToDeg(),0.,0.));
2528   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2529   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2530   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2531   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2532   ssdhybridlist->Add(ssdhybridcapacitormother);
2533   /////////////////////////////////////////////////////////////
2534   // Deallocating memory
2535   /////////////////////////////////////////////////////////////
2536   delete hybridwirecombitrans[0];
2537   delete hybridwirecombitrans[1];
2538   return ssdhybridlist;
2539   /////////////////////////////////////////////////////////////
2540 }
2541 ///////////////////////////////////////////////////////////////////////////////
2542 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2543   /////////////////////////////////////////////////////////////
2544   // SSD Cooling Block System
2545   /////////////////////////////////////////////////////////////
2546   // SSD Cooling Block and Cooling Tube Transformations
2547   /////////////////////////////////////////////////////////////
2548   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2549   localcoolingblockrot->SetAngles(0.,90.,0.);
2550   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2551   TVector3* coolingblocktransvector;
2552   coolingblocktransvector = new TVector3(fgkCoolingTubeSeparation,
2553                                                                   fgkSSDSensorLength
2554                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2555                                                                 - fgkSSDCoolingBlockWidth);
2556   const Int_t kcoolingblocktransnumber = 2;
2557   const Int_t kcoolingblocknumber = 4;
2558   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2559   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2560   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2561   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2562     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2563       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X(),//+2*coolingtubedistance,
2564                                              j*coolingblocktransvector->Y(),
2565                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2566                                                     + fgkCoolingTubeRmax));
2567       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2568     }
2569   }
2570   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2571   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2572   /////////////////////////////////////////////////////////////
2573   // Adding Cooling block to mother volume
2574   /////////////////////////////////////////////////////////////
2575   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2576     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2577   }
2578   /////////////////////////////////////////////////////////////
2579   // Deallocating memory
2580   /////////////////////////////////////////////////////////////
2581   delete coolingblocktransvector;
2582   delete localcoolingblockrot;
2583
2584   return coolingsystemother;
2585 }
2586 /////////////////////////////////////////////////////////////////////////////////
2587 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2588   /////////////////////////////////////////////////////////////
2589   // SSD Flex
2590   /////////////////////////////////////////////////////////////
2591   const Int_t kssdflexlayernumber = 2;
2592   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2593   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2594   const Int_t kmothervertexnumber = 17; 
2595   Double_t xmothervertex[kmothervertexnumber];
2596   Double_t ymothervertex[kmothervertexnumber];
2597   /////////////////////////////////////////////
2598   // Auxiliary variables for vertex positioning
2599   /////////////////////////////////////////////
2600   const Int_t kssdflexboxnumber = 5;
2601   Double_t ssdflexboxlength[kssdflexboxnumber];
2602   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2603                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2604                                           *     fgkSSDChipSeparationLength
2605                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2606                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2607   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2608   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2609                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2610   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2611   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2612                                           -     ssdflexboxlength[1];
2613   Double_t ssdflexboxwidth[kssdflexboxnumber];
2614   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2615   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2616   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2617   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2618   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2619   ///////////////////////
2620   // Setting the vertices 
2621   ///////////////////////
2622   xmothervertex[0]  = 0.0;
2623   xmothervertex[1]  = xmothervertex[0];
2624   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2625   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2626                                         + ssdflexboxlength[4];
2627   xmothervertex[4]  = xmothervertex[3];
2628   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2629   xmothervertex[6]  = xmothervertex[5];
2630   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2631   xmothervertex[8]  = xmothervertex[7];
2632   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2633   xmothervertex[10] = xmothervertex[9]; 
2634   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2635   xmothervertex[12] = xmothervertex[11];
2636   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2637   xmothervertex[14] = xmothervertex[13];
2638   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2639   xmothervertex[16] = xmothervertex[15];
2640   ymothervertex[0]  = 0.0;
2641   ymothervertex[1]  = fgkSSDFlexWidth[1];
2642   ymothervertex[2]  = fgkSSDFlexWidth[0];
2643   ymothervertex[3]  = ymothervertex[2];
2644   ymothervertex[4]  = ymothervertex[0];
2645   ymothervertex[5]  = ymothervertex[4];
2646   ymothervertex[6]  = ssdflexboxwidth[2];
2647   ymothervertex[7]  = ymothervertex[6];
2648   ymothervertex[8]  = ymothervertex[0];
2649   ymothervertex[9]  = ymothervertex[8];
2650   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2651   ymothervertex[11] = ymothervertex[10];
2652   ymothervertex[12] = ymothervertex[0];
2653   ymothervertex[13] = ymothervertex[12];
2654   ymothervertex[14] = ymothervertex[7];
2655   ymothervertex[15] = ymothervertex[14];
2656   ymothervertex[16] = ymothervertex[0];
2657   /////////////////////////////////////////////////////////////
2658   // First Mother Volume containing SSDFlex
2659   /////////////////////////////////////////////////////////////
2660   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2661   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2662                                                                     ymothervertex);
2663   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2664   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2665   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2666 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2667 //                                                                                       fSSDAir);
2668   /////////////////////////////////////////////////////////////
2669   // SSDFlex Layer Shapes
2670   /////////////////////////////////////////////////////////////
2671   for(Int_t i=0; i<kssdflexlayernumber; i++){
2672         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2673                                                                    ymothervertex);
2674     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2675         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2676   }
2677   /////////////////////////////////////
2678   // Setting Layers into Mother Volume
2679   /////////////////////////////////////
2680   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2681   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2682                                                                                                  fSSDKaptonFlexMedium};
2683   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2684                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2685   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2686   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2687   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2688         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2689                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2690                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2691         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2692     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2693                                          +                                         fgkSSDFlexHeight[1])); 
2694     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2695   }
2696   return ssdflexmother;
2697 }
2698 /////////////////////////////////////////////////////////////////////////////////
2699 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2700   /////////////////////////////////////////////////////////////
2701   // Method generating SSD End Flex   
2702   /////////////////////////////////////////
2703   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2704                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2705   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2706                                                 * TMath::DegToRad()*ssdflexradiusmax
2707                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2708                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2709                                                         - 0.1*fgkSSDFlexFullLength;
2710   const Int_t knedges = 20;  
2711   const Int_t karcnumber = 2;
2712   TVector3* vertexposition[karcnumber*(knedges+1)];
2713   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2714   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2715   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2716   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2717                                                                                  - 90.0*TMath::DegToRad()};
2718   TVector3* referencetrans[karcnumber];
2719   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2720                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2721                                                                    radius[0]);
2722   referencetrans[1] = new TVector3(referencetrans[0]->X()
2723                                         +              fgkSSDFlexLength[2],
2724      -              fgkSSDStiffenerHeight);
2725 for(Int_t i=0; i<karcnumber; i++){
2726         for(Int_t j=0; j<knedges+1; j++){
2727                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2728                                                                                                radius[i]*SinD(angle[i]));
2729                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2730         }       
2731   }
2732   ///////////////////////
2733   // Setting the vertices 
2734   ///////////////////////
2735   const Int_t kendflexlayernumber = 4;
2736   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2737   TVector3** vertex[kendflexlayernumber];
2738   for(Int_t i=0; i<kendflexlayernumber; i++) 
2739                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2740   TVector3* transvector[kendflexlayernumber+1];
2741   TVector3* deltatransvector = new TVector3();  
2742   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2743   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2744                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2745   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2746         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2747                                         *                 CosD(fgkSSDFlexAngle),
2748                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2749                                         *         SinD(fgkSSDFlexAngle),0.0);   
2750         *transvector[i] = *transvector[i-1]+*deltatransvector;
2751   }
2752   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2753   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2754   for(Int_t i=0; i<karcnumber; i++){
2755         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2756                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2757                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2758                                               /radius[i];
2759         }
2760   }
2761   for(Int_t i=0; i<kendflexlayernumber; i++){
2762         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2763         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2764         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2765                 if(j<(knedges+1)){
2766                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2767                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2768                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2769                         *vertex[i][j+2] += *referencetrans[0];
2770                         vertex[i][4*(knedges+1)-j+1] = 
2771                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2772                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2773                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2774                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2775                 }
2776                 else{
2777                 
2778                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2779                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2780                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2781                         *vertex[i][j+2] += *referencetrans[1];
2782                         vertex[i][4*(knedges+1)-j+1] = 
2783                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2784                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2785                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2786                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2787            }
2788         }
2789   }
2790   /////////////////////////////////////////////////////////////
2791   // First Mother Volume containing SSDEndFlex
2792   /////////////////////////////////////////////////////////////
2793   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2794   Double_t xmothervertex[kendflexvertexnumber];
2795   Double_t ymothervertex[kendflexvertexnumber];
2796   xmothervertex[0] = vertex[0][0]->X(); 
2797   ymothervertex[0] = vertex[0][0]->Y();
2798   for(Int_t i=1; i<kendflexvertexnumber; i++){
2799         if(i<2*(knedges+1)+2){
2800                 xmothervertex[i] = vertex[3][i]->X();
2801                 ymothervertex[i] = vertex[3][i]->Y();
2802         }
2803         else{
2804                 xmothervertex[i] = vertex[0][i]->X();
2805                 ymothervertex[i] = vertex[0][i]->Y();
2806         }
2807   }
2808   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2809                                                                            xmothervertex,ymothervertex);
2810   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2811   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2812 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2813 //                                                               ssdendflexmothershape,fSSDAir);        
2814   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2815   //////////////////////////////////////
2816   // End Flex TGeoXtru Layer Definition 
2817   //////////////////////////////////////
2818   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2819   TGeoVolume* ssdendflex[kendflexlayernumber];
2820   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2821   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2822   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2823   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2824   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2825                                                                                                         fSSDKaptonFlexMedium};
2826   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2827                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2828   for(Int_t i=0; i<kendflexlayernumber; i++){
2829         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2830                 xvertex[i][j] = vertex[i][j]->X();
2831                 yvertex[i][j] = vertex[i][j]->Y();
2832         }
2833   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2834   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2835   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2836   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2837                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2838   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2839   ssdendflexmother->AddNode(ssdendflex[i],1);
2840   }
2841   /////////////////////////////////////////////////////////////
2842   // Deallocating memory
2843   /////////////////////////////////////////////////////////////
2844   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2845   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2846   for(Int_t i=0; i<kendflexlayernumber; i++){
2847         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2848         delete [] vertex[i];
2849   }
2850   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2851   delete deltatransvector;
2852   /////////////////////////////////////////////////////////////
2853   //ssdendflexmother->CheckOverlaps(0.01);
2854   return ssdendflexmother;
2855 }
2856 ///////////////////////////////////////////////////////////////////////////////
2857 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
2858   /////////////////////////////////////////////////////////////
2859   // Method generating the Mounting Block
2860   /////////////////////////////////////////////////////////////  
2861   const Int_t kvertexnumber = 8;
2862   Double_t xvertex[kvertexnumber];
2863   Double_t yvertex[kvertexnumber];
2864   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
2865   xvertex[1] = xvertex[0];
2866   xvertex[2] = -xvertex[0];
2867   xvertex[3] = xvertex[2];
2868   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
2869                          -                                 fgkSSDMountingBlockLength[2]);
2870   xvertex[5] = xvertex[4];
2871   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
2872                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
2873                          -     fgkSSDMountingBlockScrewHoleRadius[0];
2874   xvertex[7] = xvertex[6];
2875   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
2876                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
2877   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
2878   yvertex[2] = yvertex[1]; 
2879   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
2880   yvertex[4] = yvertex[3];
2881   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
2882                          - fgkSSDMountingBlockHeight[0];
2883   yvertex[6] = yvertex[5];
2884   yvertex[7] = yvertex[0];
2885
2886   ///////////////////////////////////////////////////////////////////////
2887   // TGeoXTru Volume definition for Mounting Block Part
2888   ///////////////////////////////////////////////////////////////////////
2889   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
2890   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
2891   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
2892   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
2893   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
2894                                                                           ssdmountingblockshape,
2895                                                                                   fSSDMountingBlockMedium);
2896   ssdmountingblock->SetLineColor(fColorG10);
2897   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
2898   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
2899   TGeoRotation* mountingblockrot = new TGeoRotation();
2900   mountingblockrot->SetAngles(90.,180.,-90.);
2901   mountingblockcombitrans->SetRotation(*mountingblockrot);
2902   /////////////////////////////////////////////////////////////
2903   // Generating the Mounting Block Screw Vertices 
2904   /////////////////////////////////////////////////////////////  
2905   const Int_t kscrewvertexnumber = 15;
2906   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
2907                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
2908                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
2909                                  * TMath::RadToDeg();
2910   Double_t phi0 = 90.+alpha;
2911   Double_t phi = 270.-2*alpha;
2912   Double_t deltaphi = phi/kscrewvertexnumber;   
2913   TVector3* screwvertex[kscrewvertexnumber+1];
2914   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
2915         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
2916                                    *CosD(phi0+i*deltaphi),
2917                                    fgkSSDMountingBlockScrewHoleRadius[0]
2918                                    *SinD(phi0+i*deltaphi));
2919   Double_t xscrewvertex[kscrewvertexnumber+6];
2920   Double_t yscrewvertex[kscrewvertexnumber+6];
2921   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
2922   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
2923                                   -               fgkSSDMountingBlockScrewHoleEdge);
2924   xscrewvertex[1] = xscrewvertex[0];
2925   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
2926   xscrewvertex[2] = screwvertex[0]->X();
2927   yscrewvertex[2] = yscrewvertex[1];
2928   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
2929         xscrewvertex[i+3] = screwvertex[i]->X();        
2930         yscrewvertex[i+3] = screwvertex[i]->Y();        
2931   } 
2932   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
2933   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
2934   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
2935   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
2936   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
2937   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
2938   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
2939   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
2940                                                         +                                  fgkSSDMountingBlockHeight[2]);
2941   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
2942                                                                                 ssdmountingblockscrewshape,
2943                                                                                             fSSDMountingBlockMedium);
2944   ssdmountingblockscrew->SetLineColor(fColorG10);
2945   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
2946   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
2947   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
2948                                                                         -                                yscrewvertex[1],
2949                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
2950                                                                         -                                fgkSSDMountingBlockHeight[2]
2951                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2952                                                                         +                                fgkSSDMountingBlockHeight[2]
2953                                                                         -                                yvertex[0]));
2954   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
2955                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
2956                                                                                                                  yscrewvertex[1]
2957                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2958                                                                                                          +fgkSSDMountingBlockHeight[2]
2959                                                                                                          -yvertex[0]));
2960   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
2961                                                                                                           yscrewvertex[1],
2962                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
2963                                                                         +                                 fgkSSDMountingBlockHeight[2]
2964                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2965                                                                         +                                 fgkSSDMountingBlockHeight[2]
2966                                                                         -                                 yvertex[0]));
2967   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
2968                                                                                                          yscrewvertex[1],
2969                                                                         -                                yscrewvertex[1]
2970                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2971                                                                         +                                fgkSSDMountingBlockHeight[2]
2972                                                                         -                                yvertex[0]));
2973   TGeoRotation* ssdmountingblockscrewrot[4];
2974   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
2975         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
2976     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
2977     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
2978   for(Int_t i=1; i<4; i++) 
2979         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
2980   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
2981   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
2982   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
2983   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
2984                                                          +                                xvertex[0],yscrewvertex[1]
2985                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2986                                                          +                                fgkSSDMountingBlockHeight[2]
2987                                                          -                                yvertex[0]),0.);      
2988   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
2989   for(Int_t i=0; i<4; i++){
2990         ssdmountingblockscrewmatrix[i] = 
2991                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
2992         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
2993   }
2994   ///////////////////////////////////////////////////////////////////////
2995   // TGeoXtru for Mother Volume 
2996   ///////////////////////////////////////////////////////////////////////
2997   const Int_t kvertexmothernumber = 12;
2998   Double_t xmothervertex[kvertexmothernumber];
2999   Double_t ymothervertex[kvertexmothernumber];
3000   for(Int_t i=0; i<6; i++){
3001         xmothervertex[i] = xvertex[i];
3002         ymothervertex[i] = yvertex[i];
3003   } 
3004   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3005   ymothervertex[6]  = ymothervertex[5];
3006   xmothervertex[7]  = xmothervertex[6];
3007   ymothervertex[7]  = ymothervertex[4];
3008   xmothervertex[8]  = xmothervertex[7]
3009                                         + 0.5*(fgkSSDMountingBlockLength[1]
3010                                         -          fgkSSDMountingBlockLength[2]);
3011   ymothervertex[8]  = ymothervertex[4];
3012   xmothervertex[9]  = xmothervertex[8];
3013   ymothervertex[9]  = ymothervertex[2];
3014   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3015   ymothervertex[10] = ymothervertex[1];
3016   xmothervertex[11] = xmothervertex[10];
3017   ymothervertex[11] = ymothervertex[0];  
3018   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3019   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3020   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3021   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3022   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3023                                                                           ssdmountingblockmothershape,
3024                                                                                   fSSDAir);
3025   /////////////////////////////////////////////////////////////
3026   // Placing the Volumes into Mother Volume 
3027   /////////////////////////////////////////////////////////////
3028   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3029   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3030   for(Int_t i=0; i<4; i++) 
3031         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3032                                                                         ssdmountingblockscrewmatrix[i]);
3033   /////////////////////////////////////////////////////////////
3034   // Deallocating memory
3035   /////////////////////////////////////////////////////////////
3036   delete mountingblockrot;
3037   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3038   delete ssdmountingblockglobalrot; 
3039   delete ssdmountingblockglobaltrans; 
3040   /////////////////////////////////////////////////////////////
3041   return ssdmountingblockmother;
3042 }
3043 ///////////////////////////////////////////////////////////////////////////////
3044  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3045   /////////////////////////////////////////////////////////////
3046   // Method generating the Mounting Block Clip 
3047   /////////////////////////////////////////////////////////////  
3048   const Int_t kmothervertexnumber = 10;
3049   Double_t xmothervertex[kmothervertexnumber];
3050   Double_t ymothervertex[kmothervertexnumber];
3051   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3052                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3053   xmothervertex[1] = xmothervertex[0];
3054   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3055                                    - fgkMountingBlockClibScrewRadius);
3056   xmothervertex[3] = xmothervertex[2]; 
3057   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3058   xmothervertex[5] = xmothervertex[4]; 
3059   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3060   xmothervertex[7] = xmothervertex[6]; 
3061   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3062   xmothervertex[9] = xmothervertex[8]; 
3063   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3064                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3065   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3066   ymothervertex[2] = ymothervertex[1];
3067   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3068                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3069                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3070   ymothervertex[4] = ymothervertex[3];
3071   ymothervertex[5] = ymothervertex[2];
3072   ymothervertex[6] = ymothervertex[5];
3073   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3074   ymothervertex[8] = ymothervertex[7];
3075   ymothervertex[9] = ymothervertex[0];
3076
3077   ///////////////////////////////////////////////////////////////////////
3078   // TGeoXTru Volume definition for Mounting Block Clip Part
3079   ///////////////////////////////////////////////////////////////////////
3080   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3081   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3082   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3083   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3084   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3085                                                                           ssdmountingblockclipshape,fSSDAir);
3086   ssdmountingblockclip->SetLineColor(4);
3087   ///////////////////////////////////////////////////////////////////////
3088   // TGeoXTru Volume definition for Clip 
3089   ///////////////////////////////////////////////////////////////////////
3090   const Int_t kclipvertexnumber = 6;
3091   Double_t xclipvertex[kclipvertexnumber];
3092   Double_t yclipvertex[kclipvertexnumber];
3093   xclipvertex[0] = xmothervertex[0];
3094   xclipvertex[1] = xclipvertex[0];
3095   xclipvertex[2] = xmothervertex[6];
3096   xclipvertex[3] = xclipvertex[2];
3097   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3098   xclipvertex[5] = xclipvertex[4];
3099   yclipvertex[0] = ymothervertex[0];
3100   yclipvertex[1] = ymothervertex[1];
3101   yclipvertex[2] = yclipvertex[1];
3102   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3103   yclipvertex[4] = yclipvertex[3];
3104   yclipvertex[5] = yclipvertex[0];
3105   TGeoXtru* clipshape = new TGeoXtru(2);
3106   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3107   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3108   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3109                                                          +   fgkMountingBlockClibWidth);
3110   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3111   clip->SetLineColor(18);
3112   ///////////////////////////////////////////////////////////////////////
3113   // Ladder Support Piece  
3114   ///////////////////////////////////////////////////////////////////////
3115   const Int_t ksupportvertexnumber = 4;
3116   Double_t xsupportvertex[ksupportvertexnumber];
3117   Double_t ysupportvertex[ksupportvertexnumber];
3118   xsupportvertex[0] = xclipvertex[5];
3119   xsupportvertex[1] = xsupportvertex[0];
3120   xsupportvertex[2] = xmothervertex[9];
3121   xsupportvertex[3] = xsupportvertex[2];
3122   ysupportvertex[0] = yclipvertex[0];
3123   ysupportvertex[1] = yclipvertex[3];
3124   ysupportvertex[2] = ysupportvertex[1];
3125   ysupportvertex[3] = ysupportvertex[0];
3126   TGeoXtru* supportshape = new TGeoXtru(2);
3127   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3128   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3129   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3130   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3131   support->SetLineColor(9);
3132   ///////////////////////////////////////////////////////////////////////
3133   // TGeoXTru Volume definition for Screw   
3134   ///////////////////////////////////////////////////////////////////////
3135   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3136                                                 0.5*fgkMountingBlockClibScrewRadius};
3137   Int_t edgesnumber[2] = {50,6};
3138   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3139                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3140   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3141   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3142   clipscrew->SetLineColor(12);
3143   TGeoRotation* screwrot = new TGeoRotation();
3144   screwrot->SetAngles(0.,90.,0.);
3145   TGeoTranslation* screwtrans = new TGeoTranslation();
3146   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3147                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3148                                                          0.5*fgkSSDMountingBlockWidth+
3149                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3150   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3151   ///////////////////////////////////////////////////////////////////////
3152   // Placing the Volumes
3153   ///////////////////////////////////////////////////////////////////////
3154   ssdmountingblockclip->AddNode(clip,1);
3155   ssdmountingblockclip->AddNode(support,1);
3156   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3157   /////////////////////////////////////////////////////////////
3158   // Deallocating memory
3159   /////////////////////////////////////////////////////////////  
3160   delete screwtrans;
3161   delete screwrot;
3162   /////////////////////////////////////////////////////////////
3163   return ssdmountingblockclip;
3164 }
3165 ///////////////////////////////////////////////////////////////////////////////
3166 void AliITSv11GeometrySSD::CreateCoolingTubes() {
3167   /////////////////////////////////////////////////////////////
3168   // Method generating the Cooling Tube 
3169   // sets fcoolingtube and returns list for endladdercoolingtube
3170   /////////////////////////////////////////////////////////////  
3171   TGeoTube *coolingtubeshape[2];
3172   // Ladder Cooling Tubes
3173
3174   // MvL: Simplified cooling tubes
3175   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,0.5*fgkCoolingTubeLength);
3176   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,coolingtubeshape[0]->GetDz());
3177
3178   // End Ladder Cooling Tubes   
3179   TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3180   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3181     endladdercoolingtubeshape[i] = new  TGeoTube*[2];
3182
3183   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
3184   endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3185                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0] - sensZshift));
3186   endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3187                                                  endladdercoolingtubeshape[0][0]->GetDz());
3188   endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3189                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1] + sensZshift));
3190   endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3191                                                  endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3192   // Ladder Cooling Tubes
3193   TGeoVolume* coolingtube[2];
3194   coolingtube[0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0], fSSDCoolingTubePhynox);
3195   coolingtube[1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[1], fSSDCoolingTubeWater);
3196   coolingtube[0]->SetLineColor(fColorPhynox);
3197   coolingtube[1]->SetLineColor(fColorWater);
3198
3199   // End Ladder Cooling Tubes   
3200   TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3201   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3202     endladdercoolingtube[i] = new TGeoVolume*[2];
3203   endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3204                                               endladdercoolingtubeshape[0][0],
3205                                               fSSDCoolingTubePhynox);
3206   endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3207                                               endladdercoolingtubeshape[0][1],
3208                                               fSSDCoolingTubeWater);
3209   endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3210                                               endladdercoolingtubeshape[1][0],
3211                                               fSSDCoolingTubePhynox);
3212   endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3213                                               endladdercoolingtubeshape[1][1],
3214                                               fSSDCoolingTubeWater);
3215   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3216     endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3217     endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3218   }
3219   
3220   /////////////////////////////////////////////////////////////
3221   // Virtual Volume containing Cooling Tubes
3222   /////////////////////////////////////////////////////////////
3223   // Ladder Cooling Tubes
3224   TGeoTube* virtualcoolingtubeshape = new TGeoTube(coolingtubeshape[1]->GetRmin(),
3225                                                    coolingtubeshape[0]->GetRmax(),
3226                                                    coolingtubeshape[0]->GetDz());
3227   fcoolingtube = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape, fSSDAir);
3228   fcoolingtube->AddNode(coolingtube[0],1);
3229   fcoolingtube->AddNode(coolingtube[1],1);
3230
3231   // End Ladder Cooling Tubes
3232   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3233   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3234     endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3235                                                        endladdercoolingtubeshape[i][0]->GetRmax(),
3236                                                        endladdercoolingtubeshape[i][0]->GetDz());
3237   fendladdercoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3238                                             endladdervirtualcoolingtubeshape[0],
3239                                             fSSDAir);
3240   fendladdercoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3241                                             endladdervirtualcoolingtubeshape[1],
3242                                             fSSDAir);
3243   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3244   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3245   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3246   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);  
3247 }
3248 ///////////////////////////////////////////////////////////////////////////////
3249 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3250   /////////////////////////////////////////////////////////////
3251   // Method generating SSD Cooling Block    
3252   /////////////////////////////////////////////////////////////
3253   const Int_t kvertexnumber = 8;
3254   ///////////////////////////////////////
3255   // Vertex Positioning for TGeoXTru
3256   ///////////////////////////////////////
3257   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3258   vertexposition[0] = new TVector3(0.0,0.0);
3259   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3260   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3261                                           vertexposition[1]->Y());
3262   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3263                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3264   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3265   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3266                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3267   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3268                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3269                                         - fgkSSDCoolingBlockHoleLength[0]
3270                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3271                                           fgkSSDCoolingBlockHeight[0]
3272                                         - fgkSSDCoolingBlockHoleRadius[1],
3273                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3274   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3275                                         - fgkSSDCoolingBlockHoleLength[0]),
3276                                           vertexposition[6]->Y());
3277   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3278                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3279   Double_t phi = 180.-alpha;
3280   Double_t psi = 180.+2.*alpha;
3281   Double_t deltapsi = psi/nedges;
3282   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3283   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3284                                                   fgkSSDCoolingBlockHoleCenter);
3285   for(Int_t i=0; i<nedges+1; i++){
3286         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3287                                                                                                radius*SinD(phi+i*deltapsi));
3288    *vertexposition[kvertexnumber+i] += (*transvector);
3289   }
3290   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3291   for(Int_t i=0; i<kvertexnumber; i++)
3292     vertexposition[kvertexnumber+nedges+1+i] = 
3293                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3294   ///////////////////////////////////////////////////////////////////////
3295   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3296   ///////////////////////////////////////////////////////////////////////
3297   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3298   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3299   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3300   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3301         xvertexpoints[i] = vertexposition[i]->X();
3302         yvertexpoints[i] = vertexposition[i]->Y();
3303   } 
3304   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3305                                                                                         yvertexpoints);
3306   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3307   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3308   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3309                                                                           ssdcoolingblockshape,
3310                                                                                   fSSDAlCoolBlockMedium);
3311   ssdcoolingblock->SetLineColor(fColorAl);
3312   /////////////////////////////////////////////////////////////
3313   // Deallocating memory
3314   /////////////////////////////////////////////////////////////
3315   delete [] vertexposition;
3316   delete [] xvertexpoints;
3317   delete [] yvertexpoints;
3318   /////////////////////////////////////////////////////////////
3319   return ssdcoolingblock;
3320 }
3321 /////////////////////////////////////////////////////////////////////////////////
3322 void AliITSv11GeometrySSD::GetSSDChipCables(TGeoVolume *&cableL, TGeoVolume *&cableR, Double_t SSDChipCablesHeight, Int_t nedges){
3323   ///////////////////////////////////////////////////////
3324   static const Int_t kssdchipcablesnumber    = 2;  // Number of cables: left and right
3325   static const Int_t kssdchipcableslaynumber = 2;  // Number of layers: Al and Kapton
3326   static const Int_t kvertexnumber                        = 4*(nedges+1)+4;
3327   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3328   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3329   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeight
3330                                                  -  fgkSSDChipCablesHeight[0]
3331                                                  -  fgkSSDChipCablesHeight[1]);
3332   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3333   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3334   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3335                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3336                                                           - ssdchipcablesradius[0]
3337                                                           - fgkSSDChipCablesWidth[1]
3338                                                           - fgkSSDChipCablesWidth[2]);
3339   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3340                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3341                                                           +      fgkSSDChipCablesHeight[1]
3342                                                           +      fgkSSDSensorHeight);
3343   ///////////////////////////////////////////////////////
3344   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3345   ///////////////////////////////////////////////////////
3346   TVector3** vertexposition[kssdchipcableslaynumber];
3347   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3348                                                                                                   new TVector3*[4*(nedges+1)+4];
3349   Double_t ratio[4];
3350   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3351   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3352                    /  ssdchipcablesradius[0]; 
3353   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3354                    /  ssdchipcablesradius[0];
3355   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3356                    +  fgkSSDChipCablesHeight[1])
3357                    /  ssdchipcablesradius[0];
3358   Double_t phi = 180.;
3359   Double_t deltaphi = 180./nedges;
3360   Double_t angle = 0.0;
3361
3362   Double_t xvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3363   Double_t yvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3364
3365   TVector3* vertex = new TVector3();
3366   TVector3* transvector[kssdchipcableslaynumber];
3367   transvector[0] = new TVector3(fgkSSDChipWidth,
3368                                                                 SSDChipCablesHeight-ssdchipcablesradius[0]);
3369   transvector[1] = new TVector3();
3370   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcablesnumber];
3371   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcablesnumber];
3372   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcablesnumber] = 
3373                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3374                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3375   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3376         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3377         transvector[1]->SetY(ssdchipcablesradius[0]
3378                                  +               fgkSSDChipCablesHeight[0]
3379                                  +               fgkSSDChipCablesHeight[1]);  
3380         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3381                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeight
3382                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3383                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeight
3384                                                          - i*fgkSSDChipCablesHeight[0]);
3385                 vertexposition[i][2*(nedges+1)+2] = 
3386                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3387                                 +                                fgkSSDChipCablesWidth[1]
3388                                 +                                fgkSSDChipCablesWidth[2],
3389                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3390                                 +                                fgkSSDChipCablesHeight[1]));
3391         vertexposition[i][2*(nedges+1)+3] = 
3392                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3393                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3394                                 -                                fgkSSDChipCablesHeight[i]);
3395             for(Int_t j=0; j<nedges+1; j++){            
3396                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3397                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3398                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3399                         vertexposition[0][(nedges+1)*i+j+2] = 
3400                                                 new TVector3(*vertex+*transvector[i]);
3401                         vertexposition[1][(nedges+1)*i+j+2] = 
3402                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3403                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3404                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3405                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3406                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3407                                                 new TVector3(vertex->X()*ratio[2*i+1]
3408                                                         +                        transvector[i]->X(),
3409                                                                                  vertex->Y()*ratio[2*i+1]
3410                                                         +                transvector[i]->Y());
3411                 }
3412         }
3413         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3414                 for(Int_t j=0; j<kvertexnumber; j++){   
3415                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3416                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3417                 }
3418                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3419                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3420                                                                                 xvertexpoints[i],yvertexpoints[i]);
3421                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3422                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3423                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3424                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3425                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3426                                                           (kssdchipcablesnumber*k+i)%2==0?
3427                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3428                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3429         }
3430         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3431                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3432   }
3433   /////////////////////////////////////////////////////////////
3434   // Mother Volume definition 
3435   /////////////////////////////////////////////////////////////
3436   static const Int_t kmothervertexnumber = 8;
3437   Double_t xmothervertex[kmothervertexnumber];
3438   Double_t ymothervertex[kmothervertexnumber];
3439   xmothervertex[0] = xvertexpoints[0][1];
3440   ymothervertex[0] = yvertexpoints[0][1];
3441   xmothervertex[1] = xvertexpoints[0][2+nedges/2];
3442   ymothervertex[1] = yvertexpoints[0][1];
3443   xmothervertex[2] = xvertexpoints[0][2+nedges/2];
3444   ymothervertex[2] = yvertexpoints[0][2+nedges];
3445   xmothervertex[3] = xvertexpoints[0][3+nedges];
3446   ymothervertex[3] = yvertexpoints[0][3+nedges];
3447   xmothervertex[4] = xvertexpoints[0][3+2*nedges];
3448   ymothervertex[4] = yvertexpoints[0][3+2*nedges];
3449   xmothervertex[5] = xvertexpoints[0][4+2*nedges];
3450   ymothervertex[5] = yvertexpoints[0][4+2*nedges];
3451   xmothervertex[6] = xvertexpoints[1][5+2*nedges];
3452   ymothervertex[6] = yvertexpoints[1][5+2*nedges];
3453   xmothervertex[7] = xvertexpoints[0][1];
3454   ymothervertex[7] = yvertexpoints[1][5+2*nedges];
3455   TGeoXtru *ssdchipcablemothershape = new TGeoXtru(2);
3456   ssdchipcablemothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3457   ssdchipcablemothershape->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3458   ssdchipcablemothershape->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3459
3460   cableL = new TGeoVolume("SSDChipCableMotherLeft",ssdchipcablemothershape,fSSDAir);
3461   cableR = new TGeoVolume("SSDChipCableMotherRight",ssdchipcablemothershape,fSSDAir);
3462
3463   cableL->AddNode(ssdchipcable[0],1);
3464   cableL->AddNode(ssdchipcable[1],1);
3465   cableR->AddNode(ssdchipcable[2],1);
3466   cableR->AddNode(ssdchipcable[3],1);  
3467
3468   /////////////////////////////////////////////////////////////
3469   // Deallocating memory
3470   /////////////////////////////////////////////////////////////
3471   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3472   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3473   delete vertex; 
3474   /////////////////////////////////////////////////////////////
3475 }
3476 //_____________________________________________________________________________
3477 TGeoVolume* AliITSv11GeometrySSD::GetSSDChip() const{
3478   /////////////////////////////////////////////////////////////
3479   // SSD Chip Assembly Generation    
3480   /////////////////////////////////////////////////////////////
3481   TGeoBBox* ssdchipcompshape[2];
3482   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3483                                                                                 0.5*fgkSSDChipLength,
3484                                                                                 0.5*fgkSSDChipWidth,
3485                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3486   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3487                                                                                 0.5*fgkSSDChipLength,
3488                                                                                 0.5*fgkSSDChipWidth,
3489                                                                                 0.5*fgkSSDChipGlueHeight);
3490   TGeoVolume* ssdchipcomp[2];
3491   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3492   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3493                                                                   fSSDChipGlueMedium);
3494   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3495   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3496   TGeoTranslation* ssdchipcomptrans[2];
3497   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3498   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3499   /////////////////////////////////////////////////////////////
3500   // Virtual Volume containing SSDChip   
3501   /////////////////////////////////////////////////////////////
3502   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3503                                                                                                                  0.5*fgkSSDChipWidth,
3504                                                                                                                  0.5*fgkSSDChipHeight);
3505   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3506   /////////////////////////////////////////////////////////////
3507   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3508   return ssdchip;
3509 }
3510 /////////////////////////////////////////////////////////////////////////////////
3511 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3512   /////////////////////////////////////////////////////////////
3513   // Method returning a List containing pointers to Ladder Cable Volumes    
3514   //
3515   // Return list contains 3 assemblies: cable box, cable arb shape and the end part of the cable
3516   //                                    each contains 2 volumes, one for polyamide and one for aluminium
3517   /////////////////////////////////////////////////////////////
3518   const Int_t kladdercablesegmentnumber = 2;
3519   /////////////////////////////////////////
3520   // LadderSegmentBBox Volume
3521   /////////////////////////////////////////
3522   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3523   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3524                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3525
3526
3527   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3528                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3529   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3530
3531   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3532                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3533                                                                                            0.5*fgkSSDFlexWidth[0],
3534                                                                                            0.5*fgkSSDLadderCableWidth,
3535                                                                        0.5*fgkSSDLadderCableHeight[0]),
3536                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3537                                                                                            0.5*fgkSSDFlexWidth[0],
3538                                                                                            0.5*fgkSSDLadderCableWidth,
3539                                                                                            fgkSSDLadderCableHeight[0]
3540                                                                                            +0.5*fgkSSDLadderCableHeight[1])
3541                                                                                    };
3542   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3543   static TGeoVolume* laddercablesegmentarbassembly = 
3544                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3545
3546   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3547   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3548
3549   if (laddercablesegmentbboxshape[0] == 0) { 
3550     // Initialise static shapes and volumes 
3551   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3552                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3553                                                                            0.5*fgkSSDFlexWidth[0],
3554                                                                            0.5*fgkSSDLadderCableWidth,
3555                                                                            0.5*fgkSSDLadderCableHeight[i]); 
3556
3557   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3558                         laddercablesegmentbbox[i] =
3559                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3560                                                                                  laddercablesegmentbboxshape[i],
3561                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3562             fSSDKaptonLadderCableMedium));
3563                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3564                                                                                                                    fColorPolyhamide);
3565   }
3566   
3567   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3568                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3569                                                                                             laddercablesegmentbboxtrans[i]);
3570 /////////////////////////////////////////
3571 // LadderSegmentArb8 Volume
3572 /////////////////////////////////////////
3573   const Int_t kvertexnumber = 4;
3574   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3575   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3576                                                                                                   new TVector3*[kvertexnumber];
3577 //Shape Vertex Positioning
3578   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3579         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3580         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3581                                                                                                                   i*fgkSSDFlexHeight[0]);
3582         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3583                                                                                    +                         fgkSSDFlexHeight[1]
3584                                                                                    +                      i*fgkSSDFlexHeight[0]);
3585         laddercablesegmentvertexposition[i][3] = 
3586                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3587                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3588   }
3589   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3590                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3591   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3592                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3593
3594   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3595                                         GetArbShape(laddercablesegmentvertexposition[i],
3596                                                                 laddercablesegmentwidth[i],
3597                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3598                                                                 laddercablesegmentarbshapename[i]);
3599   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3600                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3601
3602   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3603                          laddercablesegmentarb[i] =
3604                                                    new TGeoVolume(laddercablesegmentarbname[i],
3605                                                                                   laddercablesegmentarbshape[i],
3606                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3607             fSSDKaptonLadderCableMedium)); 
3608                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3609                                                                                                                    fColorPolyhamide);
3610 }
3611   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3612   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3613                                                                                                  90.,90,-90.);   
3614   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3615                                                                                                   0.,90.,0.);    
3616   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3617                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3618                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3619                                                          + fgkSSDFlexWidth[0],0.,0.,
3620                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3621                                                      *(*laddercablesegmentarbrot[0])));
3622   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3623   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3624                                                                                    laddercablesegmentarbcombitrans);
3625   }  // End of static initialisations
3626 /////////////////////////////////////////
3627 // End Ladder Cable Volume
3628 // Note: this part depends explicitly on the length passed as an argument to the function
3629 /////////////////////////////////////////
3630   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
3631   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
3632                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
3633   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
3634                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
3635                                                                            0.5*ssdendladdercablelength,
3636                                                                            0.5*fgkSSDLadderCableWidth,
3637                                                                            0.5*fgkSSDLadderCableHeight[i]);
3638   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
3639                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
3640   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
3641   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3642                         ladderendcablesegmentbbox[i] =
3643                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
3644                                                                                  ladderendcablesegmentbboxshape[i],
3645                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3646             fSSDKaptonLadderCableMedium));
3647                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3648                                                                                                                    fColorPolyhamide);
3649   }
3650   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
3651   ladderendcablesegmentbboxtrans[0] = 
3652                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
3653                                                                                            0.5*ssdendladdercablelength,
3654                                                                                            0.5*fgkSSDLadderCableWidth,
3655                                                                                            0.5*fgkSSDLadderCableHeight[0]);
3656   ladderendcablesegmentbboxtrans[1] = 
3657                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
3658                                                                                            0.5*ssdendladdercablelength,
3659                                                                                            0.5*fgkSSDLadderCableWidth,
3660                                                                                            fgkSSDLadderCableHeight[0]
3661                                                                                            +0.5*fgkSSDLadderCableHeight[1]);
3662   TGeoVolume* ladderendcablesegmentbboxassembly = 
3663                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
3664   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3665                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
3666                                                                                             ladderendcablesegmentbboxtrans[i]);
3667 /////////////////////////////////////////
3668   TList* laddercablesegmentlist = new TList();
3669   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
3670   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
3671   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
3672   return laddercablesegmentlist;
3673 }
3674
3675 /////////////////////////////////////////////////////////////////////////////////
3676 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
3677   /////////////////////////////////////////////////////////////
3678   // Method generating Ladder Cable of given length (n modules + end)
3679   // Called by GetLadderCableAssembly
3680   /////////////////////////////////////////////////////////////
3681   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
3682   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
3683   for(Int_t i=0; i<n; i++){
3684          TGeoTranslation* laddercabletrans = new TGeoTranslation(
3685                                                         i*(fgkCarbonFiberJunctionWidth),
3686                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3687                                                         i*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3688     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
3689     if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
3690  
3691   }
3692   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
3693                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3694                                                              fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3695                                                              (n-1)*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3696   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
3697   return laddercable;
3698 }
3699 /////////////////////////////////////////////////////////////////////////////////
3700 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
3701   ///////////////////////////////////////////////////////////////////
3702   // Main method generating Ladder Cable bundles containing n cables
3703   ///////////////////////////////////////////////////////////////////
3704   Double_t totalLength = ssdendladdercablelength+(n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0];
3705   Double_t cableOrig[3] = {0.5*totalLength,1.5*fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1])};
3706   TGeoBBox *laddercableshape = new TGeoBBox(0.5*totalLength,0.5*fgkSSDLadderCableWidth,0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]),cableOrig);
3707   TGeoVolume* laddercable = new TGeoVolume("LadderCableMother", laddercableshape, fSSDAir);
3708   char laddercabletransname[100];
3709   for(Int_t i=0; i<n; i++){ 
3710     snprintf(laddercabletransname,100,"LadderCableTrans%i",i+1);
3711     laddercable->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
3712                          new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0,0));
3713   }
3714   return laddercable;
3715 }
3716 /////////////////////////////////////////////////////////////////////////////////
3717 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
3718   /////////////////////////////////////////////////////////////
3719   // Method generating Ladder Cable List Assemblies  
3720   // containing two cables bundles, i.e. P+N readout for one endcap
3721   /////////////////////////////////////////////////////////////  
3722   const Int_t kladdercableassemblynumber = 2; 
3723   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
3724   TGeoVolume* ladderCable[kladdercableassemblynumber];
3725   char laddercableassemblyname[100];
3726   TList* laddercableassemblylist = new TList();
3727   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
3728     snprintf(laddercableassemblyname,100,"LadderCableAssembly%i",i+1);
3729         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
3730         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
3731                                          new TGeoCombiTrans((n-1)
3732                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3733                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
3734                                                                                         0.,new TGeoRotation("",180,0.,0.)));
3735         laddercableassemblylist->Add(ladderCable[i]);
3736 }
3737   return laddercableassemblylist;
3738 }
3739 ///////////////////////////////////////////////////////////////////////////////
3740 void AliITSv11GeometrySSD::SetLadderSegment(){
3741   /////////////////////////////////////////////////////////////
3742   // Method Generating Ladder Segment Array
3743   /////////////////////////////////////////////////////////////
3744   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
3745   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
3746
3747   /* MvL: tried to create mother volume. Requires changes in all rotations, bc xtru is always along z-axis
3748   TGeoXtru *laddersegmentshape = new TGeoXtru(2);
3749   static const Int_t ntrianglevtx = 3;
3750   Double_t xtrianglevtx[ntrianglevtx]={-0.5*fgkCarbonFiberTriangleLength,fgkCarbonFiberTriangleLength, 0};
3751   Double_t ytrianglevtx[ntrianglevtx]={0, 0, fgkCarbonFiberTriangleLength * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad())};
3752   laddersegmentshape->DefinePolygon(ntrianglevtx,xtrianglevtx,ytrianglevtx);
3753   laddersegmentshape->DefineSection(0,0);
3754   laddersegmentshape->DefineSection(1,fgkCarbonFiberJunctionWidth);  // MVL
3755   fladdersegment[0] = new TGeoVolume("LadderSegment1",laddersegmentshape,fSSDAir);      
3756   fladdersegment[1] = new TGeoVolume("LadderSegment2",laddersegmentshape,fSSDAir);      
3757   */
3758
3759   if(!fCreateMaterials) CreateMaterials();
3760   if(!fTransformationMatrices) CreateTransformationMatrices();
3761   if(!fBasicObjects) CreateBasicObjects();
3762   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
3763   // Placing Carbon Fiber Support       
3764         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
3765                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3766                                                                                         fcarbonfibersupportmatrix[j]);  
3767                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3768                                                                                         fcarbonfibersupportmatrix[j]);
3769   }
3770   // Placing Carbon Fiber Junction
3771         for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++) {
3772         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
3773                                                                    fcarbonfiberjunctionmatrix[j]);
3774   }
3775   // Placing Carbon Fiber Lower Support
3776     for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++) {
3777                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
3778                                                            fcarbonfiberlowersupportrans[j]);    
3779     }
3780   // Placing SSD Sensor Support
3781     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
3782         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
3783                                                                      fssdsensorsupport[1][i],
3784                                                            j+1,fssdsensorsupportmatrix[j]);
3785   // Placing SSD Cooling Tube Support 
3786         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
3787                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3788                                                                    fcoolingtubesupportmatrix[j]);
3789   // Placing SSD Cooling Tube  
3790         fladdersegment[i]->AddNode(fcoolingtube,1,fcoolingtubematrix[0]);
3791         fladdersegment[i]->AddNode(fcoolingtube,2,fcoolingtubematrix[1]);
3792   // Placing SSD Hybrid
3793     switch(i){
3794         case 0: 
3795                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
3796                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3797                 break;
3798     case 1:
3799                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
3800                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3801                 break;
3802         }
3803         // Placing Cooling Block System
3804       fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
3805         // Placing SSD Flex
3806       for(Int_t j=0; j<fgkflexnumber; j++){
3807         fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
3808         fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
3809       }
3810    }
3811 }
3812 ///////////////////////////////////////////////////////////////////////////////
3813 void AliITSv11GeometrySSD::SetEndLadderSegment(){
3814   /////////////////////////////////////////////////////////////
3815   // Method Generating End Ladder
3816   /////////////////////////////////////////////////////////////
3817   // End Ladder Carbon Fiber Junction 
3818   /////////////////////////////////////////////////////////////
3819   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
3820   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
3821   if(!fCreateMaterials) CreateMaterials();
3822   if(!fTransformationMatrices) CreateTransformationMatrices();
3823   if(!fBasicObjects) CreateBasicObjects();
3824   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
3825         for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
3826                 fendladdersegment[i]->AddNode(j==2 ? 
3827                                                         fendladdercarbonfiberjunction[i][1] : 
3828                                                         fendladdercarbonfiberjunction[i][0],
3829                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
3830   }
3831   /////////////////////////////////////////////////////////////
3832   // End Ladder Carbon Fiber Support 
3833   /////////////////////////////////////////////////////////////
3834   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
3835       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
3836                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3837                   fendladdercarbonfibermatrix[i][j]);   
3838           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3839                   fendladdercarbonfibermatrix[i][j]);   
3840       }
3841   /////////////////////////////////////////////////////////////
3842   // End Ladder Mounting Block
3843   /////////////////////////////////////////////////////////////
3844   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3845        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
3846                                      fendladdermountingblockcombitrans[i]);
3847   /////////////////////////////////////////////////////////////
3848   // End Ladder Mounting Block Clip
3849   /////////////////////////////////////////////////////////////
3850   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3851         for(Int_t j=0; j<2; j++)
3852                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
3853                                               fendladdermountingblockclipmatrix[i][j]);
3854   /////////////////////////////////////////////////////////////
3855   // End Ladder Lower Supports
3856   /////////////////////////////////////////////////////////////
3857   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
3858                                 fendladderlowersupptrans[0]);
3859   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
3860                                 fendladderlowersupptrans[1]);
3861   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
3862                                 fendladderlowersupptrans[2]);
3863   /////////////////////////////////////////////////////////////
3864   // End Ladder Cooling Tube Support
3865   /////////////////////////////////////////////////////////////
3866   for(Int_t i=0; i<2; i++) 
3867         for(Int_t j=0; j<(i==0?4:2); j++)   
3868                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3869                                               fendladdercoolingtubesupportmatrix[i][j]);
3870   /////////////////////////////////////////////////////////////
3871   // End Ladder Cooling Tube Support
3872   /////////////////////////////////////////////////////////////
3873   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]); 
3874   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);
3875   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[1][0]);
3876   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[1][1]); 
3877 }
3878 ///////////////////////////////////////////////////////////////////////////////
3879 void AliITSv11GeometrySSD::SetLadder(){
3880   /////////////////////////////////////////////////////////////
3881   // Method Generating Ladder of Layer 5 and 6
3882   /////////////////////////////////////////////////////////////  
3883   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
3884                                                                                                 fgkSSDLay6SensorsNumber};
3885   /////////////////////////////////////////////////////////////////////////////                                         
3886   /// Generating Ladder Mother Volume Containing Ladder 
3887   /////////////////////////////////////////////////////////////////////////////          
3888   TGeoXtru* laddershape[fgkladdernumber];       
3889   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
3890   const Int_t kmothervertexnumber = 8;  
3891   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
3892   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
3893   ///////////////////////
3894   // Setting the vertices 
3895   ///////////////////////
3896   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
3897                                                                 * (fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]);
3898   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
3899   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
3900   xmothervertex[0][1] = xmothervertex[0][0];
3901   ymothervertex[0][1] = -0.5*fgkCoolingTubeSupportHeight; // 0.0; MvL 20-apr-2010
3902   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
3903                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
3904   ymothervertex[0][2] = ymothervertex[0][1];
3905   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
3906   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
3907   xmothervertex[0][4] = -xmothervertex[0][3];
3908   ymothervertex[0][4] = ymothervertex[0][3];
3909   xmothervertex[0][5] = -xmothervertex[0][2];
3910   ymothervertex[0][5] = ymothervertex[0][2];
3911   xmothervertex[0][6] = -xmothervertex[0][1];
3912   ymothervertex[0][6] = ymothervertex[0][1];
3913   xmothervertex[0][7] = -xmothervertex[0][0];
3914   ymothervertex[0][7] = ymothervertex[0][0];
3915   for(Int_t i=0; i<kmothervertexnumber; i++){
3916         xmothervertex[1][i] = xmothervertex[0][i];
3917         ymothervertex[1][i] = ymothervertex[0][i];
3918   }
3919 ///////////////////////////////////////////////////////////////////////////
3920 // Disalignement Mother Volume corrections 25/08/08
3921 ///////////////////////////////////////////////////////////////////////////
3922   TGeoXtru* leftladdershape1[fgkladdernumber];  
3923   TGeoXtru* leftladdershape2[fgkladdernumber];  
3924   TGeoXtru* centersensorladdershape[fgkladdernumber];   
3925   TGeoXtru* rightladdershape1[fgkladdernumber]; 
3926   TGeoXtru* rightladdershape2[fgkladdernumber]; 
3927   for(Int_t i=0; i<fgkladdernumber; i++){
3928     leftladdershape1[i] = new TGeoXtru(2);
3929     leftladdershape2[i] = new TGeoXtru(2);
3930     centersensorladdershape[i] = new TGeoXtru(2);
3931     rightladdershape1[i] = new TGeoXtru(2);
3932     rightladdershape2[i] = new TGeoXtru(2);
3933   }
3934   //////////////////////////////////////
3935   // Setting the names for shapes  
3936   //////////////////////////////////////
3937   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
3938   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
3939   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
3940   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
3941   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
3942   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
3943   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
3944   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
3945   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
3946   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
3947   //////////////////////////////////////
3948   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
3949   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
3950   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
3951   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
3952   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
3953   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
3954   for(Int_t i=0; i<fgkladdernumber; i++) {
3955     for(Int_t j=0; j<kmothervertexnumber; j++){
3956       xcentersensorvertex[i][j] = xmothervertex[i][j];
3957       ycentersensorvertex[i][j] = ymothervertex[i][j];
3958       xend1laddervertex[i][j] = xmothervertex[i][j];
3959       yend1laddervertex[i][j] = ymothervertex[i][j];
3960       xend2laddervertex[i][j] = xmothervertex[i][j];
3961       yend2laddervertex[i][j] = ymothervertex[i][j];
3962     }
3963     // Add some space around sensors to accommodate misalignments
3964     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
3965     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
3966     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
3967     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
3968     
3969     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
3970     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
3971     
3972     // Center Ladder Piece
3973     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
3974                                               ycentersensorvertex[i]);
3975     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
3976                                                  + 1.45*fgkSSDMountingBlockWidth);
3977     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
3978                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
3979                                                  - 2.4*fgkSSDMountingBlockWidth);
3980
3981     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
3982
3983     // Cuts off first corner (neg x)
3984     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
3985     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
3986     // Cuts off last part (pos x)
3987     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
3988     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
3989
3990     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
3991                                        yend1laddervertex[i]);
3992     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
3993     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
3994                                          - fgkEndLadderMountingBlockPosition[0]);
3995     
3996     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
3997                                        yend2laddervertex[i]);
3998     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
3999                                          - fgkEndLadderMountingBlockPosition[0]); 
4000     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4001                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4002
4003     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4004                                         yend1laddervertex[i]);
4005     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4006                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4007                                         -2.4*fgkSSDMountingBlockWidth);
4008     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4009                                         + fgkEndLadderMountingBlockPosition[1]);
4010
4011     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4012                                         yend2laddervertex[i]);
4013     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4014                                            + fgkEndLadderMountingBlockPosition[1]);
4015     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4016                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4017   }
4018   TGeoCompositeShape* laddershapecontainer[2];
4019   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4020                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4021                                                    "+Lay5CenterSensorContainer"
4022                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4023   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4024                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4025                                                    "+Lay6CenterSensorContainer"
4026                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4027   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4028   for(Int_t i=0; i<fgkladdernumber; i++){
4029     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4030     fladder[i]->SetLineColor(4);
4031   }
4032 ///////////////////////////////////////////////////////////////////////////
4033  if(!fCreateMaterials) CreateMaterials();
4034  if(!fTransformationMatrices) CreateTransformationMatrices();
4035  if(!fBasicObjects) CreateBasicObjects();
4036  SetLadderSegment(); 
4037  SetEndLadderSegment();
4038   for(Int_t i=0; i<fgkladdernumber; i++){
4039         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4040         //////////////////////////                                              
4041         /// Placing Ladder Segment
4042         //////////////////////////              
4043                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4044                                                                      fladdersegment[i==0 ? 1 : 0],
4045                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4046         //////////////////////////                                              
4047         /// Placing SSD Sensor
4048         //////////////////////////              
4049         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4050                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4051                                                         fssdsensormatrix[i][j]);
4052         }
4053         ///////////////////////////////                                         
4054         /// Placing End Ladder Segment
4055         ///////////////////////////////         
4056         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4057         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4058    }
4059 /////////////////////////////////////////////////////////////////////////////                                           
4060 /// Placing Ladder Cables
4061 /////////////////////////////////////////////////////////////////////////////           
4062   Int_t sidecablenumber[2][2];
4063   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4064   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4065   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4066   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4067   Double_t carbonfibertomoduleposition[3];
4068   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4069   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4070                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4071          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4072          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4073          -            fgkSSDSensorCenterSupportThickness[0]);
4074   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4075                                                                  +   0.5*fgkCoolingTubeSupportHeight
4076          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4077   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4078   Double_t ssdendladdercablelength[4];
4079   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4080                                                          + fgkSSDSensorLength
4081                                                          - fgkSSDModuleStiffenerPosition[1]
4082                                                          - fgkSSDStiffenerWidth 
4083                                                          - fgkSSDFlexWidth[0]
4084                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4085   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4086                                                          + fgkSSDModuleStiffenerPosition[1]
4087                                                          + fgkSSDStiffenerWidth
4088                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4089   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4090                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4091                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4092                                                          - kendladdercablecorrection;
4093   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4094                                                          + carbonfibertomoduleposition[1]
4095                                                          - fgkSSDModuleStiffenerPosition[1]
4096                                                          - fgkSSDStiffenerWidth)
4097                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4098
4099   TList* laddercableassemblylist[4];
4100   const Int_t kendladdercablesnumber = 4;
4101   TGeoRotation *laddercablerot = new TGeoRotation();
4102   laddercablerot->SetAngles(90.,60.,-90.);
4103   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4104         for(Int_t j=0; j<kendladdercablesnumber; j++){
4105                 laddercableassemblylist[j] = 
4106                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4107                                                                    ssdendladdercablelength[j]);
4108                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4109                                                                         j<2?1:2,fladdercablematrix[i][j]);
4110   }
4111 }
4112 ////////////////////////////////////////////////////////////////////////////////
4113 void AliITSv11GeometrySSD::SetLayer(){
4114 ////////////////////////////////////////////////////////////////////////////////
4115   // Creating Ladder of Layer 5 and Layer 6
4116   /////////////////////////////////////////////////////////////
4117   if(!fCreateMaterials) CreateMaterials();
4118   if(!fTransformationMatrices) CreateTransformationMatrices();
4119   if(!fBasicObjects) CreateBasicObjects();
4120   SetLadder(); // Generating the ladder of Layer5 and Layer6
4121   const Int_t kssdlayladdernumber[fgklayernumber] = 
4122                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4123   /////////////////////////////////////////////////////////////
4124   // Generating mother volumes for Layer5 and Layer6
4125   /////////////////////////////////////////////////////////////
4126   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4127   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4128   Int_t *ladderindex[fgklayernumber];
4129   Int_t index[fgklayernumber] = {8,9};
4130   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4131   for(Int_t i=0; i<fgklayernumber; i++) 
4132         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4133                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4134                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4135                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4136                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4137         }
4138   /////////////////////////////////////////////////////////////
4139   // Deallocating memory
4140   /////////////////////////////////////////////////////////////
4141   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
4142 }
4143 ////////////////////////////////////////////////////////////////////////////////
4144 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4145   /////////////////////////////////////////////////////////////
4146   // Insert the layer 5 in the mother volume. 
4147   /////////////////////////////////////////////////////////////
4148   if (! moth) {
4149     AliError("Can't insert layer5, mother is null!\n");
4150     return;
4151   };
4152   if(!fSSDLayer5) SetLayer();
4153   fMotherVol = moth;
4154   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4155                                                                                 + fgkLay5CenterITSPosition);
4156   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4157  }
4158 ////////////////////////////////////////////////////////////////////////////////
4159 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4160   /////////////////////////////////////////////////////////////
4161   // Insert the layer 6 in the mother volume. 
4162   /////////////////////////////////////////////////////////////
4163   if (! moth) {
4164     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4165     return;
4166   };
4167   if(!fSSDLayer6) SetLayer();
4168   fMotherVol = moth;
4169   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4170                                                                                 + fgkLay6CenterITSPosition);
4171   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4172  }
4173  ////////////////////////////////////////////////////////////////////////////////
4174  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4175   /////////////////////////////////////////////////////////////
4176   // Method generating the Arc structure of Ladder Support 
4177   /////////////////////////////////////////////////////////////
4178   const Int_t kssdlayladdernumber[fgklayernumber] = 
4179                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4180   Double_t mountingsupportedge[fgklayernumber];
4181   Double_t mountingblockratio[fgklayernumber];
4182   Double_t theta[fgklayernumber];
4183   Double_t phi[fgklayernumber];
4184   Double_t psi0[fgklayernumber];
4185   Double_t deltapsi[fgklayernumber];
4186   TVector3* mountingsupportedgevector[fgklayernumber];
4187   for(Int_t i=0; i<fgklayernumber; i++){
4188         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4189     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4190                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4191                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4192                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4193                                                           / kssdlayladdernumber[i])));
4194     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4195     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4196         mountingsupportedgevector[i] = new TVector3();
4197         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4198         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4199                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4200                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4201     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4202     deltapsi[i] = (theta[i]+phi[i])/nedges;
4203   }
4204   TVector3** vertex[fgklayernumber];
4205   TList* vertexlist[fgklayernumber];
4206   Int_t indexedge[fgklayernumber] = {0,0};
4207   for(Int_t i=0; i<fgklayernumber; i++){
4208         vertex[i] = new TVector3*[nedges+1];
4209         vertexlist[i] = new TList();
4210   } 
4211   for(Int_t i=0; i<fgklayernumber; i++){
4212         for(Int_t j=0; j<nedges+1; j++){
4213                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4214                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4215                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4216                 vertexlist[i]->Add(vertex[i][j]);
4217         }
4218         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4219   }
4220   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4221   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4222   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4223   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4224   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4225   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4226   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4227   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4228   for(Int_t i=0; i<fgklayernumber; i++){
4229     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4230     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4231     xcentervertex[i] = new Double_t[indexedge[i]+3];
4232     ycentervertex[i] = new Double_t[indexedge[i]+3];
4233         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4234         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4235         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4236         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4237         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4238                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4239                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4240                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4241                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4242                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4243                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4244                 if(j<indexedge[i]+1){
4245                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4246                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4247                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4248                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4249                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4250                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4251                 }
4252         }
4253         xsidevertex[i][1] = xsidevertex[i][0]; 
4254         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4255         xsidevertex[i][2] = xsidevertex[i][3]; 
4256         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4257         xcentervertex[i][1] = xcentervertex[i][0]; 
4258         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4259         xcentervertex[i][2] = xcentervertex[i][3]; 
4260         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4261         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4262         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4263         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4264         ycenterlowervertex[i][0] = ysidevertex[i][0];
4265         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4266         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4267   }
4268   /////////////////////////////////////////////////////////////
4269   // Building the Arc Structure of Ladder Supports 
4270   /////////////////////////////////////////////////////////////
4271   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4272   TGeoXtru* centermountingsupportshape[fgklayernumber];
4273   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4274   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4275   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4276   TGeoVolume* centermountingblocksupport[fgklayernumber];
4277   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4278   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4279   char sidemountingblockname[100];
4280   char centermountingblockname[100];
4281   char sideladdersupportpiecename[100];
4282   char centerladdersupportpiecename[100];
4283   for(Int_t i=0; i<fgklayernumber; i++){ 
4284     snprintf(sidemountingblockname,100,"MountingBlockSupportSideLay%dArc",i+5);
4285     snprintf(centermountingblockname,100,"MountingBlockSupportCenterLay%dArc",i+5);
4286     snprintf(sideladdersupportpiecename,100,"SideLadderSupportPieceLay%d",i+5);
4287     snprintf(centerladdersupportpiecename,100,"CenterLadderSupportPieceLay%d",i+5);
4288     sidemountingblocksupportshape[i] = new TGeoXtru(2);
4289     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4290                                                                                                 xsidevertex[i],ysidevertex[i]);
4291     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4292                                                                                                          -fgkMountingBlockSupportWidth[0]);
4293     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4294     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4295                                                                           sidemountingblocksupportshape[i],
4296                                                                                   fSSDAlCoolBlockMedium);
4297         sidemountingblocksupport[i]->SetLineColor(9);
4298         centermountingsupportshape[i] = new TGeoXtru(2);
4299     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4300                                                                                                 xcentervertex[i],ycentervertex[i]);
4301         centermountingsupportshape[i]->DefineSection(0,0.);
4302     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4303                                                                                                   -fgkMountingBlockSupportWidth[0]);
4304
4305     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4306                                                                           centermountingsupportshape[i],
4307                                                                                   fSSDAlCoolBlockMedium);
4308         centermountingblocksupport[i]->SetLineColor(9);
4309         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4310     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4311                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4312         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4313                                                                                                          -fgkMountingBlockSupportWidth[0]);
4314     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4315     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4316                                                                           sideladdersupportpieceshape[i],
4317                                                                                   fSSDCarbonFiberMedium);
4318         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4319         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4320     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4321                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4322         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4323     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4324                                                                                                   -fgkMountingBlockSupportWidth[0]);
4325     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4326                                                                           centerladdersupportpieceshape[i],
4327                                                                                   fSSDCarbonFiberMedium);
4328         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4329   }
4330   /////////////////////////////////////////////////////////////
4331   // Building the Up Structure of Ladder Supports 
4332   /////////////////////////////////////////////////////////////
4333   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4334   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4335   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4336   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4337   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4338   //////////////////////////////////////////////////////////
4339   // Setting the volume for TGeoXtru Mounting Block Piece  
4340   //////////////////////////////////////////////////////////
4341   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4342   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4343   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4344   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4345   TGeoVolume* mountingblockpieceup[fgklayernumber];
4346   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4347   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4348   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4349   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4350   char mountingblockpiecedownname[100];
4351   char mountingblockpieceupname[100];
4352   for(Int_t i=0; i<fgklayernumber; i++){
4353     ///////////////////////////
4354     // Mounting Block Down Vertex
4355     ///////////////////////////
4356         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4357         snprintf(mountingblockpiecedownname,100,"MountingBlockPieceDownLay%d",i+5);
4358         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4359         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4360                                               + fgkMountingBlockSupportDownHeight 
4361                                               - fgkSSDLadderVerticalDisalignment;
4362         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4363         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4364                                                                                 + fgkSSDMountingBlockHeight[1]
4365                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4366                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4367         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4368         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4369         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4370         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4371         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4372         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4373         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4374         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4375                                                                                 + fgkSSDMountingBlockHeight[2]
4376                                                                                 - fgkSSDMountingBlockHeight[0];
4377         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4378         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4379         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4380         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4381         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4382                                                                                                          mountingblockpiecedownyvertex[i]);
4383         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4384         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4385         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4386                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4387         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4388
4389     ///////////////////////////
4390     // Mounting Block Up Vertex
4391     ///////////////////////////
4392         mountingblockpieceupshape[i] = new TGeoXtru(2);
4393         snprintf(mountingblockpieceupname,100,"MountingBlockPieceUpLay%d",i+5);
4394         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4395         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4396                                                                                 + fgkMountingBlockSupportUpHeight[i]
4397                                               - fgkSSDLadderVerticalDisalignment;
4398         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4399         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4400                                                                                 + fgkSSDMountingBlockHeight[1]
4401                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4402                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4403         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4404         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4405         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4406         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4407         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4408         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4409         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4410         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4411                                                                                 + fgkSSDMountingBlockHeight[2]
4412                                                                                 - fgkSSDMountingBlockHeight[0];
4413         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4414         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4415         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4416         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4417
4418         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4419                                                                                                          mountingblockpieceupyvertex[i]);
4420         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4421         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4422         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4423                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4424         mountingblockpieceup[i]->SetLineColor(fColorG10);
4425  }
4426   ///////////////////////////////////////////////////////////////////
4427   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4428   ///////////////////////////////////////////////////////////////////
4429   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4430   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4431   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4432   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4433   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4434   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4435   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4436   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4437   char mountingblocksupportrapezoidowname[100];
4438   char mountingblocksupportrapezoidupname[100];
4439   Double_t scalefactor = 3./4.;
4440   for(Int_t i=0; i<fgklayernumber; i++){
4441   ////////////////////////////////////////////
4442   // Mounting Block Support Down Trapezoid Vertex 
4443   ////////////////////////////////////////////
4444         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4445         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4446                                                                                                  - mountingsupportedge[i];
4447         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4448         mountingblocksupportrapezoidownxvertex[i][1] = 
4449                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4450         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4451                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4452                                                                                              - mountingblockpiecedownyvertex[i][0]);
4453         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4454         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4455         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4456         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4457         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4458         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4459
4460         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4461                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4462         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4463                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4464         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4465         snprintf(mountingblocksupportrapezoidowname,100,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4466         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4467                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4468         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4469   ////////////////////////////////////////////
4470   // Mounting Block Support Up Trapezoid Vertex 
4471   ////////////////////////////////////////////
4472         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4473         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4474                                                                                                  - mountingsupportedge[i];
4475         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4476         mountingblocksupportrapezoidupxvertex[i][1] = 
4477                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4478         mountingblocksupportrapezoidupyvertex[i][1] = 
4479                                                                                                mountingblockpieceupyvertex[i][0]
4480                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4481                                                                                              - mountingblockpieceupyvertex[i][0]);
4482         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4483         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4484         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4485         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4486         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4487         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4488
4489         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4490                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4491         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4492                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4493         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4494         snprintf(mountingblocksupportrapezoidupname,100,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4495         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4496                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4497         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4498   }
4499   ///////////////////////////////////////////////////////////////////
4500   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4501   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4502   Double_t boxoriginup[fgklayernumber][2][3];
4503   Double_t boxorigindown[fgklayernumber][2][3];
4504   char mountingblocksupportboxdownname[100];
4505   char mountingblocksupportboxupname[100];
4506   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4507   mountingblocksupportrot->SetAngles(90.,180.,-90);
4508   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4509   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4510   TGeoHMatrix* laddersupportmatrix[2];
4511   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4512   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4513   /////////////////////////////////////////////////////////////
4514   // Creating Mother Volume for Containment
4515   /////////////////////////////////////////////////////////////
4516   Double_t *xmothervertex[fgklayernumber];
4517   Double_t *ymothervertex[fgklayernumber];
4518   for(Int_t i=0; i<fgklayernumber; i++){
4519         xmothervertex[i] = new Double_t[8];
4520         ymothervertex[i] = new Double_t[8];
4521   }  
4522   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4523   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4524   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4525   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4526   char upmotheladdersupportname[100];
4527   char downmotheladdersupportname[100];
4528   for(Int_t i=0; i<fgklayernumber; i++){
4529         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4530                                                     -  mountingsupportedge[i];
4531         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4532         xmothervertex[i][1] = xmothervertex[i][0];
4533         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4534                                                         + fgkMountingBlockSupportWidth[0];
4535         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4536         ymothervertex[i][2] = ymothervertex[i][1];
4537         xmothervertex[i][3] = xmothervertex[i][2];
4538         ymothervertex[i][3] = -ymothervertex[i][0];
4539         xmothervertex[i][4] = -xmothervertex[i][0];
4540         ymothervertex[i][4] = ymothervertex[i][3];
4541         xmothervertex[i][5] = xmothervertex[i][4];
4542         ymothervertex[i][5] = -ymothervertex[i][1];
4543         xmothervertex[i][6] = -xmothervertex[i][2];
4544         ymothervertex[i][6] = ymothervertex[i][5];
4545         xmothervertex[i][7] = xmothervertex[i][6];
4546         ymothervertex[i][7] = ymothervertex[i][0];
4547
4548         snprintf(downmotheladdersupportname,100,"LadderSupportDownLay%d",i+5);
4549         snprintf(upmotheladdersupportname,100,"LadderSupportUpLay%d",i+5);
4550
4551         downmotherladdersupportshape[i] = new TGeoXtru(2);
4552         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4553         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4554         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4555                                                                    +                       fgkMountingBlockSupportDownHeight
4556                                                                    +                       fgkSSDMountingBlockHeight[1]
4557                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4558                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4559                                                        - fgkSSDLadderVerticalDisalignment);
4560         
4561 //                                                 - fgkSSDModuleVerticalDisalignment);
4562         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4563
4564         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4565                                                                           downmotherladdersupportshape[i],fSSDAir);
4566     upmotherladdersupportshape[i] = new TGeoXtru(2);
4567         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4568         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4569     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4570                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4571                                                                    +                       fgkSSDMountingBlockHeight[1]
4572                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4573                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4574                                                  - fgkSSDLadderVerticalDisalignment);
4575
4576      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4577                                                                                           upmotherladdersupportshape[i],fSSDAir);
4578   }
4579   for(Int_t i=0; i<fgklayernumber; i++){
4580         /////////////////////////
4581         // Setting the box origin
4582         /////////////////////////
4583         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4584         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4585                                                    +  0.5*fgkMountingBlockSupportDownHeight
4586                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4587         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4588                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4589   
4590         boxorigindown[i][1][0] = 0.0;
4591         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4592         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4593                                                    -      fgkMountingBlockSupportWidth[0]);
4594                                                    
4595         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4596         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4597                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4598                                - 0.5*fgkSSDLadderVerticalDisalignment;
4599         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4600                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4601   
4602         boxoriginup[i][1][0] = 0.0;
4603         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4604         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4605                                                  - fgkMountingBlockSupportWidth[0]);
4606   
4607         /////////////////////////
4608     // Setting the boxes    
4609         /////////////////////////
4610         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4611                                                                                  +  fgkSSDMountingBlockLength[0]),
4612                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4613                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4614                                                                                         boxorigindown[i][0]);
4615         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4616                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4617                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4618                                                                                  -  fgkMountingBlockSupportWidth[0]),
4619                                                                                         boxorigindown[i][1]);
4620                                                                                         
4621         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4622                                                                                  +  fgkSSDMountingBlockLength[0]),
4623                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4624                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4625                                                                                         boxoriginup[i][0]);
4626
4627         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4628                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4629                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4630                                                                      -  fgkMountingBlockSupportWidth[0]),
4631                                                                                         boxoriginup[i][1]);
4632         ///////////////////////////////////////
4633         // Adding the Volumes to Mother Volume    
4634         ///////////////////////////////////////
4635         for(Int_t j=0; j<2; j++){
4636           snprintf(mountingblocksupportboxdownname,100,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4637           snprintf(mountingblocksupportboxupname,100,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4638           mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4639                                                              mountingblocksupportboxdownshape[i][j],
4640                                                              fSSDCarbonFiberMedium);
4641           mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4642                                                            mountingblocksupportboxupshape[i][j],
4643                                                            fSSDCarbonFiberMedium);
4644                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4645                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4646                 for(Int_t k=0; k<2; k++){
4647                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4648                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4649                 }
4650         }
4651         for(Int_t k=0; k<2; k++){
4652                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4653                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4654                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4655                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4656                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4657                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4658                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4659                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4660                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4661                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4662                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4663                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4664         }
4665   }
4666   TList* laddersupportlist = new TList();
4667   laddersupportlist->Add(downmotherladdersupport[0]); 
4668   laddersupportlist->Add(upmotherladdersupport[0]); 
4669   laddersupportlist->Add(downmotherladdersupport[1]); 
4670   laddersupportlist->Add(upmotherladdersupport[1]); 
4671   /////////////////////////////////////////////////////////////
4672   // Deallocating memory
4673   /////////////////////////////////////////////////////////////
4674   for(Int_t i=0; i<fgklayernumber; i++){
4675         for(Int_t j=0; j<nedges+1; j++)
4676                 delete vertex[i][j];
4677         delete mountingsupportedgevector[i];
4678         delete [] vertex[i];
4679         delete vertexlist[i];
4680         delete [] xsidevertex[i];
4681         delete [] ysidevertex[i];
4682         delete [] xcentervertex[i];
4683         delete [] ycentervertex[i];
4684         delete [] xsidelowervertex[i];
4685         delete [] ysidelowervertex[i];
4686         delete [] xcenterlowervertex[i];
4687         delete [] ycenterlowervertex[i];
4688         delete [] xmothervertex[i];
4689         delete [] ymothervertex[i];
4690   }
4691   delete [] xsidevertex;
4692   delete [] ysidevertex;
4693   delete [] xcentervertex;
4694   delete [] ycentervertex;
4695   delete [] xsidelowervertex;
4696   delete [] ysidelowervertex;
4697   delete [] xcenterlowervertex;
4698   delete [] ycenterlowervertex;
4699   delete globalrefladdersupportrot;
4700   delete mountingblocksupportrot;
4701   /////////////////////
4702   return laddersupportlist;     
4703 }
4704  ////////////////////////////////////////////////////////////////////////////////
4705 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4706 //////////////////////////////////////////
4707 // Method Generating Ladder Support Ring
4708 //////////////////////////////////////////
4709   if(!fCreateMaterials) CreateMaterials();
4710   if(!fTransformationMatrices) CreateTransformationMatrices();
4711   if(!fBasicObjects) CreateBasicObjects();
4712   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4713   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4714     const Int_t kssdlayladdernumber[fgklayernumber] = 
4715                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4716   Double_t mountingsupportedge[fgklayernumber];
4717   Double_t mountingblockratio[fgklayernumber];
4718   Double_t theta[fgklayernumber];
4719   Double_t phi[fgklayernumber];
4720   for(Int_t i=0; i<fgklayernumber; i++){
4721         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4722     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4723                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4724                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4725                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4726                                                           / kssdlayladdernumber[i])));
4727     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4728                          / fgkMountingBlockSupportRadius[i]);
4729     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4730   }
4731   TGeoRotation* globalrot = new TGeoRotation();
4732   globalrot->SetAngles(0.,-90.,0.); 
4733   TGeoRotation** laddersupportrot[fgklayernumber];
4734   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
4735   for(Int_t i=0; i<fgklayernumber; i++){                
4736         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
4737         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
4738         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4739                 laddersupportrot[i][j] = new TGeoRotation();
4740                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
4741                 switch(i){
4742                         case 0: //Ladder of Layer5  
4743                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4744                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
4745                                                                             laddersupportmatrix[i][j]); 
4746                         break;
4747                         case 1: //Ladder of Layer6 
4748                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4749                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
4750                                                                               laddersupportmatrix[i][j]); 
4751                         break;
4752                 }
4753     }
4754   }
4755   /////////////////////////////////////////////////////////////
4756   // Creating Lower Ladder Support 
4757   /////////////////////////////////////////////////////////////
4758   TVector3** ringsupportvertex[fgklayernumber];         
4759   Double_t angle = 360./nedges;
4760   for(Int_t i=0; i<fgklayernumber; i++){
4761     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
4762         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
4763                                                         *                          TMath::Cos(theta[i]));
4764         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
4765                                                         -                          mountingsupportedge[i],
4766                                                                                    ringsupportvertex[i][0]->Y());
4767         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
4768                                                                                    ringsupportvertex[i][1]->Y());                                                                               
4769     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
4770         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
4771            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
4772            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
4773            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
4774            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
4775         }
4776         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
4777     for(Int_t j=0; j<nedges+1; j++){
4778                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
4779                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*CosD(90.0-j*angle),
4780                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*SinD(90.0-j*angle));
4781         }
4782   }
4783   Double_t **xmothervertex = new Double_t*[fgklayernumber];
4784   Double_t **ymothervertex = new Double_t*[fgklayernumber];
4785   for(Int_t i=0; i<fgklayernumber; i++){
4786         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4787         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4788         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
4789                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
4790                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
4791         }
4792   }
4793 ////////////////////////////////////////////////////////////////////////////////
4794 // Start Corrections 13/06/08
4795 ////////////////////////////////////////////////////////////////////////////////
4796   char lowerladderpconsupportname[100];
4797   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
4798   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
4799   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
4800   Double_t lowerladderpconradiusmax[fgklayernumber];
4801   Double_t lowerladderpconradiusmin[fgklayernumber];
4802   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4803   lowerladdersupportrot->SetAngles(90.,180.,-90);
4804   for(Int_t i=0; i<fgklayernumber; i++){
4805         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
4806                                                                 *                          TMath::Cos(theta[i]);
4807     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeight;
4808   } 
4809   for(Int_t i=0; i<fgklayernumber; i++){
4810 ///////////////////////////  Modified Version ?///////////////////
4811     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
4812         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
4813                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
4814                                                          lowerladderpconradiusmax[i]);
4815         snprintf(lowerladderpconsupportname,100,"LowerLadderPConSupportNameLay%d",i+5);
4816         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
4817     lowerladderpconsupport[i]->SetLineColor(fColorAl);
4818         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
4819         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
4820  }
4821 ////////////////////////////////////////////////////////////////////////////////
4822 // End Corrections 13/06/08
4823 ////////////////////////////////////////////////////////////////////////////////
4824   /*char lowerladdersupportname[30];
4825   TGeoXtru* lowerladdersupportshape[fgklayernumber];
4826   TGeoVolume* lowerladdersupport[fgklayernumber];
4827   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4828   lowerladdersupportrot->SetAngles(90.,180.,-90);
4829   for(Int_t i=0; i<fgklayernumber; i++){
4830         lowerladdersupportshape[i] = new TGeoXtru(2);
4831         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
4832                                                                                           xmothervertex[i],ymothervertex[i]);
4833         lowerladdersupportshape[i]->DefineSection(0,0.);
4834     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4835         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
4836     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
4837                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
4838         lowerladdersupport[i]->SetLineColor(fColorAl);
4839         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
4840         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
4841   }*/
4842   /////////////////////////////////////////////////////////////
4843   // Deallocating memory
4844   /////////////////////////////////////////////////////////////
4845   for(Int_t i=0; i<fgklayernumber; i++){
4846         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
4847                 delete ringsupportvertex[i][j];
4848         delete [] ringsupportvertex[i];
4849   }
4850   for(Int_t i=0; i<fgklayernumber; i++){
4851         delete [] xmothervertex[i];
4852         delete [] ymothervertex[i];
4853   }
4854   delete [] xmothervertex;
4855   delete [] ymothervertex; 
4856   delete globalrot;
4857   for(Int_t i=0; i<fgklayernumber; i++){
4858         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
4859                 delete laddersupportrot[i][j];
4860         delete [] laddersupportrot[i];
4861   }
4862  }  
4863  ////////////////////////////////////////////////////////////////////////////////
4864  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
4865   /////////////////////////////////////////////////////////////
4866   // Method generating Endcap CoverPlate
4867   /////////////////////////////////////////////////////////////
4868   // Holes Definition 
4869   ///////////////////
4870   Int_t nendcapcoverplateholedges = 30;
4871   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
4872   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
4873                                                           0.5*fgkEndCapCoverPlateThickness};
4874   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
4875                                                                                                               nendcapcoverplateholedges,holesection);
4876   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
4877                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
4878   endcapcoverplatesmallhole->SetLineColor(6);
4879   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
4880                                                                                                               nendcapcoverplateholedges,holesection);
4881   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
4882                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
4883   endcapcoverplatebighole->SetLineColor(6);
4884   //////////////////////////
4885   // Screw Piece Definition 
4886   //////////////////////////
4887   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
4888   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
4889                                                                                                       CosD(0.5*smallscrewangle),
4890                                                                                                       0.5*fgkEndCapCoverPlateThickness);
4891   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
4892                                                                                                 endcapsmallscrewpieceshape,
4893                                                                                                 fSSDCoolingTubePhynox);
4894   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
4895   ///////////////////
4896   // Box Definition 
4897   ///////////////////
4898   TGeoBBox* endcapcoverplateboxshape[4];
4899   TGeoVolume* endcapcoverplatebox[4];
4900   Double_t boxorigin[5][3];
4901   boxorigin[0][0] = 0.;
4902   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
4903   boxorigin[0][2] = 0.;
4904
4905   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
4906   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
4907   boxorigin[1][2] = 0.;
4908
4909   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
4910                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
4911   boxorigin[2][1] = boxorigin[1][1];
4912   boxorigin[2][2] = 0.;
4913
4914   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
4915                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
4916   boxorigin[3][1] = boxorigin[1][1];
4917   boxorigin[3][2] = 0.;
4918
4919   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4920                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
4921                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
4922                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
4923
4924   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
4925                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4926                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4927                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4928                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
4929
4930   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
4931                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4932                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4933                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4934                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
4935
4936   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
4937                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4938                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4939                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4940                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
4941   
4942   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
4943                                                                            fSSDAlCoolBlockMedium);
4944   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
4945                                                                            fSSDAlCoolBlockMedium);
4946   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
4947                                                                            fSSDAlCoolBlockMedium);
4948   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
4949                                                                            fSSDAlCoolBlockMedium);
4950   endcapcoverplatebox[0]->SetLineColor(6);
4951   endcapcoverplatebox[1]->SetLineColor(6);
4952   endcapcoverplatebox[2]->SetLineColor(6);
4953   endcapcoverplatebox[3]->SetLineColor(6);
4954   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
4955   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4956                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
4957                                                                                         0.5*fgkEndCapCoverPlateThickness,
4958                                                                                         endcapfillingboxorigin);
4959   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
4960                                                                            fSSDAlCoolBlockMedium);
4961   endcapfillingbox->SetLineColor(6);
4962   ////////////////////////////
4963   // Contour shape Definition 
4964   ////////////////////////////
4965   const Int_t kcontourvertexnumber = 10;
4966   Double_t xcontourvertex[kcontourvertexnumber];
4967   Double_t ycontourvertex[kcontourvertexnumber];
4968   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
4969   xcontourvertex[1] = xcontourvertex[0];
4970   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
4971   xcontourvertex[3] = xcontourvertex[2];
4972   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
4973   xcontourvertex[5] = xcontourvertex[4];
4974   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
4975   xcontourvertex[7] = xcontourvertex[6];
4976   xcontourvertex[8] = xcontourvertex[4];
4977   xcontourvertex[9] = xcontourvertex[8];
4978   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
4979                                         - (kendcapcoverplatesmallholenumber[1]-1)
4980                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
4981   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
4982                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
4983   ycontourvertex[2] = ycontourvertex[1];
4984   ycontourvertex[3] = ycontourvertex[0];
4985   ycontourvertex[4] = ycontourvertex[3];
4986   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
4987   ycontourvertex[6] = ycontourvertex[5];
4988   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
4989                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
4990                                         + fgkEndCapCoverPlateSmallHoleRadius;
4991   ycontourvertex[8] = ycontourvertex[7];
4992   ycontourvertex[9] = ycontourvertex[0];
4993
4994   Double_t xboxin, dxboxin, yboxin, dyboxin;
4995   Double_t xboxout, dxboxout, yboxout, dyboxout;
4996   Double_t coordmin, coordmax;
4997   coordmin = -fgkEndCapCoverPlateLength[0];
4998   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
4999   xboxout = 0.5*(coordmin+coordmax);
5000   dxboxout = 0.5*(coordmax-coordmin);
5001   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5002                                         - (kendcapcoverplatesmallholenumber[1]-1)
5003                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5004   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5005                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5006   yboxout = 0.5*(coordmin+coordmax);
5007   dyboxout = 0.5*(coordmax-coordmin);
5008   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5009   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5010   xboxin = 0.5*(coordmin+coordmax);
5011   dxboxin = 0.5*(coordmax-coordmin);
5012   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5013   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5014                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5015                                         + fgkEndCapCoverPlateSmallHoleRadius;
5016   yboxin = 0.5*(coordmin+coordmax);
5017   dyboxin = 0.5*(coordmax-coordmin);
5018   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5019   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5020                                                          xboxout, yboxout, 0.);
5021   trendCapCoverPlateContourboxout->RegisterYourself();
5022   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5023   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5024                                                          xboxin, yboxin, 0.);
5025   trendCapCoverPlateContourboxin->RegisterYourself();
5026   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5027         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5028
5029   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5030                                                                            fSSDAlCoolBlockMedium);
5031   contour->SetLineColor(6);
5032   /////////////////////////////
5033   // Hole Contour Shape Definition 
5034   ////////////////////////////
5035   coordmin = xcontourvertex[0];
5036   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5037   xboxout = 0.5*(coordmin+coordmax);
5038   dxboxout = 0.5*(coordmax-coordmin);
5039   coordmin = ycontourvertex[1];
5040   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5041   yboxout = 0.5*(coordmin+coordmax);
5042   dyboxout = 0.5*(coordmax-coordmin);
5043   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5044                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5045   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5046   xboxin = 0.5*(coordmin+coordmax);
5047   dxboxin = 0.5*(coordmax-coordmin);
5048   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5049                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5050   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5051   yboxin = 0.5*(coordmin+coordmax);
5052   dyboxin = 0.5*(coordmax-coordmin);
5053   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5054   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5055                                                          xboxout, yboxout, 0.);
5056   trendCapCoverPlateContourboxout1->RegisterYourself();
5057   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5058   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5059                                                          xboxin, yboxin, 0.);
5060   trendCapCoverPlateContourboxin1->RegisterYourself();
5061   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5062         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5063
5064
5065   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5066   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5067   xboxout = 0.5*(coordmin+coordmax);
5068   dxboxout = 0.5*(coordmax-coordmin);
5069   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5070                                                    - fgkEndCapCoverPlateWidth[0]);
5071   coordmax = ycontourvertex[0];
5072   yboxout = 0.5*(coordmin+coordmax);
5073   dyboxout = 0.5*(coordmax-coordmin);
5074   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5075                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5076   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5077   xboxin = 0.5*(coordmin+coordmax);
5078   dxboxin = 0.5*(coordmax-coordmin);
5079   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5080                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5081                                                    - fgkEndCapCoverPlateWidth[0]
5082                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5083   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5084   yboxin = 0.5*(coordmin+coordmax);
5085   dyboxin = 0.5*(coordmax-coordmin);
5086   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5087   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5088                                                          xboxout, yboxout, 0.);
5089   trendCapCoverPlateContourboxout2->RegisterYourself();
5090   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5091   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5092                                                          xboxin, yboxin, 0.);
5093   trendCapCoverPlateContourboxin2->RegisterYourself();
5094   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5095         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5096   
5097 //  const Int_t kholecontourvertexnumber = 10;
5098
5099   Double_t xholecontourvertex[2][kcontourvertexnumber];
5100   Double_t yholecontourvertex[2][kcontourvertexnumber];
5101   xholecontourvertex[0][0] = xcontourvertex[0];
5102   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5103   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5104   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5105   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5106                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5107                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5108   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5109   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5110                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5111   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5112   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5113   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5114   
5115   yholecontourvertex[0][0] = ycontourvertex[1];
5116   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5117   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5118   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5119   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5120   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5121                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5122   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5123   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5124   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5125   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5126
5127   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5128   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5129   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5130   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5131   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5132                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5133                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5134   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5135   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5136                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5137   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5138   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5139   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5140   
5141   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5142                                                    - fgkEndCapCoverPlateWidth[0]);
5143   yholecontourvertex[1][1] = ycontourvertex[0];
5144   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5145   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5146   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5147   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5148                                                    - fgkEndCapCoverPlateWidth[0]
5149                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5150   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5151   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5152   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5153   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5154
5155   TGeoVolume* holecontour[2];
5156   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5157                                                                   fSSDAlCoolBlockMedium);
5158   holecontour[0]->SetLineColor(6);
5159   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5160                                                                   fSSDAlCoolBlockMedium);
5161   holecontour[1]->SetLineColor(6);
5162   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5163                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5164   TGeoTranslation*  bigholetrans[3];
5165   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5166                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5167   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5168                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5169                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5170   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5171                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5172   /////////////////////////////////
5173   // Mother Volume Xtru Definition 
5174   /////////////////////////////////
5175   const Int_t kmothervertexnumber = 12;
5176   Double_t xmothervertex[kmothervertexnumber];  
5177   Double_t ymothervertex[kmothervertexnumber];  
5178   xmothervertex[0]  = xcontourvertex[0];
5179   xmothervertex[1]  = xmothervertex[0];
5180   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5181   xmothervertex[3]  = xmothervertex[2];
5182   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5183   xmothervertex[5]  = xmothervertex[4];
5184   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5185   xmothervertex[7]  = xmothervertex[6];
5186   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5187                                         + fgkEndCapCoverPlateLength[2]; 
5188   xmothervertex[9]  = xmothervertex[8];
5189   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5190   xmothervertex[11] = xmothervertex[10];
5191   
5192   ymothervertex[0]  = ycontourvertex[0];
5193   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5194   ymothervertex[2]  = ymothervertex[1];
5195   ymothervertex[3]  = ycontourvertex[1];
5196   ymothervertex[4]  = ymothervertex[3];
5197   ymothervertex[5]  = ymothervertex[1];
5198   ymothervertex[6]  = ymothervertex[5];
5199   ymothervertex[7]  = ymothervertex[0];
5200   ymothervertex[8]  = ymothervertex[7];
5201   ymothervertex[9]  = ymothervertex[8]
5202                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5203   ymothervertex[10] = ymothervertex[9];
5204   ymothervertex[11] = ymothervertex[8];
5205   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5206   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5207   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5208   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5209   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5210   ////////////////////////////////////////
5211   // Adding Nodes
5212   ////////////////////////////////////////
5213 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5214   TGeoTranslation*** endcapcoverplatesmallholetrans;
5215   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5216   Double_t transx[4] = {0,
5217                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5218                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5219                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5220                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5221                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5222   Int_t index = 0;
5223   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5224         endcapcoverplatesmallholetrans[i] = 
5225                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5226     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5227                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5228             endcapcoverplatesmallholetrans[i][j] = 
5229                 new TGeoTranslation(transx[i],
5230                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5231             if(index!=10){ 
5232                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5233                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5234                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5235                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5236                 }
5237                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5238                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5239                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5240     }
5241   }
5242   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5243   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5244   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5245   mothercoverplate->AddNode(endcapfillingbox,1);
5246   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5247   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5248   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5249   mothercoverplate->AddNode(holecontour[0],1);
5250   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5251   mothercoverplate->AddNode(holecontour[1],1);  
5252   mothercoverplate->AddNode(contour,1);
5253   
5254   for (Int_t i = 0; i < kendcapcoverplatesmallholenumber[0]; i++) 
5255     delete [] endcapcoverplatesmallholetrans[i];
5256   delete [] endcapcoverplatesmallholetrans;
5257   /////////////////////////////////
5258   return mothercoverplate;      
5259  }
5260  ////////////////////////////////////////////////////////////////////////////////
5261  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5262   /////////////////////////////////////////////////////////////
5263   // Getting EndCap Cooling Tube 
5264   /////////////////////////////////////////////////////////////
5265   TGeoTorus* endcapcoolingtubetorushape[5];
5266   TGeoVolume* endcapcoolingtubetorus[5];
5267   TGeoTube* endcapcoolingtubeshape[4];
5268   TGeoVolume* endcapcoolingtube[4];
5269   char endcapcoolingtubetorusname[100];
5270   char endcapcoolingtubename[100];
5271   TGeoTorus* endcapcoolingwatertubetorushape[5];
5272   TGeoVolume* endcapcoolingwatertubetorus[5];
5273   TGeoTube* endcapcoolingwatertubeshape[4];
5274   TGeoVolume* endcapcoolingwatertube[4];
5275   char endcapcoolingwatertubetorusname[100];
5276   char endcapcoolingwatertubename[100];
5277   for(Int_t i=0; i<5; i++){
5278     snprintf(endcapcoolingtubetorusname,100,"EndCapCoolingTubeTorus%d",i+1);
5279     snprintf(endcapcoolingtubename,100,"EndCapCoolingTube%d",i+1);
5280     snprintf(endcapcoolingwatertubetorusname,100,"EndCapCoolingWaterTubeTorus%d",i+1);
5281     snprintf(endcapcoolingwatertubename,100,"EndCapCoolingWaterTube%d",i+1);
5282     if(i==3){
5283       endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5284                                                     fgkEndCapCoolingTubeRadiusMin,
5285                                                     fgkEndCapCoolingTubeRadiusMax,
5286                                                     90.0,fgkEndCapCoolingTubeAngle[3]);
5287       endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5288                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5289                                                          90.0,fgkEndCapCoolingTubeAngle[3]);
5290     }
5291     else{
5292       endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5293                                                     :fgkEndCapCoolingTubeAxialRadius[1],
5294                                                     fgkEndCapCoolingTubeRadiusMin,
5295                                                     fgkEndCapCoolingTubeRadiusMax,
5296                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5297       endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5298                                                          :fgkEndCapCoolingTubeAxialRadius[1],
5299                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5300                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5301     }
5302         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5303                                                                                            endcapcoolingtubetorushape[i],
5304                                                                                            fSSDCoolingTubePhynox);
5305         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5306                                                                                                         endcapcoolingwatertubetorushape[i],
5307                                                                                                         fSSDCoolingTubeWater);
5308     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5309     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5310     if(i<4){
5311                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5312                                                                   fgkEndCapCoolingTubeRadiusMax,
5313                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5314                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5315                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5316         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5317                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5318         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5319                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5320                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5321                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5322         }
5323   }
5324   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5325   /////////////////////////////////////////
5326   // Transformation for Volume Positioning 
5327   /////////////////////////////////////////
5328   TGeoCombiTrans* coolingtubecombitrans[6];
5329   TGeoRotation* coolingtuberot[8];
5330   TGeoTranslation* coolingtubetrans[6];
5331   TGeoHMatrix* coolingtubematrix[4];
5332   TGeoCombiTrans* torustubecombitrans[4];
5333   TGeoRotation* torustuberot[7];
5334   TGeoTranslation* torustubetrans[4];
5335   TGeoHMatrix* torustubematrix[5];
5336   TGeoCombiTrans* coolingwatertubecombitrans[6];
5337   TGeoRotation* coolingwatertuberot[8];
5338   TGeoTranslation* coolingwatertubetrans[6];
5339   TGeoHMatrix* coolingwatertubematrix[4];
5340   TGeoCombiTrans* toruswatertubecombitrans[4];
5341   TGeoRotation* toruswatertuberot[7];
5342   TGeoTranslation* toruswatertubetrans[4];
5343   TGeoHMatrix* toruswatertubematrix[5];
5344   for(Int_t i=0; i<8; i++){
5345     if(i<6){
5346          coolingtubetrans[i] = new TGeoTranslation();
5347          coolingwatertubetrans[i] = new TGeoTranslation();
5348     }
5349     if(i<8){
5350          coolingtuberot[i] = new TGeoRotation();
5351          coolingwatertuberot[i] = new TGeoRotation();
5352     }
5353     if(i<4){
5354          torustubetrans[i] = new TGeoTranslation();
5355          toruswatertubetrans[i] = new TGeoTranslation();
5356     }
5357     if(i<7){
5358          torustuberot[i] = new TGeoRotation();
5359          toruswatertuberot[i] = new TGeoRotation();
5360         }
5361   }
5362   /////////////////////////////////////////
5363   // Transformation for Inox Volume Positioning 
5364   /////////////////////////////////////////
5365   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5366                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5367   coolingtuberot[0]->SetAngles(0.,90.,0.);
5368   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5369                                                                                                 *coolingtuberot[0]);
5370                                                                                                 
5371   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5372   coolingtuberot[1]->SetAngles(0.,90.,0.);
5373   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5374                                                                                                 *coolingtuberot[1]);
5375
5376   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5377                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5378                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5379                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5380                                                                           0.);
5381   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5382   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5383                                                                                                 *coolingtuberot[2]);
5384
5385   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5386                                            *                             (*coolingtubecombitrans[1]));
5387
5388   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5389                                                                          endcapcoolingtubeshape[1]->GetDz());
5390   torustuberot[0]->SetAngles(0.,90.,0.); 
5391   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5392
5393   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5394
5395   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5396                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5397   coolingtuberot[3]->SetAngles(0.,90.,0.);
5398   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5399                                                                                                 *coolingtuberot[3]);
5400   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5401   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5402   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5403   
5404   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5405                                                                         endcapcoolingtubeshape[2]->GetDz());
5406   torustuberot[1]->SetAngles(0.,90.,0.); 
5407   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5408   torustuberot[2]->SetAngles(180.,0.,0.); 
5409   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5410   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5411
5412   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5413                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5414   torustuberot[3]->SetAngles(0.,90.,0.); 
5415   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5416   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5417   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5418   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5419
5420   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5421                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5422   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5423   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5424                                                                                                 *coolingtuberot[5]);
5425   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5426   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5427   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5428   
5429   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5430                                                                         endcapcoolingtubeshape[0]->GetDz());
5431   torustuberot[5]->SetAngles(0.,90.,0.); 
5432   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5433   torustuberot[6]->SetAngles(-90.,0.,0.); 
5434   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5435   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5436   
5437   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5438                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5439   coolingtuberot[6]->SetAngles(0.,90.,0.);
5440   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5441                                                                                                 *coolingtuberot[6]);
5442   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5443   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5444   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5445     /////////////////////////////////////////
5446   // Transformation for Water Volume Positioning 
5447   /////////////////////////////////////////
5448   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5449                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5450   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5451   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5452                                                                                                      *coolingwatertuberot[0]);
5453
5454   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5455   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5456   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5457                                                                                                      *coolingwatertuberot[1]);
5458
5459   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5460                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5461                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5462                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5463                                                                               0.);
5464   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5465   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5466                                                                                                     *coolingwatertuberot[2]);
5467
5468   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5469                                            *                                 (*coolingwatertubecombitrans[1]));
5470                                            
5471   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5472                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5473   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5474   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5475                                                                                                    *toruswatertuberot[0]);
5476
5477   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5478                                                   *                                     (*toruswatertubecombitrans[0]));
5479
5480   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5481                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5482   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5483   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5484                                                                                                      *coolingwatertuberot[3]);
5485   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5486   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5487                                                         *                                 (*coolingwatertubecombitrans[3]));
5488   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5489
5490   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5491                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5492   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5493   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5494                                                                                                    *toruswatertuberot[1]);
5495   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5496   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5497                                                   *                 (*toruswatertubecombitrans[1]));
5498   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5499   
5500   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5501                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5502   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5503   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5504                                                                                                    *toruswatertuberot[3]);
5505   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5506   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5507                                                   *                                     (*toruswatertubecombitrans[2]));
5508   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5509
5510   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5511                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5512   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5513   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5514                                                                                                      *coolingwatertuberot[5]);
5515   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5516   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5517                                                         *                                 (*coolingwatertubecombitrans[4]));
5518   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5519   
5520   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5521                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5522   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5523   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5524                                                                                                    *toruswatertuberot[5]);
5525   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5526   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5527                                                   *                 (*toruswatertubecombitrans[3]));
5528   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5529   
5530   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5531                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5532   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5533   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5534                                                                                                      *coolingwatertuberot[6]);
5535   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5536   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5537                                                         *                                 (*coolingwatertubecombitrans[5]));
5538   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5539   /////////////////////////////////////////
5540   // Positioning Volumes
5541   /////////////////////////////////////////
5542   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5543   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5544   
5545   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5546   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5547
5548   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5549   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5550  
5551   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5552   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5553
5554   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5555   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5556
5557   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5558   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5559
5560   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5561   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5562
5563   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5564   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5565   
5566   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5567   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5568  
5569   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5570   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5571   /////////////////////////////////////////////////////////////
5572   // Deallocating memory
5573   /////////////////////////////////////////////////////////////
5574   for(Int_t i=0; i<8; i++){
5575     if(i<6){
5576          delete coolingtubetrans[i];
5577          delete coolingwatertubetrans[i];
5578          if(i!=0){
5579           delete coolingtubecombitrans[i];
5580           delete coolingwatertubecombitrans[i];
5581          }
5582         }
5583     if(i<8){
5584           delete coolingtuberot[i];
5585           delete coolingwatertuberot[i];
5586     }
5587     if(i<4){
5588                 delete torustubetrans[i];
5589                 delete toruswatertubetrans[i];
5590                 delete torustubecombitrans[i];
5591                 delete toruswatertubecombitrans[i];
5592         } 
5593     if(i<7){
5594          delete torustuberot[i];
5595          delete toruswatertuberot[i];
5596         }
5597   }
5598   /////////////////////////////////////////////////////////////
5599   return endcapcoolingtubemother;
5600  }
5601  ////////////////////////////////////////////////////////////////////////////////
5602  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5603   /////////////////////////////////////////////////////////////
5604   // Getting EndCap Cover Side 
5605   /////////////////////////////////////////////////////////////
5606   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5607   const Int_t kvertexnumber = 15; 
5608   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5609   xvertex[0]  = 0.0;
5610   xvertex[1]  = xvertex[0];
5611   xvertex[2]  = fgkEndCapSideCoverLength[0];
5612   xvertex[3]  = fgkEndCapSideCoverLength[1];
5613   xvertex[4]  = xvertex[3];
5614   xvertex[5]  = fgkEndCapSideCoverLength[2];
5615   xvertex[6]  = xvertex[5];
5616   xvertex[7]  = xvertex[2];
5617   xvertex[8]  = xvertex[7];
5618   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5619   xvertex[10] = xvertex[9];
5620   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5621                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5622                           * fgkEndCapSideCoverLength[4];
5623   xvertex[12] = xvertex[11];
5624   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5625                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5626                           * fgkEndCapSideCoverLength[4];
5627   xvertex[14] = xvertex[13];
5628   yvertex[0]  = 0.0;
5629   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5630   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5631   yvertex[3]  = yvertex[2];
5632   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5633   yvertex[5]  = yvertex[4];
5634   yvertex[6]  = yvertex[0];
5635   yvertex[7]  = yvertex[6];
5636   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5637   yvertex[9]  = yvertex[8];
5638   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5639   yvertex[11] = yvertex[10];
5640   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5641   yvertex[13] = yvertex[12];
5642   yvertex[14] = yvertex[6];
5643   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5644   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5645   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5646   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5647   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5648   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5649   endcapsidecovershapein->SetName("endcapsidecovershapein");
5650   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5651   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5652   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5653
5654
5655   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5656   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5657                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5658   endcapsidecover->SetLineColor(fColorPhynox);
5659   ////////////////////////////////////////////
5660   // Defininition of Mother Volume
5661   ////////////////////////////////////////////
5662   const Int_t kmothervertexnumber = 7;
5663   Double_t xmothervertex[kmothervertexnumber]; 
5664   Double_t ymothervertex[kmothervertexnumber]; 
5665   for(Int_t i=0; i<kmothervertexnumber; i++){
5666         xmothervertex[i] = xvertex[i];
5667         ymothervertex[i] = yvertex[i];
5668   }
5669   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5670   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5671   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5672   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5673   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5674                                                                 endcapsidecovermothershape,fSSDAir);
5675   ////////////////////////////////////////////
5676   endcapsidecovermother->AddNode(endcapsidecover,1);
5677   TGeoBBox* endcapsidecoverboxshape[4];
5678   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5679                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5680                                                                0.5*fgkEndCapSideCoverLength[4],
5681                                                                    0.5*fgkEndCapSideCoverThickness); 
5682   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5683                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5684                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5685                                                          -     fgkEndCapSideCoverLength[4]),
5686                                                                    0.5*fgkEndCapSideCoverThickness); 
5687   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5688                                                                0.5*fgkEndCapSideCoverLength[4],
5689                                                                    0.5*fgkEndCapSideCoverThickness); 
5690   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5691                                                                0.5*fgkEndCapSideCoverWidth[5],
5692                                                                    0.5*fgkEndCapSideCoverThickness); 
5693   TGeoVolume* endcapsidecoverbox[4];
5694   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5695   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5696   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5697   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5698   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5699 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5700   TGeoTranslation** endcapsidecoverboxtrans;
5701   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5702   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5703                                                          +                                         fgkEndCapSideCoverLength[0],
5704                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5705                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5706   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5707                                                          +                     xvertex[11],
5708                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5709                                                          +                     yvertex[12],0.);
5710   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5711                                                          +                     xvertex[11],
5712                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5713                                                          +                     yvertex[12]
5714                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5715                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5716   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5717   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5718   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5719   for(Int_t i=0; i<2; i++)
5720         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5721                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5722                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5723                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5724                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5725                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5726                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5727                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5728         }
5729   for(Int_t i=0; i<2; i++)
5730         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5731                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5732                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5733                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5734                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5735                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5736                                                         +fgkEndCapSideCoverLength[4]),0.0);
5737                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5738                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5739                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5740                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5741         }
5742   delete [] endcapsidecoverboxtrans;
5743   return endcapsidecovermother;
5744  } 
5745  ////////////////////////////////////////////////////////////////////////////////
5746  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5747  ////////////////////////////////////////////////////////////////////////////////
5748  // Method returning Interface Card A, Interface Card B, Supply Card 
5749  ////////////////////////////////////////////////////////////////////////////////
5750  /////////////////////
5751  // Supply Card
5752  /////////////////////
5753  // Electronic Board Back Al Plane
5754  const Int_t kelectboardbackvertexnumber = 8;
5755  Double_t xelectboardback[kelectboardbackvertexnumber];
5756  Double_t yelectboardback[kelectboardbackvertexnumber];
5757  xelectboardback[0] = 0.0;
5758  xelectboardback[1] = xelectboardback[0];
5759  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5760  xelectboardback[3] = xelectboardback[2];
5761  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5762  xelectboardback[5] = xelectboardback[4];
5763  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5764  xelectboardback[7] = xelectboardback[6];
5765  
5766  yelectboardback[0] = 0.0;
5767  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5768  yelectboardback[2] = yelectboardback[1];
5769  yelectboardback[3] = yelectboardback[0];
5770  yelectboardback[4] = yelectboardback[3];
5771  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5772  yelectboardback[6] = yelectboardback[5];
5773  yelectboardback[7] = yelectboardback[4];
5774  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5775  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5776                                                                         xelectboardback,yelectboardback); 
5777  electboardbackshape->DefineSection(0,0.0);
5778  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5779  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5780                                                                                          electboardbackshape,fSSDSupportRingAl);
5781  electboardback->SetLineColor(fColorAl);
5782  // Electronic Board Kapton Layer
5783  const Int_t kelectlayervertexnumber = 8;
5784  Double_t xelectlayer[kelectlayervertexnumber];
5785  Double_t yelectlayer[kelectlayervertexnumber];
5786  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5787  xelectlayer[1] = xelectlayer[0];
5788  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5789  xelectlayer[3] = xelectlayer[2];
5790  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5791      
5792  yelectlayer[0] = 0.0;
5793  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5794  yelectlayer[2] = yelectlayer[1];
5795  yelectlayer[3] = yelectlayer[0];
5796  yelectlayer[4] = yelectlayer[3];
5797  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5798  yelectlayer[6] = yelectlayer[5];
5799  yelectlayer[7] = yelectlayer[4];
5800  TGeoXtru* electlayershape = new TGeoXtru(2);
5801  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5802  electlayershape->DefineSection(0,0.0);
5803  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5804  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5805                                                                                          electlayershape,fSSDKaptonFlexMedium);
5806  electlayer->SetLineColor(fColorKapton);
5807  // JMD Connector Female
5808  const Int_t kjmdconnectorvertexnumber = 6;
5809  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5810  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5811  xjmdconnectorvertex[0] = 0.0; 
5812  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5813  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5814  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5815  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5816  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5817
5818  yjmdconnectorvertex[0] = 0.0; 
5819  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5820  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5821  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5822  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5823  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5824  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5825  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5826                                                                   yjmdconnectorvertex); 
5827  jmdconnectorshape->DefineSection(0,0.0);
5828  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
5829  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
5830                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
5831  jmdconnector->SetLineColor(fColorG10);
5832  // Top Cable Connector
5833  const Int_t kcableconnectorvertexnumber = 8;
5834  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
5835  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
5836  xconnectorvertex[0] = 0.0;
5837  xconnectorvertex[1] = xconnectorvertex[0];
5838  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
5839  xconnectorvertex[3] = xconnectorvertex[2];
5840  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
5841                                          - fgkEndCapCardCableConnectorLength[2];
5842  xconnectorvertex[5] = xconnectorvertex[4];
5843  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
5844  xconnectorvertex[7] = xconnectorvertex[6];
5845
5846  yconnectorvertex[0] = 0.0;
5847  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
5848  yconnectorvertex[2] = yconnectorvertex[1];
5849  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
5850  yconnectorvertex[4] = yconnectorvertex[3];
5851  yconnectorvertex[5] = yconnectorvertex[1];
5852  yconnectorvertex[6] = yconnectorvertex[5];
5853  yconnectorvertex[7] = yconnectorvertex[0];
5854  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
5855  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
5856                                                                     yconnectorvertex); 
5857  cableconnectorshape->DefineSection(0,0.0);
5858  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
5859  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
5860                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
5861  cableconnector->SetLineColor(fColorG10);
5862  // Strip Connection
5863  TGeoBBox* endcapstripconnectionshape = 
5864                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
5865                                                                                          0.5*fgkEndCapStripConnectionThickness,
5866                                                                                          0.5*fgkEndCapStripConnectionWidth);
5867  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
5868                                                                                                         endcapstripconnectionshape,
5869                                                                                                         fSSDSupportRingAl);
5870  endcapstripconnection->SetLineColor(fColorAl);
5871  // Interface Card B
5872  const Int_t kcardBvertexnumber = 12; 
5873  Double_t xcardBvertexnumber[kcardBvertexnumber];
5874  Double_t ycardBvertexnumber[kcardBvertexnumber];
5875
5876  xcardBvertexnumber[0]  = 0.0;
5877  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
5878  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
5879  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
5880  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
5881  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
5882  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
5883  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
5884  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
5885  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
5886  xcardBvertexnumber[10] = xcardBvertexnumber[7];
5887  xcardBvertexnumber[11] = xcardBvertexnumber[10];
5888  
5889  ycardBvertexnumber[0]  = 0.0;
5890  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
5891  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
5892  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
5893  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
5894  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
5895  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
5896  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
5897  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
5898  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
5899  ycardBvertexnumber[10] = ycardBvertexnumber[9];
5900  ycardBvertexnumber[11] = ycardBvertexnumber[0];
5901
5902  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
5903  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
5904  interfacecardBshape->DefineSection(0,0.);
5905  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
5906  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
5907                                                                                          fSSDMountingBlockMedium);
5908  interfacecardB->SetLineColor(46);
5909  // Interface Card B Electronic Board
5910  const Int_t kelectboardcardBvertexnumber = 14; 
5911  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
5912  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
5913
5914  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
5915  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
5916  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
5917  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
5918  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
5919  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
5920  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
5921  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
5922  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
5923  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
5924  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
5925  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
5926  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
5927  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
5928
5929  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
5930  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
5931  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
5932  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
5933  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
5934  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
5935  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
5936  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
5937  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
5938  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
5939  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
5940  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
5941  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
5942  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
5943
5944  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
5945  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
5946                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
5947  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
5948  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
5949                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
5950  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
5951                                                                                           fSSDSupportRingAl);
5952  electboardcardB->SetLineColor(fColorAl);
5953  // Generating Stiffener 2
5954  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
5955                                                                                            0.5*fgkEndCapStiffenerThickness,
5956                                                                                            0.5*fgkEndCapStiffenerLength);
5957  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
5958  endcapstiffener->SetLineColor(fColorAl);   
5959  // Generating Mother Interface Card B Container
5960  const Int_t kinterfacecardBmothervertexnumber = 10;
5961  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
5962  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
5963
5964  xinterfacecardBmothervertex[0] = 0.0;
5965  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
5966  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
5967                                                                 + fgkEndCapInterfaceCardBThickness;
5968  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
5969  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
5970                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
5971  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
5972  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
5973  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
5974  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
5975                                                                 + fgkEndCapCardJMDConnectorLength[0];
5976  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
5977
5978  yinterfacecardBmothervertex[0] = 0.0;
5979  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
5980                                                                 + fgkEndCapInterfaceCardBWidth[1]
5981                                                                 + fgkEndCapInterfaceCardBWidth[2];
5982  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
5983  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
5984  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
5985  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
5986  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
5987  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
5988                                                                 + fgkEndCapCardJMDConnectorWidth[0]
5989                                                                 + fgkEndCapCardJMDConnectorWidth[1];
5990  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
5991  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
5992  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
5993  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
5994                                                                                   xinterfacecardBmothervertex,
5995                                                                                   yinterfacecardBmothervertex);
5996  interfacecardBmothershape->DefineSection(0,-1.e-15);
5997  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
5998  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
5999                                                                                                    interfacecardBmothershape,fSSDAir);
6000  electboardcardB->SetLineColor(fColorAl);
6001  // Positioning Volumes Mother Interface Card B Container 
6002  TGeoRotation* interfacecardBrot = new TGeoRotation();
6003  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6004  interfacecardBrot->SetAngles(90.,-90.,-90.);
6005  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6006  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6007  TGeoRotation* electboardcardBrot = new TGeoRotation();
6008  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6009  electboardcardBrot->SetAngles(90.,90.,-90.);
6010  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6011  TGeoCombiTrans* electboardcardBcombitrans = 
6012                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6013  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6014  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6015  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6016  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6017  TGeoTranslation* jmdconnectorcardBtrans[3];
6018  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6019  for(Int_t i=0; i<3; i++){
6020    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6021                                                          + fgkEndCapCardJMDConnectorLength[0], 
6022                                                            fgkEndCapCardElectBoardLayerWidth[1],
6023                                                            0.5*fgkEndCapCardJMDConnectorThickness
6024                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6025                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6026                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6027    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6028                                                                                                            *jmdconnectorcardBrot);
6029    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6030  }
6031  // Mother Supply Card Container 
6032  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6033  // Interface Card Container
6034  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6035  // Placing Volumes in Mother Supply Card Container
6036  // JMD Connector Positioning
6037  TGeoTranslation* jmdconnectortrans[2];
6038  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6039  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6040                                                                                         fgkEndCapCardElectBoardBackLength[0]
6041                                           -                                             fgkEndCapCardJMDConnectorThickness
6042                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6043  TGeoRotation* jmdconnectorot = new TGeoRotation();
6044  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6045                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6046                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6047                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6048                                                                       fgkEndCapCardJMDConnectorThickness
6049                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6050  jmdconnectorot->SetAngles(90.,180.,-90);
6051  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6052                                                                                 * jmdconnectorot);
6053  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6054  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6055  // Top Cable Connector Placing
6056  TGeoRotation* cableconnectorot[2];
6057  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6058  TGeoTranslation* cableconnectortrans[3];
6059  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6060  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6061  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6062  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6063  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6064                                                                                                                            *cableconnectorot[0]);
6065  TGeoHMatrix* cableconnectormatrix[2];
6066  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6067                                                         new TGeoHMatrix((*cableconnectorot[1])
6068                                                                                    *(*cableconnectorcombitrans));
6069  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6070                                            -                               fgkEndCapCardCableConnectorThickness,
6071                                                                                 fgkEndCapCardCableConnectorLength[0]
6072                                            +                            fgkEndCapCardCableConnectorToLayer);
6073  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6074                                            -                2.*fgkEndCapCardCableConnectorThickness
6075                                            -                            fgkEndCapCardCableConnectorDistance,
6076                                                                                 fgkEndCapCardCableConnectorLength[0]
6077                                            +                            fgkEndCapCardCableConnectorToLayer);
6078  for(Int_t i=0; i<2; i++){
6079         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6080     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6081  }
6082  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6083  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6084  electboardbackrot->SetAngles(90.,-90.,-90.);
6085  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6086                                                         +                fgkEndCapCardJMDConnectorLength[0]
6087                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6088  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6089                                                                                                                            *electboardbackrot);
6090  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6091  // Electronic Board Kapton Layer Positioning
6092  TGeoRotation* electlayerrot = new TGeoRotation();
6093  TGeoTranslation* electlayertrans[2];
6094  TGeoCombiTrans* electlayercombitrans[2];
6095  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6096  electlayerrot->SetAngles(90.,-90.,-90.);
6097  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6098                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6099  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6100                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6101                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6102  for(Int_t i=0; i<2; i++){
6103         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6104         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6105  }
6106  // Placing Volumes in Mother Interface Card Container
6107  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6108  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6109  for(Int_t i=0; i<2; i++){
6110         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6111  }
6112  /////////////////////////////////////////////////////////////
6113  // Generation of Card Interface Container
6114  /////////////////////////////////////////////////////////////
6115  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6116                                                   - fgkEndCapCardJMDConnectorLength[0]
6117                                                   - fgkEndCapInterfaceCardBThickness
6118                                                   - 9.*fgkEndCapStripConnectionThickness
6119                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6120  const Int_t kcardinterfacecontainervertexnumber = 14;
6121  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6122  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6123  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6124                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6125  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6126  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6127                                                                    + fgkEndCapStripConnectionThickness
6128                                                                    - fgkEndCapCardElectBoardLayerThickness
6129                                                                    - fgkEndCapCardCableConnectorWidth[0];
6130  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6131  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6132  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6133  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6134                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6135  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6136  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6137                                                                    + fgkEndCapInterfaceCardBThickness;
6138  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6139  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6140                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6141  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6142  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6143                                    - fgkEndCapInterfaceElectBoardCardBThickness
6144                                                                    + fgkEndCapCardJMDConnectorLength[0]
6145                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6146  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6147
6148  ycardinterfacecontainervertex[0]  = 0.;
6149  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6150                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6151                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6152  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6153  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6154                                                                    - fgkEndCapStripConnectionWidth;
6155  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6156  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6157  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6158  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6159                                                                    + fgkEndCapInterfaceCardBWidth[1]
6160                                                                    + fgkEndCapInterfaceCardBWidth[2];
6161  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6162  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6163  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6164  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6165  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6166  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6167  
6168  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6169  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6170                                                                                   xcardinterfacecontainervertex,
6171                                                                                   ycardinterfacecontainervertex);
6172  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6173                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6174  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6175                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6176  TGeoVolume** cardinterfacecontainer;
6177  cardinterfacecontainer = new TGeoVolume*[4];
6178  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6179                                                                                         interfacecardmothershape,fSSDAir); 
6180  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6181                                                                                         interfacecardmothershape,fSSDAir); 
6182  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6183                                                                                         interfacecardmothershape,fSSDAir); 
6184  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6185                                                                                         interfacecardmothershape,fSSDAir); 
6186  /////////////////////////////////
6187  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6188  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6189  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6190  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6191  /////////////////////////////////
6192  TGeoRotation* endcapstripconnectionrot[2];
6193  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6194  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6195  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6196  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6197                                                                         *                                 (*endcapstripconnectionrot[0]));
6198  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6199  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6200                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6201                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6202                                                                                         -endcapstripconnectionshape->GetDZ(),
6203                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6204  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6205  TGeoTranslation* cardinterfacetrans[9];
6206  TGeoHMatrix* cardinterfacematrix[9]; 
6207  for(Int_t i=0; i<7; i++){ 
6208         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6209                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6210                                                                                                 0.0,0.0);  
6211         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6212                                                    *                             (*endcapstripconnectionmatrix));
6213  }
6214  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6215                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6216                                                                                                 0.0,0.0);  
6217  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6218                                                 *                                 (*endcapstripconnectionmatrix));
6219  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6220                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6221                                                                                                 0.0,0.0);  
6222  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6223                                                 *                                 (*endcapstripconnectionmatrix));
6224
6225  for(Int_t i=0; i<4; i++){
6226         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6227                                                                            cardinterfacematrix[7]);                             
6228         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6229                                                                            cardinterfacematrix[8]);                             
6230  }
6231  TGeoTranslation* mothersupplycardtrans = 
6232                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6233                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6234                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6235  TGeoHMatrix* mothersupplycardmatrix[7];
6236  Int_t index[4] = {1,1,1,1};
6237  for(Int_t i=0; i<7; i++){
6238         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6239                                                         *                                 (*mothersupplycardtrans));
6240         for(Int_t j=0; j<4; j++){
6241                 switch(j){
6242                         case 0: //Layer5 EndCap Left Side  
6243                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6244                                                                                                    cardinterfacematrix[i]);                             
6245                                 if(i!=0){
6246                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6247                                                                                                            mothersupplycardmatrix[i]);                  
6248                                         index[j]++;
6249
6250                                 }
6251                         break;
6252                         case 1: //Layer5 EndCap Rigth Side  
6253                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6254                                                                                                    cardinterfacematrix[i]);                     
6255                                 if(i>0&&i<6){
6256                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6257                                                                                                            mothersupplycardmatrix[i]);                  
6258                                         index[j]++;
6259                                 }
6260                         break;
6261                         case 2: //Layer6 EndCap Left Side  
6262                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6263                                                                                                    cardinterfacematrix[i]);                             
6264                                 if(i!=6){
6265                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6266                                                                                                            mothersupplycardmatrix[i]);                  
6267                                         index[j]++;
6268                                 }
6269                         break;
6270                         case 3: //Layer6 EndCap Right Side  
6271                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6272                                                                                                    cardinterfacematrix[i]);                             
6273                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6274                                                                                                    mothersupplycardmatrix[i]);                  
6275                                 index[j]++;
6276                         break;
6277                 }
6278         }
6279  }
6280  // Positioning Interface 
6281  TGeoTranslation* motherinterfacecardtrans = 
6282                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6283                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6284                                                          -fgkEndCapCardElectBoardLayerThickness
6285                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6286  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6287                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6288  // Positioning Interface Card B 
6289  TGeoTranslation* interfacecardBmothertrans = 
6290                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6291                                                                                 + 2.*fgkEndCapStripConnectionThickness
6292                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6293                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6294                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6295  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6296                                                                                                                          interfacecardBmothertrans);
6297  // Positioning Stiffener 
6298  TGeoTranslation* endcapstiffenertrans = 
6299                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6300                                                                            +    2.0*fgkEndCapStripConnectionThickness
6301                                                                            +    fgkEndCapInterfaceCardBThickness
6302                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6303                                                                            +    stiffenertransx
6304                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6305                                                                                         endcapstiffenershape->GetDZ()
6306                                                                            -    0.5*(fgkEndCapStiffenerLength
6307                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6308  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6309  /////////////////////////////////////////////////////////////
6310  // Deallocating memory
6311  /////////////////////////////////////////////////////////////
6312  delete interfacecardBrot;
6313  delete interfacecardBtrans;
6314  delete electboardcardBtrans;
6315  delete electboardcardBrot; 
6316  delete jmdconnectorcardBrot;
6317  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6318  delete jmdconnectorot;
6319  delete jmdconnectortrans[1];
6320  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6321  delete cableconnectorcombitrans;
6322  delete electboardbacktrans;
6323  delete electboardbackrot;
6324  delete electlayerrot;
6325  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6326  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6327  delete mothersupplycardtrans;
6328  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6329  /////////////////////////////////////////////////////////////
6330  return cardinterfacecontainer;
6331  }
6332  ////////////////////////////////////////////////////////////////////////////////
6333  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6334   /////////////////////////////////////////////////////////////
6335   // Method returning EndCap Mother Volume
6336   /////////////////////////////////////////////////////////////
6337   const Int_t kendcapcoverplatesmallholenumber = 9;
6338   Double_t endcapmotherorigin[3];
6339   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6340                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6341                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6342   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6343                                           -                      fgkEndCapCoverPlateWidth[2]
6344                                           -       (kendcapcoverplatesmallholenumber-1)
6345                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6346                                           +  0.5*(fgkEndCapSideCoverLength[2]
6347                                           +               fgkEndCapCoverPlateWidth[1]
6348                                           -       fgkEndCapCoverPlateWidth[0])
6349                                           -      (fgkEndCapCoverPlateWidth[1]
6350                                           -       fgkEndCapCoverPlateWidth[0]);
6351   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6352                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6353                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6354                                                 +      fgkEndCapSideCoverWidth[1]
6355                                                 +      fgkEndCapSideCoverThickness
6356                                                 +      fgkEndCapKaptonFoilThickness);
6357   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6358                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6359                                                           +              2.0* fgkEndCapSideCoverThickness),
6360                                                                          0.5* (fgkEndCapSideCoverLength[2]
6361                                                           +                    fgkEndCapCoverPlateWidth[1]
6362                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6363                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6364                                                       +                                    fgkEndCapSideCoverWidth[1]
6365                                                           +                                       fgkEndCapSideCoverThickness
6366                                                       +                                   fgkEndCapKaptonFoilThickness),
6367                                                                                          endcapmotherorigin);
6368   TGeoVolume** endcapassembly;  
6369   endcapassembly = new TGeoVolume*[4];
6370   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6371                                                                                         endcapmothershape,fSSDAir); 
6372   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6373                                                                                         endcapmothershape,fSSDAir); 
6374   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6375                                                                                         endcapmothershape,fSSDAir); 
6376   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6377                                                                                         endcapmothershape,fSSDAir); 
6378  /////////////////////////////////
6379  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6380  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6381  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6382  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6383  /////////////////////////////////
6384   /////////////////////////////////////////////////////
6385   // Placing Endcap Cover Plate
6386   /////////////////////////////////////////////////////
6387   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6388   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6389   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6390   TGeoCombiTrans* endcapcoverplatecombitrans = 
6391                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6392                                                                                          endcapcoverplaterot);
6393   TGeoTranslation* endcapcoverplatetrans = 
6394                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6395   TGeoHMatrix* endcapcoverplatematrix = 
6396                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6397                                                                           *       (*endcapcoverplatecombitrans));
6398   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6399   /////////////////////////////////////////////////////
6400   // Placing Endcap Side Cover
6401   /////////////////////////////////////////////////////
6402   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6403   TGeoRotation* endcapsidecoverot[2];
6404   TGeoCombiTrans* endcapsidecovercombitrans[3];
6405   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6406   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6407   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6408                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6409                                                                                         - fgkEndCapCoverPlateWidth[2]
6410                                                                                     - (kendcapcoverplatesmallholenumber-1)
6411                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6412                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6413                                                                                         + fgkEndCapSideCoverLength[2],
6414                                                                                           0.5*(fgkEndCapSideCoverThickness
6415                                                                                         + fgkEndCapCoverPlateThickness)
6416                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6417                                                                                           endcapsidecoverot[0]);
6418   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6419   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6420                                                                                                         0.5*fgkEndCapCoverPlateThickness
6421                                                                                                         -fgkEndCapSideCoverWidth[1],
6422                                                                                                         endcapsidecoverot[1]);
6423   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6424                                                                                                         +fgkEndCapCoverPlateLength[3]
6425                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6426                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6427                                                                                                         0.5*fgkEndCapCoverPlateThickness
6428                                                                                                         -fgkEndCapSideCoverWidth[1],
6429                                                                                                         endcapsidecoverot[1]);
6430   TGeoHMatrix* endcapsidecovermatrix[2];
6431   for(Int_t i=0; i<2; i++){
6432    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6433                                                         *                                 (*endcapsidecovercombitrans[0]));
6434         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6435                                                                                                                 endcapsidecovermatrix[i]);
6436   }
6437   /////////////////////////////////////////////////////
6438   // Placing Endcap Cooling Tube
6439   /////////////////////////////////////////////////////
6440   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6441   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6442   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6443   TGeoCombiTrans* endcapccolingtubecombitrans 
6444                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6445                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6446                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6447                                                 - fgkEndCapCoolingTubeToCoverSide,
6448                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6449                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6450   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6451                                                                                                           endcapccolingtubecombitrans);
6452   /////////////////////////////////////////////////////
6453   // Placing Screws 
6454   /////////////////////////////////////////////////////
6455   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6456                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6457   Int_t screwcoverplatedgesnumber[2] = {20,20};
6458   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6459                                                                                 fgkEndCapCoverPlateThickness
6460                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6461   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6462                                                                                                  screwcoverplatedgesnumber,
6463                                                                                                  screwcoverplatesection);
6464   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6465                                                                                            screwcoverplateshape,
6466                                                                                            fSSDCoolingTubePhynox); 
6467   screwcoverplate->SetLineColor(12);
6468   Double_t transx[4] = {0,
6469                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6470                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6471                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6472                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6473                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6474   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6475 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6476   TGeoTranslation*** endcapcoverplatescrewtrans;
6477   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6478   Int_t index = 0;
6479   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6480         endcapcoverplatescrewtrans[i] = 
6481                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6482     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6483                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6484         if(index==1||index==9||index==28||index==36){
6485                         endcapcoverplatescrewtrans[i][j] = 
6486                                 new TGeoTranslation(transx[i],
6487                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6488                                                                         fgkEndCapSideCoverThickness);
6489                 }
6490                 else{
6491                         endcapcoverplatescrewtrans[i][j] = 
6492                                 new TGeoTranslation(transx[i],
6493                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6494                                                                         0.);
6495                 }
6496             if(index!=19) 
6497                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6498                                                                                           endcapcoverplatescrewtrans[i][j]);
6499         }
6500   }
6501   /////////////////////////////////////////////////////
6502   // Placing Cover Plate Clips 
6503   /////////////////////////////////////////////////////
6504   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6505                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6506                                                                                                          0.5*fgkEndCapSideCoverThickness);
6507   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6508                                                                                                         endcapcoverplateclipshape,
6509                                                                                                         fSSDCoolingTubePhynox);
6510   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6511                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6512                                                                                                          0.5*fgkEndCapSideCoverThickness);
6513   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6514                                                                                                         endcapcoverplatedownclipshape,
6515                                                                                                         fSSDCoolingTubePhynox);
6516   TGeoTranslation* endcapcoverplatecliptrans[4];
6517   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6518                                                            -                     fgkEndCapCoverPlateLength[0]
6519                                                            -                     fgkEndCapSideCoverThickness,
6520                                                                                                          0.0,
6521                                                                                                  0.5*(fgkEndCapSideCoverThickness
6522                                                            +                                              fgkEndCapCoverPlateThickness));
6523   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6524                                                            -                     fgkEndCapCoverPlateLength[0]
6525                                                            -                     fgkEndCapSideCoverThickness,
6526                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6527                                                            *                                     fgkEndCapSideCoverWidth[5],
6528                                                                                                  0.5*(fgkEndCapSideCoverThickness
6529                                                            +                                              fgkEndCapCoverPlateThickness));
6530   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6531                                                            -                     fgkEndCapCoverPlateLength[0]
6532                                                            +                                     fgkEndCapCoverPlateLength[1]
6533                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6534                                                            -                                     fgkEndCapCoverPlateClipLength
6535                                                            +                                 fgkEndCapSideCoverThickness,
6536                                                                                                          0.0,
6537                                                                                                  0.5*(fgkEndCapSideCoverThickness
6538                                                            +                                              fgkEndCapCoverPlateThickness));
6539   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6540                                                            -                     fgkEndCapCoverPlateLength[0]
6541                                                            +                                     fgkEndCapCoverPlateLength[1]
6542                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6543                                                            -                                     fgkEndCapCoverPlateClipLength
6544                                                            +                                 fgkEndCapSideCoverThickness,
6545                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6546                                                            *                                     fgkEndCapSideCoverWidth[5],
6547                                                                                                  0.5*(fgkEndCapSideCoverThickness
6548                                                            +                                              fgkEndCapCoverPlateThickness));
6549   endcapcoverplateclip->SetLineColor(fColorPhynox);
6550   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6551   for(Int_t i=0; i<4; i++) 
6552         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6553                                                                                                    endcapcoverplatecliptrans[i]);  
6554   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6555   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6556                                                                    -                     fgkEndCapCoverPlateLength[0]
6557                                                                    -                     fgkEndCapSideCoverThickness,
6558                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6559                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6560                                                                                                         0.5*(fgkEndCapSideCoverThickness
6561                                                                +                                         fgkEndCapCoverPlateThickness)
6562                                                                    -                     fgkEndCapSideCoverWidth[1]
6563                                                                    -                                     fgkEndCapSideCoverThickness);
6564   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6565                                                                    -                     fgkEndCapCoverPlateLength[0]
6566                                                                    -                     fgkEndCapSideCoverThickness,
6567                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6568                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6569                                                                    +                            fgkEndCapSideCoverLength[2]
6570                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6571                                                                                                         0.5*(fgkEndCapSideCoverThickness
6572                                                                +                                         fgkEndCapCoverPlateThickness)
6573                                                                    -                     fgkEndCapSideCoverWidth[1]
6574                                                                    -                                     fgkEndCapSideCoverThickness);
6575   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6576                                                                    -                     fgkEndCapCoverPlateLength[0]
6577                                                                    +                     fgkEndCapSideCoverThickness
6578                                                                    +                     fgkEndCapCoverPlateLength[1]
6579                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6580                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6581                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6582                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6583                                                                                                         0.5*(fgkEndCapSideCoverThickness
6584                                                                +                                         fgkEndCapCoverPlateThickness)
6585                                                                    -                     fgkEndCapSideCoverWidth[1]
6586                                                                    -                                     fgkEndCapSideCoverThickness);
6587   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6588                                                                    -                     fgkEndCapCoverPlateLength[0]
6589                                                                    +                     fgkEndCapSideCoverThickness
6590                                                                    +                     fgkEndCapCoverPlateLength[1]
6591                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6592                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6593                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6594                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6595                                                                    +                                 fgkEndCapSideCoverLength[2]
6596                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6597                                                                                                         0.5*(fgkEndCapSideCoverThickness
6598                                                                +                                         fgkEndCapCoverPlateThickness)
6599                                                                    -                     fgkEndCapSideCoverWidth[1]
6600                                                                    -                                     fgkEndCapSideCoverThickness);
6601   for(Int_t i=0; i<4; i++)
6602         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6603                                                                                                    endcapcoverplatedowncliptrans[i]);
6604   /////////////////////////////////////////////////////
6605   // Placing Kapton Foil
6606   /////////////////////////////////////////////////////
6607   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6608                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6609                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6610   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6611                                                                                                 endcapkaptonfoilshape,
6612                                                                                                 fSSDKaptonFlexMedium);
6613   endcapkaptonfoil->SetLineColor(8);
6614   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6615                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6616                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6617                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6618                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6619                                                                              -                     fgkEndCapSideCoverWidth[1]
6620                                                                                  -                     fgkEndCapSideCoverThickness);
6621   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6622   /////////////////////////////////////////////////////////////
6623   // Placing Electronic Tubes
6624   /////////////////////////////////////////////////////////////
6625   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6626                                                                              - fgkEndCapInterfaceCardBThickness
6627                                                                              - 9.*fgkEndCapStripConnectionThickness
6628                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6629                                                                                fgkEndCapKaptonFoilWidth
6630                                                                              - fgkEndCapInterfaceCardBThickness
6631                                                                              - 9.*fgkEndCapStripConnectionThickness
6632                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6633                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6634   TGeoVolume* endcapeffectivecables[2];
6635   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6636                                                                                          fgkEndCapEffectiveCableRadiusMax,
6637                                                                                          endcapeffectivecableswidth[0],
6638                                                                                          10,"EndCapEffectiveCables1"); 
6639   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6640                                                                                          fgkEndCapEffectiveCableRadiusMax,
6641                                                                                          endcapeffectivecableswidth[1],
6642                                                                                          25,"EndCapEffectiveCables2"); 
6643   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6644   TGeoTranslation* endcapeffectivecablestrans[2];
6645   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6646                                           -                                                        0.5*endcapeffectivecableswidth[0]
6647                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6648                                           -                                                               fgkEndCapCoverPlateWidth[2]
6649                                           -                                             (kendcapcoverplatesmallholenumber-1)
6650                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6651                                           +                                             fgkEndCapSideCoverLength[2],
6652                                           -                     0.5*fgkEndCapCoverPlateThickness
6653                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6654                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6655                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6656   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6657                                           -                                                        0.5*endcapeffectivecableswidth[1]
6658                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6659                                           -                                                               fgkEndCapCoverPlateWidth[2]
6660                                           -                                             (kendcapcoverplatesmallholenumber-1)
6661                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6662                                           +                                         fgkEndCapSideCoverLength[2],
6663                                           -                     0.5*fgkEndCapCoverPlateThickness
6664                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6665                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6666                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6667   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6668   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6669   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6670                                                                                                                    *endcapeffectivecablesrot);
6671   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6672                                                                                                                    *endcapeffectivecablesrot);
6673 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6674 //                                                                                                        endcapeffectivecablescombitrans[0]);
6675   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6676                                                                                                           endcapeffectivecablescombitrans[1]);
6677   /////////////////////////////////////////////////////////////
6678   // Placing End Cap Cards
6679   /////////////////////////////////////////////////////////////
6680   TGeoVolume** endcapcards = GetEndCapCards();
6681   TGeoRotation* endcapcardsrot[2];
6682   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6683   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6684   TGeoTranslation* endcapcardstrans[2]; 
6685   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6686                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6687   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6688   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6689   TGeoHMatrix* endcapcardsmatrix[2];
6690   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6691   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6692                                                   - fgkEndCapCardJMDConnectorLength[0]
6693                                                   - fgkEndCapInterfaceCardBThickness
6694                                                   - 9.*fgkEndCapStripConnectionThickness
6695                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6696   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6697                                           -                                             fgkEndCapCoverPlateLength[0]
6698                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6699                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6700                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6701                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6702                                           -                                                               fgkEndCapInterfaceCardBThickness
6703                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6704                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6705                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6706                                           -                                                               fgkEndCapCoverPlateWidth[2]
6707                                           -                                             (kendcapcoverplatesmallholenumber-1)
6708                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6709                                           +                     fgkEndCapKaptonFoilWidth,
6710                                                                                           0.5*fgkEndCapCoverPlateThickness
6711                                           -                                                     fgkEndCapSideCoverWidth[1]);
6712   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6713   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6714    /////////////////////////////////////////////////////////////
6715   // Deallocating memory
6716   /////////////////////////////////////////////////////////////
6717   delete endcapcoverplaterot;
6718   delete endcapcoverplatecombitrans;
6719   delete endcapcoverplatetrans;
6720   for(Int_t i=0; i<3; i++){
6721    delete endcapsidecovercombitrans[i];
6722    if(i<2) delete endcapsidecoverot[i]; 
6723   }
6724   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6725   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6726   delete endcapcardsmatrix[0];
6727   return endcapassembly;
6728  } 
6729  ////////////////////////////////////////////////////////////////////////////////
6730  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6731                                                                                                                         Double_t radiusmax, 
6732                                                                                                                         Double_t width, 
6733                                                                                                                         Int_t ncables,
6734                                                                                                                         const char* volname){
6735   /////////////////////////////////////////////////////////////
6736   // Generating EndCap High Voltage Tubes 
6737   /////////////////////////////////////////////////////////////
6738   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6739   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
6740
6741   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6742   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6743                                                                                                    effectiveouteradius,0.5*width);
6744   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6745                                                                                                 effectiveinnertubeshape,
6746                                                                                                 fSSDStiffenerConnectorMedium);
6747   effectiveinnertube->SetLineColor(41);
6748   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6749                                                                                                 effectiveoutertubeshape,
6750                                                                                                 fSSDKaptonChipCableMedium);
6751   effectiveoutertube->SetLineColor(39);
6752   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6753   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6754   effectivemothertube->AddNode(effectiveinnertube,1);
6755   effectivemothertube->AddNode(effectiveoutertube,1);
6756   return effectivemothertube;
6757  } 
6758  ////////////////////////////////////////////////////////////////////////////////
6759  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6760   /////////////////////////////////////////////////////////////
6761   // Generating EndCap Support Layer 5 and Layer 6 
6762   /////////////////////////////////////////////////////////////
6763   const Int_t knedges = 5;
6764   ///////////////////////////////////////////////
6765   // Setting the vertices for TGeoXtru Up Volume
6766   ///////////////////////////////////////////////
6767   const Int_t klayernumber = 2;
6768   Double_t xupvertex[klayernumber][knedges+3];
6769   Double_t yupvertex[klayernumber][knedges+3];
6770   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6771   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6772   Double_t middlepsi[klayernumber] = {0.0,0.0};
6773   for(Int_t i=0; i<klayernumber; i++){
6774         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6775         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6776         xupvertex[i][2] = -xupvertex[i][1];
6777         xupvertex[i][3] = -xupvertex[i][0];
6778
6779         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6780         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6781         yupvertex[i][2] =  yupvertex[i][1];
6782         yupvertex[i][3] =  yupvertex[i][0];
6783         
6784     middledgeangle[i] = upedgeangle[i]/knedges;
6785     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6786     for(Int_t j=1; j<knedges; j++){
6787                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6788                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6789         }
6790   }
6791   ////////////////////////////////////
6792   // Generating Up TGeoXtru
6793   ////////////////////////////////////
6794   TGeoXtru* upendcapsupportshape[klayernumber];
6795   TGeoVolume* upendcapsupport[klayernumber]; 
6796   char upendcapsupportname[100]; 
6797   for(Int_t i=0; i<klayernumber; i++){
6798    upendcapsupportshape[i] = new TGeoXtru(2);
6799    snprintf(upendcapsupportname,100,"UpEndCapSupportPieceLayer%i",i+5);
6800    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6801    upendcapsupportshape[i]->DefineSection(0,0.);
6802    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6803    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6804                                                                         fSSDSupportRingAl);
6805    upendcapsupport[i]->SetLineColor(5);
6806   }
6807   ///////////////////////////////////////////////
6808   // Setting the vertices for TGeoXtru Down Volume
6809   ///////////////////////////////////////////////
6810   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6811   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6812   for(Int_t i=0; i<klayernumber; i++){
6813         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6814         xdownvertex[i][1] =  xupvertex[i][0];
6815         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6816         ydownvertex[i][1] =  yupvertex[i][0];
6817         for(Int_t j=0; j<knedges; j++){
6818                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6819                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6820         } 
6821         for(Int_t j=0; j<knedges; j++){
6822                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6823                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6824                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6825                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
6826         }
6827   }
6828   ////////////////////////////////////
6829   // Generating Down TGeoXtru
6830   ////////////////////////////////////  
6831   TGeoXtru* downendcapsupportshape[klayernumber];
6832   TGeoVolume* downendcapsupport[klayernumber]; 
6833   char downendcapsupportname[100]; 
6834   for(Int_t i=0; i<klayernumber; i++){
6835         downendcapsupportshape[i] = new TGeoXtru(2);
6836         snprintf(downendcapsupportname,100,"DownEndCapSupportPieceLayer%i",i+5);
6837         downendcapsupportshape[i] = new TGeoXtru(2);
6838         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
6839     if(i==0){
6840                 downendcapsupportshape[i]->DefineSection(0,0.);
6841                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
6842     }
6843         else{
6844                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
6845                                                                  -                 fgkEndCapSupportLowWidth[i]);
6846                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6847         }
6848     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
6849                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
6850         downendcapsupport[i]->SetLineColor(5);
6851   }
6852   ///////////////////////////////////////////////
6853   // Setting TGeoPgon Volume
6854   ///////////////////////////////////////////////
6855   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6856                                                                                                    fgkSSDLay6LadderNumber};
6857   TGeoPgon* endcapsupportmothershape[klayernumber];
6858   TGeoVolume** endcapsupportmother;
6859   endcapsupportmother = new TGeoVolume*[klayernumber];
6860   char endcapsupportmothername[100];
6861   for(Int_t i=0; i<klayernumber; i++){
6862         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6863         snprintf(endcapsupportmothername,100,"EndCapSupportMotherLayer%i",i+5);
6864         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
6865     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
6866                                                                                           ydownvertex[i][0],yupvertex[i][1]);
6867     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
6868                                                                                         fSSDAir);       
6869   }
6870   ////////////////////////////////////
6871   TGeoRotation** endcapsupportrot[klayernumber];
6872   for(Int_t i=0; i<2; i++){
6873         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
6874         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6875            endcapsupportrot[i][j] = new TGeoRotation();
6876            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
6877        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
6878        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
6879         }
6880   }
6881   return endcapsupportmother;
6882  } 
6883  ////////////////////////////////////////////////////////////////////////////////
6884  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
6885   /////////////////////////////////////////////////////////////
6886   // Setting End Cap Support Layer 5 and 6. 
6887   /////////////////////////////////////////////////////////////
6888   const Int_t kendcapcoverplatesmallholenumber = 9;
6889   const Int_t klayernumber = 2;
6890   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6891                                                                                                    fgkSSDLay6LadderNumber};
6892   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
6893                                                                                 360.0/kssdlayladdernumber[1]};
6894   TGeoVolume** endcapsupport = EndCapSupport();
6895   TGeoVolume** endcapassembly = GetEndCapAssembly();
6896   TGeoPgon* endcapsupportshape[klayernumber];
6897   Double_t* radiusmin[klayernumber];
6898   Double_t* radiusmax[klayernumber];
6899   for(Int_t i=0; i<klayernumber; i++){
6900     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
6901         radiusmin[i] = endcapsupportshape[i]->GetRmin();
6902         radiusmax[i] = endcapsupportshape[i]->GetRmax();
6903   }  
6904   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
6905   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
6906                                                                           endcapassemblyshape->GetDY(),
6907                                                                           endcapassemblyshape->GetDZ()};
6908   ///////////////////////////////////////////////
6909   // Setting TGeoPgon Volume for Mother Container
6910   ///////////////////////////////////////////////
6911   TGeoPgon* endcapsupportsystemshape[klayernumber];
6912   char endcapsupportsystemothername[100];
6913   for(Int_t i=0; i<klayernumber; i++){
6914         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6915         snprintf(endcapsupportsystemothername,100,"EndCapSupportSystemLayer%i",i+5);
6916         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
6917                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
6918                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6919                                                                                            +2.*endcapassemblycenter[2])
6920                                                                                            /CosD(0.5*upedgeangle[i]));  
6921     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
6922                                                                                                  -(fgkEndCapCoverPlateWidth[1]
6923                                                                                              - fgkEndCapCoverPlateWidth[0]),
6924                                                                                            *radiusmin[i],
6925                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6926                                                                                            +2.*endcapassemblycenter[2])
6927                                                                                            /CosD(0.5*upedgeangle[i]));
6928   }
6929   fgkEndCapSupportSystem = new TGeoVolume*[4];
6930   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
6931                                                                           endcapsupportsystemshape[0],fSSDAir); 
6932   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
6933                                                                           endcapsupportsystemshape[0],fSSDAir); 
6934   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
6935                                                                           endcapsupportsystemshape[1],fSSDAir); 
6936   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
6937                                                                           endcapsupportsystemshape[1],fSSDAir); 
6938   ///////////////////////////////////////////////
6939   TGeoTranslation* endcapassemblytrans[klayernumber];
6940   for(Int_t i=0; i<klayernumber; i++)
6941         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
6942                                                                            -  fgkEndCapSideCoverThickness
6943                                                                            +  endcapassemblycenter[0],
6944                                                                            -  0.5*fgkEndCapCoverPlateThickness
6945                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
6946                                                                            +  2.0*endcapassemblycenter[2]
6947                                                                            +  0.5*fgkEndCapSupportLength[i]
6948                                                                            /  TanD(0.5*upedgeangle[i]),
6949                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
6950                                                                            -  fgkEndCapCoverPlateWidth[2]
6951                                                                            - (kendcapcoverplatesmallholenumber-1)
6952                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
6953   TGeoRotation** endcapassemblyrot[klayernumber];
6954   TGeoHMatrix** endcapassemblymatrix[klayernumber];
6955   for(Int_t i=0; i<klayernumber; i++){
6956    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
6957    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
6958    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
6959    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
6960    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
6961    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
6962    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
6963    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6964         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
6965         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
6966    }
6967   }
6968   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
6969                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
6970   for(Int_t i=0; i<2*klayernumber; i++){
6971         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
6972                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
6973                                                                                                                                            endcapassemblymatrix[1][j+2]);
6974         }
6975         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
6976   }
6977    /////////////////////////////////////////////////////////////
6978   // Deallocating memory
6979   /////////////////////////////////////////////////////////////
6980   for(Int_t i=0; i<klayernumber; i++){
6981         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
6982                 delete endcapassemblyrot[i][j];
6983         }
6984         delete [] endcapassemblyrot[i];
6985         delete endcapassemblymatrix[i][0];
6986         delete endcapassemblymatrix[i][1];
6987   }
6988   /////////////////////////////////////////////////////////////
6989   }
6990   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
6991   /////////////////////////////////////////////////////////////
6992   // Setting End Cap Support + End Cap Assembly of Layer 5. 
6993   /////////////////////////////////////////////////////////////
6994   if (! moth) {
6995     AliError("Can't insert end cap support of layer5, mother is null!\n");
6996     return;
6997   };
6998   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
6999   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7000   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7001                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7002                                                                            +            fgkEndCapSupportCenterLay5Position
7003                                                                            -            fgkEndCapSideCoverLength[2]);
7004   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7005                                                                                                 fgkEndCapSideCoverLength[2]
7006                                                                            -        fgkEndCapSupportCenterLay5Position
7007                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7008   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7009   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7010   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7011         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7012   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7013   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7014    /////////////////////////////////////////////////////////////
7015   // Deallocating memory
7016   /////////////////////////////////////////////////////////////
7017   delete endcapsupportsystemrot;
7018   delete endcapsupportsystemITSCentertrans[1];
7019  }
7020   /////////////////////////////////////////////////////////////
7021   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7022   /////////////////////////////////////////////////////////////
7023   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7024   /////////////////////////////////////////////////////////////
7025   if (! moth) {
7026     AliError("Can't insert end cap support of layer6, mother is null!\n");
7027     return;
7028   };
7029   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7030   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7031   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7032                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7033                                                                            +            fgkEndCapSupportCenterLay6Position
7034                                                                            -            fgkEndCapSideCoverLength[2]);
7035   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7036                                                                                                 fgkEndCapSideCoverLength[2]
7037                                                                            -        fgkEndCapSupportCenterLay6Position
7038                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7039   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7040   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7041   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7042         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7043   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7044   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7045    /////////////////////////////////////////////////////////////
7046   // Deallocating memory
7047   /////////////////////////////////////////////////////////////
7048   delete endcapsupportsystemrot;
7049   delete endcapsupportsystemITSCentertrans[1];
7050  }
7051  ////////////////////////////////////////////////////////////////////////////////
7052  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7053   /////////////////////////////////////////////////////////////
7054   // Setting Ladder Support of Layer 5. 
7055   /////////////////////////////////////////////////////////////
7056   if (! moth) {
7057     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7058     return;
7059   };
7060   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7061   fMotherVol = moth;
7062   TGeoTranslation* centerITSRingSupportLay5trans[2];
7063   for(Int_t i=0; i<2; i++){
7064         centerITSRingSupportLay5trans[i] = 
7065                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7066     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7067   }
7068  }
7069  ////////////////////////////////////////////////////////////////////////////////
7070  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7071   /////////////////////////////////////////////////////////////
7072   // Setting Ladder Support of Layer 6. 
7073   /////////////////////////////////////////////////////////////
7074   if (! moth) {
7075     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7076     return;
7077   };
7078   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7079   fMotherVol = moth;
7080   TGeoTranslation* centerITSRingSupportLay6trans[2];
7081   for(Int_t i=0; i<2; i++){
7082         centerITSRingSupportLay6trans[i] = 
7083                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7084     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7085   }
7086  }
7087  ////////////////////////////////////////////////////////////////////////////////
7088  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7089   /////////////////////////////////////////////////////////////
7090   // Setting Ladder Support of Layer 6. 
7091   /////////////////////////////////////////////////////////////
7092   if (! moth) {
7093     AliError("Can't insert SSD Cone, mother is null!\n");
7094     return;
7095   };
7096   if(!fSSDCone) SetSSDCone();
7097   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7098                                                                 +                                         fgkSSDCentralAL3SupportLength);
7099     moth->AddNode(fSSDCone,1,ssdconetrans);
7100 }
7101  ////////////////////////////////////////////////////////////////////////////////
7102  void AliITSv11GeometrySSD::SetSSDCone(){
7103   /////////////////////////////////////////////////////////////
7104   // Method generating SSDCone 
7105   /////////////////////////////////////////////////////////////
7106   if(!fCreateMaterials) CreateMaterials();
7107   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7108   Double_t ssdpconesectionradiusmax[16];
7109   Double_t ssdpconesectionradiusmin[16];
7110   Double_t ssdpconezsection[16];
7111   TGeoPcon* ssdpconelittleholeshape[8];
7112   TGeoVolume* ssdpconelittlehole[8];
7113   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7114   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7115   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7116                                                       / SinD(fgkSSDPConeAngle)
7117                                                           + ssdpconesectionradiusmin[0];
7118   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7119                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7120                                                           / SinD(fgkSSDPConeAngle);
7121   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7122   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7123                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7124   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7125   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7126                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7127   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7128   ssdpconelittlehole[0]->SetLineColor(4);
7129   /////////////////////////////////////////////////////////////
7130   ssdpconezsection[2] = ssdpconezsection[1];  
7131   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7132   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7133   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7134                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7135                                                           / SinD(fgkSSDPConeAngle);
7136   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7137                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7138   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7139                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7140   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7141                                                                    * TMath::RadToDeg();
7142   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7143                                                                                                           60.-ssdpconelittleholeangle,2);    
7144   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7145                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7146   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7147   ssdpconelittlehole[1]->SetLineColor(4);
7148   TGeoRotation* ssdconelittleholerot[6];
7149   for(Int_t i=0; i<6; i++){
7150         ssdconelittleholerot[i] = new TGeoRotation();
7151     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7152   }
7153   /////////////////////////////////////////////////////////////
7154   ssdpconezsection[4] = ssdpconezsection[3];  
7155   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7156   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7157   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7158                                                           * CosD(fgkSSDPConeAngle)
7159                                                           / SinD(fgkSSDPConeAngle);
7160   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7161   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7162                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7163   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7164   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7165                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7166   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7167   ssdpconelittlehole[2]->SetLineColor(4);
7168   ///////////////////////////////////////////////////
7169   ssdpconezsection[6] = ssdpconezsection[5];  
7170   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7171   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7172   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7173                                                           -ssdpconezsection[0]
7174                                                           * CosD(fgkSSDPConeAngle)
7175                                                           / SinD(fgkSSDPConeAngle);
7176   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7177   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7178                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7179   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7180                                                                    * TMath::RadToDeg();
7181   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7182                                                                                                           45.-ssdpconemiddleholeangle,2);    
7183   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7184                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7185   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7186   ssdpconelittlehole[3]->SetLineColor(4);
7187   TGeoRotation* ssdconemiddleholerot[8];
7188   for(Int_t i=0; i<8; i++){
7189         ssdconemiddleholerot[i] = new TGeoRotation();
7190     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7191   }
7192   /////////////////////////////////////////////////////////////
7193   ssdpconezsection[8] = ssdpconezsection[7];  
7194   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7195   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7196   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7197                                                           * CosD(fgkSSDPConeAngle)
7198                                                           / SinD(fgkSSDPConeAngle);
7199   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7200   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7201                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7202   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7203   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7204                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7205   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7206   ssdpconelittlehole[4]->SetLineColor(4);
7207   /////////////////////////////////////////////////////////////
7208   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7209   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7210                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7211                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7212                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7213                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7214   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7215   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7216                                                                                  * TMath::RadToDeg();
7217   ssdpconezsection[10] = ssdpconezsection[9];
7218   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7219   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7220   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7221                                                           * CosD(fgkSSDPConeAngle)
7222                                                           / SinD(fgkSSDPConeAngle);
7223   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7224   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7225                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7226   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7227                                                                                         ssdpconetrapezoidsectionangle,2);    
7228   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7229                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7230   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7231   ssdpconelittlehole[5]->SetLineColor(4);
7232   TGeoRotation* ssdconeupradiusrot[8];
7233   for(Int_t i=0; i<8; i++){
7234         ssdconeupradiusrot[i] = new TGeoRotation();
7235     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7236   }
7237   /////////////////////////////////////////////////////////////
7238   ssdpconezsection[12] = ssdpconezsection[11];
7239   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7240   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7241   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7242   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7243   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7244   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7245   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7246                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7247   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7248   ssdpconelittlehole[6]->SetLineColor(4);
7249   /////////////////////////////////////////////////////////////
7250   ssdpconezsection[14] = 0.0;
7251   ssdpconezsection[15] = ssdpconezsection[0];
7252   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7253   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7254   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7255   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7256   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7257   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7258                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7259   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7260   ssdpconelittlehole[7]->SetLineColor(4);
7261   /////////////////////////////////////////////////////////////
7262   TGeoTube* ssdtubeconeshape[2];
7263   TGeoVolume* ssdtubecone[2];
7264   TGeoTranslation* ssdtubeconetrans[2];
7265   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7266                                                                            fgkSSDPConeExternalRadius,
7267                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7268   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7269                                                                            0.5*ssdpconezsection[0]); 
7270   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7271   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7272   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7273                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7274                                           + ssdpconezsection[13]);
7275   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7276   ssdtubecone[0]->SetLineColor(4);
7277   ssdtubecone[1]->SetLineColor(4);
7278   /////////////////////////////////////////////////////////////
7279   // Mother Volume Container
7280   /////////////////////////////////////////////////////////////
7281   Double_t ssdconemotherradiusmin[8];
7282   Double_t ssdconemotherradiusmax[8];
7283   Double_t ssdconemothersection[8]; 
7284   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7285   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7286   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7287   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7288   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7289   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7290   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7291   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7292   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7293   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7294   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7295   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7296   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7297   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7298   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7299   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7300   ssdconemothersection[0] = 0.0;
7301   ssdconemothersection[1] = ssdpconezsection[0];
7302   ssdconemothersection[2] = ssdpconezsection[0];
7303   ssdconemothersection[3] = ssdpconezsection[11];
7304   ssdconemothersection[4] = ssdpconezsection[11];
7305   ssdconemothersection[5] = ssdpconezsection[13];
7306   ssdconemothersection[6] = ssdpconezsection[13];
7307   ssdconemothersection[7] = fgkSSDPConeLength;
7308   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7309   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7310                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7311   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7312   /////////////////////////////////////////////////////////////
7313   //Placing the Volumes into Mother 
7314   /////////////////////////////////////////////////////////////
7315   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7316   for(Int_t i=0; i<6; i++){
7317         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7318   }
7319   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7320   for(Int_t i=0; i<8; i++){
7321     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7322   }
7323   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7324   for(Int_t i=0; i<8; i++){
7325     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7326   }
7327   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7328   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7329   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7330   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7331   /////////////////////////////////////////////////////////////
7332   // ITS General Support
7333   /////////////////////////////////////////////////////////////
7334   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7335                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7336   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7337   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7338                                                                              - fgkSSDCentralAL3SupportLength);
7339   ssdcentralsupport->SetLineColor(4);
7340   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7341   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7342                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7343   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7344   TGeoTranslation* ssdcentralal3supportrans[3]; 
7345   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7346   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7347                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7348   ssdcentralal3support->SetLineColor(4);
7349   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7350   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7351   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7352   Double_t ssdpconcentralradiusmin[2];
7353   Double_t ssdpconcentralradiusmax[2];
7354   Double_t ssdpconcentralsection[2];
7355   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7356   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7357   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7358   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7359   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7360   ssdpconcentralsection[1] = 0.;
7361   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7362                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7363   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7364   ssdpconcentralal3->SetLineColor(4);
7365   fSSDCone->AddNode(ssdpconcentralal3,1);
7366   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7367   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7368   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7369                                                                 -2.*fgkSSDCentralAL3SupportLength);
7370   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7371                                                                                                                      *ssdcentralal3supportrot);
7372   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7373   TGeoRotation* ssdconemotherot = new TGeoRotation();
7374   ssdconemotherot->SetAngles(90.,180.,-90.);
7375   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7376                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7377   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7378   fSSDCone->AddNode(ssdconemother,1);
7379   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7380   /////////////////////////////////////////////////////////////
7381   // Deallocating memory
7382   /////////////////////////////////////////////////////////////
7383   delete ssdcentralal3supportrot;
7384   delete ssdcentralal3supportrans[2];
7385   delete ssdconemotherot;
7386   delete ssdconemothertrans;
7387   /////////////////////////////////////////////////////////////
7388  }
7389  ////////////////////////////////////////////////////////////////////////////////
7390  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7391   /////////////////////////////////////////////////////////////
7392   // Setting SSD Cables
7393   /////////////////////////////////////////////////////////////
7394   if (! moth) {
7395     AliError("Can't insert SSD Cables, mother is null!\n");
7396     return;
7397   };
7398   TGeoVolume* ssdcables = SetSSDCables();
7399   moth->AddNode(ssdcables,1);
7400 }
7401  ////////////////////////////////////////////////////////////////////////////////
7402  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7403   /////////////////////////////////////////////////////////////
7404   // Method generating SSDCables
7405   /////////////////////////////////////////////////////////////
7406   // SSD Layer 5 Cables
7407   //////////////////////////////////////////////////////////////////////////////////////////////////
7408   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7409   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7410   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7411   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7412   //////////////////////////////////////////////////////////////////////////////////////////////////
7413   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7414   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7415                                                                             -  fgkSSDLowerPConeRadius)
7416                                                                             * TanD(fgkSSDPConeAngle);
7417   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7418                                                                               + fgkEndCapSupportCenterLay5Position
7419                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7420   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7421                                                                            - ssdcableslay5startconedistance; 
7422   ssdcablelay5rightsidelength *= ssdcablesfactor;
7423   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7424   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7425                                                                                                 ssdcableslay5rightsideradiusmax,
7426                                                                                                 0.5*ssdcablelay5rightsidelength); 
7427   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7428                                                                                                          ssdcablelay5rightubeshape,
7429                                                                                                          fSSDCopper);
7430   ssdcablelay5righttube->SetLineColor(9);
7431   TGeoTranslation* ssdcablelay5rightrans = 
7432                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7433                                                                                  +              fgkEndCapSupportCenterLay5Position
7434                                                                                  +      0.5*ssdcablelay5rightsidelength);
7435   ////////////////////////////////////
7436   //  Double_t cablescapacity[20];
7437   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7438   ////////////////////////////////////
7439   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7440   ////////////////////////////////////
7441   // TGeoPCone Volumes
7442   ///////////////////////////////////
7443   TGeoPcon* ssdcableslay5pconshape[3];
7444   TGeoVolume* ssdcableslay5pcon[3]; 
7445   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7446   Double_t ssdcableslay5pconzsection[6];
7447   Double_t ssdcableslay5pconrmin[6];
7448   Double_t ssdcableslay5pconrmax[6];
7449   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7450   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7451   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7452   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7453   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7454                                                            + fgkEndCapSupportCenterLay5Position
7455                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7456   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7457                                                            + fgkSSDCentralAL3SupportLength
7458                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7459                                                            * TanD(fgkSSDPConeAngle);      
7460   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7461                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7462   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7463                                                            ssdcableslay5pconshape[0],fSSDCopper);
7464   ssdcableslay5pcon[0]->SetLineColor(9);
7465   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7466 ////////////////////////////////////
7467 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7468 ////////////////////////////////////
7469   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7470   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7471                                                            + fgkSSDCentralAL3SupportLength
7472                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7473                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7474   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7475                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7476                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7477   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7478                                                                                    ssdcableangle,2);   
7479   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7480   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7481   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7482                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7483   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7484   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7485   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7486                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7487   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7488   ssdcableslay5pcon[1]->SetLineColor(9);
7489   ////////////////////////////////////
7490   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7491                                                                                    ssdcableangle,2);   
7492   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7493   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7494   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7495   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7496   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7497   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7498                                                            * TanD(fgkSSDPConeAngle)
7499                                                            + 0.5*fgkSSDCentralSupportLength
7500                                                            + fgkSSDCentralAL3SupportLength;
7501   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7502   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7503                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7504   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7505   ssdcableslay5pcon[2]->SetLineColor(9);
7506 ////////////////////////////////////
7507   TGeoRotation* ssdcableslay5pconrot[4];        
7508   for(Int_t i=0; i<4; i++){
7509    ssdcableslay5pconrot[i] = new TGeoRotation();
7510    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7511    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7512    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7513   }
7514   ////////////////////////////////////
7515   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7516   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7517   ////////////////////////////////////
7518   // Positioning Left SSD Cables Part
7519   ////////////////////////////////////
7520   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7521                                                                                                         - 0.5*ssdcablelay5rightsidelength
7522                                                                                                         - fgkEndCapSupportCenterLay5Position
7523                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7524   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7525   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7526   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7527   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7528   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7529   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7530         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7531         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7532     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7533   }
7534   ////////////////////////////////////
7535   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7536   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7537   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7538   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7539   /////////////////////////////////////////////////////////////
7540   // Water Tubes Layer 5
7541   /////////////////////////
7542   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7543                                                                                      ssdcableslay5rightsideradiusmax
7544                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7545                                                                                      0.5*ssdcablelay5rightsidelength); 
7546   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7547                                                                                                          ssdcablelay5rightubewatershape,
7548                                                                                                          fSSDCoolingTubeWater);
7549   ssdcablelay5rightwatertube->SetLineColor(7);
7550   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7551   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7552   ////////////////////////////////////
7553   // TGeoPCone Water Volumes Layer 
7554   ///////////////////////////////////
7555   TGeoPcon* ssdcableslay5pconwatershape[3];
7556   TGeoVolume* ssdcableslay5pconwater[3]; 
7557   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7558   Double_t ssdcableslay5pconwaterzsection[6];
7559   Double_t ssdcableslay5pcwateronrmin[6];
7560   Double_t ssdcableslay5pconwaterrmax[6];
7561   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7562   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7563                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7564   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7565   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7566                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7567   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7568   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7569   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7570                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7571   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7572                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7573   ssdcableslay5pconwater[0]->SetLineColor(7);
7574   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7575   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7576 ////////////////////////////////////
7577   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7578   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7579   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7580                                                                                                 ssdcableangle,2);   
7581   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7582   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7583                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7584   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7585   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7586                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7587   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7588                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7589   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7590                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7591   ssdcableslay5pconwater[1]->SetLineColor(7);
7592 ////////////////////////////////////
7593   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7594                                                                                                 ssdcableangle,2);   
7595   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7596   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7597                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7598   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7599   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7600                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7601   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7602   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7603   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7604                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7605   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7606                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7607   ssdcableslay5pconwater[2]->SetLineColor(7);
7608 ////////////////////////////////////
7609   TGeoRotation* ssdcableslay5pconwaterot[4];    
7610   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7611   for(Int_t i=0; i<4; i++){
7612    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7613    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7614    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7615         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7616         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7617         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7618         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7619         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7620   }
7621   /////////////////////////
7622   // SSD Layer 6 Cables
7623   /////////////////////////
7624   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7625   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7626   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7627   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7628                                                                                                 ssdcableslay6rightsideradiusmax,
7629                                                                                                 0.5*ssdcablelay6rightsidelength); 
7630   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7631                                                                                                          ssdcablelay6rightubeshape,
7632                                                                                                          fSSDCopper);
7633   ssdcablelay6righttube->SetLineColor(9);
7634   TGeoTranslation* ssdcablelay6rightrans = 
7635                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7636                                                                                  +              fgkEndCapSupportCenterLay6Position
7637                                                                                  +      0.5*ssdcablelay6rightsidelength);
7638   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7639                                                                                                         - 0.5*ssdcablelay6rightsidelength
7640                                                                                                         - fgkEndCapSupportCenterLay6Position
7641                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7642   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7643   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7644   ////////////////////////////////////
7645   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7646   ////////////////////////////////////
7647   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7648                                                                                    ssdcableangle,2);   
7649   TGeoVolume* ssdcableslay6pcon;
7650   Double_t ssdcableslay6pconrmin[2];
7651   Double_t ssdcableslay6pconrmax[2];
7652   Double_t ssdcableslay6pconzsection[2];
7653   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7654   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7655   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7656   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7657   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7658                                                            + fgkEndCapSupportCenterLay6Position
7659                                                            + ssdcablelay6rightsidelength;
7660   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7661   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7662                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7663   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7664                                                            ssdcableslay6pconshape,fSSDCopper);
7665   ssdcableslay6pcon->SetLineColor(9);
7666   for(Int_t i=0; i<4; i++){
7667    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7668    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7669   }
7670   ////////////////////////////////////
7671   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7672   /////////////////////////
7673   // Water Tubes Layer 6
7674   /////////////////////////
7675   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7676                                                                                                                   ssdcableslay6rightsideradiusmax
7677                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7678                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7679   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7680                                                                                                          ssdcablelay6righwatertubeshape,
7681                                                                                                          fSSDCoolingTubeWater);
7682   ssdcablelay6rightwatertube->SetLineColor(7);
7683   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7684   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7685   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7686                                                                                    ssdcableangle,2);   
7687   TGeoVolume* ssdcableslay6waterpcon;
7688   Double_t ssdcableslay6waterpconrmin[2];
7689   Double_t ssdcableslay6waterpconrmax[2];
7690   Double_t ssdcableslay6waterpconzsection[2];
7691   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7692   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7693                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7694   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7695   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7696   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7697                                                            + fgkEndCapSupportCenterLay6Position
7698                                                            + ssdcablelay6rightsidelength;
7699   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7700   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7701                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7702   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7703                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7704   ssdcableslay6waterpcon->SetLineColor(7);
7705   TGeoRotation* ssdcableslay6pconwaterot[4];    
7706   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7707   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7708   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7709   for(Int_t i=0; i<4; i++){
7710    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7711    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7712    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7713                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7714    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7715    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7716   }
7717   ////////////////////////////////////////
7718   // From ITS Ring to Patch Panel3-RB26
7719   ////////////////////////////////////////
7720   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7721   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7722   Double_t ssdcablepatchpanel3RB26zsection[2];
7723   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeight+2.8;
7724   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7725                                                                           + fgkSSDCablesLay5RightSideHeight
7726                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7727   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7728   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7729                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7730                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7731   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7732                                                                                  + fgkSSDCentralAL3SupportLength
7733                                                                                  + fgkSSDPConeZLength[0];
7734   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7735   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7736                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7737                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7738   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7739                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7740   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7741                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7742   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7743   TGeoRotation* ssdcablepatchpanel3B26rot[4];
7744   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7745   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7746   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7747                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7748   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7749   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7750                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7751   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7752   ////////////////////////////////////
7753   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7754   ////////////////////////////////////////
7755   //  ITS Ring Cables RB26 Part
7756   ////////////////////////////////////////
7757   Double_t ssdcableitsring3BB26pconzsection[2];
7758   Double_t ssdcableitsring3BB26pconrmin[2];
7759   Double_t ssdcableitsring3BB26pconrmax[2];
7760   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7761                                                                           + fgkSSDCentralAL3SupportLength
7762                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7763   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7764   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7765   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7766                                                                   + fgkSSDCablesLay5RightSideHeight
7767                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7768   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7769   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7770   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7771   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7772                                                                    -              0.5*ssdcableangle,ssdcableangle
7773                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7774                                                                    -                             fgkSSDCableAngle),2);
7775   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7776                                                                    -              0.5*ssdcableangle,ssdcableangle
7777                                                                    +                      3.0*fgkSSDCableAngle
7778                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7779   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7780                                                                    -              0.5*ssdcableangle,ssdcableangle
7781                                                                    -                      fgkSSDCableAngle
7782                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7783   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7784                                                                    -              0.5*ssdcableangle,ssdcableangle
7785                                                                    +                      3.0*fgkSSDCableAngle
7786                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7787   for(Int_t i=0;i<4;i++)
7788         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7789                                                          ssdcableitsring3BB26pconrmin[j],
7790                                                          ssdcableitsring3BB26pconrmax[j]); 
7791   TGeoVolume* ssdcableitsring3BB26pcon[4];
7792   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7793                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7794   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7795                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7796   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7797                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7798   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7799                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7800   for(Int_t i=0;i<4;i++){
7801         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7802         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7803 }
7804   ////////////////////////////////////
7805   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7806   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7807   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7808   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7809   ////////////////////////////////////////
7810   // From ITS Ring to Patch Panel2-RB24
7811   ////////////////////////////////////////
7812   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7813   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7814   Double_t ssdcablepatchpanel3RB24zsection[2];
7815   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7816   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7817   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7818   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7819                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7820                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7821                                                                           + 0.5*fgkSSDPatchPanelHeight;
7822   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7823                                                                          -  fgkSSDCentralAL3SupportLength
7824                                                                          -  fgkSSDPConeZLength[0];
7825   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
7826   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
7827                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7828                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7829   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
7830                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
7831   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
7832                                                                                                 ssdcablepatchpanel3RB24pconshape,
7833                                                                                                 fSSDCopper);
7834   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
7835   TGeoRotation* ssdcablepatchpanel3B24rot[4];
7836   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
7837   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
7838   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
7839                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7840   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
7841   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
7842                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7843   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
7844   ////////////////////////////////////
7845   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
7846   ////////////////////////////////////////
7847   //  ITS Ring Cables RB24 Part
7848   ////////////////////////////////////////
7849   Double_t ssdcableitsring3BB24pconzsection[2];
7850   Double_t ssdcableitsring3BB24pconrmin[2];
7851   Double_t ssdcableitsring3BB24pconrmax[2];
7852   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
7853   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
7854   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7855   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
7856                                                                   + fgkSSDCablesLay5RightSideHeight
7857                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7858   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
7859   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
7860   TGeoPcon* ssdcableitsring3BB24pconshape[4];
7861   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7862                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7863                                                                    -                             fgkSSDCableAngle),2);
7864   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
7865                                                                      ssdcableangle-fgkSSDCableAngle
7866                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7867   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7868                                                                    -                      fgkSSDCableAngle
7869                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
7870   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
7871                                                                                                   ssdcableangle-fgkSSDCableAngle
7872                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7873   for(Int_t i=0;i<4;i++)
7874         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
7875                                                          ssdcableitsring3BB24pconrmin[j],
7876                                                          ssdcableitsring3BB24pconrmax[j]); 
7877   TGeoVolume* ssdcableitsring3BB24pcon[4];
7878   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
7879                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
7880   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
7881                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
7882   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
7883                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
7884   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
7885                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
7886   for(Int_t i=0;i<4;i++){
7887         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
7888         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
7889 }
7890   ////////////////////////////////////
7891   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
7892   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
7893   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
7894   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
7895   ////////////////////////////////////
7896   // Volumes for Material Budget 
7897   ////////////////////////////////////
7898   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
7899                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
7900                                                                                                          ssdcableslay6rightsideradiusmax
7901                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
7902                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
7903   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
7904                                                                                                          ssdcablelay6materialbudgetubeshape,
7905                                                                                                          fSSDCopper);
7906   ssdcablelay6materialbudgetube->SetLineColor(9);
7907   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
7908   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
7909
7910   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
7911                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
7912   TGeoVolume* ssdcablelay6materialbudgetpcon;
7913   Double_t ssdcablelay6materialbudgetpconrmin[2];
7914   Double_t ssdcablelay6materialbudgetpconrmax[2];
7915   Double_t ssdcablelay6materialbudgetpconzsection[2];
7916   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
7917                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7918   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
7919                                                                                 + fgkSSDCableMaterialBudgetHeight;
7920   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
7921   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
7922   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7923                                                                                         + fgkEndCapSupportCenterLay6Position
7924                                                                                         + ssdcablelay6rightsidelength;
7925   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7926   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
7927                                                   ssdcablelay6materialbudgetpconzsection[i],
7928                                                   ssdcablelay6materialbudgetpconrmin[i],
7929                                                   ssdcablelay6materialbudgetpconrmax[i]); 
7930   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
7931                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
7932   ssdcablelay6materialbudgetpcon->SetLineColor(9);
7933   for(Int_t i=0; i<4; i++){
7934    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
7935    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7936   }
7937 ////////////////////////////////////
7938  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
7939   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
7940   Double_t ssdcablesvolume = 0.0;
7941   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
7942   std::cout << ssdcablesvolume << std::endl;*/
7943   return ssdcablesmother;
7944  }
7945  ////////////////////////////////////////////////////////////////////////////////
7946 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3 const * const vertexpos[4] , const Double_t* width, 
7947                                             Double_t height, const char* shapename, Int_t isign) const{
7948   /////////////////////////////////////////////////////////////
7949   // Method generating an Arb shape 
7950   /////////////////////////////////////////////////////////////
7951   const Int_t kvertexnumber = 8;
7952   const Int_t ktransvectnumber = 2;
7953   TVector3 vertex[kvertexnumber];
7954   TVector3 transvector[2];
7955   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
7956   /////////////////////////////////////////////////////////////
7957   //Setting the vertices for TGeoArb8
7958   /////////////////////////////////////////////////////////////
7959   vertex[0] = *vertexpos[0];
7960   vertex[1] = *vertexpos[1];
7961   vertex[2] = vertex[1]; 
7962   vertex[3] = vertex[0]; 
7963   vertex[4] = *vertexpos[2];
7964   vertex[5] = *vertexpos[3];
7965   vertex[6] = vertex[5];
7966   vertex[7] = vertex[4];
7967
7968   // NB: order of points is clockwise
7969   if (isign < 0) {
7970     vertex[2] -= transvector[0];
7971     vertex[3] -= transvector[0];
7972     vertex[6] -= transvector[1];
7973     vertex[7] -= transvector[1];
7974   }
7975   else {
7976     vertex[0] += transvector[0];
7977     vertex[1] += transvector[0];
7978     vertex[4] += transvector[1];
7979     vertex[5] += transvector[1];
7980   }
7981
7982   /////////////////////////////////////////////////////////////
7983   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
7984   for(Int_t i = 0; i<kvertexnumber;i++) {
7985     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
7986   }
7987
7988   return arbshape;
7989
7990 ///////////////////////////////////////////////////////////////////////////////
7991 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
7992                                                                 Double_t rmax, Int_t nedges, Double_t height){
7993   /////////////////////////////////////////////////////////////
7994   // Method generating Arc shape 
7995   /////////////////////////////////////////////////////////////
7996         const Int_t kvertexnumber = 2*nedges+2;
7997         TGeoXtru* arcshape = new TGeoXtru(2);   
7998         TVector3** vertexposition[2];
7999         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8000         Double_t angle = 0.;
8001     for(Int_t i=0; i<nedges+1; i++){ 
8002                 angle = 90.+0.5*phi-i*(phi/nedges);
8003                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8004                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8005         }
8006         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8007         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8008         for(Int_t i=0; i<kvertexnumber; i++){ 
8009                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8010                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8011                 }
8012                 else if(i>=1&&i<nedges+2)
8013                 {
8014                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8015                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8016                 }
8017         else
8018                 {
8019                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8020                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8021                 }
8022     }
8023   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8024   arcshape->DefineSection(0,-0.5*height);
8025   arcshape->DefineSection(1,0.5*height);
8026   /////////////////////////////////////////////////////////////
8027   // Deallocating memory
8028   /////////////////////////////////////////////////////////////
8029   for(Int_t i=0; i<2; i++){
8030         for(Int_t j=0; j<nedges+1; j++)
8031                 delete vertexposition[i][j];
8032         delete [] vertexposition[i];
8033   }
8034   delete [] xvertexpoints;
8035   delete [] yvertexpoints;
8036   /////////////////////////////////////////////////////////////
8037         return arcshape;
8038 }
8039 ////////////////////////////////////////////////////////////////////////////////
8040 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(const Double_t* radius,const Int_t* edgesnumber,const Double_t* section) const {
8041   ///////////////////////////////////////////////////////////////////////
8042   // Method Generating the Screw Shape  
8043   // radius[0]: outer radius
8044   // radius[1]: inner radius
8045   // edgesnumber[0]: outer number of edges
8046   // edgesnumber[1]: inner number of edges
8047   // section[0]: lower section position
8048   // section[1]: higher section position
8049   ///////////////////////////////////////////////////////////////////////
8050   Double_t outradius = radius[0];
8051   Double_t inradius = radius[1];
8052   Int_t outvertexnumber = edgesnumber[0];
8053   Int_t invertexnumber = edgesnumber[1];
8054   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8055   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8056   for(Int_t i=0; i<outvertexnumber; i++){
8057         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8058         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8059   }
8060   for(Int_t i=0; i<invertexnumber; i++){
8061         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8062         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8063   }
8064   TGeoXtru* screwshapeout = new TGeoXtru(2);
8065   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8066   screwshapeout->DefineSection(0,section[0]);
8067   screwshapeout->DefineSection(1,section[1]);
8068   TGeoXtru* screwshapein = new TGeoXtru(2);
8069   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8070   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8071   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8072   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8073   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8074   
8075   delete [] xscrewvertex;
8076   delete [] yscrewvertex;
8077   return screwshape;
8078 }
8079 ////////////////////////////////////////////////////////////////////////////////
8080 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, const Double_t *section) const {
8081   ///////////////////////////////////////////////////////////////////////
8082   // Method Generating the Hole Shape  
8083   // radius of the Hole
8084   // nedges: number of edges to approximate the circle
8085   ///////////////////////////////////////////////////////////////////////
8086   Double_t* xholevertex = new Double_t[nedges];
8087   Double_t* yholevertex = new Double_t[nedges];
8088   Double_t z  = 0.5*(section[0]+section[1]);
8089   Double_t dz = 0.5*(section[1]-section[0]);
8090   TGeoTranslation *tr = 0;
8091   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8092      tr = new TGeoTranslation(0.,0.,z);
8093      tr->RegisterYourself();
8094   }   
8095   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8096   for(Int_t i=0; i<nedges; i++){
8097         xholevertex[i] = radius*CosD(i*360./nedges);
8098         yholevertex[i] = radius*SinD(i*360./nedges);
8099   }
8100   TGeoXtru* holeshapeout = new TGeoXtru(2);
8101   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8102   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8103   holeshapeout->DefineSection(1,section[1]+0.01);
8104   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8105   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8106   
8107   delete [] xholevertex;
8108   delete [] yholevertex;
8109   return holeshape;
8110 }
8111 ////////////////////////////////////////////////////////////////////////////////
8112 TVector3* AliITSv11GeometrySSD::GetReflection(const TVector3* vector,const Double_t* param) const{
8113   /////////////////////////////////////////////////////////////
8114   // Given an axis specified by param, it gives the reflection of the point
8115   // respect to the axis
8116   /////////////////////////////////////////////////////////////
8117   TVector3* n = new TVector3(param[0],param[1],param[2]);
8118   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8119   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8120   /////////////////////////////////////////////////////////////
8121   // Deallocating memory
8122   /////////////////////////////////////////////////////////////
8123   delete n;
8124   /////////////////////////////////////////////////////////////
8125   return reflectedvector;
8126 }
8127 ////////////////////////////////////////////////////////////////////////////////
8128 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(const TGeoHMatrix* ct,
8129                                                        Double_t dx,
8130                                                        Double_t dy,
8131                                                        Double_t dz) const{
8132   /////////////////////////////////////////////////////////////
8133   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8134   /////////////////////////////////////////////////////////////
8135   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8136   const Double_t *vect = hmatrix->GetTranslation();
8137   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8138   hmatrix->SetTranslation(newvect);
8139   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8140   delete hmatrix;
8141   return matrix;
8142 }
8143 ////////////////////////////////////////////////////////////////////////////////
8144 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8145   /////////////////////////////////////////////////////////////
8146   // Method returning the Medium type 
8147   /////////////////////////////////////////////////////////////
8148   char ch[100];
8149   snprintf(ch,100, "ITS_%s",mediumName);
8150   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8151   if (! medium)
8152     AliError(Form("medium %s not found !\n", mediumName));
8153   return medium;
8154 }
8155 ////////////////////////////////////////////////////////////////////////////////
8156 void AliITSv11GeometrySSD::CreateMaterials(){
8157 ///////////////////////////////////
8158 // This part has to be modified
8159 ///////////////////////////////////
8160   ///////////////////////////////////
8161   // Silicon for Sensor
8162   /////////////////////////////////// 
8163   fSSDSensorMedium = GetMedium("SI$");
8164   ///////////////////////////////////
8165   // Silicon Mixture for Sensor
8166   /////////////////////////////////// 
8167   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8168   fSSDChipGlueMedium = GetMedium("EPOXY$");
8169   ///////////////////////////////////
8170   // Stiffener Components Materials
8171   /////////////////////////////////// 
8172   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8173   ///////////////////////////  
8174   // Stiffener Connectors 
8175   ///////////////////////////  
8176   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8177   ////////////////////////////////  
8178   // Stiffener 0603-1812 Capacitor
8179   ////////////////////////////////  
8180   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8181   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8182   fSSDStiffenerCapacitorCapMedium = GetMedium("NiSn$");
8183   ///////////////////////////  
8184   // Stiffener Hybrid Wire 
8185   ///////////////////////////  
8186   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8187   ///////////////////////////  
8188   // Al for Cooling Block
8189   ///////////////////////////  
8190   fSSDAlCoolBlockMedium = GetMedium("AL$");
8191   //////////////////////////////////////////////////////  
8192   // Kapton and Al for Chip Cable Flex and Ladder Cables
8193   //////////////////////////////////////////////////////  
8194   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8195   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8196   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8197   fSSDAlTraceFlexMedium = GetMedium("AL$");
8198   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8199   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8200   /////////////////////////////////////////////////////////////////  
8201   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8202   //////////////////////////////////////////////////////////////////  
8203   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8204   /////////////////////////////////////////////////////////////////  
8205   // G10 for Detector Leg, TubeHolder
8206   //////////////////////////////////////////////////////////////////  
8207   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8208   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8209   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8210   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8211   /////////////////////////////////////////////////////////////////  
8212   // Water and Phynox for Cooling Tube
8213   //////////////////////////////////////////////////////////////////  
8214   fSSDCoolingTubeWater = GetMedium("WATER$");
8215   fSSDCoolingTubePhynox = GetMedium("INOX$");
8216   /////////////////////////////////////////////////////////////////////
8217   // Material for Support Rings
8218   /////////////////////////////////////////////////////////////////////
8219   fSSDSupportRingAl = GetMedium("AL$");
8220   fSSDRohaCellCone = GetMedium("ROHACELL$");
8221   /////////////////////////////////////////////////////////////////////
8222   fSSDAir = GetMedium("SDD AIR$");
8223   fSSDCopper = GetMedium("COPPER$");
8224   fSSDSn = GetMedium("Sn$");
8225   fCreateMaterials = kTRUE;
8226 }
8227 /////////////////////////////////////////////////////////////////////
8228