]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Script to draw occupancies
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41
42 /////////////////////////////////////////////////////////////////////////////////
43 // Names of the Sensitive Volumes of Layer 5 and Layer 6
44 /////////////////////////////////////////////////////////////////////////////////
45 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
47 /////////////////////////////////////////////////////////////////////////////////
48 //Parameters for SSD Geometry
49 /////////////////////////////////////////////////////////////////////////////////
50 // Variable for Vertical Disalignement of Modules
51 /////////////////////////////////////////////////////////////////////////////////
52 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
55 // For ladders:
56 const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.520*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.295*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603CapLength  =  0.900*fgkmm;  // Includes solder
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
97 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812CapLength  =  0.215*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   1.400*fgkmm;   
101 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = {44.32*fgkmm, 0.33*fgkmm};
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
105 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       =   0.25*fgkSSDStiffenerHeight;
108 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
109 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSnHeight     =   0.15*fgkmm;
111 /////////////////////////////////////////////////////////////////////////////////
112 // Cooling Block (lengths are in mm and angles in degrees)
113 /////////////////////////////////////////////////////////////////////////////////
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
117                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
119   {1.025*fgkmm, 0.120*fgkmm};  // Added 50 micron tolerance for thicker wall cooling pipe (March 2010)
120 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
121                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
122 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
123                                                                                                                                          1.500*fgkmm;
124 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
125                                                                                                                                          0.300*fgkmm;
126 /////////////////////////////////////////////////////////////////////////////////
127 // SSD Sensor (lengths are in mm and angles in degrees)
128 /////////////////////////////////////////////////////////////////////////////////
129 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
130                                                                                                                  "SSDSensorSensitiveVol";
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
132 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
135                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
136 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
137 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
138 /////////////////////////////////////////////////////////////////////////////////
139 // Flex (lengths are in mm and angles in degrees)
140 /////////////////////////////////////////////////////////////////////////////////
141 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
143                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
144                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
145                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
146                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
147                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
149                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
151                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
152 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
153 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
154 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
155 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
156                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
157 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
158                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
159 /////////////////////////////////////////////////////////////////////////////////
160 // SSD Ladder Cable (lengths are in mm and angles in degrees)
161 /////////////////////////////////////////////////////////////////////////////////
162 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
163 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableHeight[2] = {  0.030*fgkmm*17.5/23.5,  1.25 * 0.030*fgkmm};   // Al covers ~ 17.5/23.5 of surface, Kapton includes glue+foam   
164 /////////////////////////////////////////////////////////////////////////////////
165 // SSD Module (lengths are in mm and angles in degrees)
166 /////////////////////////////////////////////////////////////////////////////////
167 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
168                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
169 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
170                                                                                                                                         45.600*fgkmm;
171 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
172                                                                                                                                          5.075*fgkmm;
173 /////////////////////////////////////////////////////////////////////////////////
174 // Sensor Support (lengths are in mm and angles in degrees)
175 /////////////////////////////////////////////////////////////////////////////////
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
177                                                                                                                                          5.800*fgkmm;
178 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
179                                                                                                                                          2.000*fgkmm;
180 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
181                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
182                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
183 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
184 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
185 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
186                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
187 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
188                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
189                                                             +  fgkSSDSensorSideSupportThickness[0])
190                                                                 -  fgkSSDSensorSideSupportLength;
191 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
192                                                                                                                                     5.250*fgkmm;
193 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
194                                                                                                                                         1.680*fgkmm;
195 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
196                                                                   = {fgkSSDSensorSideSupportHeight[0]
197                                                                   +  fgkSSDSensorSideSupportThickness[0],
198                                                                          fgkSSDSensorSideSupportHeight[1]
199                                                                   +  fgkSSDSensorSideSupportThickness[1]};
200 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
201                                                                   =  {fgkSSDSensorSideSupportThickness[0],
202                                                                           fgkSSDSensorSideSupportThickness[1]};
203 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
204                                                                                                                                    19.000*fgkmm;
205 /////////////////////////////////////////////////////////////////////////////////
206 // Chip Cables (lengths are in mm and angles in degrees)
207 /////////////////////////////////////////////////////////////////////////////////
208 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
209                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
210 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
211                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
212                                                                   -  (fgkSSDSensorSideSupportHeight[1]
213                                                                   -   fgkSSDSensorSideSupportHeight[0])
214                                                                   -   fgkSSDModuleVerticalDisalignment
215                                                                   -   fgkSSDCoolingBlockHoleCenter
216                                                                   -   fgkSSDStiffenerHeight
217                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
218                                                                           fgkSSDModuleCoolingBlockToSensor
219                                                                   -   fgkSSDModuleVerticalDisalignment  
220                                                                   -   fgkSSDCoolingBlockHoleCenter
221                                                                   -       fgkSSDStiffenerHeight
222                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
223 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
224                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
225 /////////////////////////////////////////////////////////////////////////////////
226 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
227 /////////////////////////////////////////////////////////////////////////////////
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
229                                                                                                                                         3.820*fgkmm;
230 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
231 //                                                                                                                                         3.780;
232 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
233                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
235                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
236 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
237                                                                                                                                 { 30.00, 90.00};
238 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
239                                                                                                                                          1.78*fgkmm;
240 /////////////////////////////////////////////////////////////////////////////////
241 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
242 /////////////////////////////////////////////////////////////////////////////////
243 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
244                                                                    = fgkSSDModuleSensorSupportDistance
245                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
247 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
248                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
249 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
250                                                                                                                                         1.630*fgkmm;
251 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
252 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
253                                                                         = fgkCarbonFiberTriangleLength
254                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
255                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
256                                                                         * TMath::DegToRad());
257 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
258                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
259                                                                         - fgkCarbonFiberSupportWidth)
260                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
261                                                                         - fgkCarbonFiberSupportWidth;
262 /////////////////////////////////////////////////////////////////////////////////
263 // Carbon Fiber Lower Support Parameters (lengths are in mm)
264 /////////////////////////////////////////////////////////////////////////////////
265 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
266 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
267                                                                                                                                           =  0.950*fgkmm;
268 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
269                                                                                                                                           =  1.600*fgkmm;
270 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
271                                                                                                                                           =  0.830*fgkmm;
272 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
273                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
274 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
275                                                                         = fgkCarbonFiberJunctionWidth
276                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
277                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
278 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
279                                                                         = {fgkCarbonFiberLowerSupportWidth
280                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
281                                                                            fgkCarbonFiberLowerSupportWidth
282                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
283                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
284 /////////////////////////////////////////////////////////////////////////////////
285 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
286 /////////////////////////////////////////////////////////////////////////////////
287 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
288                                                            {0.5 * (fgkSSDLay5LadderLength
289                                                                         -  fgkSSDLay5SensorsNumber
290                                                                         *  fgkCarbonFiberJunctionWidth
291                                                                         -  fgkCarbonFiberLowerSupportWidth),
292                                                                 0.5 * (fgkSSDLay5LadderLength
293                                                                         -  fgkSSDLay5SensorsNumber
294                                                                         *  fgkCarbonFiberJunctionWidth
295                                                                         +  fgkCarbonFiberLowerSupportWidth)};
296 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
297                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
298                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
299 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
300                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
301                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
302 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
303                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
304 /////////////////////////////////////////////////////////////////////////////////
305 // Cooling Tube Support (lengths are in mm and angles in degrees)
306 /////////////////////////////////////////////////////////////////////////////////
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
309                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
312 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
313 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
314                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
315 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
316                                                                                                                                           11.70*fgkmm;
317 /////////////////////////////////////////////////////////////////////////////////
318 // Cooling Tube (lengths are in mm and angles in degrees)
319 /////////////////////////////////////////////////////////////////////////////////
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
321 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  1.915*fgkmm/2; // Nominal + 50 micron tolerance; real pipes are closer to 450 micron wall thickness
322 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
323                                                                                                         fgkCarbonFiberJunctionWidth;
324 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
325                                                                          fgkSSDModuleSensorSupportDistance
326                                                                   +      fgkSSDCoolingBlockLength;
327 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
328 /////////////////////////////////////////////////////////////////////////////////
329 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
330 /////////////////////////////////////////////////////////////////////////////////
331 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
332                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
333 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
334                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
335 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
336                                                                                                                                           20.0*fgkmm;
337 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
338                                                                                                                                                     40.0;
339 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
340                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
341 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
342                                                                                                                                           2.5*fgkmm;
343 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
344                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
345 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
346                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
347 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
348                                                                                                                                           1.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
350                                                                                                                                           6.0*fgkmm;
351 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeight      =  
352                                                                                                                                           4.0*fgkmm;
353 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
354                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
355 /////////////////////////////////////////////////////////////////////////////////
356 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
357 /////////////////////////////////////////////////////////////////////////////////
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
359 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
360 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
362 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
363 /////////////////////////////////////////////////////////////////////////////////
364 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
365 /////////////////////////////////////////////////////////////////////////////////
366 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
368 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
369                                                                                                   -  fgkSSDMountingBlockHeight[1]
370                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
371                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
372                                                                                                   -      fgkMountingBlockSupportDownHeight,
373                                                                                                          fgkSSDLay6RadiusMin
374                                                                                                   -  fgkSSDMountingBlockHeight[1]
375                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
376                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
377                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
378 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
379                                                                                                     -  fgkSSDMountingBlockHeight[1]
380                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
381                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
382                                                                                                         -  fgkMountingBlockSupportRadius[0],
383                                                                                                            fgkSSDLay6RadiusMax
384                                                                                                     -  fgkSSDMountingBlockHeight[1]
385                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
386                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
387                                                                                                         -  fgkMountingBlockSupportRadius[1]};
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeight = 10.0*fgkmm; // To be verified
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
390 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
391 /////////////////////////////////////////////////////////////////////////////////
392 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
393 /////////////////////////////////////////////////////////////////////////////////
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
398                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
400                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
401 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
402                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
408 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
409 /////////////////////////////////////////////////////////////////////////////////
410 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
411 /////////////////////////////////////////////////////////////////////////////////
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
414 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
415 /////////////////////////////////////////////////////////////////////////////////
416 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
417 /////////////////////////////////////////////////////////////////////////////////
418 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
419                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
422 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
423                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
424 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
425                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
426 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
427 /////////////////////////////////////////////////////////////////////////////////
428 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
429 /////////////////////////////////////////////////////////////////////////////////
430 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
431                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
432 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
433                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
434                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
435 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
436 /////////////////////////////////////////////////////////////////////////////////
437 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
438 /////////////////////////////////////////////////////////////////////////////////
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
440                                                                                                            {62.0*fgkmm,21.87*fgkmm};
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
442                                                                                                             {47.0*fgkmm,0.35*fgkmm};
443 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
444                                                                                                                                           1.0*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
446 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
447                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
448 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
449                                                                                                                                          0.15*fgkmm;
450 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
451                                                                                                                                          19.0*fgkmm;
452 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
453                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
454 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
455                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
456 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
457                                                                                                                                           2.1*fgkmm;
458 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
459                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
460 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
461                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
462 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
463                                                                                                                                            19*fgkmm; 
464 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
465                                                                                                                                           1.0*fgkmm;
466 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
467                                                                                                                                           3.6*fgkmm;
468 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
469                                                                                                                                          61.0*fgkmm; 
470 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
471                                                                                                                                          5.97*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
474                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
475                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
476 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
477                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
478 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
479                                                                                                                                           1.0*fgkmm; 
480 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
481                                                                                                                                    = 0.15*fgkmm; 
482 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
483                                                                                                                                          20.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
488 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
489 /////////////////////////////////////////////////////////////////////////////////
490 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
491 /////////////////////////////////////////////////////////////////////////////////
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
500 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
501 /////////////////////////////////////////////////////////////////////////////////
502 // SSD Cone Parameters (lengths are in mm and angles in degrees)
503 /////////////////////////////////////////////////////////////////////////////////
504 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
509 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
526 /////////////////////////////////////////////////////////////////////////////////
527 // SSD Cables Parameters (lengths are in mm and angles in degrees)
528 /////////////////////////////////////////////////////////////////////////////////
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
533 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
536 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeight = 87.5*fgkmm;
542 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
544 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
545 /////////////////////////////////////////////////////////////////////////////////
546 ClassImp(AliITSv11GeometrySSD)
547 /////////////////////////////////////////////////////////////////////////////////
548 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
549   AliITSv11Geometry(),
550   fSSDChipMedium(),
551   fSSDChipGlueMedium(),
552   fSSDStiffenerMedium(),
553   fSSDStiffenerConnectorMedium(),
554   fSSDStiffener0603CapacitorMedium(),
555   fSSDStiffener1812CapacitorMedium(),
556   fSSDStiffenerCapacitorCapMedium(),
557   fSSDStiffenerHybridWireMedium(),
558   fSSDKaptonFlexMedium(),
559   fSSDAlTraceFlexMedium(),
560   fSSDAlTraceLadderCableMedium(),
561   fSSDKaptonLadderCableMedium(),
562   fSSDKaptonChipCableMedium(),
563   fSSDAlTraceChipCableMedium(),
564   fSSDAlCoolBlockMedium(),
565   fSSDSensorMedium(),
566   fSSDSensorSupportMedium(),
567   fSSDCarbonFiberMedium(),
568   fSSDTubeHolderMedium(),
569   fSSDCoolingTubeWater(),
570   fSSDCoolingTubePhynox(),
571   fSSDSupportRingAl(),
572   fSSDMountingBlockMedium(),
573   fSSDRohaCellCone(),
574   fSSDAir(),
575   fSSDCopper(),
576   fSSDSn(),
577   fCreateMaterials(kFALSE),
578   fTransformationMatrices(kFALSE),
579   fBasicObjects(kFALSE),
580   fcarbonfiberjunction(),
581   fcoolingtubesupport(),
582   fhybridmatrix(),
583   fssdcoolingblocksystem(),
584   fcoolingblocksystematrix(),
585   fssdstiffenerflex(),
586   fssdendflex(),
587   fcoolingtube(0),
588   fendladdercoolingtubesupportmatrix(),
589   fendladdermountingblock(),
590   fendladdermountingblockclip(),
591   fSSDSensor5(),
592   fSSDSensor6(),
593   fSSDLayer5(), 
594   fSSDLayer6(),
595   fMotherVol(),
596   fLay5LadderSupportRing(),
597   fLay6LadderSupportRing(),
598   fgkEndCapSupportSystem(),
599   fSSDCone(),
600   fColorCarbonFiber(4),
601   fColorRyton(5),
602   fColorPhynox(14),
603   fColorSilicon(3),
604   fColorAl(38),
605   fColorNiSn(40),
606   fColorKapton(6),
607   fColorPolyhamide(5),
608   fColorStiffener(9),
609   fColorEpoxy(30),
610   fColorWater(7),
611   fColorG10(41)
612 {
613   ////////////////////////
614   // Standard constructor
615   ////////////////////////
616
617   for (Int_t i=0; i < fgkcarbonfibersupportnumber; i++) {
618     fcarbonfibersupport[i] = 0;
619     fcarbonfibersupportmatrix[i] = 0;
620   }
621   for (Int_t i=0; i < fgkcarbonfiberjunctionumber; i++) {
622     fcarbonfiberjunctionmatrix[i] = 0;
623   }
624   for (Int_t i=0; i < fgkcarbonfiberlowersupportnumber; i++) {
625     fcarbonfiberlowersupport[i] = 0;
626     fcarbonfiberlowersupportrans[0] = 0;
627   }
628   for (Int_t i=0; i < fgkvolumekind; i++) {
629     fssdsensorsupport[i] = 0;
630   }
631   for (Int_t i=0; i < fgkssdsensorsupportnumber; i++) {
632     fssdsensorsupportmatrix[i] = 0;
633   }
634   for (Int_t i=0; i < fgkcoolingtubesupportnumber; i++) {
635     fcoolingtubesupportmatrix[i] = 0;
636   }
637   for (Int_t i=0; i < fgkhybridcompnumber; i++) {
638     fssdhybridcomponent[i] = 0;
639   }
640   for (Int_t i=0; i < fgkcoolingblocknumber; i++) {
641     fcoolingblockmatrix[i] = 0;
642   }
643   for (Int_t i=0; i < fgkflexnumber; i++) {
644     fstiffenerflexmatrix[i] = 0;
645     fendflexmatrix[i] = 0;
646   }
647   for (Int_t i=0; i < fgkendladdercoolingtubenumber; i++) {
648     fendladdercoolingtube[i] = 0;
649     for (Int_t j = 0; j < 2; j++) 
650       fendladdercoolingtubematrix[i][j] = 0;
651   }
652   for (Int_t i=0; i < fgkendlabbercarbonfiberjunctionumber; i++) {
653     fendladdercarbonfiberjunction[i] = 0;
654   }
655   for (Int_t i=0; i < fgkendladdercarbonfiberjunctionmatrixnumber; i++) {
656     fendladdercarbonfiberjunctionmatrix[i] = 0;
657   }
658   for (Int_t i=0; i < fgkendladdercarbonfibermatrixnumber; i++) {
659     fendladdercarbonfibermatrix[i] = 0;
660   }
661   for (Int_t i=0; i < fgkendladdermountingblocknumber; i++) {
662     fendladdermountingblockclipmatrix[i] = 0;
663   }
664   for (Int_t i = 0; i < fgkendladderlowersuppnumber+1; i++) {
665     fendladderlowersupptrans[i] = 0;
666   }
667   for (Int_t i = 0; i < fgkladdercablesnumber; i++) {
668     fladdercablematrix[i] = 0;
669   }
670   for (Int_t i = 0; i < fgkladdersegmentnumber; i++) {
671     fladdersegment[i] = 0;
672   }
673   for (Int_t i = 0; i < fgkladdernumber; i++) {
674     fladder[i] = 0;
675     fladdermatrix[i] = 0;
676     fssdsensormatrix[i] = 0;
677     flayermatrix[i] = 0;
678   }
679   for (Int_t i = 0; i < 2; i++) {
680     fLay5LadderSupport[i] = 0;
681     fLay6LadderSupport[i] = 0;
682   }
683 }
684 /////////////////////////////////////////////////////////////////////////////////
685 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
686   AliITSv11Geometry(s.GetDebug()),
687   fSSDChipMedium(s.fSSDChipMedium),
688   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
689   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
690   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
691   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
692   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
693   fSSDStiffenerCapacitorCapMedium(s.fSSDStiffenerCapacitorCapMedium),
694   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
695   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
696   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
697   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
698   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
699   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
700   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
701   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
702   fSSDSensorMedium(s.fSSDSensorMedium),
703   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
704   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
705   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
706   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
707   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
708   fSSDSupportRingAl(s.fSSDSupportRingAl),
709   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
710   fSSDRohaCellCone(s.fSSDRohaCellCone),
711   fSSDAir(s.fSSDAir),
712   fSSDCopper(s.fSSDCopper),  
713   fSSDSn(s.fSSDSn),
714   fCreateMaterials(s.fCreateMaterials),
715   fTransformationMatrices(s.fTransformationMatrices),
716   fBasicObjects(s.fBasicObjects),
717   fcarbonfiberjunction(s.fcarbonfiberjunction),
718   fcoolingtubesupport(s.fcoolingtubesupport),
719   fhybridmatrix(s.fhybridmatrix),
720   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
721   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
722   fssdstiffenerflex(s.fssdstiffenerflex),
723   fssdendflex(s.fssdendflex),
724   fcoolingtube(s.fcoolingtube),
725   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
726   fendladdermountingblock(s.fendladdermountingblock),
727   fendladdermountingblockclip(s.fendladdermountingblockclip),
728   fSSDSensor5(s.fSSDSensor5),
729   fSSDSensor6(s.fSSDSensor6),
730   fSSDLayer5(s.fSSDLayer5),     
731   fSSDLayer6(s.fSSDLayer6),
732   fMotherVol(s.fMotherVol),
733   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
734   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
735   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
736   fSSDCone(s.fSSDCone),
737   fColorCarbonFiber(s.fColorCarbonFiber),
738   fColorRyton(s.fColorRyton),
739   fColorPhynox(s.fColorPhynox),
740   fColorSilicon(s.fColorSilicon),
741   fColorAl(s.fColorAl),
742   fColorNiSn(s.fColorNiSn),
743   fColorKapton(s.fColorKapton),
744   fColorPolyhamide(s.fColorPolyhamide),
745   fColorStiffener(s.fColorStiffener),
746   fColorEpoxy(s.fColorEpoxy),
747   fColorWater(s.fColorWater),
748   fColorG10(s.fColorG10)
749 {
750   ////////////////////////
751   // Copy Constructor
752   ////////////////////////
753 }
754 /////////////////////////////////////////////////////////////////////////////////
755 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
756 operator=(const AliITSv11GeometrySSD &s){
757   ////////////////////////
758   // Assignment operator
759   ////////////////////////
760   this->~AliITSv11GeometrySSD();
761   new(this) AliITSv11GeometrySSD(s); 
762   return *this;
763 /*      
764   if(&s == this) return *this;
765   fMotherVol = s.fMotherVol;
766   return *this;
767  */
768 }
769 ///////////////////////////////////////////////////////////////////////////////
770 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
771   ///////////////////////////////////////////////////////////////////////  
772   // Method generating the trasformation matrix for the whole SSD Geometry   
773   ///////////////////////////////////////////////////////////////////////  
774   // Setting some variables for Carbon Fiber Supportmatrix creation
775   //////////////////////////////////////////////////////////////////////
776   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
777                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
778   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
779                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
780                                                                  +      fgkCarbonFiberSupportWidth);
781   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
782                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
783   TGeoRotation* carbonfiberot[3];
784   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
785   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
786   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
787   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
788   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
789                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
790                                                   -  fgkCarbonFiberTriangleLength
791                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
792   ///////////////////////////////////////////
793   //Setting Local Translations and Rotations: 
794   ///////////////////////////////////////////
795   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
796   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
797                                                                          0.5*carbonfibersupportheight,NULL);    
798   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
799                                                                          2.*symmetryplaneposition+transvector[1],
800                                                                          transvector[2], carbonfiberot[2]);
801   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
802   /////////////////////////////////////////////////////////////
803   // Carbon Fiber Support Transformations
804   /////////////////////////////////////////////////////////////
805   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
806   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
807                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
808                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
809                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
810   }             
811   /////////////////////////////////////////////////////////////
812   // Carbon Fiber Junction Transformation
813   /////////////////////////////////////////////////////////////
814   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
815   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
816   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
817   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
818   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
819         localcarbonfiberjunctionmatrix[i] = 
820                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
821         localcarbonfiberjunctionrot[i] = 
822                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
823         localcarbonfiberjunctiontrans[i] = 
824                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
825   }
826   ///////////////////////
827   // Setting Translations
828   ///////////////////////
829   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
830   localcarbonfiberjunctiontrans[1][0] = 
831                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
832   localcarbonfiberjunctiontrans[2][0] = 
833                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
834                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
835                                  fgkCarbonFiberTriangleLength
836                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
837   localcarbonfiberjunctiontrans[0][1] = 
838                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
839   localcarbonfiberjunctiontrans[1][1] = 
840                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
841   localcarbonfiberjunctiontrans[2][1] = 
842                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
843   ////////////////////
844   // Setting Rotations
845   ////////////////////
846   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
847                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
848                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
849   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
850         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
851   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
852   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
853   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
854   ////////////////////////////////////////
855   // Setting Carbon Fiber Junction matrix 
856   ////////////////////////////////////////
857   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
858                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
859                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
860                         localcarbonfiberjunctionmatrix[i][j] = 
861                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
862                                                            *localcarbonfiberjunctionrot[i][j]);
863                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
864          }
865   }
866   /////////////////////////////////////////////////////////////
867   // Carbon Fiber Lower Support Transformations
868   /////////////////////////////////////////////////////////////
869   TGeoTranslation* localcarbonfiberlowersupportrans[2];
870   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
871                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
872                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
873                                                                          0.0);
874   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
875                                                                          fgkCarbonFiberJunctionWidth
876                                                                 -    fgkCarbonFiberLowerSupportWidth
877                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
878                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
879                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
880    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
881    fcarbonfiberlowersupportrans[0] = 
882                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
883    fcarbonfiberlowersupportrans[1] = 
884                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
885   /////////////////////////////////////////////////////////////
886   // SSD Sensor Support Transformations
887   /////////////////////////////////////////////////////////////
888   const Int_t kssdsensorsupportmatrixnumber = 3;
889   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
890   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
891   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
892   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
893         localssdsensorsupportmatrix[i] = 
894                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
895         localssdsensorsupportrot[i] = 
896                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
897         localssdsensorsupportrans[i] = 
898                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
899   }
900   ///////////////////////
901   // Setting Translations
902   ///////////////////////
903   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
904                                                                           0.5*fgkSSDSensorSideSupportWidth,
905                                                                           0.0);
906   localssdsensorsupportrans[1][0] = 
907                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
908   localssdsensorsupportrans[2][0] = 
909                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
910   localssdsensorsupportrans[0][1] = 
911                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
912                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
913                                                                                 0.0);
914   localssdsensorsupportrans[1][1] = 
915                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
916                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
917                                                                     -   fgkSSDModuleSensorSupportDistance,
918                                                                                 0.0);
919   localssdsensorsupportrans[2][1] = 
920                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
921                                                                         -    fgkSSDSensorCenterSupportPosition,
922                                                                                  0.5*fgkSSDSensorCenterSupportWidth
923                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
924                                                                                  fgkSSDSensorCenterSupportThickness[0]);
925   localssdsensorsupportrans[0][2] = 
926                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
927                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
928                                                                                  fgkCarbonFiberJunctionWidth
929                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
930                                                                         +    fgkSSDSensorCenterSupportLength
931                                                                         -    fgkSSDSensorCenterSupportThickness[0])
932                                                                         -    fgkSSDSensorCenterSupportPosition,
933                                                                              0.0);
934   localssdsensorsupportrans[1][2] = 
935                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
936   localssdsensorsupportrans[2][2] = 
937                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
938   ////////////////////
939   // Setting Rotations
940   ////////////////////
941   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
942                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
943                         localssdsensorsupportrot[i][j] = new TGeoRotation();
944   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
945         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
946         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
947   }
948   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
949   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
950   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
951   ////////////////////////////////////////
952   // SSD Sensor Support matrix 
953   ////////////////////////////////////////
954   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
955                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
956                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
957                         localssdsensorsupportmatrix[i][j] = 
958                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
959                                                            *localssdsensorsupportrot[i][j]);
960                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
961          }
962   }
963   /////////////////////////////////////////////////////////////
964   // SSD Cooling Tube Support Transformations
965   /////////////////////////////////////////////////////////////
966   const Int_t kcoolingtubesupportmatrixnumber = 2;
967   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
968   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
969   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
970   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
971                                                                                                         /fgkCoolingTubeSupportRmax);
972   localcoolingtubesupportrans[0] = 
973                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
974                                                 +  2.*(fgkCoolingTubeSupportLength
975                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
976                                                 +  fgkCarbonFiberTriangleLength
977                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
978   localcoolingtubesupportrans[1] = 
979                         new TGeoTranslation(fgkCarbonFiberJunctionLength
980                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
981                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
982                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
983                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
984                     -  0.5*(fgkCarbonFiberLowerSupportWidth
985                                         +          fgkSSDSensorCenterSupportLength
986                     -      fgkSSDSensorCenterSupportThickness[0])
987                                         +  0.5*fgkSSDSensorLength,
988                                         -  0.5*fgkCoolingTubeSupportHeight);  
989   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
990   localcoolingtubesupportrot[i] = new TGeoRotation();
991   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
992   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
993   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
994         localcoolingtubesupportmatrix[i] = 
995                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
996                                                    *localcoolingtubesupportrot[i]);
997   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
998   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
999                                                                 (*localcoolingtubesupportmatrix[0]));
1000   /////////////////////////////////////////////////////////////
1001   // End Ladder SSD Cooling Tube Support Transformations
1002   /////////////////////////////////////////////////////////////
1003   TGeoTranslation** localendladdercooltubetrans[2];
1004   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
1005   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
1006   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
1007   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
1008                                                                                         -          (fgkCoolingTubeSupportLength
1009                                                                                         -               fgkCoolingTubeSupportRmax),
1010                                                                                                         fgkEndLadderMountingBlockPosition[0]
1011                                                                                         -               fgkendladdercoolingsupportdistance[0]
1012                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
1013                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1014   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
1015                                                                                         -          (fgkCoolingTubeSupportLength
1016                                                                                         -               fgkCoolingTubeSupportRmax),
1017                                                                                                         fgkEndLadderMountingBlockPosition[0]
1018                                                                                         +               fgkendladdercoolingsupportdistance[1]
1019                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
1020                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1021   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
1022                                                                                         -       fgkCoolingTubeSupportRmax)
1023                                                                                         +               fgkCarbonFiberTriangleLength
1024                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
1025                                                                                                 0.0,
1026                                                                                                 0.0);
1027   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
1028                                                                                                         fgkendladdercoolingsupportdistance[0]
1029                                                                                         +               fgkendladdercoolingsupportdistance[1],
1030                                                                                                         0.0);
1031   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
1032   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
1033                                                                                         +               fgkCarbonFiberJunctionLength
1034                                                                                         -               fgkCoolingTubeSupportLength,
1035                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
1036                                                                                         -       0.5*fgkCoolingTubeSupportWidth
1037                                                                                                    -fgkendladdercoolingsupportdistance[2],
1038                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1039   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
1040                                                                                         +               fgkCoolingTubeSupportLength
1041                                                                                         -               fgkCoolingTubeSupportRmax
1042                                                                                         -               fgkCarbonFiberJunctionLength,
1043                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
1044                                                                                         -       0.5*fgkCoolingTubeSupportWidth
1045                                                                                         -               fgkendladdercoolingsupportdistance[2],
1046                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
1047   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
1048   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
1049   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
1050   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
1051   (*localcoolingtubesupportrot[1]));
1052   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
1053   (*localcoolingtubesupportrot[1]));
1054   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
1055   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
1056   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
1057   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
1058   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
1059
1060   fendladdercoolingtubesupportmatrix[1][0] =    
1061                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
1062                                                                                    *(*localcoolingtubesupportrot[1]));
1063   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
1064   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
1065   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
1066   /////////////////////////////////////////////////////////////
1067   // SSD Cooling Tube Transformations
1068   /////////////////////////////////////////////////////////////
1069   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
1070   localcoolingtuberot->SetAngles(0.,90.,0.);
1071   TGeoTranslation* localcoolingtubetrans[2];
1072   TVector3* localcoolingtubevect[2];
1073
1074   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1075                                                   -fgkCarbonFiberTriangleLength),
1076                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
1077                                             - fgkCarbonFiberLowerSupportWidth 
1078                                             - fgkLowerSupportToSensorZ ,
1079                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1080   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
1081                                               localcoolingtubevect[0]->Y(),
1082                                               localcoolingtubevect[0]->Z());
1083   for(Int_t j=0; j<2; j++){
1084     localcoolingtubetrans[j] = 
1085         new TGeoTranslation(localcoolingtubevect[j]->X(),
1086                             localcoolingtubevect[j]->Y(),
1087                             localcoolingtubevect[j]->Z());
1088      fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
1089                                              *(*localcoolingtuberot));
1090   }
1091   /////////////////////////////////////////////////////////////
1092   // SSD End Ladder Cooling Tube Transformations
1093   /////////////////////////////////////////////////////////////
1094   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1095   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1096   TGeoTranslation** localendlladdercoolingtubetrans[2];
1097   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
1098   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
1099   for(Int_t i=0; i<2; i++)      
1100         for(Int_t j=0; j<2; j++)        
1101                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1102
1103   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
1104   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1105                                                                         -        fgkCoolingTubeSupportRmax)
1106                                                                         +        fgkCarbonFiberJunctionLength,
1107                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1108                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1109   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1110                                                                         -        fgkCoolingTubeSupportRmax)
1111                                                                         -        fgkCarbonFiberJunctionLength
1112                                                                         +    fgkCarbonFiberTriangleLength,
1113                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1114                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1115
1116   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1117                                                           -   fgkCoolingTubeSupportRmax)
1118                                                         +       fgkCarbonFiberJunctionLength,
1119                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1120                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1121   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1122                                                   -      fgkCoolingTubeSupportRmax)
1123                                                   -      fgkCarbonFiberJunctionLength
1124                                                   +    fgkCarbonFiberTriangleLength,
1125                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1126                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1127   for(Int_t i=0; i<2; i++)
1128         for(Int_t j=0; j<2; j++){
1129                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1130                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1131         }
1132   /////////////////////////////////////////////////////////////
1133   // SSD Hybrid Components Transformations
1134   /////////////////////////////////////////////////////////////
1135   const Int_t khybridmatrixnumber = 3;
1136   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1137   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1138                                             0.5*fgkSSDStiffenerWidth,
1139                                             0.5*fgkSSDStiffenerHeight);
1140   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1141                                             fgkSSDModuleStiffenerPosition[1],0.0);
1142
1143   localhybridtrans[2] = new TGeoTranslation(
1144                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1145                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1146                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1147                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1148                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1149                       -       fgkSSDSensorCenterSupportThickness[0]),
1150                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1151                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1152                                           -       fgkSSDModuleVerticalDisalignment)); 
1153   fhybridmatrix = new TGeoHMatrix();
1154   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1155   /////////////////////////////////////////////////////////////
1156   // SSD Cooling Block Transformations
1157   /////////////////////////////////////////////////////////////
1158   TGeoTranslation localcoolingblocktrans (fcoolingtubematrix[0]->GetTranslation()[0] 
1159                                           - 0.5*fgkSSDCoolingBlockLength,
1160                                           fhybridmatrix->GetTranslation()[1]-0.5*fgkSSDStiffenerWidth,
1161                                           fhybridmatrix->GetTranslation()[2]+0.5*fgkSSDStiffenerHeight+
1162                                           0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1163   fcoolingblocksystematrix = new TGeoHMatrix(localcoolingblocktrans);
1164   /////////////////////////////////////////////////////////////
1165   // SSD Stiffener Flex Transformations
1166   /////////////////////////////////////////////////////////////
1167   const Int_t klocalflexmatrixnumber = 4;
1168   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1169   for(Int_t i=0; i<fgkflexnumber; i++)    
1170       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1171   for(Int_t i=0; i<fgkflexnumber; i++)
1172       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1173             localflexmatrix[i][j] = new TGeoCombiTrans();
1174   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1175                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1176                                                                   -    fgkSSDStiffenerWidth;
1177   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1178                                         +0.5*fgkSSDStiffenerLength,
1179                                          0.5*fgkSSDStiffenerWidth,
1180                                         -0.5*fgkSSDStiffenerHeight
1181                                         -0.5*fgkSSDFlexHeight[0]);
1182   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1183                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1184                                         -0.5*fgkSSDStiffenerWidth,
1185                                         -0.5*fgkSSDStiffenerHeight
1186                                         -0.5*fgkSSDFlexHeight[0]);
1187   TGeoRotation* localflexrot = new TGeoRotation();
1188   localflexrot->SetAngles(180.,0.,0.);    
1189   localflexmatrix[1][0]->SetRotation(localflexrot);
1190   for(Int_t i=0; i<fgkflexnumber; i++)
1191       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1192             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1193   for(Int_t i=0; i<fgkflexnumber; i++){
1194       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1195       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1196             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1197   }
1198   /////////////////////////////////////////////////////////////
1199   // SSD End Flex Transformations
1200   /////////////////////////////////////////////////////////////
1201   TGeoRotation* localendflexrot = new TGeoRotation();
1202   localendflexrot->SetAngles(0.0,90.0,0.0);
1203   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1204   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1205                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1206   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1207                             * TMath::DegToRad()*ssdflexradiusmax
1208                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1209                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1210                                                                                    - 0.1*fgkSSDFlexFullLength;
1211   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1212                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1213                             +      fgkSSDFlexLength[2];
1214   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1215                               0.5*fgkSSDFlexWidth[0],
1216                               2.*fgkSSDStiffenerHeight
1217                             + 0.5*fgkSSDFlexHeight[0]);      
1218   localendflexmatrix->SetRotation(localendflexrot);
1219   for(Int_t i=0; i<fgkflexnumber; i++) 
1220       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1221   /////////////////////////////////////////////////////////////
1222   // End Ladder Carbon Fiber Junction
1223   /////////////////////////////////////////////////////////////
1224   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1225   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1226   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1227   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1228       localendladdercarbonfiberjunctionmatrix[i] 
1229             = new TGeoCombiTrans*[fgkendladdercarbonfiberjunctionmatrixnumber];
1230       localendladdercarbonfiberjunctionrot[i] 
1231             = new TGeoRotation*[fgkendladdercarbonfiberjunctionmatrixnumber];
1232       localendladdercarbonfiberjunctiontrans[i] 
1233             = new TGeoTranslation*[fgkendladdercarbonfiberjunctionmatrixnumber];
1234       fendladdercarbonfiberjunctionmatrix[i]
1235             = new TGeoHMatrix*[fgkendladdercarbonfiberjunctionmatrixnumber];
1236   }
1237   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1238       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1239             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1240             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1241       }
1242   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1243       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
1244           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1245   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1246       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1247                               0.0,0.0);
1248       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1249                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1250                 *                     SinD(fgkCarbonFiberTriangleAngle),
1251                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1252   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1253   }
1254   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1255   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1256   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1257   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1258       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1259       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1260       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1261       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1262             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1263       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1264             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1265                                *localendladdercarbonfiberjunctionglobalrot[i]);
1266   }
1267   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1268       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1269             localendladdercarbonfiberjunctionmatrix[i][j] = 
1270                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1271                                      *localendladdercarbonfiberjunctionrot[i][j]);
1272            fendladdercarbonfiberjunctionmatrix[i][j] =
1273             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1274             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1275       }  
1276   /////////////////////////////////////////////////////////////
1277   // End Ladder Carbon Fiber Support
1278   /////////////////////////////////////////////////////////////
1279   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1280   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1281       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1282       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1283             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1284       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1285   }
1286   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1287       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1288             fendladdercarbonfibermatrix[i][j] = 
1289             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1290             *(*fcarbonfibersupportmatrix[j]));
1291   /////////////////////////////////////////////////////////////
1292   // End Ladder SSD Mounting Block
1293   /////////////////////////////////////////////////////////////
1294   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1295       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1296   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1297       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1298                                 +        fgkSSDMountingBlockLength[1])
1299                                 +  0.5*fgkCarbonFiberTriangleLength,
1300                                 fgkEndLadderMountingBlockPosition[i],
1301                                 -  fgkSSDMountingBlockHeight[1]
1302                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1303   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1304   endladdermountingblockrot->SetAngles(0.,90.,0.);
1305   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1306         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1307   /////////////////////////////////////////////////////////////
1308   // End Ladder SSD Mounting Block Clip Matrix 
1309   /////////////////////////////////////////////////////////////
1310   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1311         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1312   
1313   TGeoRotation* localendladdercliprot = new TGeoRotation();
1314   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1315   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1316                                                                                   -     fgkSSDMountingBlockLength[1])
1317                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1318   localendladdercliprot->SetAngles(90.,180.,-90.);
1319   TGeoCombiTrans* localendladderclipcombitrans = 
1320                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1321   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1322         for(Int_t j=0; j<2; j++){
1323                 fendladdermountingblockclipmatrix[i][j] = 
1324                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1325                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1326         }
1327   /////////////////////////////////////////////////////////////
1328   // End Ladder Carbon Fiber Lower Support
1329   /////////////////////////////////////////////////////////////
1330   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1331       fendladderlowersupptrans[i] = 
1332             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1333                         +  0.5*fgkSSDMountingBlockWidth),
1334                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1335   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1336                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1337                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1338                                                                          0.0);
1339   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1340  /////////////////////////////////////////////////////////////
1341   // Matrix for positioning Ladder into mother volume
1342   /////////////////////////////////////////////////////////////
1343   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1344   for(Int_t i=0; i<fgkladdernumber; i++) 
1345         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1346   TGeoRotation* localladdermotherrot = new TGeoRotation();
1347   localladdermotherrot->SetAngles(0.,90.,0.);  
1348   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1349   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1350   for(Int_t i=0; i<fgkladdernumber; i++){
1351         localladdermothertrans[i] = new TGeoTranslation(0.,
1352                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1353                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1354                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1355                                                           * fgkCarbonFiberJunctionWidth,0.);
1356         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1357                                                                                                                 *localladdermotherrot);
1358         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1359         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1360   }
1361   /////////////////////////////////////////////////////////////
1362   // Ladder Cables Matrices
1363   /////////////////////////////////////////////////////////////
1364   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1365                                              + fgkSSDFlexHeight[1];  
1366   Double_t ssdladdercabletransx[3];
1367   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1368                                                   *   SinD(2.*fgkSSDFlexAngle)
1369                                                   *       CosD(2.*fgkSSDFlexAngle);
1370   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1371                                                   -     ssdladdercabletransx[0]
1372                                                   /     SinD(2.*fgkSSDFlexAngle))
1373                                                   *     CosD(fgkSSDFlexAngle);                                          
1374   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1375                                                   *       TMath::DegToRad()*ssdflexradiusmax
1376                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1377                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1378                                                   -       fgkSSDLadderCableWidth)
1379                                                   *       CosD(2.*fgkSSDFlexAngle);
1380   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1381                                                   *     TanD(2.*fgkSSDFlexAngle),
1382                                                         ssdladdercabletransx[1]
1383                                                   *     TanD(fgkSSDFlexAngle),
1384                                                         ssdladdercabletransx[2]
1385                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1386   TGeoRotation* localladdercablerot[3]; 
1387   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1388   localladdercablerot[0]->SetAngles(90.,0.,0.);
1389   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1390   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1391                                                  *                        (*localladdercablerot[0]));
1392   //TGeoRotation* localladdercablerot = new TGeoRotation();     
1393   //localladdercablerot->SetAngles(90.,0.,0.);
1394   ////////////////////////////////////////////
1395   // LocalLadderCableCombiTransMatrix
1396   ////////////////////////////////////////////
1397   const Int_t klocalladdersidecablesnumber = 2;
1398   const Int_t klocalladdercombitransnumber = 5;
1399   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1400   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1401          localladdercablecombitransmatrix[i] = 
1402                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1403   ///////////////////////////////////////////
1404   // Left Side Ladder Cables Transformations
1405   ///////////////////////////////////////////
1406   localladdercablecombitransmatrix[0][0]  =
1407                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1408                                                 0.,0.,NULL);
1409   localladdercablecombitransmatrix[0][1] = 
1410         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1411                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1412                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1413                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1414                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1415                                            + fgkSSDSensorCenterSupportLength
1416                                            - fgkSSDSensorCenterSupportThickness[0]),
1417                                            - (fgkSSDModuleCoolingBlockToSensor
1418                                            + 0.5*fgkCoolingTubeSupportHeight
1419                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1420                                            - fgkSSDChipHeight),NULL);
1421   localladdercablecombitransmatrix[0][2] = 
1422                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1423                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1424   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1425                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1426                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1427                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1428                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1429                                                                                                 new TGeoRotation("",180.,0.,0.));
1430   localladdercablecombitransmatrix[0][4] = 
1431                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1432                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1433                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1434                                                           0.,
1435                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1436                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1437                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1438                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1439   ///////////////////////////////////////////
1440   // Rigth Side Ladder Cables Transformations
1441   ///////////////////////////////////////////
1442   TGeoCombiTrans* localladdercablessdmodulematrix = 
1443         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1444                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1445                                                                          fgkSSDStiffenerWidth,
1446                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1447   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1448    localladdercablecombitransmatrix[1][i] = 
1449                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1450                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1451   ///////////////////////////////////////////
1452   // Setting LadderCableHMatrix
1453   ///////////////////////////////////////////
1454   Int_t beamaxistrans[2][3];
1455   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1456   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1457   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1458   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1459   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1460   beamaxistrans[1][2] = beamaxistrans[1][0];
1461   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1462   TGeoRotation* laddercablerot = new TGeoRotation();
1463   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1464   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1465   Double_t* laddercabletransvector;     
1466   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1467         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1468         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1469   }
1470   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1471         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1472                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1473                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1474                         localladdercablehmatrix[i][j]->MultiplyLeft(
1475                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1476         }
1477                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1478                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1479                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1480                                                                          laddercabletransvector[1]
1481                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1482                                         *                                fgkCarbonFiberJunctionWidth,
1483                                                                          laddercabletransvector[2]);
1484                 laddercablecombitrans->SetRotation(*laddercablerot);
1485                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1486                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1487         }
1488     fladdercablematrix[i][2] = 
1489                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1490                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1491         fladdercablematrix[i][3] = 
1492                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1493                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1494   }
1495   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1496     for(Int_t j=0; j<klocalladdercombitransnumber-1; j++) 
1497       fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1498   
1499   ///////////////////////////////////////////
1500   // Setting Ladder HMatrix
1501   ///////////////////////////////////////////
1502   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1503                                                                                                 fgkSSDLay6SensorsNumber};
1504   for(Int_t i=0; i<fgkladdernumber; i++){
1505         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1506         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1507                 fladdermatrix[i][j] = new TGeoHMatrix();
1508                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1509                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1510                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1511         }
1512   }
1513   ///////////////////////////////////////////
1514   // Setting SSD Sensor Matrix 
1515   ///////////////////////////////////////////
1516   TGeoCombiTrans* localssdsensorcombitrans[2];
1517   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1518   localssdsensorrot->SetAngles(0.,90.,0.);      
1519   TGeoTranslation* localssdsensortrans[2];
1520   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1521   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1522                                          fgkCarbonFiberJunctionWidth 
1523                                          - fgkCarbonFiberLowerSupportWidth 
1524                                          - fgkLowerSupportToSensorZ,
1525                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1526                                           -             fgkSSDModuleCoolingBlockToSensor
1527                                           +    (fgkSSDSensorSideSupportHeight[1]
1528                                           -             fgkSSDSensorSideSupportHeight[0]));
1529   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1530                                          fgkCarbonFiberJunctionWidth 
1531                                          - fgkCarbonFiberLowerSupportWidth 
1532                                          - fgkLowerSupportToSensorZ,
1533                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1534                                                         -fgkSSDModuleCoolingBlockToSensor);
1535
1536   for(Int_t i=0; i<2; i++) 
1537         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1538                                                                                                          *localssdsensorrot);   
1539     for(Int_t i=0; i<fgkladdernumber; i++){
1540         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1541         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1542                 switch(i){
1543                         case 0: //Ladder of Layer5  
1544                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1545                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1546                                                                                                 *localssdsensorcombitrans[1])));
1547                         break;
1548                         case 1: //Ladder of Layer6 
1549                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1550                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1551                                                                                                 *localssdsensorcombitrans[0])));
1552                 break;
1553                 }
1554           }
1555   }     
1556   //////////////////////////
1557   // Setting SSD End Ladder  
1558   //////////////////////////
1559   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1560   for(Int_t i=0; i<2; i++){
1561         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1562         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1563         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1564         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1565         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1566         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1567         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1568         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1569    }
1570   /////////////////////////////////////////////////////
1571   // Setting the CombiTransformation to pass ITS center 
1572   /////////////////////////////////////////////////////
1573   Double_t itscentertransz[fgklayernumber];
1574   itscentertransz[0] = fgkSSDLay5LadderLength
1575                                          - fgkLay5CenterITSPosition;
1576   itscentertransz[1] = fgkSSDLay6LadderLength
1577                                          - fgkLay6CenterITSPosition;
1578   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1579                                                    + 0.5*fgkCoolingTubeSupportHeight;
1580   TGeoRotation* itscenterrot[3];
1581   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1582   itscenterrot[0]->SetAngles(90.,180.,-90.);
1583   itscenterrot[1]->SetAngles(0.,90.,0.);
1584   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1585   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1586   for(Int_t i=0; i<fgklayernumber; i++) 
1587         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1588                                                          itssensortransy,
1589                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1590                                                    - itscentertransz[i],itscenterrot[2]);
1591   TGeoRotation** locallayerrot[fgklayernumber];
1592   TGeoTranslation** locallayertrans[fgklayernumber];    
1593   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1594   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1595   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1596                                          - fgkLay5CenterITSPosition);
1597   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1598                                          - fgkLay6CenterITSPosition);
1599   const Int_t kssdlayladdernumber[fgklayernumber] = 
1600                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1601   for(Int_t i=0; i<fgklayernumber; i++){
1602     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1603     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1604         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1605         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1606   }
1607   Double_t layerladderangleposition[fgklayernumber] = 
1608                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1609   Double_t layerradius = 0.;
1610   for(Int_t i=0; i<fgklayernumber; i++){        
1611         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1612                 switch(i){
1613                         case 0: //Ladder of Layer5  
1614                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1615                         break;
1616                         case 1: //Ladder of Layer6 
1617                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1618                 break;
1619                 }
1620                 locallayerrot[i][j] = new TGeoRotation();
1621                 locallayertrans[i][j] = new TGeoTranslation();
1622                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1623                 locallayertrans[i][j]->SetTranslation(layerradius 
1624                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1625                                                             layerradius 
1626                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1627                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1628                                                                          *locallayerrot[i][j]);
1629                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1630                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1631                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1632         }
1633   }
1634   /////////////////////////////////////////////////////////////
1635   // Deallocating memory
1636   /////////////////////////////////////////////////////////////
1637   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1638         delete carbonfiberot[i];
1639         delete localcarbonfibersupportmatrix[i];
1640   }
1641   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1642      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1643        delete localcarbonfiberjunctionmatrix[i][j];
1644            delete localcarbonfiberjunctionrot[i][j];
1645            delete localcarbonfiberjunctiontrans[i][j];
1646            }
1647        delete [] localcarbonfiberjunctionmatrix[i];
1648        delete [] localcarbonfiberjunctionrot[i];
1649        delete [] localcarbonfiberjunctiontrans[i];
1650   }
1651   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1652            delete localcarbonfiberlowersupportrans[i];
1653   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1654      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1655        delete localssdsensorsupportmatrix[i][j];
1656            delete localssdsensorsupportrot[i][j];
1657            delete localssdsensorsupportrans[i][j];
1658            }
1659        delete [] localssdsensorsupportmatrix[i];
1660        delete [] localssdsensorsupportrot[i];
1661        delete [] localssdsensorsupportrans[i];
1662   }
1663   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1664         delete localcoolingtubesupportmatrix[i];
1665         delete localcoolingtubesupportrot[i];
1666         delete localcoolingtubesupportrans[i];
1667   }
1668   for(Int_t j=0; j<2; j++){
1669     delete localcoolingtubevect[j];
1670     delete localcoolingtubetrans[j];
1671   }
1672  delete endladdermountingblockrot;
1673  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1674  for(Int_t i=0; i<fgkflexnumber; i++){
1675       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1676             delete localflexmatrix[i][j];
1677       delete [] localflexmatrix[i];
1678  }
1679  delete localendlladdercoolingtuberot;
1680  for(Int_t i=0; i<2; i++){
1681         for(Int_t j=0; j<2; j++)
1682           delete localendlladdercoolingtubetrans[i][j];
1683         delete [] localendlladdercoolingtubetrans[i];
1684   }
1685
1686  delete localflexrot;
1687  delete localendflexrot;
1688  delete localendflexmatrix;
1689  for(Int_t i=0; i<fgkladdernumber; i++){ 
1690         delete localladdermothertrans[i];
1691         delete localladdermothercombitrans[i];
1692   }
1693  delete localladdermotherrot;
1694  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1695       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
1696             delete localendladdercarbonfiberjunctionmatrix[i][j];
1697             delete localendladdercarbonfiberjunctionrot[i][j];
1698             delete localendladdercarbonfiberjunctiontrans[i][j];
1699       }
1700       delete [] localendladdercarbonfiberjunctionmatrix[i];
1701       delete [] localendladdercarbonfiberjunctionrot[i];
1702       delete [] localendladdercarbonfiberjunctiontrans[i];
1703       delete localendladdercarbonfiberjunctionglobalrot[i];
1704       delete localendladdercarbonfiberjunctionglobaltrans[i];
1705       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1706  }
1707   for(Int_t i=0; i<2; i++){
1708         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1709         delete [] localendladdercooltubetrans[i];
1710   }
1711   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1712       delete localendladdercarbonfibertrans[i];
1713   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1714   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1715         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1716                 delete localladdercablecombitransmatrix[i][j];
1717                 delete []localladdercablecombitransmatrix[i];
1718   }
1719   delete localendladdercliprot;
1720   delete localendladdercliptrans;
1721   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1722         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1723                 delete localladdercablehmatrix[i][j];
1724         delete []localladdercablehmatrix[i];
1725   }
1726   delete laddercablerot;
1727   delete laddercabletrans;
1728   delete laddercablecombitrans;
1729   delete localladdercablessdmodulematrix;
1730   delete localssdsensorrot;     
1731   for(Int_t i=0; i<2; i++){
1732         delete localssdsensortrans[i];
1733         delete localssdsensorcombitrans[i];
1734   }
1735   for(Int_t i=0; i<fgklayernumber; i++){
1736         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1737                 delete locallayerrot[i][j];
1738                 delete locallayertrans[i][j];
1739                 delete locallayercombitrans[i][j];
1740     }
1741         delete [] locallayerrot[i];
1742         delete [] locallayertrans[i];
1743         delete [] locallayercombitrans[i];
1744         delete localbeamaxistrans[i];
1745   }
1746   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1747   for(Int_t i=0; i<fgkladdernumber; i++){
1748         for(Int_t j=0; j<fgkladdernumber; j++)
1749                 delete ladderglobalmatrix[i][j];
1750         delete [] ladderglobalmatrix[i];
1751   }
1752   /////////////////////////////////////////////////////////////
1753   fTransformationMatrices = kTRUE;      
1754 }
1755 ///////////////////////////////////////////////////////////////////////////////
1756 void AliITSv11GeometrySSD::CreateBasicObjects(){
1757   /////////////////////////////////////////////////////////////  
1758   // Method generating the Objects of SSD Geometry    
1759   /////////////////////////////////////////////////////////////
1760   // SSD Sensor
1761   ///////////////////////////////////
1762   SetSSDSensor();
1763   /////////////////////////////////////////////////////////////  
1764   // Carbon Fiber Support    
1765   /////////////////////////////////////////////////////////////  
1766   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1767   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1768       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1769   /////////////////////////////////////////////////////////////
1770   // Carbon Fiber Junction 
1771   /////////////////////////////////////////////////////////////
1772   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1773   /////////////////////////////////////////////////////////////
1774   // Carbon Fiber Lower Support
1775   /////////////////////////////////////////////////////////////
1776   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1777   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1778         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1779   /////////////////////////////
1780   // SSD Sensor Support
1781   /////////////////////////////
1782   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1783                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1784   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1785                                                                          fgkSSDSensorSideSupportThickness[1]};
1786   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1787         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1788                                                                                            fgkSSDSensorSideSupportHeight[i],
1789                                                                                            fgkSSDSensorSideSupportWidth,
1790                                                                                            sidesupporthickness);  
1791         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1792                                                                                            fgkSSDSensorCenterSupportHeight[i],
1793                                                                                            fgkSSDSensorCenterSupportWidth,
1794                                                                                            sidesupporthickness);
1795   }
1796   /////////////////////////////////////////////////////////////
1797   // SSD Cooling Tube Support
1798   /////////////////////////////////////////////////////////////
1799   Int_t edgesnumber = 3;
1800   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1801   /////////////////////////////////////////////////////////////
1802   // SSD Hybrid
1803   /////////////////////////////////////////////////////////////
1804   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1805   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1806         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1807   /////////////////////////////////////////////////////////////
1808   // SSD Cooling Block System
1809   /////////////////////////////////////////////////////////////
1810   fssdcoolingblocksystem = GetCoolingBlockSystem();
1811    /////////////////////////////////////////////////////////////
1812   // SSD Cooling Tube
1813   /////////////////////////////////////////////////////////////
1814   CreateCoolingTubes();
1815   /////////////////////////////////////////////////////////////
1816   // SSD Flex  
1817   /////////////////////////////////////////////////////////////
1818   fssdstiffenerflex = GetSSDStiffenerFlex();
1819   fssdendflex = GetSSDEndFlex();
1820   ///////////////////////////////////
1821   // End Ladder Carbon Fiber Junction
1822   ///////////////////////////////////
1823   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1824                                                    fendladdercarbonfiberjunction[i] = 
1825                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1826   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1827     fendladdercarbonfiberjunction[i][0] = 
1828                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1829     fendladdercarbonfiberjunction[i][1] = 
1830                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1831   }
1832   ///////////////////////////////////
1833   // End Ladder Mounting Block
1834   ///////////////////////////////////
1835   fendladdermountingblock = GetSSDMountingBlock();
1836   ///////////////////////////////////
1837   // End Ladder Mounting Block
1838   ///////////////////////////////////
1839   fendladdermountingblockclip = GetMountingBlockClip();
1840   ///////////////////////////////////
1841   // Ladder Support 
1842   ///////////////////////////////////
1843   TList* laddersupportlist = GetMountingBlockSupport(20);
1844   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1845   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1846   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1847   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1848   /////////////////////////////////////////////////////////////
1849   // Deallocating memory
1850   /////////////////////////////////////////////////////////////
1851   delete carbonfibersupportlist;
1852   delete carbonfiberlowersupportlist;
1853   delete ssdhybridcomponentslist;
1854   delete laddersupportlist;
1855   /////////////////////////////////////////////////////////////
1856   fBasicObjects = kTRUE;
1857 }
1858 /////////////////////////////////////////////////////////////////////////////////
1859 void AliITSv11GeometrySSD::SetSSDSensor(){
1860   ////////////////////////////////////////////////////////////////
1861   // Method generating SSD Sensors: it sets the private variables
1862   // fSSDSensor5, fSSDSensor6  
1863   ////////////////////////////////////////////////////////////////
1864   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1865   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1866   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1867                                                 0.5*ssdsensitivewidth,
1868                                                 0.5*fgkSSDSensorHeight,
1869                                                 0.5*ssdsensitivelength);
1870   TGeoVolume* ssdsensorsensitiveLay5 = 
1871         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1872   TGeoVolume* ssdsensorsensitiveLay6 = 
1873         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1874   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1875   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1876   TGeoBBox* ssdsensorinsensitiveshape[2];
1877   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1878                                                 0.5*fgkSSDSensorInsensitiveWidth,
1879                                                 0.5*fgkSSDSensorHeight,
1880                                                 0.5*fgkSSDSensorLength);
1881   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1882                                                 0.5*ssdsensitivewidth,
1883                                                 0.5*fgkSSDSensorHeight,
1884                                                 0.5*fgkSSDSensorInsensitiveWidth);
1885   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1886                                              "SSDSensorInsensitive2"};
1887   TGeoVolume* ssdsensorinsensitive[2];
1888   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1889       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1890                      fSSDSensorMedium);
1891       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1892   }
1893   /////////////////////////////////////////////////////////////
1894   // Virtual Volume containing SSD Sensor  
1895   /////////////////////////////////////////////////////////////
1896   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1897                                                                                              0.5*fgkSSDSensorWidth,
1898                                                                                              0.5*fgkSSDSensorHeight,
1899                                                                                              0.5*fgkSSDSensorLength);
1900   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1901                                                                                  fSSDAir);      
1902   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1903                                                                                  fSSDAir);      
1904   /////////////////////////////////////////////////////////////
1905   for(Int_t i=0; i<4; i++){ 
1906             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1907             ssdsensorinsensitive[1],i<2?1:2,
1908                         new TGeoTranslation(
1909                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1910       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1911                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1912       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1913             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1914             ssdsensorinsensitive[1],i<2?1:2,
1915                         new TGeoTranslation(
1916                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1917       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1918                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1919       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1920   }
1921     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1922     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1923 }
1924 ///////////////////////////////////////////////////////////////////////////////
1925 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1926   /////////////////////////////////////////////////////////////  
1927   // Method generating the Carbon Fiber Support   
1928   /////////////////////////////////////////////////////////////  
1929   const Int_t kvertexnumber = 4;
1930   const Int_t kshapesnumber = 2;
1931   TVector3** vertexposition[kshapesnumber];
1932   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1933   Double_t carbonfibersupportxaxisEdgeproj = 
1934                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1935         *       TMath::DegToRad());
1936   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1937                                  /                         fgkCarbonFiberSupportXAxisLength);
1938   /////////////////////
1939   //Vertex Positioning
1940   ////////////////////
1941   vertexposition[0][0] = new TVector3();
1942   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1943                                                                           fgkCarbonFiberSupportYAxisLength);
1944   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1945                                                                           carbonfibersupportxaxisEdgeproj
1946                                            *                      TMath::Tan(theta));
1947   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1948                                            -                      carbonfibersupportxaxisEdgeproj,
1949                                                                           fgkCarbonFiberSupportYAxisLength
1950                                            -                      vertexposition[0][2]->Y());
1951   ////////////////////////////////////////////////////
1952   //Setting the parameters for Isometry Transformation
1953   ////////////////////////////////////////////////////
1954   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1955                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1956                                                                  +      fgkCarbonFiberSupportWidth);
1957   Double_t* param = new Double_t[4]; 
1958   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1959   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1960     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1961                  (GetReflection(vertexposition[0][j],param))->Y());
1962   const char* carbonfibersupportshapename[kshapesnumber] = 
1963                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1964   const char* carbonfibersupportname[kshapesnumber] = 
1965                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1966   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1967   TGeoVolume* carbonfibersupport[kshapesnumber];
1968   TList* carbonfibersupportlist = new TList();
1969   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1970   Double_t carbonfibersupportheight = 
1971           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1972           *TMath::DegToRad());
1973   for(Int_t i = 0; i< kshapesnumber; i++){
1974    carbonfibersupportshape[i] = 
1975                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1976                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1977    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1978                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1979    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1980    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1981    }
1982   /////////////////////////////////////////////////////////////
1983   // Deallocating memory
1984   /////////////////////////////////////////////////////////////
1985   for(Int_t i=0; i< kshapesnumber; i++){
1986      for(Int_t j=0; j< kvertexnumber; j++)
1987            delete vertexposition[i][j];
1988        delete [] vertexposition[i];
1989   }
1990   delete [] param;
1991   /////////////////////////////////////////////////////////////
1992    return carbonfibersupportlist;
1993 }
1994 /////////////////////////////////////////////////////////////////////////////////
1995 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1996   /////////////////////////////////////////////////////////////
1997   // Method generating SSD Carbon Fiber Junction
1998   /////////////////////////////////////////////////////////////
1999   const Int_t kvertexnumber = 6;
2000   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2001   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2002                                             *  TMath::DegToRad()),-1.,0.,0.};
2003   TVector3* vertex[kvertexnumber];
2004   vertex[0] = new TVector3();
2005   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2006                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2007                         *                         TMath::DegToRad()),
2008                                                   fgkCarbonFiberJunctionEdge[0]
2009                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2010                         *                         TMath::DegToRad()));
2011   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2012                                                    fgkCarbonFiberJunctionEdge[1]);
2013   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2014   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2015   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2016   Double_t xvertexpoints[6], yvertexpoints[6];
2017   for(Int_t i=0; i<kvertexnumber; i++) 
2018           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2019   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2020   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2021   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2022   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2023                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2024   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2025   /////////////////////////////////////////////////////////////
2026   // Deallocating memory
2027   /////////////////////////////////////////////////////////////
2028   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2029   ///////////////////////////////////////////////////////////// 
2030   return carbonfiberjunction;
2031 }
2032 ////////////////////////////////////////////////////////////////////////////////
2033 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2034   /////////////////////////////////////////////////////////////
2035   // Method generating the Carbon Fiber Lower Support   
2036   /////////////////////////////////////////////////////////////  
2037   const Int_t kvertexnumber = 4;
2038   const Int_t kshapesnumber = 2;
2039   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2040                                                                 fgkCarbonFiberLowerSupportWidth};
2041   TVector3** vertexposition[kshapesnumber];
2042   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2043                                                  new TVector3*[kvertexnumber];
2044   //First Shape Vertex Positioning
2045   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2046   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2047                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2048   vertexposition[0][2] = new TVector3();
2049   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2050   //Second Shape Vertex Positioning
2051   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2052                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2053                                  /                              fgkCarbonFiberTriangleLength);
2054   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2055                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2056                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2057   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2058                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2059                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2060   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2061   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2062                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2063   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
2064                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2065   const char* carbonfiberlowersupportname[kshapesnumber] = 
2066                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2067   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2068   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2069   TList* carbonfiberlowersupportlist = new TList();
2070   for(Int_t i = 0; i< kshapesnumber; i++){ 
2071         carbonfiberlowersupportshape[i] = 
2072                                                                 GetArbShape(vertexposition[i],width,
2073                                                                                         fgkCarbonFiberLowerSupportHeight,
2074                                                                                         carbonfiberlowersupportshapename[i]);
2075     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2076                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2077         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2078     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2079   }
2080   /////////////////////////////////////////////////////////////
2081   // Deallocating memory
2082   /////////////////////////////////////////////////////////////
2083   for(Int_t i=0; i< kshapesnumber; i++){
2084      for(Int_t j=0; j< kvertexnumber; j++)
2085            delete vertexposition[i][j];
2086        delete [] vertexposition[i];
2087   }
2088   /////////////////////////////////////////////////////////////
2089   return carbonfiberlowersupportlist;
2090 }
2091 ///////////////////////////////////////////////////////////////////////////////
2092 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2093                                                                  Double_t width, const Double_t* thickness)const{
2094   /////////////////////////////////////////////////////////////
2095   // Method generating the Sensor Support   
2096   /////////////////////////////////////////////////////////////  
2097         const Int_t kvertexnumber = 6;
2098         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2099     TVector3* vertexposition[kvertexnumber];
2100         vertexposition[0] = new TVector3();     
2101         vertexposition[1] = new TVector3(0.0,length);   
2102         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2103         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2104         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2105         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2106         Double_t xvertexpoints[6], yvertexpoints[6];
2107         for(Int_t i=0; i<kvertexnumber; i++) 
2108                 xvertexpoints[i] = vertexposition[i]->X(), 
2109                 yvertexpoints[i] = vertexposition[i]->Y();
2110     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2111     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2112     ssdsensorsupportshape->DefineSection(1,0.5*width);
2113     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2114                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2115   /////////////////////////////////////////////////////////////
2116   // Deallocating memory
2117   /////////////////////////////////////////////////////////////
2118         for (Int_t i=0; i<kvertexnumber; i++)
2119                 delete vertexposition[i];
2120   /////////////////////////////////////////////////////////////
2121     return ssdsensorsupport;
2122 }
2123 ////////////////////////////////////////////////////////////////////////////////
2124 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2125   /////////////////////////////////////////////////////////////
2126   // Method generating the Cooling Tube Support
2127   /////////////////////////////////////////////////////////////
2128   if(nedges%2!=0) nedges--;     
2129   const Int_t kvertexnumber = nedges+5;
2130   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2131                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2132   Double_t angle = 90.+phi;
2133   Double_t psi = 90.-phi;
2134   ///////////////////////////////////////
2135   // Vertex Positioning for TGeoXTru
2136   ///////////////////////////////////////
2137   TVector3** vertexposition = new TVector3*[kvertexnumber];
2138
2139   Double_t Router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
2140   vertexposition[0] = new TVector3(Router*CosD(angle),
2141                                                                    Router*SinD(angle));
2142   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2143                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2144   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2145                                                                    fgkCoolingTubeSupportRmax);
2146   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2147                                                                    fgkCoolingTubeSupportRmax);
2148   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2149                                                                     vertexposition[1]->Y());
2150
2151   for(Int_t i=0; i<nedges; i++)
2152         vertexposition[i+5] = 
2153                 new TVector3(Router*CosD(psi+i*(2.*phi/nedges)),
2154                              Router*SinD(psi+i*(2.*phi/nedges)));
2155   ///////////////////////////////////////////////////////////////////////
2156   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2157   ///////////////////////////////////////////////////////////////////////
2158   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2159   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2160   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2161   for(Int_t i=0; i<kvertexnumber; i++){
2162         xvertexpoints[i] = vertexposition[i]->X();
2163         yvertexpoints[i] = vertexposition[i]->Y();
2164   } 
2165   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2166                                                                                         yvertexpoints);
2167   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2168   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2169   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2170                                                                           coolingtubesupportarcshape,
2171                                                                                   fSSDTubeHolderMedium);
2172   coolingtubesupportarc->SetLineColor(fColorG10);
2173   //////////////////////////////////////////////////////////////////////////
2174   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2175   //////////////////////////////////////////////////////////////////////////
2176   TGeoTubeSeg* coolingtubesupportsegshape = 
2177                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2178                                                                                         fgkCoolingTubeSupportRmax,
2179                                                                                         0.5*fgkCoolingTubeSupportWidth,
2180                                                                                         phi,360-phi);
2181   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2182                                                                                         coolingtubesupportsegshape,
2183                                                                                         fSSDTubeHolderMedium);
2184   coolingtubesupportseg->SetLineColor(fColorG10);
2185   //////////////////////////////////////////////////////////////////////////
2186   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2187   //////////////////////////////////////////////////////////////////////////
2188   Double_t* boxorigin = new Double_t[3];
2189   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2190   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2191   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2192                                                                                  0.5*fgkCoolingTubeSupportHeight,
2193                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2194   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2195                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2196   coolingtubesupportbox->SetLineColor(fColorG10);
2197   //////////////////////////////////////////////////////////////////////////
2198   // Cooling Tube for Cooling Tube Support 
2199   //////////////////////////////////////////////////////////////////////////
2200   TGeoXtru* coolingtubearcshape[2];
2201   coolingtubearcshape[0] = new TGeoXtru(2);     
2202   Double_t* xvert = new Double_t[nedges+2];
2203   Double_t* yvert = new Double_t[nedges+2];
2204   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2205   ////////////////////////////////////////
2206   // Positioning the vertices for TGeoXTru
2207   ////////////////////////////////////////
2208   xvert[0] = 0., yvert[0] = 0.;
2209   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2210   for(Int_t i=0; i< nedges; i++)
2211                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2212                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2213   ////////////////////////////////////////
2214   // Defining TGeoXTru PolyGone
2215   ////////////////////////////////////////
2216   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2217   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2218   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2219   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2220                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2221   TGeoVolume* coolingtubearc[2];
2222   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2223                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2224   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2225                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2226   coolingtubearc[0]->SetLineColor(fColorWater);
2227   coolingtubearc[1]->SetLineColor(fColorPhynox);
2228   ////////////////////////////////////////////
2229   // Defining TGeoTubeSeg Part of Cooling Tube
2230   ////////////////////////////////////////////
2231   TGeoTubeSeg* coolingtubesegshape[2];
2232   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2233                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2234   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2235                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2236   TGeoVolume* coolingtubeseg[2];
2237   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2238                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2239   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2240                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2241   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2242   coolingtubeseg[1]->SetLineColor(fColorWater);
2243   /////////////////////////////////////////////////////////////
2244   // Virtual Volume containing Cooling Tube Support  
2245   /////////////////////////////////////////////////////////////
2246   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2247   const Int_t kvirtualvertexnumber = 8;
2248   TVector3* virtualvertex[kvirtualvertexnumber];
2249    ////////////////////////////////////////
2250   // Positioning the vertices for TGeoXTru
2251   ////////////////////////////////////////
2252   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2253   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2254   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2255   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2256   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2257   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2258   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2259   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2260   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2261   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2262         xmothervertex[i] = virtualvertex[i]->X(),
2263         ymothervertex[i] = virtualvertex[i]->Y();
2264   ////////////////////////////////////////
2265   // Defining TGeoXTru PolyGone
2266   ////////////////////////////////////////
2267   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2268                                                                                                                                          ymothervertex);
2269   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2270   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2271   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2272     virtualCoolingTubeSupportShape,fSSDAir); */
2273   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
2274
2275   ////////////////////////////////////////
2276   // Positioning Volumes in Virtual Volume
2277   ////////////////////////////////////////
2278   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2279   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2280   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2281   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2282   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2283   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2284   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2285   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2286   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2287   /////////////////////////////////////////////////////////////
2288   // Deallocating memory
2289   /////////////////////////////////////////////////////////////
2290   delete [] vertexposition;
2291   delete [] xvertexpoints;
2292   delete [] yvertexpoints;
2293   delete [] xvert;
2294   delete [] yvert;
2295   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2296         delete virtualvertex[i];
2297   /////////////////////////////////////////////////////////////
2298         return virtualcoolingtubesupport;
2299 }
2300 /////////////////////////////////////////////////////////////////////////////////
2301 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2302   /////////////////////////////////////////////////////////////
2303   // Method generating List containing SSD Hybrid Components   
2304   /////////////////////////////////////////////////////////////
2305   TList* ssdhybridlist = new TList();
2306   const Int_t kssdstiffenernumber = 2;
2307   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2308                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2309                                                                   -    fgkSSDStiffenerWidth;
2310   Double_t ssdchipcablesradius[kssdstiffenernumber];
2311   for(Int_t i=0; i<kssdstiffenernumber; i++)
2312           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2313                                -  fgkSSDChipCablesHeight[0]
2314                                -  fgkSSDChipCablesHeight[1]);
2315   /////////////////////////////////////////////////////////////
2316   // Mother Volumes Containers 
2317   /////////////////////////////////////////////////////////////
2318   const Int_t kmothernumber = 2;
2319   const Int_t kmothervertexnumber = 8;
2320   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2321   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2322
2323   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
2324   TGeoVolume* ssdhybridmother[kmothernumber][2];
2325
2326   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
2327   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
2328   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
2329
2330   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2331   for(Int_t i=0; i<kmothernumber; i++){
2332     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
2333     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
2334     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
2335     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2336       -fgkSSDChipCablesHeight[i+2];
2337     
2338     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
2339     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
2340     xmothervertex[i][3] = xmothervertex[i][2];
2341     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1];
2342
2343     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
2344     ymothervertex[i][4] = ymothervertex[i][3];
2345     xmothervertex[i][5] = xmothervertex[i][4];
2346     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i];
2347
2348     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
2349     ymothervertex[i][6] = ymothervertex[i][5];
2350     
2351     xmothervertex[i][7] = xmothervertex[i][6];
2352     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
2353     TGeoXtru *shape = new TGeoXtru(2);
2354     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
2355     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
2356     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
2357     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
2358     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
2359     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2360    }   
2361   /////////////////////////////////////////////////////////////
2362   // SSD Stiffener   
2363   /////////////////////////////////////////////////////////////
2364   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2365                                              0.5*fgkSSDStiffenerLength,
2366                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2367                                              0.5*fgkSSDStiffenerHeight);
2368   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2369                                             fSSDStiffenerMedium);  
2370   ssdstiffener->SetLineColor(fColorStiffener); 
2371
2372 ////////////////////////////
2373 // Capacitor 0603-2200 nF
2374 ///////////////////////////
2375   const Int_t knapacitor0603number = 5;
2376   TGeoBBox* capacitor0603mothershape =  new TGeoBBox("Capacitor0603MotherShape",
2377                                                0.5*fgkSSDCapacitor0603Length + fgkSSDCapacitor0603CapLength,
2378                                                0.5*fgkSSDCapacitor0603Width,
2379                                                0.5*fgkSSDCapacitor0603Height);
2380   TGeoVolume* capacitor0603mother = new TGeoVolume("Capacitor0603Mother",capacitor0603mothershape,
2381                                              fSSDAir); 
2382
2383   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2384                                                0.5*fgkSSDCapacitor0603Length,
2385                                                0.5*fgkSSDCapacitor0603Width,
2386                                                0.5*fgkSSDCapacitor0603Height);
2387   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2388                                              fSSDStiffener0603CapacitorMedium); 
2389   capacitor0603->SetLineColor(fColorAl);
2390   TGeoTranslation *cap0603trans = new TGeoTranslation(0.,0.,0.);
2391   capacitor0603mother->AddNode(capacitor0603,1,cap0603trans);
2392
2393   TGeoBBox* capacitor0603capshape =  new TGeoBBox("Capacitor0603CapShape",
2394                                                0.5*fgkSSDCapacitor0603CapLength,
2395                                                0.5*fgkSSDCapacitor0603Width,
2396                                                0.5*fgkSSDCapacitor0603Height);
2397   TGeoVolume* capacitor0603cap = new TGeoVolume("Capacitor0603Cap",capacitor0603capshape,
2398                                              fSSDStiffenerCapacitorCapMedium); 
2399   capacitor0603cap->SetLineColor(fColorNiSn);
2400   TGeoTranslation *cap0603captrans1 = new TGeoTranslation(- capacitor0603shape->GetDX() - capacitor0603capshape->GetDX(),0.,0.);
2401   capacitor0603mother->AddNode(capacitor0603cap,1,cap0603captrans1);
2402   TGeoTranslation *cap0603captrans2 = new TGeoTranslation(capacitor0603shape->GetDX() + capacitor0603capshape->GetDX(),0.,0.);
2403   capacitor0603mother->AddNode(capacitor0603cap,2,cap0603captrans2);
2404
2405
2406   TGeoVolume* ssdchip = GetSSDChip();
2407
2408   const Int_t knedges = 5;
2409   TGeoVolume *ssdchipcables[2];
2410
2411   for(Int_t i=0; i<kmothernumber; i++){
2412     for(Int_t j=0; j<kssdstiffenernumber; j++){
2413       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
2414       for(Int_t k=1; k<knapacitor0603number+1; k++){
2415         ssdhybridmother[i][j]->AddNode(capacitor0603mother,k,
2416                                        new TGeoCombiTrans("",
2417                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
2418                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
2419                                                           (k-3.)/6*fgkSSDStiffenerLength,
2420                                                           hybridmotherrotInv));
2421       }
2422     }
2423     
2424     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
2425     for(Int_t k=0; k<fgkSSDChipNumber; k++){
2426       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
2427                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
2428                                                             - fgkSSDChipCablesHeight[i+2],
2429                                                             (k+0.5-fgkSSDChipNumber/2)*
2430                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
2431       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
2432                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
2433                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
2434                                                      hybridmotherrotInv);
2435       for(Int_t j=0; j<kssdstiffenernumber; j++){
2436         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
2437         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
2438       }
2439     }  
2440     // Final placement by assembly
2441     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
2442     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
2443     ssdhybridlist->Add(ssdhybridassembly[i]);
2444   }    
2445   /////////////////////////////////////////////////////////////
2446   // Mother Volume Containing Capacitor Part 
2447   /////////////////////////////////////////////////////////////
2448   const Int_t kcapacitormothernumber = 8;
2449   Double_t xcapacitorvertex[kcapacitormothernumber];
2450   Double_t ycapacitorvertex[kcapacitormothernumber];  
2451   ///////////////////////
2452   // Setting the vertices 
2453   ///////////////////////
2454   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2455   xcapacitorvertex[1] = xcapacitorvertex[0];   
2456   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2457   xcapacitorvertex[3] = xcapacitorvertex[2];   
2458   xcapacitorvertex[4] = xcapacitorvertex[0];   
2459   xcapacitorvertex[5] = xcapacitorvertex[0];   
2460   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2461   xcapacitorvertex[7] = xcapacitorvertex[6];   
2462   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2463   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2464   ycapacitorvertex[2] = ycapacitorvertex[1];   
2465   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2466   ycapacitorvertex[4] = ycapacitorvertex[3];   
2467   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2468   ycapacitorvertex[6] = ycapacitorvertex[5];   
2469   ycapacitorvertex[7] = ycapacitorvertex[0];   
2470   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2471   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2472                                               ycapacitorvertex);
2473   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2474   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2475 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2476 //                                          fSSDAir);
2477   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2478 ////////////////////////////
2479 // Connector 
2480 ///////////////////////////
2481   const Int_t kssdconnectorlayernumber = 3;
2482   TGeoBBox* ssdconnectorshape[kssdconnectorlayernumber];
2483   Double_t ssdConnectorThickness[kssdconnectorlayernumber]={fgkSSDConnectorAlHeight,fgkSSDConnectorNiHeight,fgkSSDConnectorSnHeight};
2484   /*
2485   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2486   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2487                                    +  fgkSSDConnectorAlHeight};  
2488   */
2489   Double_t ssdconnectororigin[3] = {0,0,0.5*fgkSSDStiffenerHeight};
2490   const char* ssdconnectorname[kssdconnectorlayernumber] = {"SSDConnectorAl","SSDConnectorNi","SSDConnectorSn"};
2491   TGeoMedium *ssdConnectorMedium[kssdconnectorlayernumber]={fSSDAlTraceFlexMedium,fSSDStiffenerConnectorMedium,fSSDSn};
2492   TGeoVolume* ssdconnector[kssdconnectorlayernumber];
2493   for(Int_t i=0; i<kssdconnectorlayernumber; i++){
2494     ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2495       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2496                                           0.5*fgkSSDConnectorWidth,
2497                                           0.5*ssdConnectorThickness[i],
2498                                           ssdconnectororigin);
2499       ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2500       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2501                                        ssdConnectorMedium[i]);      
2502       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorNiSn);
2503   }
2504   const Int_t kssdconnectornumber = 4;
2505   TGeoTranslation* ssdconnectortrans[kssdconnectornumber];
2506   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2507                        +  fgkSSDConnectorPosition[0]
2508                        -  fgkSSDConnectorSeparation
2509                        -  1.5*fgkSSDConnectorLength,
2510                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2511                        -  fgkSSDConnectorPosition[1]
2512                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2513   ssdconnectortrans[1] = new TGeoTranslation(
2514                        -  ssdstiffenershape->GetDX()
2515                        +  fgkSSDConnectorPosition[0]
2516                        -  0.5*fgkSSDConnectorLength,
2517                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2518                        -  fgkSSDConnectorPosition[1]
2519                        -  ssdconnectorshape[0]->GetDY(),0.0);
2520   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2521                        -  fgkSSDConnectorPosition[0]
2522                        +  fgkSSDConnectorSeparation
2523                        +  1.5*fgkSSDConnectorLength,
2524                           -(ssdstiffenershape->GetDY()
2525                        -  fgkSSDConnectorPosition[1]
2526                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2527   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2528                        -  fgkSSDConnectorPosition[0]
2529                        +  0.5*fgkSSDConnectorLength,
2530                           -(ssdstiffenershape->GetDY()
2531                        -  fgkSSDConnectorPosition[1]
2532                        -  ssdconnectorshape[0]->GetDY()),0.0);
2533   for(Int_t i=0; i<kssdconnectornumber; i++) {
2534     Int_t nlay = kssdconnectorlayernumber - 1;
2535     if (i == 1 || i == 2)
2536       nlay++;
2537     for(Int_t j=0; j<nlay; j++)
2538       ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2539   }
2540 ////////////////////////////
2541 // Capacitor 1812-330 nF
2542 /////////////////////////// 
2543 //  Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2544   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2545                                                                                          0.5*fgkSSDCapacitor1812Length,
2546                                                                                          0.5*fgkSSDCapacitor1812Width,
2547                                                0.5*fgkSSDCapacitor1812Height);
2548   //            ssdcapacitor1812origin);
2549   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2550                                              fSSDStiffener1812CapacitorMedium); 
2551   capacitor1812->SetLineColor(fColorAl);
2552   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2553                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2554                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2555   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2556
2557   TGeoBBox* capacitor1812capshape =  new TGeoBBox("Capacitor1812CapShape",
2558     0.5*fgkSSDCapacitor1812CapLength, 0.5*fgkSSDCapacitor1812Width,
2559     0.5*fgkSSDCapacitor1812Height);
2560   TGeoVolume* capacitor1812cap = new TGeoVolume("Capacitor1812Cap",capacitor1812capshape,
2561                                              fSSDStiffenerCapacitorCapMedium);
2562   capacitor1812cap->SetLineColor(fColorNiSn);
2563   TGeoTranslation* capacitor1812captrans1 = new TGeoTranslation(
2564         - capacitor1812shape->GetDX() - capacitor1812capshape->GetDX(),
2565         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2566         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2567         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2568   ssdhybridcapacitormother->AddNode(capacitor1812cap,1,capacitor1812captrans1);
2569   TGeoTranslation* capacitor1812captrans2 = new TGeoTranslation(
2570         capacitor1812shape->GetDX() + capacitor1812capshape->GetDX(),
2571         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2572         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2573         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2574   ssdhybridcapacitormother->AddNode(capacitor1812cap,2,capacitor1812captrans2);
2575
2576 ////////////////////////////
2577 //Hybrid Wire
2578 ////////////////////////////
2579   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2580                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2581                                  - fgkSSDConnectorSeparation;
2582   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2583                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2584   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2585
2586   Double_t wireangle = TMath::ATan(wirex/wirey);
2587   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2588                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2589   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2590                                              fSSDStiffenerHybridWireMedium); 
2591   hybridwire->SetLineColor(fColorPhynox);
2592   TGeoCombiTrans* hybridwirecombitrans[2];
2593   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2594                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2595                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2596                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2597                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2598                                    ssdstiffenershape->GetDZ()
2599                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight+fgkSSDConnectorSnHeight,
2600                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2601   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2602                             0.0,
2603                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2604                             0.0,        
2605                             new TGeoRotation("HybridWireRot2",
2606                           - wireangle*TMath::RadToDeg(),0.,0.));
2607   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2608   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2609   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2610   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2611   ssdhybridlist->Add(ssdhybridcapacitormother);
2612   /////////////////////////////////////////////////////////////
2613   // Deallocating memory
2614   /////////////////////////////////////////////////////////////
2615   delete hybridwirecombitrans[0];
2616   delete hybridwirecombitrans[1];
2617   return ssdhybridlist;
2618   /////////////////////////////////////////////////////////////
2619 }
2620 ///////////////////////////////////////////////////////////////////////////////
2621 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2622   /////////////////////////////////////////////////////////////
2623   // SSD Cooling Block System
2624   /////////////////////////////////////////////////////////////
2625   // SSD Cooling Block and Cooling Tube Transformations
2626   /////////////////////////////////////////////////////////////
2627   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2628   localcoolingblockrot->SetAngles(0.,90.,0.);
2629   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2630   TVector3* coolingblocktransvector;
2631   coolingblocktransvector = new TVector3(fgkCoolingTubeSeparation,
2632                                                                   fgkSSDSensorLength
2633                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2634                                                                 - fgkSSDCoolingBlockWidth);
2635   const Int_t kcoolingblocktransnumber = 2;
2636   const Int_t kcoolingblocknumber = 4;
2637   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2638   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2639   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2640   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2641     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2642       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X(),//+2*coolingtubedistance,
2643                                              j*coolingblocktransvector->Y(),
2644                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2645                                                     + fgkCoolingTubeRmax));
2646       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2647     }
2648   }
2649   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2650   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2651   /////////////////////////////////////////////////////////////
2652   // Adding Cooling block to mother volume
2653   /////////////////////////////////////////////////////////////
2654   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2655     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2656   }
2657   /////////////////////////////////////////////////////////////
2658   // Deallocating memory
2659   /////////////////////////////////////////////////////////////
2660   delete coolingblocktransvector;
2661   delete localcoolingblockrot;
2662
2663   return coolingsystemother;
2664 }
2665 /////////////////////////////////////////////////////////////////////////////////
2666 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2667   /////////////////////////////////////////////////////////////
2668   // SSD Flex
2669   /////////////////////////////////////////////////////////////
2670   const Int_t kssdflexlayernumber = 2;
2671   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2672   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2673   const Int_t kmothervertexnumber = 17; 
2674   Double_t xmothervertex[kmothervertexnumber];
2675   Double_t ymothervertex[kmothervertexnumber];
2676   /////////////////////////////////////////////
2677   // Auxiliary variables for vertex positioning
2678   /////////////////////////////////////////////
2679   const Int_t kssdflexboxnumber = 5;
2680   Double_t ssdflexboxlength[kssdflexboxnumber];
2681   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2682                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2683                                           *     fgkSSDChipSeparationLength
2684                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2685                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2686   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2687   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2688                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2689   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2690   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2691                                           -     ssdflexboxlength[1];
2692   Double_t ssdflexboxwidth[kssdflexboxnumber];
2693   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2694   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2695   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2696   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2697   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2698   ///////////////////////
2699   // Setting the vertices 
2700   ///////////////////////
2701   xmothervertex[0]  = 0.0;
2702   xmothervertex[1]  = xmothervertex[0];
2703   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2704   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2705                                         + ssdflexboxlength[4];
2706   xmothervertex[4]  = xmothervertex[3];
2707   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2708   xmothervertex[6]  = xmothervertex[5];
2709   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2710   xmothervertex[8]  = xmothervertex[7];
2711   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2712   xmothervertex[10] = xmothervertex[9]; 
2713   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2714   xmothervertex[12] = xmothervertex[11];
2715   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2716   xmothervertex[14] = xmothervertex[13];
2717   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2718   xmothervertex[16] = xmothervertex[15];
2719   ymothervertex[0]  = 0.0;
2720   ymothervertex[1]  = fgkSSDFlexWidth[1];
2721   ymothervertex[2]  = fgkSSDFlexWidth[0];
2722   ymothervertex[3]  = ymothervertex[2];
2723   ymothervertex[4]  = ymothervertex[0];
2724   ymothervertex[5]  = ymothervertex[4];
2725   ymothervertex[6]  = ssdflexboxwidth[2];
2726   ymothervertex[7]  = ymothervertex[6];
2727   ymothervertex[8]  = ymothervertex[0];
2728   ymothervertex[9]  = ymothervertex[8];
2729   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2730   ymothervertex[11] = ymothervertex[10];
2731   ymothervertex[12] = ymothervertex[0];
2732   ymothervertex[13] = ymothervertex[12];
2733   ymothervertex[14] = ymothervertex[7];
2734   ymothervertex[15] = ymothervertex[14];
2735   ymothervertex[16] = ymothervertex[0];
2736   /////////////////////////////////////////////////////////////
2737   // First Mother Volume containing SSDFlex
2738   /////////////////////////////////////////////////////////////
2739   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2740   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2741                                                                     ymothervertex);
2742   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2743   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2744   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2745 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2746 //                                                                                       fSSDAir);
2747   /////////////////////////////////////////////////////////////
2748   // SSDFlex Layer Shapes
2749   /////////////////////////////////////////////////////////////
2750   for(Int_t i=0; i<kssdflexlayernumber; i++){
2751         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2752                                                                    ymothervertex);
2753     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2754         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2755   }
2756   /////////////////////////////////////
2757   // Setting Layers into Mother Volume
2758   /////////////////////////////////////
2759   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2760   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2761                                                                                                  fSSDKaptonFlexMedium};
2762   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2763                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2764   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2765   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2766   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2767         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2768                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2769                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2770         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2771     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2772                                          +                                         fgkSSDFlexHeight[1])); 
2773     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2774   }
2775   return ssdflexmother;
2776 }
2777 /////////////////////////////////////////////////////////////////////////////////
2778 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2779   /////////////////////////////////////////////////////////////
2780   // Method generating SSD End Flex   
2781   /////////////////////////////////////////
2782   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2783                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2784   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2785                                                 * TMath::DegToRad()*ssdflexradiusmax
2786                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2787                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2788                                                         - 0.1*fgkSSDFlexFullLength;
2789   const Int_t knedges = 20;  
2790   const Int_t karcnumber = 2;
2791   TVector3* vertexposition[karcnumber*(knedges+1)];
2792   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2793   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2794   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2795   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2796                                                                                  - 90.0*TMath::DegToRad()};
2797   TVector3* referencetrans[karcnumber];
2798   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2799                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2800                                                                    radius[0]);
2801   referencetrans[1] = new TVector3(referencetrans[0]->X()
2802                                         +              fgkSSDFlexLength[2],
2803      -              fgkSSDStiffenerHeight);
2804 for(Int_t i=0; i<karcnumber; i++){
2805         for(Int_t j=0; j<knedges+1; j++){
2806                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2807                                                                                                radius[i]*SinD(angle[i]));
2808                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2809         }       
2810   }
2811   ///////////////////////
2812   // Setting the vertices 
2813   ///////////////////////
2814   const Int_t kendflexlayernumber = 4;
2815   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2816   TVector3** vertex[kendflexlayernumber];
2817   for(Int_t i=0; i<kendflexlayernumber; i++) 
2818                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2819   TVector3* transvector[kendflexlayernumber+1];
2820   TVector3* deltatransvector = new TVector3();  
2821   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2822   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2823                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2824   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2825         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2826                                         *                 CosD(fgkSSDFlexAngle),
2827                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2828                                         *         SinD(fgkSSDFlexAngle),0.0);   
2829         *transvector[i] = *transvector[i-1]+*deltatransvector;
2830   }
2831   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2832   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2833   for(Int_t i=0; i<karcnumber; i++){
2834         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2835                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2836                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2837                                               /radius[i];
2838         }
2839   }
2840   for(Int_t i=0; i<kendflexlayernumber; i++){
2841         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2842         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2843         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2844                 if(j<(knedges+1)){
2845                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2846                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2847                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2848                         *vertex[i][j+2] += *referencetrans[0];
2849                         vertex[i][4*(knedges+1)-j+1] = 
2850                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2851                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2852                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2853                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2854                 }
2855                 else{
2856                 
2857                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2858                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2859                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2860                         *vertex[i][j+2] += *referencetrans[1];
2861                         vertex[i][4*(knedges+1)-j+1] = 
2862                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2863                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2864                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2865                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2866            }
2867         }
2868   }
2869   /////////////////////////////////////////////////////////////
2870   // First Mother Volume containing SSDEndFlex
2871   /////////////////////////////////////////////////////////////
2872   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2873   Double_t xmothervertex[kendflexvertexnumber];
2874   Double_t ymothervertex[kendflexvertexnumber];
2875   xmothervertex[0] = vertex[0][0]->X(); 
2876   ymothervertex[0] = vertex[0][0]->Y();
2877   for(Int_t i=1; i<kendflexvertexnumber; i++){
2878         if(i<2*(knedges+1)+2){
2879                 xmothervertex[i] = vertex[3][i]->X();
2880                 ymothervertex[i] = vertex[3][i]->Y();
2881         }
2882         else{
2883                 xmothervertex[i] = vertex[0][i]->X();
2884                 ymothervertex[i] = vertex[0][i]->Y();
2885         }
2886   }
2887   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2888                                                                            xmothervertex,ymothervertex);
2889   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2890   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2891 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2892 //                                                               ssdendflexmothershape,fSSDAir);        
2893   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2894   //////////////////////////////////////
2895   // End Flex TGeoXtru Layer Definition 
2896   //////////////////////////////////////
2897   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2898   TGeoVolume* ssdendflex[kendflexlayernumber];
2899   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2900   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2901   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2902   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2903   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2904                                                                                                         fSSDKaptonFlexMedium};
2905   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2906                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2907   for(Int_t i=0; i<kendflexlayernumber; i++){
2908         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2909                 xvertex[i][j] = vertex[i][j]->X();
2910                 yvertex[i][j] = vertex[i][j]->Y();
2911         }
2912   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2913   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2914   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2915   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2916                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2917   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2918   ssdendflexmother->AddNode(ssdendflex[i],1);
2919   }
2920   /////////////////////////////////////////////////////////////
2921   // Deallocating memory
2922   /////////////////////////////////////////////////////////////
2923   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2924   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2925   for(Int_t i=0; i<kendflexlayernumber; i++){
2926         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2927         delete [] vertex[i];
2928   }
2929   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2930   delete deltatransvector;
2931   /////////////////////////////////////////////////////////////
2932   //ssdendflexmother->CheckOverlaps(0.01);
2933   return ssdendflexmother;
2934 }
2935 ///////////////////////////////////////////////////////////////////////////////
2936 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
2937   /////////////////////////////////////////////////////////////
2938   // Method generating the Mounting Block
2939   /////////////////////////////////////////////////////////////  
2940   const Int_t kvertexnumber = 8;
2941   Double_t xvertex[kvertexnumber];
2942   Double_t yvertex[kvertexnumber];
2943   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
2944   xvertex[1] = xvertex[0];
2945   xvertex[2] = -xvertex[0];
2946   xvertex[3] = xvertex[2];
2947   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
2948                          -                                 fgkSSDMountingBlockLength[2]);
2949   xvertex[5] = xvertex[4];
2950   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
2951                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
2952                          -     fgkSSDMountingBlockScrewHoleRadius[0];
2953   xvertex[7] = xvertex[6];
2954   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
2955                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
2956   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
2957   yvertex[2] = yvertex[1]; 
2958   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
2959   yvertex[4] = yvertex[3];
2960   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
2961                          - fgkSSDMountingBlockHeight[0];
2962   yvertex[6] = yvertex[5];
2963   yvertex[7] = yvertex[0];
2964
2965   ///////////////////////////////////////////////////////////////////////
2966   // TGeoXTru Volume definition for Mounting Block Part
2967   ///////////////////////////////////////////////////////////////////////
2968   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
2969   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
2970   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
2971   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
2972   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
2973                                                                           ssdmountingblockshape,
2974                                                                                   fSSDMountingBlockMedium);
2975   ssdmountingblock->SetLineColor(fColorG10);
2976   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
2977   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
2978   TGeoRotation* mountingblockrot = new TGeoRotation();
2979   mountingblockrot->SetAngles(90.,180.,-90.);
2980   mountingblockcombitrans->SetRotation(*mountingblockrot);
2981   /////////////////////////////////////////////////////////////
2982   // Generating the Mounting Block Screw Vertices 
2983   /////////////////////////////////////////////////////////////  
2984   const Int_t kscrewvertexnumber = 15;
2985   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
2986                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
2987                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
2988                                  * TMath::RadToDeg();
2989   Double_t phi0 = 90.+alpha;
2990   Double_t phi = 270.-2*alpha;
2991   Double_t deltaphi = phi/kscrewvertexnumber;   
2992   TVector3* screwvertex[kscrewvertexnumber+1];
2993   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
2994         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
2995                                    *CosD(phi0+i*deltaphi),
2996                                    fgkSSDMountingBlockScrewHoleRadius[0]
2997                                    *SinD(phi0+i*deltaphi));
2998   Double_t xscrewvertex[kscrewvertexnumber+6];
2999   Double_t yscrewvertex[kscrewvertexnumber+6];
3000   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3001   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3002                                   -               fgkSSDMountingBlockScrewHoleEdge);
3003   xscrewvertex[1] = xscrewvertex[0];
3004   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3005   xscrewvertex[2] = screwvertex[0]->X();
3006   yscrewvertex[2] = yscrewvertex[1];
3007   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3008         xscrewvertex[i+3] = screwvertex[i]->X();        
3009         yscrewvertex[i+3] = screwvertex[i]->Y();        
3010   } 
3011   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3012   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3013   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3014   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3015   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3016   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3017   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3018   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3019                                                         +                                  fgkSSDMountingBlockHeight[2]);
3020   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3021                                                                                 ssdmountingblockscrewshape,
3022                                                                                             fSSDMountingBlockMedium);
3023   ssdmountingblockscrew->SetLineColor(fColorG10);
3024   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3025   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3026   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3027                                                                         -                                yscrewvertex[1],
3028                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3029                                                                         -                                fgkSSDMountingBlockHeight[2]
3030                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3031                                                                         +                                fgkSSDMountingBlockHeight[2]
3032                                                                         -                                yvertex[0]));
3033   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3034                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3035                                                                                                                  yscrewvertex[1]
3036                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3037                                                                                                          +fgkSSDMountingBlockHeight[2]
3038                                                                                                          -yvertex[0]));
3039   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3040                                                                                                           yscrewvertex[1],
3041                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3042                                                                         +                                 fgkSSDMountingBlockHeight[2]
3043                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3044                                                                         +                                 fgkSSDMountingBlockHeight[2]
3045                                                                         -                                 yvertex[0]));
3046   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3047                                                                                                          yscrewvertex[1],
3048                                                                         -                                yscrewvertex[1]
3049                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3050                                                                         +                                fgkSSDMountingBlockHeight[2]
3051                                                                         -                                yvertex[0]));
3052   TGeoRotation* ssdmountingblockscrewrot[4];
3053   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3054         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3055     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3056     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3057   for(Int_t i=1; i<4; i++) 
3058         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3059   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3060   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3061   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3062   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3063                                                          +                                xvertex[0],yscrewvertex[1]
3064                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3065                                                          +                                fgkSSDMountingBlockHeight[2]
3066                                                          -                                yvertex[0]),0.);      
3067   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3068   for(Int_t i=0; i<4; i++){
3069         ssdmountingblockscrewmatrix[i] = 
3070                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3071         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3072   }
3073   ///////////////////////////////////////////////////////////////////////
3074   // TGeoXtru for Mother Volume 
3075   ///////////////////////////////////////////////////////////////////////
3076   const Int_t kvertexmothernumber = 12;
3077   Double_t xmothervertex[kvertexmothernumber];
3078   Double_t ymothervertex[kvertexmothernumber];
3079   for(Int_t i=0; i<6; i++){
3080         xmothervertex[i] = xvertex[i];
3081         ymothervertex[i] = yvertex[i];
3082   } 
3083   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3084   ymothervertex[6]  = ymothervertex[5];
3085   xmothervertex[7]  = xmothervertex[6];
3086   ymothervertex[7]  = ymothervertex[4];
3087   xmothervertex[8]  = xmothervertex[7]
3088                                         + 0.5*(fgkSSDMountingBlockLength[1]
3089                                         -          fgkSSDMountingBlockLength[2]);
3090   ymothervertex[8]  = ymothervertex[4];
3091   xmothervertex[9]  = xmothervertex[8];
3092   ymothervertex[9]  = ymothervertex[2];
3093   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3094   ymothervertex[10] = ymothervertex[1];
3095   xmothervertex[11] = xmothervertex[10];
3096   ymothervertex[11] = ymothervertex[0];  
3097   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3098   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3099   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3100   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3101   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3102                                                                           ssdmountingblockmothershape,
3103                                                                                   fSSDAir);
3104   /////////////////////////////////////////////////////////////
3105   // Placing the Volumes into Mother Volume 
3106   /////////////////////////////////////////////////////////////
3107   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3108   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3109   for(Int_t i=0; i<4; i++) 
3110         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3111                                                                         ssdmountingblockscrewmatrix[i]);
3112   /////////////////////////////////////////////////////////////
3113   // Deallocating memory
3114   /////////////////////////////////////////////////////////////
3115   delete mountingblockrot;
3116   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3117   delete ssdmountingblockglobalrot; 
3118   delete ssdmountingblockglobaltrans; 
3119   /////////////////////////////////////////////////////////////
3120   return ssdmountingblockmother;
3121 }
3122 ///////////////////////////////////////////////////////////////////////////////
3123  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3124   /////////////////////////////////////////////////////////////
3125   // Method generating the Mounting Block Clip 
3126   /////////////////////////////////////////////////////////////  
3127   const Int_t kmothervertexnumber = 10;
3128   Double_t xmothervertex[kmothervertexnumber];
3129   Double_t ymothervertex[kmothervertexnumber];
3130   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3131                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3132   xmothervertex[1] = xmothervertex[0];
3133   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3134                                    - fgkMountingBlockClibScrewRadius);
3135   xmothervertex[3] = xmothervertex[2]; 
3136   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3137   xmothervertex[5] = xmothervertex[4]; 
3138   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3139   xmothervertex[7] = xmothervertex[6]; 
3140   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3141   xmothervertex[9] = xmothervertex[8]; 
3142   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3143                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3144   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3145   ymothervertex[2] = ymothervertex[1];
3146   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3147                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3148                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3149   ymothervertex[4] = ymothervertex[3];
3150   ymothervertex[5] = ymothervertex[2];
3151   ymothervertex[6] = ymothervertex[5];
3152   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3153   ymothervertex[8] = ymothervertex[7];
3154   ymothervertex[9] = ymothervertex[0];
3155
3156   ///////////////////////////////////////////////////////////////////////
3157   // TGeoXTru Volume definition for Mounting Block Clip Part
3158   ///////////////////////////////////////////////////////////////////////
3159   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3160   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3161   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3162   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3163   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3164                                                                           ssdmountingblockclipshape,fSSDAir);
3165   ssdmountingblockclip->SetLineColor(4);
3166   ///////////////////////////////////////////////////////////////////////
3167   // TGeoXTru Volume definition for Clip 
3168   ///////////////////////////////////////////////////////////////////////
3169   const Int_t kclipvertexnumber = 6;
3170   Double_t xclipvertex[kclipvertexnumber];
3171   Double_t yclipvertex[kclipvertexnumber];
3172   xclipvertex[0] = xmothervertex[0];
3173   xclipvertex[1] = xclipvertex[0];
3174   xclipvertex[2] = xmothervertex[6];
3175   xclipvertex[3] = xclipvertex[2];
3176   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3177   xclipvertex[5] = xclipvertex[4];
3178   yclipvertex[0] = ymothervertex[0];
3179   yclipvertex[1] = ymothervertex[1];
3180   yclipvertex[2] = yclipvertex[1];
3181   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3182   yclipvertex[4] = yclipvertex[3];
3183   yclipvertex[5] = yclipvertex[0];
3184   TGeoXtru* clipshape = new TGeoXtru(2);
3185   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3186   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3187   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3188                                                          +   fgkMountingBlockClibWidth);
3189   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3190   clip->SetLineColor(18);
3191   ///////////////////////////////////////////////////////////////////////
3192   // Ladder Support Piece  
3193   ///////////////////////////////////////////////////////////////////////
3194   const Int_t ksupportvertexnumber = 4;
3195   Double_t xsupportvertex[ksupportvertexnumber];
3196   Double_t ysupportvertex[ksupportvertexnumber];
3197   xsupportvertex[0] = xclipvertex[5];
3198   xsupportvertex[1] = xsupportvertex[0];
3199   xsupportvertex[2] = xmothervertex[9];
3200   xsupportvertex[3] = xsupportvertex[2];
3201   ysupportvertex[0] = yclipvertex[0];
3202   ysupportvertex[1] = yclipvertex[3];
3203   ysupportvertex[2] = ysupportvertex[1];
3204   ysupportvertex[3] = ysupportvertex[0];
3205   TGeoXtru* supportshape = new TGeoXtru(2);
3206   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3207   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3208   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3209   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3210   support->SetLineColor(9);
3211   ///////////////////////////////////////////////////////////////////////
3212   // TGeoXTru Volume definition for Screw   
3213   ///////////////////////////////////////////////////////////////////////
3214   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3215                                                 0.5*fgkMountingBlockClibScrewRadius};
3216   Int_t edgesnumber[2] = {50,6};
3217   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3218                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3219   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3220   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3221   clipscrew->SetLineColor(12);
3222   TGeoRotation* screwrot = new TGeoRotation();
3223   screwrot->SetAngles(0.,90.,0.);
3224   TGeoTranslation* screwtrans = new TGeoTranslation();
3225   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3226                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3227                                                          0.5*fgkSSDMountingBlockWidth+
3228                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3229   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3230   ///////////////////////////////////////////////////////////////////////
3231   // Placing the Volumes
3232   ///////////////////////////////////////////////////////////////////////
3233   ssdmountingblockclip->AddNode(clip,1);
3234   ssdmountingblockclip->AddNode(support,1);
3235   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3236   /////////////////////////////////////////////////////////////
3237   // Deallocating memory
3238   /////////////////////////////////////////////////////////////  
3239   delete screwtrans;
3240   delete screwrot;
3241   /////////////////////////////////////////////////////////////
3242   return ssdmountingblockclip;
3243 }
3244 ///////////////////////////////////////////////////////////////////////////////
3245 void AliITSv11GeometrySSD::CreateCoolingTubes() {
3246   /////////////////////////////////////////////////////////////
3247   // Method generating the Cooling Tube 
3248   // sets fcoolingtube and returns list for endladdercoolingtube
3249   /////////////////////////////////////////////////////////////  
3250   TGeoTube *coolingtubeshape[2];
3251   // Ladder Cooling Tubes
3252
3253   // MvL: Simplified cooling tubes
3254   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,0.5*fgkCoolingTubeLength);
3255   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,coolingtubeshape[0]->GetDz());
3256
3257   // End Ladder Cooling Tubes   
3258   TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3259   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3260     endladdercoolingtubeshape[i] = new  TGeoTube*[2];
3261
3262   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
3263   endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3264                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0] - sensZshift));
3265   endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3266                                                  endladdercoolingtubeshape[0][0]->GetDz());
3267   endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3268                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1] + sensZshift));
3269   endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3270                                                  endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3271   // Ladder Cooling Tubes
3272   TGeoVolume* coolingtube[2];
3273   coolingtube[0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0], fSSDCoolingTubePhynox);
3274   coolingtube[1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[1], fSSDCoolingTubeWater);
3275   coolingtube[0]->SetLineColor(fColorPhynox);
3276   coolingtube[1]->SetLineColor(fColorWater);
3277
3278   // End Ladder Cooling Tubes   
3279   TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3280   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3281     endladdercoolingtube[i] = new TGeoVolume*[2];
3282   endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3283                                               endladdercoolingtubeshape[0][0],
3284                                               fSSDCoolingTubePhynox);
3285   endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3286                                               endladdercoolingtubeshape[0][1],
3287                                               fSSDCoolingTubeWater);
3288   endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3289                                               endladdercoolingtubeshape[1][0],
3290                                               fSSDCoolingTubePhynox);
3291   endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3292                                               endladdercoolingtubeshape[1][1],
3293                                               fSSDCoolingTubeWater);
3294   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3295     endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3296     endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3297   }
3298   
3299   /////////////////////////////////////////////////////////////
3300   // Virtual Volume containing Cooling Tubes
3301   /////////////////////////////////////////////////////////////
3302   // Ladder Cooling Tubes
3303   TGeoTube* virtualcoolingtubeshape = new TGeoTube(coolingtubeshape[1]->GetRmin(),
3304                                                    coolingtubeshape[0]->GetRmax(),
3305                                                    coolingtubeshape[0]->GetDz());
3306   fcoolingtube = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape, fSSDAir);
3307   fcoolingtube->AddNode(coolingtube[0],1);
3308   fcoolingtube->AddNode(coolingtube[1],1);
3309
3310   // End Ladder Cooling Tubes
3311   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3312   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3313     endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3314                                                        endladdercoolingtubeshape[i][0]->GetRmax(),
3315                                                        endladdercoolingtubeshape[i][0]->GetDz());
3316   fendladdercoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3317                                             endladdervirtualcoolingtubeshape[0],
3318                                             fSSDAir);
3319   fendladdercoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3320                                             endladdervirtualcoolingtubeshape[1],
3321                                             fSSDAir);
3322   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3323   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3324   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3325   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);  
3326 }
3327 ///////////////////////////////////////////////////////////////////////////////
3328 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3329   /////////////////////////////////////////////////////////////
3330   // Method generating SSD Cooling Block    
3331   /////////////////////////////////////////////////////////////
3332   const Int_t kvertexnumber = 8;
3333   ///////////////////////////////////////
3334   // Vertex Positioning for TGeoXTru
3335   ///////////////////////////////////////
3336   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3337   vertexposition[0] = new TVector3(0.0,0.0);
3338   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3339   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3340                                           vertexposition[1]->Y());
3341   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3342                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3343   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3344   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3345                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3346   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3347                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3348                                         - fgkSSDCoolingBlockHoleLength[0]
3349                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3350                                           fgkSSDCoolingBlockHeight[0]
3351                                         - fgkSSDCoolingBlockHoleRadius[1],
3352                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3353   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3354                                         - fgkSSDCoolingBlockHoleLength[0]),
3355                                           vertexposition[6]->Y());
3356   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3357                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3358   Double_t phi = 180.-alpha;
3359   Double_t psi = 180.+2.*alpha;
3360   Double_t deltapsi = psi/nedges;
3361   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3362   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3363                                                   fgkSSDCoolingBlockHoleCenter);
3364   for(Int_t i=0; i<nedges+1; i++){
3365         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3366                                                                                                radius*SinD(phi+i*deltapsi));
3367    *vertexposition[kvertexnumber+i] += (*transvector);
3368   }
3369   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3370   for(Int_t i=0; i<kvertexnumber; i++)
3371     vertexposition[kvertexnumber+nedges+1+i] = 
3372                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3373   ///////////////////////////////////////////////////////////////////////
3374   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3375   ///////////////////////////////////////////////////////////////////////
3376   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3377   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3378   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3379   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3380         xvertexpoints[i] = vertexposition[i]->X();
3381         yvertexpoints[i] = vertexposition[i]->Y();
3382   } 
3383   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3384                                                                                         yvertexpoints);
3385   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3386   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3387   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3388                                                                           ssdcoolingblockshape,
3389                                                                                   fSSDAlCoolBlockMedium);
3390   ssdcoolingblock->SetLineColor(fColorAl);
3391   /////////////////////////////////////////////////////////////
3392   // Deallocating memory
3393   /////////////////////////////////////////////////////////////
3394   delete [] vertexposition;
3395   delete [] xvertexpoints;
3396   delete [] yvertexpoints;
3397   /////////////////////////////////////////////////////////////
3398   return ssdcoolingblock;
3399 }
3400 /////////////////////////////////////////////////////////////////////////////////
3401 void AliITSv11GeometrySSD::GetSSDChipCables(TGeoVolume *&cableL, TGeoVolume *&cableR, Double_t SSDChipCablesHeight, Int_t nedges){
3402   ///////////////////////////////////////////////////////
3403   static const Int_t kssdchipcablesnumber    = 2;  // Number of cables: left and right
3404   static const Int_t kssdchipcableslaynumber = 2;  // Number of layers: Al and Kapton
3405   static const Int_t kvertexnumber                        = 4*(nedges+1)+4;
3406   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3407   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3408   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeight
3409                                                  -  fgkSSDChipCablesHeight[0]
3410                                                  -  fgkSSDChipCablesHeight[1]);
3411   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3412   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3413   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3414                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3415                                                           - ssdchipcablesradius[0]
3416                                                           - fgkSSDChipCablesWidth[1]
3417                                                           - fgkSSDChipCablesWidth[2]);
3418   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3419                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3420                                                           +      fgkSSDChipCablesHeight[1]
3421                                                           +      fgkSSDSensorHeight);
3422   ///////////////////////////////////////////////////////
3423   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3424   ///////////////////////////////////////////////////////
3425   TVector3** vertexposition[kssdchipcableslaynumber];
3426   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3427                                                                                                   new TVector3*[4*(nedges+1)+4];
3428   Double_t ratio[4];
3429   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3430   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3431                    /  ssdchipcablesradius[0]; 
3432   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3433                    /  ssdchipcablesradius[0];
3434   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3435                    +  fgkSSDChipCablesHeight[1])
3436                    /  ssdchipcablesradius[0];
3437   Double_t phi = 180.;
3438   Double_t deltaphi = 180./nedges;
3439   Double_t angle = 0.0;
3440
3441   Double_t xvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3442   Double_t yvertexpoints[kssdchipcableslaynumber][kvertexnumber];
3443
3444   TVector3* vertex = new TVector3();
3445   TVector3* transvector[kssdchipcableslaynumber];
3446   transvector[0] = new TVector3(fgkSSDChipWidth,
3447                                                                 SSDChipCablesHeight-ssdchipcablesradius[0]);
3448   transvector[1] = new TVector3();
3449   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcablesnumber];
3450   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcablesnumber];
3451   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcablesnumber] = 
3452                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3453                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3454   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3455         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3456         transvector[1]->SetY(ssdchipcablesradius[0]
3457                                  +               fgkSSDChipCablesHeight[0]
3458                                  +               fgkSSDChipCablesHeight[1]);  
3459         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3460                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeight
3461                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3462                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeight
3463                                                          - i*fgkSSDChipCablesHeight[0]);
3464                 vertexposition[i][2*(nedges+1)+2] = 
3465                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3466                                 +                                fgkSSDChipCablesWidth[1]
3467                                 +                                fgkSSDChipCablesWidth[2],
3468                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3469                                 +                                fgkSSDChipCablesHeight[1]));
3470         vertexposition[i][2*(nedges+1)+3] = 
3471                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3472                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3473                                 -                                fgkSSDChipCablesHeight[i]);
3474             for(Int_t j=0; j<nedges+1; j++){            
3475                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3476                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3477                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3478                         vertexposition[0][(nedges+1)*i+j+2] = 
3479                                                 new TVector3(*vertex+*transvector[i]);
3480                         vertexposition[1][(nedges+1)*i+j+2] = 
3481                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3482                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3483                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3484                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3485                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3486                                                 new TVector3(vertex->X()*ratio[2*i+1]
3487                                                         +                        transvector[i]->X(),
3488                                                                                  vertex->Y()*ratio[2*i+1]
3489                                                         +                transvector[i]->Y());
3490                 }
3491         }
3492         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3493                 for(Int_t j=0; j<kvertexnumber; j++){   
3494                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3495                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3496                 }
3497                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3498                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3499                                                                                 xvertexpoints[i],yvertexpoints[i]);
3500                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3501                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3502                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3503                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3504                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3505                                                           (kssdchipcablesnumber*k+i)%2==0?
3506                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3507                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3508         }
3509         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3510                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3511   }
3512   /////////////////////////////////////////////////////////////
3513   // Mother Volume definition 
3514   /////////////////////////////////////////////////////////////
3515   static const Int_t kmothervertexnumber = 8;
3516   Double_t xmothervertex[kmothervertexnumber];
3517   Double_t ymothervertex[kmothervertexnumber];
3518   xmothervertex[0] = xvertexpoints[0][1];
3519   ymothervertex[0] = yvertexpoints[0][1];
3520   xmothervertex[1] = xvertexpoints[0][2+nedges/2];
3521   ymothervertex[1] = yvertexpoints[0][1];
3522   xmothervertex[2] = xvertexpoints[0][2+nedges/2];
3523   ymothervertex[2] = yvertexpoints[0][2+nedges];
3524   xmothervertex[3] = xvertexpoints[0][3+nedges];
3525   ymothervertex[3] = yvertexpoints[0][3+nedges];
3526   xmothervertex[4] = xvertexpoints[0][3+2*nedges];
3527   ymothervertex[4] = yvertexpoints[0][3+2*nedges];
3528   xmothervertex[5] = xvertexpoints[0][4+2*nedges];
3529   ymothervertex[5] = yvertexpoints[0][4+2*nedges];
3530   xmothervertex[6] = xvertexpoints[1][5+2*nedges];
3531   ymothervertex[6] = yvertexpoints[1][5+2*nedges];
3532   xmothervertex[7] = xvertexpoints[0][1];
3533   ymothervertex[7] = yvertexpoints[1][5+2*nedges];
3534   TGeoXtru *ssdchipcablemothershape = new TGeoXtru(2);
3535   ssdchipcablemothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3536   ssdchipcablemothershape->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3537   ssdchipcablemothershape->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3538
3539   cableL = new TGeoVolume("SSDChipCableMotherLeft",ssdchipcablemothershape,fSSDAir);
3540   cableR = new TGeoVolume("SSDChipCableMotherRight",ssdchipcablemothershape,fSSDAir);
3541
3542   cableL->AddNode(ssdchipcable[0],1);
3543   cableL->AddNode(ssdchipcable[1],1);
3544   cableR->AddNode(ssdchipcable[2],1);
3545   cableR->AddNode(ssdchipcable[3],1);  
3546
3547   /////////////////////////////////////////////////////////////
3548   // Deallocating memory
3549   /////////////////////////////////////////////////////////////
3550   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3551   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3552   delete vertex; 
3553   /////////////////////////////////////////////////////////////
3554 }
3555 //_____________________________________________________________________________
3556 TGeoVolume* AliITSv11GeometrySSD::GetSSDChip() const{
3557   /////////////////////////////////////////////////////////////
3558   // SSD Chip Assembly Generation    
3559   /////////////////////////////////////////////////////////////
3560   TGeoBBox* ssdchipcompshape[2];
3561   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3562                                                                                 0.5*fgkSSDChipLength,
3563                                                                                 0.5*fgkSSDChipWidth,
3564                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3565   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3566                                                                                 0.5*fgkSSDChipLength,
3567                                                                                 0.5*fgkSSDChipWidth,
3568                                                                                 0.5*fgkSSDChipGlueHeight);
3569   TGeoVolume* ssdchipcomp[2];
3570   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3571   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3572                                                                   fSSDChipGlueMedium);
3573   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3574   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3575   TGeoTranslation* ssdchipcomptrans[2];
3576   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3577   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3578   /////////////////////////////////////////////////////////////
3579   // Virtual Volume containing SSDChip   
3580   /////////////////////////////////////////////////////////////
3581   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3582                                                                                                                  0.5*fgkSSDChipWidth,
3583                                                                                                                  0.5*fgkSSDChipHeight);
3584   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3585   /////////////////////////////////////////////////////////////
3586   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3587   return ssdchip;
3588 }
3589 /////////////////////////////////////////////////////////////////////////////////
3590 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3591   /////////////////////////////////////////////////////////////
3592   // Method returning a List containing pointers to Ladder Cable Volumes    
3593   //
3594   // Return list contains 3 assemblies: cable box, cable arb shape and the end part of the cable
3595   //                                    each contains 2 volumes, one for polyamide and one for aluminium
3596   /////////////////////////////////////////////////////////////
3597   const Int_t kladdercablesegmentnumber = 2;
3598   /////////////////////////////////////////
3599   // LadderSegmentBBox Volume
3600   /////////////////////////////////////////
3601   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3602   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3603                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3604
3605
3606   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3607                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3608   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3609
3610   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3611                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3612                                                                                            0.5*fgkSSDFlexWidth[0],
3613                                                                                            0.5*fgkSSDLadderCableWidth,
3614                                                                        0.5*fgkSSDLadderCableHeight[0]),
3615                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3616                                                                                            0.5*fgkSSDFlexWidth[0],
3617                                                                                            0.5*fgkSSDLadderCableWidth,
3618                                                                                            fgkSSDLadderCableHeight[0]
3619                                                                                            +0.5*fgkSSDLadderCableHeight[1])
3620                                                                                    };
3621   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3622   static TGeoVolume* laddercablesegmentarbassembly = 
3623                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3624
3625   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3626   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3627
3628   if (laddercablesegmentbboxshape[0] == 0) { 
3629     // Initialise static shapes and volumes 
3630   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3631                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3632                                                                            0.5*fgkSSDFlexWidth[0],
3633                                                                            0.5*fgkSSDLadderCableWidth,
3634                                                                            0.5*fgkSSDLadderCableHeight[i]); 
3635
3636   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3637                         laddercablesegmentbbox[i] =
3638                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3639                                                                                  laddercablesegmentbboxshape[i],
3640                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3641             fSSDKaptonLadderCableMedium));
3642                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3643                                                                                                                    fColorPolyhamide);
3644   }
3645   
3646   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3647                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3648                                                                                             laddercablesegmentbboxtrans[i]);
3649 /////////////////////////////////////////
3650 // LadderSegmentArb8 Volume
3651 /////////////////////////////////////////
3652   const Int_t kvertexnumber = 4;
3653   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3654   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3655                                                                                                   new TVector3*[kvertexnumber];
3656 //Shape Vertex Positioning
3657   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3658         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3659         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3660                                                                                                                   i*fgkSSDFlexHeight[0]);
3661         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3662                                                                                    +                         fgkSSDFlexHeight[1]
3663                                                                                    +                      i*fgkSSDFlexHeight[0]);
3664         laddercablesegmentvertexposition[i][3] = 
3665                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3666                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3667   }
3668   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3669                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3670   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3671                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3672
3673   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3674                                         GetArbShape(laddercablesegmentvertexposition[i],
3675                                                                 laddercablesegmentwidth[i],
3676                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3677                                                                 laddercablesegmentarbshapename[i]);
3678   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3679                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3680
3681   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3682                          laddercablesegmentarb[i] =
3683                                                    new TGeoVolume(laddercablesegmentarbname[i],
3684                                                                                   laddercablesegmentarbshape[i],
3685                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3686             fSSDKaptonLadderCableMedium)); 
3687                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3688                                                                                                                    fColorPolyhamide);
3689 }
3690   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3691   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3692                                                                                                  90.,90,-90.);   
3693   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3694                                                                                                   0.,90.,0.);    
3695   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3696                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3697                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3698                                                          + fgkSSDFlexWidth[0],0.,0.,
3699                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3700                                                      *(*laddercablesegmentarbrot[0])));
3701   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3702   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3703                                                                                    laddercablesegmentarbcombitrans);
3704   }  // End of static initialisations
3705 /////////////////////////////////////////
3706 // End Ladder Cable Volume
3707 // Note: this part depends explicitly on the length passed as an argument to the function
3708 /////////////////////////////////////////
3709   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
3710   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
3711                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
3712   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
3713                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
3714                                                                            0.5*ssdendladdercablelength,
3715                                                                            0.5*fgkSSDLadderCableWidth,
3716                                                                            0.5*fgkSSDLadderCableHeight[i]);
3717   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
3718                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
3719   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
3720   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3721                         ladderendcablesegmentbbox[i] =
3722                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
3723                                                                                  ladderendcablesegmentbboxshape[i],
3724                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3725             fSSDKaptonLadderCableMedium));
3726                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3727                                                                                                                    fColorPolyhamide);
3728   }
3729   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
3730   ladderendcablesegmentbboxtrans[0] = 
3731                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
3732                                                                                            0.5*ssdendladdercablelength,
3733                                                                                            0.5*fgkSSDLadderCableWidth,
3734                                                                                            0.5*fgkSSDLadderCableHeight[0]);
3735   ladderendcablesegmentbboxtrans[1] = 
3736                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
3737                                                                                            0.5*ssdendladdercablelength,
3738                                                                                            0.5*fgkSSDLadderCableWidth,
3739                                                                                            fgkSSDLadderCableHeight[0]
3740                                                                                            +0.5*fgkSSDLadderCableHeight[1]);
3741   TGeoVolume* ladderendcablesegmentbboxassembly = 
3742                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
3743   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3744                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
3745                                                                                             ladderendcablesegmentbboxtrans[i]);
3746 /////////////////////////////////////////
3747   TList* laddercablesegmentlist = new TList();
3748   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
3749   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
3750   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
3751   return laddercablesegmentlist;
3752 }
3753
3754 /////////////////////////////////////////////////////////////////////////////////
3755 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
3756   /////////////////////////////////////////////////////////////
3757   // Method generating Ladder Cable of given length (n modules + end)
3758   // Called by GetLadderCableAssembly
3759   /////////////////////////////////////////////////////////////
3760   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
3761   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
3762   for(Int_t i=0; i<n; i++){
3763          TGeoTranslation* laddercabletrans = new TGeoTranslation(
3764                                                         i*(fgkCarbonFiberJunctionWidth),
3765                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3766                                                         i*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3767     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
3768     if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
3769  
3770   }
3771   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
3772                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3773                                                              fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3774                                                              (n-1)*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
3775   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
3776   return laddercable;
3777 }
3778 /////////////////////////////////////////////////////////////////////////////////
3779 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
3780   ///////////////////////////////////////////////////////////////////
3781   // Main method generating Ladder Cable bundles containing n cables
3782   ///////////////////////////////////////////////////////////////////
3783   Double_t totalLength = ssdendladdercablelength+(n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0];
3784   Double_t cableOrig[3] = {0.5*totalLength,1.5*fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1])};
3785   TGeoBBox *laddercableshape = new TGeoBBox(0.5*totalLength,0.5*fgkSSDLadderCableWidth,0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]),cableOrig);
3786   TGeoVolume* laddercable = new TGeoVolume("LadderCableMother", laddercableshape, fSSDAir);
3787   char laddercabletransname[100];
3788   for(Int_t i=0; i<n; i++){ 
3789     snprintf(laddercabletransname,100,"LadderCableTrans%i",i+1);
3790     laddercable->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
3791                          new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0,0));
3792   }
3793   return laddercable;
3794 }
3795 /////////////////////////////////////////////////////////////////////////////////
3796 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
3797   /////////////////////////////////////////////////////////////
3798   // Method generating Ladder Cable List Assemblies  
3799   // containing two cables bundles, i.e. P+N readout for one endcap
3800   /////////////////////////////////////////////////////////////  
3801   const Int_t kladdercableassemblynumber = 2; 
3802   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
3803   TGeoVolume* ladderCable[kladdercableassemblynumber];
3804   char laddercableassemblyname[100];
3805   TList* laddercableassemblylist = new TList();
3806   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
3807     snprintf(laddercableassemblyname,100,"LadderCableAssembly%i",i+1);
3808         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
3809         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
3810                                          new TGeoCombiTrans((n-1)
3811                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3812                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
3813                                                                                         0.,new TGeoRotation("",180,0.,0.)));
3814         laddercableassemblylist->Add(ladderCable[i]);
3815 }
3816   return laddercableassemblylist;
3817 }
3818 ///////////////////////////////////////////////////////////////////////////////
3819 void AliITSv11GeometrySSD::SetLadderSegment(){
3820   /////////////////////////////////////////////////////////////
3821   // Method Generating Ladder Segment Array
3822   /////////////////////////////////////////////////////////////
3823   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
3824   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
3825
3826   /* MvL: tried to create mother volume. Requires changes in all rotations, bc xtru is always along z-axis
3827   TGeoXtru *laddersegmentshape = new TGeoXtru(2);
3828   static const Int_t ntrianglevtx = 3;
3829   Double_t xtrianglevtx[ntrianglevtx]={-0.5*fgkCarbonFiberTriangleLength,fgkCarbonFiberTriangleLength, 0};
3830   Double_t ytrianglevtx[ntrianglevtx]={0, 0, fgkCarbonFiberTriangleLength * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad())};
3831   laddersegmentshape->DefinePolygon(ntrianglevtx,xtrianglevtx,ytrianglevtx);
3832   laddersegmentshape->DefineSection(0,0);
3833   laddersegmentshape->DefineSection(1,fgkCarbonFiberJunctionWidth);  // MVL
3834   fladdersegment[0] = new TGeoVolume("LadderSegment1",laddersegmentshape,fSSDAir);      
3835   fladdersegment[1] = new TGeoVolume("LadderSegment2",laddersegmentshape,fSSDAir);      
3836   */
3837
3838   if(!fCreateMaterials) CreateMaterials();
3839   if(!fTransformationMatrices) CreateTransformationMatrices();
3840   if(!fBasicObjects) CreateBasicObjects();
3841   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
3842   // Placing Carbon Fiber Support       
3843         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
3844                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3845                                                                                         fcarbonfibersupportmatrix[j]);  
3846                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3847                                                                                         fcarbonfibersupportmatrix[j]);
3848   }
3849   // Placing Carbon Fiber Junction
3850         for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++) {
3851         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
3852                                                                    fcarbonfiberjunctionmatrix[j]);
3853   }
3854   // Placing Carbon Fiber Lower Support
3855     for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++) {
3856                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
3857                                                            fcarbonfiberlowersupportrans[j]);    
3858     }
3859   // Placing SSD Sensor Support
3860     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
3861         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
3862                                                                      fssdsensorsupport[1][i],
3863                                                            j+1,fssdsensorsupportmatrix[j]);
3864   // Placing SSD Cooling Tube Support 
3865         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
3866                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3867                                                                    fcoolingtubesupportmatrix[j]);
3868   // Placing SSD Cooling Tube  
3869         fladdersegment[i]->AddNode(fcoolingtube,1,fcoolingtubematrix[0]);
3870         fladdersegment[i]->AddNode(fcoolingtube,2,fcoolingtubematrix[1]);
3871   // Placing SSD Hybrid
3872     switch(i){
3873         case 0: 
3874                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
3875                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3876                 break;
3877     case 1:
3878                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
3879                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3880                 break;
3881         }
3882         // Placing Cooling Block System
3883       fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
3884         // Placing SSD Flex
3885       for(Int_t j=0; j<fgkflexnumber; j++){
3886         fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
3887         fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
3888       }
3889    }
3890 }
3891 ///////////////////////////////////////////////////////////////////////////////
3892 void AliITSv11GeometrySSD::SetEndLadderSegment(){
3893   /////////////////////////////////////////////////////////////
3894   // Method Generating End Ladder
3895   /////////////////////////////////////////////////////////////
3896   // End Ladder Carbon Fiber Junction 
3897   /////////////////////////////////////////////////////////////
3898   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
3899   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
3900   if(!fCreateMaterials) CreateMaterials();
3901   if(!fTransformationMatrices) CreateTransformationMatrices();
3902   if(!fBasicObjects) CreateBasicObjects();
3903   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
3904         for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
3905                 fendladdersegment[i]->AddNode(j==2 ? 
3906                                                         fendladdercarbonfiberjunction[i][1] : 
3907                                                         fendladdercarbonfiberjunction[i][0],
3908                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
3909   }
3910   /////////////////////////////////////////////////////////////
3911   // End Ladder Carbon Fiber Support 
3912   /////////////////////////////////////////////////////////////
3913   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
3914       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
3915                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3916                   fendladdercarbonfibermatrix[i][j]);   
3917           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3918                   fendladdercarbonfibermatrix[i][j]);   
3919       }
3920   /////////////////////////////////////////////////////////////
3921   // End Ladder Mounting Block
3922   /////////////////////////////////////////////////////////////
3923   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3924        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
3925                                      fendladdermountingblockcombitrans[i]);
3926   /////////////////////////////////////////////////////////////
3927   // End Ladder Mounting Block Clip
3928   /////////////////////////////////////////////////////////////
3929   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3930         for(Int_t j=0; j<2; j++)
3931                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
3932                                               fendladdermountingblockclipmatrix[i][j]);
3933   /////////////////////////////////////////////////////////////
3934   // End Ladder Lower Supports
3935   /////////////////////////////////////////////////////////////
3936   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
3937                                 fendladderlowersupptrans[0]);
3938   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
3939                                 fendladderlowersupptrans[1]);
3940   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
3941                                 fendladderlowersupptrans[2]);
3942   /////////////////////////////////////////////////////////////
3943   // End Ladder Cooling Tube Support
3944   /////////////////////////////////////////////////////////////
3945   for(Int_t i=0; i<2; i++) 
3946         for(Int_t j=0; j<(i==0?4:2); j++)   
3947                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3948                                               fendladdercoolingtubesupportmatrix[i][j]);
3949   /////////////////////////////////////////////////////////////
3950   // End Ladder Cooling Tube Support
3951   /////////////////////////////////////////////////////////////
3952   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]); 
3953   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);
3954   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[1][0]);
3955   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[1][1]); 
3956 }
3957 ///////////////////////////////////////////////////////////////////////////////
3958 void AliITSv11GeometrySSD::SetLadder(){
3959   /////////////////////////////////////////////////////////////
3960   // Method Generating Ladder of Layer 5 and 6
3961   /////////////////////////////////////////////////////////////  
3962   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
3963                                                                                                 fgkSSDLay6SensorsNumber};
3964   /////////////////////////////////////////////////////////////////////////////                                         
3965   /// Generating Ladder Mother Volume Containing Ladder 
3966   /////////////////////////////////////////////////////////////////////////////          
3967   TGeoXtru* laddershape[fgkladdernumber];       
3968   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
3969   const Int_t kmothervertexnumber = 8;  
3970   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
3971   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
3972   ///////////////////////
3973   // Setting the vertices 
3974   ///////////////////////
3975   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
3976                                                                 * (fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]);
3977   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
3978   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
3979   xmothervertex[0][1] = xmothervertex[0][0];
3980   ymothervertex[0][1] = -0.5*fgkCoolingTubeSupportHeight; // 0.0; MvL 20-apr-2010
3981   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
3982                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
3983   ymothervertex[0][2] = ymothervertex[0][1];
3984   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
3985   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
3986   xmothervertex[0][4] = -xmothervertex[0][3];
3987   ymothervertex[0][4] = ymothervertex[0][3];
3988   xmothervertex[0][5] = -xmothervertex[0][2];
3989   ymothervertex[0][5] = ymothervertex[0][2];
3990   xmothervertex[0][6] = -xmothervertex[0][1];
3991   ymothervertex[0][6] = ymothervertex[0][1];
3992   xmothervertex[0][7] = -xmothervertex[0][0];
3993   ymothervertex[0][7] = ymothervertex[0][0];
3994   for(Int_t i=0; i<kmothervertexnumber; i++){
3995         xmothervertex[1][i] = xmothervertex[0][i];
3996         ymothervertex[1][i] = ymothervertex[0][i];
3997   }
3998 ///////////////////////////////////////////////////////////////////////////
3999 // Disalignement Mother Volume corrections 25/08/08
4000 ///////////////////////////////////////////////////////////////////////////
4001   TGeoXtru* leftladdershape1[fgkladdernumber];  
4002   TGeoXtru* leftladdershape2[fgkladdernumber];  
4003   TGeoXtru* centersensorladdershape[fgkladdernumber];   
4004   TGeoXtru* rightladdershape1[fgkladdernumber]; 
4005   TGeoXtru* rightladdershape2[fgkladdernumber]; 
4006   for(Int_t i=0; i<fgkladdernumber; i++){
4007     leftladdershape1[i] = new TGeoXtru(2);
4008     leftladdershape2[i] = new TGeoXtru(2);
4009     centersensorladdershape[i] = new TGeoXtru(2);
4010     rightladdershape1[i] = new TGeoXtru(2);
4011     rightladdershape2[i] = new TGeoXtru(2);
4012   }
4013   //////////////////////////////////////
4014   // Setting the names for shapes  
4015   //////////////////////////////////////
4016   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
4017   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
4018   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
4019   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
4020   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
4021   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
4022   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
4023   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
4024   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
4025   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
4026   //////////////////////////////////////
4027   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
4028   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
4029   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
4030   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
4031   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
4032   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
4033   for(Int_t i=0; i<fgkladdernumber; i++) {
4034     for(Int_t j=0; j<kmothervertexnumber; j++){
4035       xcentersensorvertex[i][j] = xmothervertex[i][j];
4036       ycentersensorvertex[i][j] = ymothervertex[i][j];
4037       xend1laddervertex[i][j] = xmothervertex[i][j];
4038       yend1laddervertex[i][j] = ymothervertex[i][j];
4039       xend2laddervertex[i][j] = xmothervertex[i][j];
4040       yend2laddervertex[i][j] = ymothervertex[i][j];
4041     }
4042     // Add some space around sensors to accommodate misalignments
4043     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
4044     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
4045     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
4046     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
4047     
4048     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
4049     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
4050     
4051     // Center Ladder Piece
4052     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
4053                                               ycentersensorvertex[i]);
4054     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4055                                                  + 1.45*fgkSSDMountingBlockWidth);
4056     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
4057                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4058                                                  - 2.4*fgkSSDMountingBlockWidth);
4059
4060     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
4061
4062     // Cuts off first corner (neg x)
4063     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
4064     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
4065     // Cuts off last part (pos x)
4066     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
4067     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
4068
4069     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
4070                                        yend1laddervertex[i]);
4071     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4072     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4073                                          - fgkEndLadderMountingBlockPosition[0]);
4074     
4075     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
4076                                        yend2laddervertex[i]);
4077     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4078                                          - fgkEndLadderMountingBlockPosition[0]); 
4079     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4080                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4081
4082     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4083                                         yend1laddervertex[i]);
4084     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4085                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4086                                         -2.4*fgkSSDMountingBlockWidth);
4087     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4088                                         + fgkEndLadderMountingBlockPosition[1]);
4089
4090     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4091                                         yend2laddervertex[i]);
4092     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4093                                            + fgkEndLadderMountingBlockPosition[1]);
4094     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4095                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4096   }
4097   TGeoCompositeShape* laddershapecontainer[2];
4098   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4099                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4100                                                    "+Lay5CenterSensorContainer"
4101                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4102   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4103                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4104                                                    "+Lay6CenterSensorContainer"
4105                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4106   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4107   for(Int_t i=0; i<fgkladdernumber; i++){
4108     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4109     fladder[i]->SetLineColor(4);
4110   }
4111 ///////////////////////////////////////////////////////////////////////////
4112  if(!fCreateMaterials) CreateMaterials();
4113  if(!fTransformationMatrices) CreateTransformationMatrices();
4114  if(!fBasicObjects) CreateBasicObjects();
4115  SetLadderSegment(); 
4116  SetEndLadderSegment();
4117   for(Int_t i=0; i<fgkladdernumber; i++){
4118         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4119         //////////////////////////                                              
4120         /// Placing Ladder Segment
4121         //////////////////////////              
4122                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4123                                                                      fladdersegment[i==0 ? 1 : 0],
4124                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4125         //////////////////////////                                              
4126         /// Placing SSD Sensor
4127         //////////////////////////              
4128         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4129                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4130                                                         fssdsensormatrix[i][j]);
4131         }
4132         ///////////////////////////////                                         
4133         /// Placing End Ladder Segment
4134         ///////////////////////////////         
4135         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4136         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4137    }
4138 /////////////////////////////////////////////////////////////////////////////                                           
4139 /// Placing Ladder Cables
4140 /////////////////////////////////////////////////////////////////////////////           
4141   Int_t sidecablenumber[2][2];
4142   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4143   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4144   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4145   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4146   Double_t carbonfibertomoduleposition[3];
4147   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4148   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4149                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4150          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4151          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4152          -            fgkSSDSensorCenterSupportThickness[0]);
4153   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4154                                                                  +   0.5*fgkCoolingTubeSupportHeight
4155          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4156   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4157   Double_t ssdendladdercablelength[4];
4158   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4159                                                          + fgkSSDSensorLength
4160                                                          - fgkSSDModuleStiffenerPosition[1]
4161                                                          - fgkSSDStiffenerWidth 
4162                                                          - fgkSSDFlexWidth[0]
4163                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4164   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4165                                                          + fgkSSDModuleStiffenerPosition[1]
4166                                                          + fgkSSDStiffenerWidth
4167                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4168   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4169                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4170                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4171                                                          - kendladdercablecorrection;
4172   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4173                                                          + carbonfibertomoduleposition[1]
4174                                                          - fgkSSDModuleStiffenerPosition[1]
4175                                                          - fgkSSDStiffenerWidth)
4176                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4177
4178   TList* laddercableassemblylist[4];
4179   const Int_t kendladdercablesnumber = 4;
4180   TGeoRotation *laddercablerot = new TGeoRotation();
4181   laddercablerot->SetAngles(90.,60.,-90.);
4182   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4183         for(Int_t j=0; j<kendladdercablesnumber; j++){
4184                 laddercableassemblylist[j] = 
4185                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4186                                                                    ssdendladdercablelength[j]);
4187                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4188                                                                         j<2?1:2,fladdercablematrix[i][j]);
4189   }
4190 }
4191 ////////////////////////////////////////////////////////////////////////////////
4192 void AliITSv11GeometrySSD::SetLayer(){
4193 ////////////////////////////////////////////////////////////////////////////////
4194   // Creating Ladder of Layer 5 and Layer 6
4195   /////////////////////////////////////////////////////////////
4196   if(!fCreateMaterials) CreateMaterials();
4197   if(!fTransformationMatrices) CreateTransformationMatrices();
4198   if(!fBasicObjects) CreateBasicObjects();
4199   SetLadder(); // Generating the ladder of Layer5 and Layer6
4200   const Int_t kssdlayladdernumber[fgklayernumber] = 
4201                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4202   /////////////////////////////////////////////////////////////
4203   // Generating mother volumes for Layer5 and Layer6
4204   /////////////////////////////////////////////////////////////
4205   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4206   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4207   Int_t *ladderindex[fgklayernumber];
4208   Int_t index[fgklayernumber] = {8,9};
4209   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4210   for(Int_t i=0; i<fgklayernumber; i++) 
4211         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4212                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4213                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4214                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4215                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4216         }
4217   /////////////////////////////////////////////////////////////
4218   // Deallocating memory
4219   /////////////////////////////////////////////////////////////
4220   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
4221 }
4222 ////////////////////////////////////////////////////////////////////////////////
4223 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4224   /////////////////////////////////////////////////////////////
4225   // Insert the layer 5 in the mother volume. 
4226   /////////////////////////////////////////////////////////////
4227   if (! moth) {
4228     AliError("Can't insert layer5, mother is null!\n");
4229     return;
4230   };
4231   if(!fSSDLayer5) SetLayer();
4232   fMotherVol = moth;
4233   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4234                                                                                 + fgkLay5CenterITSPosition);
4235   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4236  }
4237 ////////////////////////////////////////////////////////////////////////////////
4238 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4239   /////////////////////////////////////////////////////////////
4240   // Insert the layer 6 in the mother volume. 
4241   /////////////////////////////////////////////////////////////
4242   if (! moth) {
4243     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4244     return;
4245   };
4246   if(!fSSDLayer6) SetLayer();
4247   fMotherVol = moth;
4248   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4249                                                                                 + fgkLay6CenterITSPosition);
4250   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4251  }
4252  ////////////////////////////////////////////////////////////////////////////////
4253  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4254   /////////////////////////////////////////////////////////////
4255   // Method generating the Arc structure of Ladder Support 
4256   /////////////////////////////////////////////////////////////
4257   const Int_t kssdlayladdernumber[fgklayernumber] = 
4258                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4259   Double_t mountingsupportedge[fgklayernumber];
4260   Double_t mountingblockratio[fgklayernumber];
4261   Double_t theta[fgklayernumber];
4262   Double_t phi[fgklayernumber];
4263   Double_t psi0[fgklayernumber];
4264   Double_t deltapsi[fgklayernumber];
4265   TVector3* mountingsupportedgevector[fgklayernumber];
4266   for(Int_t i=0; i<fgklayernumber; i++){
4267         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4268     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4269                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4270                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4271                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4272                                                           / kssdlayladdernumber[i])));
4273     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4274     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4275         mountingsupportedgevector[i] = new TVector3();
4276         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4277         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4278                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4279                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4280     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4281     deltapsi[i] = (theta[i]+phi[i])/nedges;
4282   }
4283   TVector3** vertex[fgklayernumber];
4284   TList* vertexlist[fgklayernumber];
4285   Int_t indexedge[fgklayernumber] = {0,0};
4286   for(Int_t i=0; i<fgklayernumber; i++){
4287         vertex[i] = new TVector3*[nedges+1];
4288         vertexlist[i] = new TList();
4289   } 
4290   for(Int_t i=0; i<fgklayernumber; i++){
4291         for(Int_t j=0; j<nedges+1; j++){
4292                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4293                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4294                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4295                 vertexlist[i]->Add(vertex[i][j]);
4296         }
4297         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4298   }
4299   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4300   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4301   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4302   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4303   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4304   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4305   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4306   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4307   for(Int_t i=0; i<fgklayernumber; i++){
4308     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4309     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4310     xcentervertex[i] = new Double_t[indexedge[i]+3];
4311     ycentervertex[i] = new Double_t[indexedge[i]+3];
4312         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4313         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4314         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4315         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4316         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4317                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4318                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4319                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4320                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4321                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4322                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4323                 if(j<indexedge[i]+1){
4324                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4325                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4326                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4327                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4328                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4329                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4330                 }
4331         }
4332         xsidevertex[i][1] = xsidevertex[i][0]; 
4333         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4334         xsidevertex[i][2] = xsidevertex[i][3]; 
4335         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4336         xcentervertex[i][1] = xcentervertex[i][0]; 
4337         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4338         xcentervertex[i][2] = xcentervertex[i][3]; 
4339         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4340         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4341         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4342         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4343         ycenterlowervertex[i][0] = ysidevertex[i][0];
4344         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4345         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4346   }
4347   /////////////////////////////////////////////////////////////
4348   // Building the Arc Structure of Ladder Supports 
4349   /////////////////////////////////////////////////////////////
4350   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4351   TGeoXtru* centermountingsupportshape[fgklayernumber];
4352   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4353   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4354   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4355   TGeoVolume* centermountingblocksupport[fgklayernumber];
4356   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4357   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4358   char sidemountingblockname[100];
4359   char centermountingblockname[100];
4360   char sideladdersupportpiecename[100];
4361   char centerladdersupportpiecename[100];
4362   for(Int_t i=0; i<fgklayernumber; i++){ 
4363     snprintf(sidemountingblockname,100,"MountingBlockSupportSideLay%dArc",i+5);
4364     snprintf(centermountingblockname,100,"MountingBlockSupportCenterLay%dArc",i+5);
4365     snprintf(sideladdersupportpiecename,100,"SideLadderSupportPieceLay%d",i+5);
4366     snprintf(centerladdersupportpiecename,100,"CenterLadderSupportPieceLay%d",i+5);
4367     sidemountingblocksupportshape[i] = new TGeoXtru(2);
4368     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4369                                                                                                 xsidevertex[i],ysidevertex[i]);
4370     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4371                                                                                                          -fgkMountingBlockSupportWidth[0]);
4372     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4373     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4374                                                                           sidemountingblocksupportshape[i],
4375                                                                                   fSSDAlCoolBlockMedium);
4376         sidemountingblocksupport[i]->SetLineColor(9);
4377         centermountingsupportshape[i] = new TGeoXtru(2);
4378     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4379                                                                                                 xcentervertex[i],ycentervertex[i]);
4380         centermountingsupportshape[i]->DefineSection(0,0.);
4381     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4382                                                                                                   -fgkMountingBlockSupportWidth[0]);
4383
4384     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4385                                                                           centermountingsupportshape[i],
4386                                                                                   fSSDAlCoolBlockMedium);
4387         centermountingblocksupport[i]->SetLineColor(9);
4388         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4389     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4390                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4391         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4392                                                                                                          -fgkMountingBlockSupportWidth[0]);
4393     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4394     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4395                                                                           sideladdersupportpieceshape[i],
4396                                                                                   fSSDCarbonFiberMedium);
4397         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4398         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4399     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4400                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4401         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4402     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4403                                                                                                   -fgkMountingBlockSupportWidth[0]);
4404     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4405                                                                           centerladdersupportpieceshape[i],
4406                                                                                   fSSDCarbonFiberMedium);
4407         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4408   }
4409   /////////////////////////////////////////////////////////////
4410   // Building the Up Structure of Ladder Supports 
4411   /////////////////////////////////////////////////////////////
4412   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4413   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4414   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4415   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4416   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4417   //////////////////////////////////////////////////////////
4418   // Setting the volume for TGeoXtru Mounting Block Piece  
4419   //////////////////////////////////////////////////////////
4420   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4421   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4422   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4423   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4424   TGeoVolume* mountingblockpieceup[fgklayernumber];
4425   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4426   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4427   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4428   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4429   char mountingblockpiecedownname[100];
4430   char mountingblockpieceupname[100];
4431   for(Int_t i=0; i<fgklayernumber; i++){
4432     ///////////////////////////
4433     // Mounting Block Down Vertex
4434     ///////////////////////////
4435         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4436         snprintf(mountingblockpiecedownname,100,"MountingBlockPieceDownLay%d",i+5);
4437         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4438         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4439                                               + fgkMountingBlockSupportDownHeight 
4440                                               - fgkSSDLadderVerticalDisalignment;
4441         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4442         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4443                                                                                 + fgkSSDMountingBlockHeight[1]
4444                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4445                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4446         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4447         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4448         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4449         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4450         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4451         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4452         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4453         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4454                                                                                 + fgkSSDMountingBlockHeight[2]
4455                                                                                 - fgkSSDMountingBlockHeight[0];
4456         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4457         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4458         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4459         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4460         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4461                                                                                                          mountingblockpiecedownyvertex[i]);
4462         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4463         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4464         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4465                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4466         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4467
4468     ///////////////////////////
4469     // Mounting Block Up Vertex
4470     ///////////////////////////
4471         mountingblockpieceupshape[i] = new TGeoXtru(2);
4472         snprintf(mountingblockpieceupname,100,"MountingBlockPieceUpLay%d",i+5);
4473         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4474         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4475                                                                                 + fgkMountingBlockSupportUpHeight[i]
4476                                               - fgkSSDLadderVerticalDisalignment;
4477         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4478         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4479                                                                                 + fgkSSDMountingBlockHeight[1]
4480                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4481                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4482         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4483         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4484         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4485         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4486         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4487         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4488         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4489         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4490                                                                                 + fgkSSDMountingBlockHeight[2]
4491                                                                                 - fgkSSDMountingBlockHeight[0];
4492         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4493         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4494         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4495         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4496
4497         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4498                                                                                                          mountingblockpieceupyvertex[i]);
4499         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4500         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4501         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4502                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4503         mountingblockpieceup[i]->SetLineColor(fColorG10);
4504  }
4505   ///////////////////////////////////////////////////////////////////
4506   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4507   ///////////////////////////////////////////////////////////////////
4508   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4509   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4510   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4511   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4512   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4513   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4514   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4515   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4516   char mountingblocksupportrapezoidowname[100];
4517   char mountingblocksupportrapezoidupname[100];
4518   Double_t scalefactor = 3./4.;
4519   for(Int_t i=0; i<fgklayernumber; i++){
4520   ////////////////////////////////////////////
4521   // Mounting Block Support Down Trapezoid Vertex 
4522   ////////////////////////////////////////////
4523         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4524         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4525                                                                                                  - mountingsupportedge[i];
4526         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4527         mountingblocksupportrapezoidownxvertex[i][1] = 
4528                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4529         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4530                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4531                                                                                              - mountingblockpiecedownyvertex[i][0]);
4532         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4533         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4534         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4535         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4536         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4537         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4538
4539         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4540                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4541         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4542                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4543         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4544         snprintf(mountingblocksupportrapezoidowname,100,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4545         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4546                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4547         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4548   ////////////////////////////////////////////
4549   // Mounting Block Support Up Trapezoid Vertex 
4550   ////////////////////////////////////////////
4551         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4552         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4553                                                                                                  - mountingsupportedge[i];
4554         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4555         mountingblocksupportrapezoidupxvertex[i][1] = 
4556                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4557         mountingblocksupportrapezoidupyvertex[i][1] = 
4558                                                                                                mountingblockpieceupyvertex[i][0]
4559                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4560                                                                                              - mountingblockpieceupyvertex[i][0]);
4561         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4562         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4563         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4564         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4565         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4566         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4567
4568         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4569                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4570         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4571                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4572         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4573         snprintf(mountingblocksupportrapezoidupname,100,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4574         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4575                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4576         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4577   }
4578   ///////////////////////////////////////////////////////////////////
4579   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4580   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4581   Double_t boxoriginup[fgklayernumber][2][3];
4582   Double_t boxorigindown[fgklayernumber][2][3];
4583   char mountingblocksupportboxdownname[100];
4584   char mountingblocksupportboxupname[100];
4585   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4586   mountingblocksupportrot->SetAngles(90.,180.,-90);
4587   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4588   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4589   TGeoHMatrix* laddersupportmatrix[2];
4590   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4591   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4592   /////////////////////////////////////////////////////////////
4593   // Creating Mother Volume for Containment
4594   /////////////////////////////////////////////////////////////
4595   Double_t *xmothervertex[fgklayernumber];
4596   Double_t *ymothervertex[fgklayernumber];
4597   for(Int_t i=0; i<fgklayernumber; i++){
4598         xmothervertex[i] = new Double_t[8];
4599         ymothervertex[i] = new Double_t[8];
4600   }  
4601   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4602   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4603   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4604   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4605   char upmotheladdersupportname[100];
4606   char downmotheladdersupportname[100];
4607   for(Int_t i=0; i<fgklayernumber; i++){
4608         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4609                                                     -  mountingsupportedge[i];
4610         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4611         xmothervertex[i][1] = xmothervertex[i][0];
4612         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4613                                                         + fgkMountingBlockSupportWidth[0];
4614         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4615         ymothervertex[i][2] = ymothervertex[i][1];
4616         xmothervertex[i][3] = xmothervertex[i][2];
4617         ymothervertex[i][3] = -ymothervertex[i][0];
4618         xmothervertex[i][4] = -xmothervertex[i][0];
4619         ymothervertex[i][4] = ymothervertex[i][3];
4620         xmothervertex[i][5] = xmothervertex[i][4];
4621         ymothervertex[i][5] = -ymothervertex[i][1];
4622         xmothervertex[i][6] = -xmothervertex[i][2];
4623         ymothervertex[i][6] = ymothervertex[i][5];
4624         xmothervertex[i][7] = xmothervertex[i][6];
4625         ymothervertex[i][7] = ymothervertex[i][0];
4626
4627         snprintf(downmotheladdersupportname,100,"LadderSupportDownLay%d",i+5);
4628         snprintf(upmotheladdersupportname,100,"LadderSupportUpLay%d",i+5);
4629
4630         downmotherladdersupportshape[i] = new TGeoXtru(2);
4631         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4632         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4633         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4634                                                                    +                       fgkMountingBlockSupportDownHeight
4635                                                                    +                       fgkSSDMountingBlockHeight[1]
4636                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4637                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4638                                                        - fgkSSDLadderVerticalDisalignment);
4639         
4640 //                                                 - fgkSSDModuleVerticalDisalignment);
4641         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4642
4643         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4644                                                                           downmotherladdersupportshape[i],fSSDAir);
4645     upmotherladdersupportshape[i] = new TGeoXtru(2);
4646         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4647         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4648     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4649                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4650                                                                    +                       fgkSSDMountingBlockHeight[1]
4651                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4652                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4653                                                  - fgkSSDLadderVerticalDisalignment);
4654
4655      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4656                                                                                           upmotherladdersupportshape[i],fSSDAir);
4657   }
4658   for(Int_t i=0; i<fgklayernumber; i++){
4659         /////////////////////////
4660         // Setting the box origin
4661         /////////////////////////
4662         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4663         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4664                                                    +  0.5*fgkMountingBlockSupportDownHeight
4665                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4666         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4667                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4668   
4669         boxorigindown[i][1][0] = 0.0;
4670         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4671         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4672                                                    -      fgkMountingBlockSupportWidth[0]);
4673                                                    
4674         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4675         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4676                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4677                                - 0.5*fgkSSDLadderVerticalDisalignment;
4678         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4679                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4680   
4681         boxoriginup[i][1][0] = 0.0;
4682         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4683         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4684                                                  - fgkMountingBlockSupportWidth[0]);
4685   
4686         /////////////////////////
4687     // Setting the boxes    
4688         /////////////////////////
4689         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4690                                                                                  +  fgkSSDMountingBlockLength[0]),
4691                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4692                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4693                                                                                         boxorigindown[i][0]);
4694         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4695                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4696                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4697                                                                                  -  fgkMountingBlockSupportWidth[0]),
4698                                                                                         boxorigindown[i][1]);
4699                                                                                         
4700         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4701                                                                                  +  fgkSSDMountingBlockLength[0]),
4702                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4703                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4704                                                                                         boxoriginup[i][0]);
4705
4706         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4707                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4708                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4709                                                                      -  fgkMountingBlockSupportWidth[0]),
4710                                                                                         boxoriginup[i][1]);
4711         ///////////////////////////////////////
4712         // Adding the Volumes to Mother Volume    
4713         ///////////////////////////////////////
4714         for(Int_t j=0; j<2; j++){
4715           snprintf(mountingblocksupportboxdownname,100,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4716           snprintf(mountingblocksupportboxupname,100,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4717           mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4718                                                              mountingblocksupportboxdownshape[i][j],
4719                                                              fSSDCarbonFiberMedium);
4720           mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4721                                                            mountingblocksupportboxupshape[i][j],
4722                                                            fSSDCarbonFiberMedium);
4723                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4724                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4725                 for(Int_t k=0; k<2; k++){
4726                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4727                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4728                 }
4729         }
4730         for(Int_t k=0; k<2; k++){
4731                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4732                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4733                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4734                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4735                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4736                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4737                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4738                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4739                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4740                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4741                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4742                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4743         }
4744   }
4745   TList* laddersupportlist = new TList();
4746   laddersupportlist->Add(downmotherladdersupport[0]); 
4747   laddersupportlist->Add(upmotherladdersupport[0]); 
4748   laddersupportlist->Add(downmotherladdersupport[1]); 
4749   laddersupportlist->Add(upmotherladdersupport[1]); 
4750   /////////////////////////////////////////////////////////////
4751   // Deallocating memory
4752   /////////////////////////////////////////////////////////////
4753   for(Int_t i=0; i<fgklayernumber; i++){
4754         for(Int_t j=0; j<nedges+1; j++)
4755                 delete vertex[i][j];
4756         delete mountingsupportedgevector[i];
4757         delete [] vertex[i];
4758         delete vertexlist[i];
4759         delete [] xsidevertex[i];
4760         delete [] ysidevertex[i];
4761         delete [] xcentervertex[i];
4762         delete [] ycentervertex[i];
4763         delete [] xsidelowervertex[i];
4764         delete [] ysidelowervertex[i];
4765         delete [] xcenterlowervertex[i];
4766         delete [] ycenterlowervertex[i];
4767         delete [] xmothervertex[i];
4768         delete [] ymothervertex[i];
4769   }
4770   delete [] xsidevertex;
4771   delete [] ysidevertex;
4772   delete [] xcentervertex;
4773   delete [] ycentervertex;
4774   delete [] xsidelowervertex;
4775   delete [] ysidelowervertex;
4776   delete [] xcenterlowervertex;
4777   delete [] ycenterlowervertex;
4778   delete globalrefladdersupportrot;
4779   delete mountingblocksupportrot;
4780   /////////////////////
4781   return laddersupportlist;     
4782 }
4783  ////////////////////////////////////////////////////////////////////////////////
4784 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4785 //////////////////////////////////////////
4786 // Method Generating Ladder Support Ring
4787 //////////////////////////////////////////
4788   if(!fCreateMaterials) CreateMaterials();
4789   if(!fTransformationMatrices) CreateTransformationMatrices();
4790   if(!fBasicObjects) CreateBasicObjects();
4791   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4792   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4793     const Int_t kssdlayladdernumber[fgklayernumber] = 
4794                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4795   Double_t mountingsupportedge[fgklayernumber];
4796   Double_t mountingblockratio[fgklayernumber];
4797   Double_t theta[fgklayernumber];
4798   Double_t phi[fgklayernumber];
4799   for(Int_t i=0; i<fgklayernumber; i++){
4800         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4801     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4802                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4803                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4804                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4805                                                           / kssdlayladdernumber[i])));
4806     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4807                          / fgkMountingBlockSupportRadius[i]);
4808     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4809   }
4810   TGeoRotation* globalrot = new TGeoRotation();
4811   globalrot->SetAngles(0.,-90.,0.); 
4812   TGeoRotation** laddersupportrot[fgklayernumber];
4813   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
4814   for(Int_t i=0; i<fgklayernumber; i++){                
4815         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
4816         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
4817         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4818                 laddersupportrot[i][j] = new TGeoRotation();
4819                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
4820                 switch(i){
4821                         case 0: //Ladder of Layer5  
4822                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4823                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
4824                                                                             laddersupportmatrix[i][j]); 
4825                         break;
4826                         case 1: //Ladder of Layer6 
4827                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4828                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
4829                                                                               laddersupportmatrix[i][j]); 
4830                         break;
4831                 }
4832     }
4833   }
4834   /////////////////////////////////////////////////////////////
4835   // Creating Lower Ladder Support 
4836   /////////////////////////////////////////////////////////////
4837   TVector3** ringsupportvertex[fgklayernumber];         
4838   Double_t angle = 360./nedges;
4839   for(Int_t i=0; i<fgklayernumber; i++){
4840     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
4841         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
4842                                                         *                          TMath::Cos(theta[i]));
4843         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
4844                                                         -                          mountingsupportedge[i],
4845                                                                                    ringsupportvertex[i][0]->Y());
4846         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
4847                                                                                    ringsupportvertex[i][1]->Y());                                                                               
4848     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
4849         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
4850            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
4851            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
4852            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
4853            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
4854         }
4855         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
4856     for(Int_t j=0; j<nedges+1; j++){
4857                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
4858                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*CosD(90.0-j*angle),
4859                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*SinD(90.0-j*angle));
4860         }
4861   }
4862   Double_t **xmothervertex = new Double_t*[fgklayernumber];
4863   Double_t **ymothervertex = new Double_t*[fgklayernumber];
4864   for(Int_t i=0; i<fgklayernumber; i++){
4865         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4866         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4867         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
4868                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
4869                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
4870         }
4871   }
4872 ////////////////////////////////////////////////////////////////////////////////
4873 // Start Corrections 13/06/08
4874 ////////////////////////////////////////////////////////////////////////////////
4875   char lowerladderpconsupportname[100];
4876   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
4877   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
4878   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
4879   Double_t lowerladderpconradiusmax[fgklayernumber];
4880   Double_t lowerladderpconradiusmin[fgklayernumber];
4881   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4882   lowerladdersupportrot->SetAngles(90.,180.,-90);
4883   for(Int_t i=0; i<fgklayernumber; i++){
4884         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
4885                                                                 *                          TMath::Cos(theta[i]);
4886     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeight;
4887   } 
4888   for(Int_t i=0; i<fgklayernumber; i++){
4889 ///////////////////////////  Modified Version ?///////////////////
4890     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
4891         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
4892                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
4893                                                          lowerladderpconradiusmax[i]);
4894         snprintf(lowerladderpconsupportname,100,"LowerLadderPConSupportNameLay%d",i+5);
4895         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
4896     lowerladderpconsupport[i]->SetLineColor(fColorAl);
4897         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
4898         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
4899  }
4900 ////////////////////////////////////////////////////////////////////////////////
4901 // End Corrections 13/06/08
4902 ////////////////////////////////////////////////////////////////////////////////
4903   /*char lowerladdersupportname[30];
4904   TGeoXtru* lowerladdersupportshape[fgklayernumber];
4905   TGeoVolume* lowerladdersupport[fgklayernumber];
4906   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4907   lowerladdersupportrot->SetAngles(90.,180.,-90);
4908   for(Int_t i=0; i<fgklayernumber; i++){
4909         lowerladdersupportshape[i] = new TGeoXtru(2);
4910         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
4911                                                                                           xmothervertex[i],ymothervertex[i]);
4912         lowerladdersupportshape[i]->DefineSection(0,0.);
4913     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4914         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
4915     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
4916                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
4917         lowerladdersupport[i]->SetLineColor(fColorAl);
4918         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
4919         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
4920   }*/
4921   /////////////////////////////////////////////////////////////
4922   // Deallocating memory
4923   /////////////////////////////////////////////////////////////
4924   for(Int_t i=0; i<fgklayernumber; i++){
4925         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
4926                 delete ringsupportvertex[i][j];
4927         delete [] ringsupportvertex[i];
4928   }
4929   for(Int_t i=0; i<fgklayernumber; i++){
4930         delete [] xmothervertex[i];
4931         delete [] ymothervertex[i];
4932   }
4933   delete [] xmothervertex;
4934   delete [] ymothervertex; 
4935   delete globalrot;
4936   for(Int_t i=0; i<fgklayernumber; i++){
4937         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
4938                 delete laddersupportrot[i][j];
4939         delete [] laddersupportrot[i];
4940   }
4941  }  
4942  ////////////////////////////////////////////////////////////////////////////////
4943  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
4944   /////////////////////////////////////////////////////////////
4945   // Method generating Endcap CoverPlate
4946   /////////////////////////////////////////////////////////////
4947   // Holes Definition 
4948   ///////////////////
4949   Int_t nendcapcoverplateholedges = 30;
4950   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
4951   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
4952                                                           0.5*fgkEndCapCoverPlateThickness};
4953   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
4954                                                                                                               nendcapcoverplateholedges,holesection);
4955   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
4956                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
4957   endcapcoverplatesmallhole->SetLineColor(6);
4958   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
4959                                                                                                               nendcapcoverplateholedges,holesection);
4960   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
4961                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
4962   endcapcoverplatebighole->SetLineColor(6);
4963   //////////////////////////
4964   // Screw Piece Definition 
4965   //////////////////////////
4966   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
4967   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
4968                                                                                                       CosD(0.5*smallscrewangle),
4969                                                                                                       0.5*fgkEndCapCoverPlateThickness);
4970   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
4971                                                                                                 endcapsmallscrewpieceshape,
4972                                                                                                 fSSDCoolingTubePhynox);
4973   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
4974   ///////////////////
4975   // Box Definition 
4976   ///////////////////
4977   TGeoBBox* endcapcoverplateboxshape[4];
4978   TGeoVolume* endcapcoverplatebox[4];
4979   Double_t boxorigin[5][3];
4980   boxorigin[0][0] = 0.;
4981   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
4982   boxorigin[0][2] = 0.;
4983
4984   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
4985   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
4986   boxorigin[1][2] = 0.;
4987
4988   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
4989                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
4990   boxorigin[2][1] = boxorigin[1][1];
4991   boxorigin[2][2] = 0.;
4992
4993   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
4994                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
4995   boxorigin[3][1] = boxorigin[1][1];
4996   boxorigin[3][2] = 0.;
4997
4998   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4999                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5000                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5001                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5002
5003   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5004                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5005                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5006                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5007                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5008
5009   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5010                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5011                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5012                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5013                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5014
5015   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5016                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5017                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5018                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5019                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5020   
5021   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5022                                                                            fSSDAlCoolBlockMedium);
5023   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5024                                                                            fSSDAlCoolBlockMedium);
5025   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5026                                                                            fSSDAlCoolBlockMedium);
5027   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5028                                                                            fSSDAlCoolBlockMedium);
5029   endcapcoverplatebox[0]->SetLineColor(6);
5030   endcapcoverplatebox[1]->SetLineColor(6);
5031   endcapcoverplatebox[2]->SetLineColor(6);
5032   endcapcoverplatebox[3]->SetLineColor(6);
5033   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5034   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5035                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5036                                                                                         0.5*fgkEndCapCoverPlateThickness,
5037                                                                                         endcapfillingboxorigin);
5038   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5039                                                                            fSSDAlCoolBlockMedium);
5040   endcapfillingbox->SetLineColor(6);
5041   ////////////////////////////
5042   // Contour shape Definition 
5043   ////////////////////////////
5044   const Int_t kcontourvertexnumber = 10;
5045   Double_t xcontourvertex[kcontourvertexnumber];
5046   Double_t ycontourvertex[kcontourvertexnumber];
5047   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5048   xcontourvertex[1] = xcontourvertex[0];
5049   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5050   xcontourvertex[3] = xcontourvertex[2];
5051   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5052   xcontourvertex[5] = xcontourvertex[4];
5053   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5054   xcontourvertex[7] = xcontourvertex[6];
5055   xcontourvertex[8] = xcontourvertex[4];
5056   xcontourvertex[9] = xcontourvertex[8];
5057   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5058                                         - (kendcapcoverplatesmallholenumber[1]-1)
5059                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5060   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5061                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5062   ycontourvertex[2] = ycontourvertex[1];
5063   ycontourvertex[3] = ycontourvertex[0];
5064   ycontourvertex[4] = ycontourvertex[3];
5065   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5066   ycontourvertex[6] = ycontourvertex[5];
5067   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5068                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5069                                         + fgkEndCapCoverPlateSmallHoleRadius;
5070   ycontourvertex[8] = ycontourvertex[7];
5071   ycontourvertex[9] = ycontourvertex[0];
5072
5073   Double_t xboxin, dxboxin, yboxin, dyboxin;
5074   Double_t xboxout, dxboxout, yboxout, dyboxout;
5075   Double_t coordmin, coordmax;
5076   coordmin = -fgkEndCapCoverPlateLength[0];
5077   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5078   xboxout = 0.5*(coordmin+coordmax);
5079   dxboxout = 0.5*(coordmax-coordmin);
5080   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5081                                         - (kendcapcoverplatesmallholenumber[1]-1)
5082                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5083   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5084                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5085   yboxout = 0.5*(coordmin+coordmax);
5086   dyboxout = 0.5*(coordmax-coordmin);
5087   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5088   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5089   xboxin = 0.5*(coordmin+coordmax);
5090   dxboxin = 0.5*(coordmax-coordmin);
5091   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5092   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5093                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5094                                         + fgkEndCapCoverPlateSmallHoleRadius;
5095   yboxin = 0.5*(coordmin+coordmax);
5096   dyboxin = 0.5*(coordmax-coordmin);
5097   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5098   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5099                                                          xboxout, yboxout, 0.);
5100   trendCapCoverPlateContourboxout->RegisterYourself();
5101   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5102   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5103                                                          xboxin, yboxin, 0.);
5104   trendCapCoverPlateContourboxin->RegisterYourself();
5105   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5106         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5107
5108   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5109                                                                            fSSDAlCoolBlockMedium);
5110   contour->SetLineColor(6);
5111   /////////////////////////////
5112   // Hole Contour Shape Definition 
5113   ////////////////////////////
5114   coordmin = xcontourvertex[0];
5115   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5116   xboxout = 0.5*(coordmin+coordmax);
5117   dxboxout = 0.5*(coordmax-coordmin);
5118   coordmin = ycontourvertex[1];
5119   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5120   yboxout = 0.5*(coordmin+coordmax);
5121   dyboxout = 0.5*(coordmax-coordmin);
5122   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5123                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5124   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5125   xboxin = 0.5*(coordmin+coordmax);
5126   dxboxin = 0.5*(coordmax-coordmin);
5127   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5128                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5129   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5130   yboxin = 0.5*(coordmin+coordmax);
5131   dyboxin = 0.5*(coordmax-coordmin);
5132   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5133   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5134                                                          xboxout, yboxout, 0.);
5135   trendCapCoverPlateContourboxout1->RegisterYourself();
5136   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5137   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5138                                                          xboxin, yboxin, 0.);
5139   trendCapCoverPlateContourboxin1->RegisterYourself();
5140   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5141         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5142
5143
5144   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5145   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5146   xboxout = 0.5*(coordmin+coordmax);
5147   dxboxout = 0.5*(coordmax-coordmin);
5148   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5149                                                    - fgkEndCapCoverPlateWidth[0]);
5150   coordmax = ycontourvertex[0];
5151   yboxout = 0.5*(coordmin+coordmax);
5152   dyboxout = 0.5*(coordmax-coordmin);
5153   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5154                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5155   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5156   xboxin = 0.5*(coordmin+coordmax);
5157   dxboxin = 0.5*(coordmax-coordmin);
5158   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5159                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5160                                                    - fgkEndCapCoverPlateWidth[0]
5161                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5162   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5163   yboxin = 0.5*(coordmin+coordmax);
5164   dyboxin = 0.5*(coordmax-coordmin);
5165   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5166   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5167                                                          xboxout, yboxout, 0.);
5168   trendCapCoverPlateContourboxout2->RegisterYourself();
5169   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5170   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5171                                                          xboxin, yboxin, 0.);
5172   trendCapCoverPlateContourboxin2->RegisterYourself();
5173   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5174         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5175   
5176 //  const Int_t kholecontourvertexnumber = 10;
5177
5178   Double_t xholecontourvertex[2][kcontourvertexnumber];
5179   Double_t yholecontourvertex[2][kcontourvertexnumber];
5180   xholecontourvertex[0][0] = xcontourvertex[0];
5181   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5182   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5183   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5184   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5185                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5186                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5187   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5188   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5189                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5190   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5191   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5192   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5193   
5194   yholecontourvertex[0][0] = ycontourvertex[1];
5195   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5196   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5197   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5198   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5199   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5200                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5201   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5202   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5203   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5204   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5205
5206   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5207   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5208   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5209   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5210   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5211                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5212                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5213   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5214   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5215                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5216   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5217   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5218   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5219   
5220   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5221                                                    - fgkEndCapCoverPlateWidth[0]);
5222   yholecontourvertex[1][1] = ycontourvertex[0];
5223   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5224   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5225   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5226   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5227                                                    - fgkEndCapCoverPlateWidth[0]
5228                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5229   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5230   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5231   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5232   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5233
5234   TGeoVolume* holecontour[2];
5235   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5236                                                                   fSSDAlCoolBlockMedium);
5237   holecontour[0]->SetLineColor(6);
5238   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5239                                                                   fSSDAlCoolBlockMedium);
5240   holecontour[1]->SetLineColor(6);
5241   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5242                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5243   TGeoTranslation*  bigholetrans[3];
5244   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5245                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5246   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5247                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5248                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5249   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5250                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5251   /////////////////////////////////
5252   // Mother Volume Xtru Definition 
5253   /////////////////////////////////
5254   const Int_t kmothervertexnumber = 12;
5255   Double_t xmothervertex[kmothervertexnumber];  
5256   Double_t ymothervertex[kmothervertexnumber];  
5257   xmothervertex[0]  = xcontourvertex[0];
5258   xmothervertex[1]  = xmothervertex[0];
5259   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5260   xmothervertex[3]  = xmothervertex[2];
5261   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5262   xmothervertex[5]  = xmothervertex[4];
5263   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5264   xmothervertex[7]  = xmothervertex[6];
5265   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5266                                         + fgkEndCapCoverPlateLength[2]; 
5267   xmothervertex[9]  = xmothervertex[8];
5268   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5269   xmothervertex[11] = xmothervertex[10];
5270   
5271   ymothervertex[0]  = ycontourvertex[0];
5272   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5273   ymothervertex[2]  = ymothervertex[1];
5274   ymothervertex[3]  = ycontourvertex[1];
5275   ymothervertex[4]  = ymothervertex[3];
5276   ymothervertex[5]  = ymothervertex[1];
5277   ymothervertex[6]  = ymothervertex[5];
5278   ymothervertex[7]  = ymothervertex[0];
5279   ymothervertex[8]  = ymothervertex[7];
5280   ymothervertex[9]  = ymothervertex[8]
5281                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5282   ymothervertex[10] = ymothervertex[9];
5283   ymothervertex[11] = ymothervertex[8];
5284   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5285   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5286   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5287   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5288   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5289   ////////////////////////////////////////
5290   // Adding Nodes
5291   ////////////////////////////////////////
5292 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5293   TGeoTranslation*** endcapcoverplatesmallholetrans;
5294   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5295   Double_t transx[4] = {0,
5296                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5297                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5298                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5299                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5300                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5301   Int_t index = 0;
5302   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5303         endcapcoverplatesmallholetrans[i] = 
5304                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5305     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5306                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5307             endcapcoverplatesmallholetrans[i][j] = 
5308                 new TGeoTranslation(transx[i],
5309                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5310             if(index!=10){ 
5311                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5312                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5313                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5314                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5315                 }
5316                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5317                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5318                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5319     }
5320   }
5321   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5322   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5323   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5324   mothercoverplate->AddNode(endcapfillingbox,1);
5325   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5326   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5327   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5328   mothercoverplate->AddNode(holecontour[0],1);
5329   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5330   mothercoverplate->AddNode(holecontour[1],1);  
5331   mothercoverplate->AddNode(contour,1);
5332   
5333   for (Int_t i = 0; i < kendcapcoverplatesmallholenumber[0]; i++) 
5334     delete [] endcapcoverplatesmallholetrans[i];
5335   delete [] endcapcoverplatesmallholetrans;
5336   /////////////////////////////////
5337   return mothercoverplate;      
5338  }
5339  ////////////////////////////////////////////////////////////////////////////////
5340  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5341   /////////////////////////////////////////////////////////////
5342   // Getting EndCap Cooling Tube 
5343   /////////////////////////////////////////////////////////////
5344   TGeoTorus* endcapcoolingtubetorushape[5];
5345   TGeoVolume* endcapcoolingtubetorus[5];
5346   TGeoTube* endcapcoolingtubeshape[4];
5347   TGeoVolume* endcapcoolingtube[4];
5348   char endcapcoolingtubetorusname[100];
5349   char endcapcoolingtubename[100];
5350   TGeoTorus* endcapcoolingwatertubetorushape[5];
5351   TGeoVolume* endcapcoolingwatertubetorus[5];
5352   TGeoTube* endcapcoolingwatertubeshape[4];
5353   TGeoVolume* endcapcoolingwatertube[4];
5354   char endcapcoolingwatertubetorusname[100];
5355   char endcapcoolingwatertubename[100];
5356   for(Int_t i=0; i<5; i++){
5357     snprintf(endcapcoolingtubetorusname,100,"EndCapCoolingTubeTorus%d",i+1);
5358     snprintf(endcapcoolingtubename,100,"EndCapCoolingTube%d",i+1);
5359     snprintf(endcapcoolingwatertubetorusname,100,"EndCapCoolingWaterTubeTorus%d",i+1);
5360     snprintf(endcapcoolingwatertubename,100,"EndCapCoolingWaterTube%d",i+1);
5361     if(i==3){
5362       endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5363                                                     fgkEndCapCoolingTubeRadiusMin,
5364                                                     fgkEndCapCoolingTubeRadiusMax,
5365                                                     90.0,fgkEndCapCoolingTubeAngle[3]);
5366       endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5367                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5368                                                          90.0,fgkEndCapCoolingTubeAngle[3]);
5369     }
5370     else{
5371       endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5372                                                     :fgkEndCapCoolingTubeAxialRadius[1],
5373                                                     fgkEndCapCoolingTubeRadiusMin,
5374                                                     fgkEndCapCoolingTubeRadiusMax,
5375                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5376       endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5377                                                          :fgkEndCapCoolingTubeAxialRadius[1],
5378                                                          0.,fgkEndCapCoolingTubeRadiusMin,
5379                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5380     }
5381         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5382                                                                                            endcapcoolingtubetorushape[i],
5383                                                                                            fSSDCoolingTubePhynox);
5384         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5385                                                                                                         endcapcoolingwatertubetorushape[i],
5386                                                                                                         fSSDCoolingTubeWater);
5387     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5388     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5389     if(i<4){
5390                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5391                                                                   fgkEndCapCoolingTubeRadiusMax,
5392                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5393                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5394                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5395         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5396                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5397         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5398                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5399                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5400                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5401         }
5402   }
5403   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5404   /////////////////////////////////////////
5405   // Transformation for Volume Positioning 
5406   /////////////////////////////////////////
5407   TGeoCombiTrans* coolingtubecombitrans[6];
5408   TGeoRotation* coolingtuberot[8];
5409   TGeoTranslation* coolingtubetrans[6];
5410   TGeoHMatrix* coolingtubematrix[4];
5411   TGeoCombiTrans* torustubecombitrans[4];
5412   TGeoRotation* torustuberot[7];
5413   TGeoTranslation* torustubetrans[4];
5414   TGeoHMatrix* torustubematrix[5];
5415   TGeoCombiTrans* coolingwatertubecombitrans[6];
5416   TGeoRotation* coolingwatertuberot[8];
5417   TGeoTranslation* coolingwatertubetrans[6];
5418   TGeoHMatrix* coolingwatertubematrix[4];
5419   TGeoCombiTrans* toruswatertubecombitrans[4];
5420   TGeoRotation* toruswatertuberot[7];
5421   TGeoTranslation* toruswatertubetrans[4];
5422   TGeoHMatrix* toruswatertubematrix[5];
5423   for(Int_t i=0; i<8; i++){
5424     if(i<6){
5425          coolingtubetrans[i] = new TGeoTranslation();
5426          coolingwatertubetrans[i] = new TGeoTranslation();
5427     }
5428     if(i<8){
5429          coolingtuberot[i] = new TGeoRotation();
5430          coolingwatertuberot[i] = new TGeoRotation();
5431     }
5432     if(i<4){
5433          torustubetrans[i] = new TGeoTranslation();
5434          toruswatertubetrans[i] = new TGeoTranslation();
5435     }
5436     if(i<7){
5437          torustuberot[i] = new TGeoRotation();
5438          toruswatertuberot[i] = new TGeoRotation();
5439         }
5440   }
5441   /////////////////////////////////////////
5442   // Transformation for Inox Volume Positioning 
5443   /////////////////////////////////////////
5444   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5445                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5446   coolingtuberot[0]->SetAngles(0.,90.,0.);
5447   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5448                                                                                                 *coolingtuberot[0]);
5449                                                                                                 
5450   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5451   coolingtuberot[1]->SetAngles(0.,90.,0.);
5452   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5453                                                                                                 *coolingtuberot[1]);
5454
5455   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5456                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5457                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5458                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5459                                                                           0.);
5460   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5461   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5462                                                                                                 *coolingtuberot[2]);
5463
5464   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5465                                            *                             (*coolingtubecombitrans[1]));
5466
5467   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5468                                                                          endcapcoolingtubeshape[1]->GetDz());
5469   torustuberot[0]->SetAngles(0.,90.,0.); 
5470   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5471
5472   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5473
5474   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5475                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5476   coolingtuberot[3]->SetAngles(0.,90.,0.);
5477   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5478                                                                                                 *coolingtuberot[3]);
5479   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5480   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5481   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5482   
5483   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5484                                                                         endcapcoolingtubeshape[2]->GetDz());
5485   torustuberot[1]->SetAngles(0.,90.,0.); 
5486   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5487   torustuberot[2]->SetAngles(180.,0.,0.); 
5488   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5489   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5490
5491   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5492                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5493   torustuberot[3]->SetAngles(0.,90.,0.); 
5494   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5495   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5496   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5497   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5498
5499   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5500                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5501   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5502   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5503                                                                                                 *coolingtuberot[5]);
5504   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5505   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5506   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5507   
5508   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5509                                                                         endcapcoolingtubeshape[0]->GetDz());
5510   torustuberot[5]->SetAngles(0.,90.,0.); 
5511   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5512   torustuberot[6]->SetAngles(-90.,0.,0.); 
5513   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5514   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5515   
5516   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5517                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5518   coolingtuberot[6]->SetAngles(0.,90.,0.);
5519   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5520                                                                                                 *coolingtuberot[6]);
5521   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5522   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5523   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5524     /////////////////////////////////////////
5525   // Transformation for Water Volume Positioning 
5526   /////////////////////////////////////////
5527   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5528                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5529   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5530   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5531                                                                                                      *coolingwatertuberot[0]);
5532
5533   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5534   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5535   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5536                                                                                                      *coolingwatertuberot[1]);
5537
5538   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5539                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5540                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5541                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5542                                                                               0.);
5543   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5544   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5545                                                                                                     *coolingwatertuberot[2]);
5546
5547   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5548                                            *                                 (*coolingwatertubecombitrans[1]));
5549                                            
5550   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5551                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5552   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5553   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5554                                                                                                    *toruswatertuberot[0]);
5555
5556   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5557                                                   *                                     (*toruswatertubecombitrans[0]));
5558
5559   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5560                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5561   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5562   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5563                                                                                                      *coolingwatertuberot[3]);
5564   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5565   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5566                                                         *                                 (*coolingwatertubecombitrans[3]));
5567   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5568
5569   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5570                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5571   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5572   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5573                                                                                                    *toruswatertuberot[1]);
5574   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5575   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5576                                                   *                 (*toruswatertubecombitrans[1]));
5577   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5578   
5579   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5580                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5581   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5582   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5583                                                                                                    *toruswatertuberot[3]);
5584   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5585   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5586                                                   *                                     (*toruswatertubecombitrans[2]));
5587   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5588
5589   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5590                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5591   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5592   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5593                                                                                                      *coolingwatertuberot[5]);
5594   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5595   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5596                                                         *                                 (*coolingwatertubecombitrans[4]));
5597   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5598   
5599   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5600                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5601   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5602   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5603                                                                                                    *toruswatertuberot[5]);
5604   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5605   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5606                                                   *                 (*toruswatertubecombitrans[3]));
5607   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5608   
5609   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5610                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5611   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5612   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5613                                                                                                      *coolingwatertuberot[6]);
5614   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5615   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5616                                                         *                                 (*coolingwatertubecombitrans[5]));
5617   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5618   /////////////////////////////////////////
5619   // Positioning Volumes
5620   /////////////////////////////////////////
5621   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5622   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5623   
5624   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5625   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5626
5627   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5628   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5629  
5630   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5631   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5632
5633   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5634   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5635
5636   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5637   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5638
5639   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5640   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5641
5642   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5643   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5644   
5645   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5646   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5647  
5648   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5649   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5650   /////////////////////////////////////////////////////////////
5651   // Deallocating memory
5652   /////////////////////////////////////////////////////////////
5653   for(Int_t i=0; i<8; i++){
5654     if(i<6){
5655          delete coolingtubetrans[i];
5656          delete coolingwatertubetrans[i];
5657          if(i!=0){
5658           delete coolingtubecombitrans[i];
5659           delete coolingwatertubecombitrans[i];
5660          }
5661         }
5662     if(i<8){
5663           delete coolingtuberot[i];
5664           delete coolingwatertuberot[i];
5665     }
5666     if(i<4){
5667                 delete torustubetrans[i];
5668                 delete toruswatertubetrans[i];
5669                 delete torustubecombitrans[i];
5670                 delete toruswatertubecombitrans[i];
5671         } 
5672     if(i<7){
5673          delete torustuberot[i];
5674          delete toruswatertuberot[i];
5675         }
5676   }
5677   /////////////////////////////////////////////////////////////
5678   return endcapcoolingtubemother;
5679  }
5680  ////////////////////////////////////////////////////////////////////////////////
5681  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5682   /////////////////////////////////////////////////////////////
5683   // Getting EndCap Cover Side 
5684   /////////////////////////////////////////////////////////////
5685   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5686   const Int_t kvertexnumber = 15; 
5687   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5688   xvertex[0]  = 0.0;
5689   xvertex[1]  = xvertex[0];
5690   xvertex[2]  = fgkEndCapSideCoverLength[0];
5691   xvertex[3]  = fgkEndCapSideCoverLength[1];
5692   xvertex[4]  = xvertex[3];
5693   xvertex[5]  = fgkEndCapSideCoverLength[2];
5694   xvertex[6]  = xvertex[5];
5695   xvertex[7]  = xvertex[2];
5696   xvertex[8]  = xvertex[7];
5697   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5698   xvertex[10] = xvertex[9];
5699   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5700                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5701                           * fgkEndCapSideCoverLength[4];
5702   xvertex[12] = xvertex[11];
5703   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5704                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5705                           * fgkEndCapSideCoverLength[4];
5706   xvertex[14] = xvertex[13];
5707   yvertex[0]  = 0.0;
5708   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5709   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5710   yvertex[3]  = yvertex[2];
5711   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5712   yvertex[5]  = yvertex[4];
5713   yvertex[6]  = yvertex[0];
5714   yvertex[7]  = yvertex[6];
5715   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5716   yvertex[9]  = yvertex[8];
5717   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5718   yvertex[11] = yvertex[10];
5719   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5720   yvertex[13] = yvertex[12];
5721   yvertex[14] = yvertex[6];
5722   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5723   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5724   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5725   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5726   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5727   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5728   endcapsidecovershapein->SetName("endcapsidecovershapein");
5729   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5730   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5731   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5732
5733
5734   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5735   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5736                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5737   endcapsidecover->SetLineColor(fColorPhynox);
5738   ////////////////////////////////////////////
5739   // Defininition of Mother Volume
5740   ////////////////////////////////////////////
5741   const Int_t kmothervertexnumber = 7;
5742   Double_t xmothervertex[kmothervertexnumber]; 
5743   Double_t ymothervertex[kmothervertexnumber]; 
5744   for(Int_t i=0; i<kmothervertexnumber; i++){
5745         xmothervertex[i] = xvertex[i];
5746         ymothervertex[i] = yvertex[i];
5747   }
5748   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5749   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5750   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5751   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5752   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5753                                                                 endcapsidecovermothershape,fSSDAir);
5754   ////////////////////////////////////////////
5755   endcapsidecovermother->AddNode(endcapsidecover,1);
5756   TGeoBBox* endcapsidecoverboxshape[4];
5757   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5758                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5759                                                                0.5*fgkEndCapSideCoverLength[4],
5760                                                                    0.5*fgkEndCapSideCoverThickness); 
5761   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5762                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5763                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5764                                                          -     fgkEndCapSideCoverLength[4]),
5765                                                                    0.5*fgkEndCapSideCoverThickness); 
5766   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5767                                                                0.5*fgkEndCapSideCoverLength[4],
5768                                                                    0.5*fgkEndCapSideCoverThickness); 
5769   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5770                                                                0.5*fgkEndCapSideCoverWidth[5],
5771                                                                    0.5*fgkEndCapSideCoverThickness); 
5772   TGeoVolume* endcapsidecoverbox[4];
5773   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5774   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5775   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5776   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5777   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5778 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5779   TGeoTranslation** endcapsidecoverboxtrans;
5780   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5781   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5782                                                          +                                         fgkEndCapSideCoverLength[0],
5783                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5784                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5785   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5786                                                          +                     xvertex[11],
5787                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5788                                                          +                     yvertex[12],0.);
5789   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5790                                                          +                     xvertex[11],
5791                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5792                                                          +                     yvertex[12]
5793                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5794                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5795   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5796   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5797   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5798   for(Int_t i=0; i<2; i++)
5799         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5800                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5801                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5802                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5803                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5804                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5805                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5806                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5807         }
5808   for(Int_t i=0; i<2; i++)
5809         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5810                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5811                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5812                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5813                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5814                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5815                                                         +fgkEndCapSideCoverLength[4]),0.0);
5816                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5817                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5818                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5819                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5820         }
5821   delete [] endcapsidecoverboxtrans;
5822   return endcapsidecovermother;
5823  } 
5824  ////////////////////////////////////////////////////////////////////////////////
5825  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5826  ////////////////////////////////////////////////////////////////////////////////
5827  // Method returning Interface Card A, Interface Card B, Supply Card 
5828  ////////////////////////////////////////////////////////////////////////////////
5829  /////////////////////
5830  // Supply Card
5831  /////////////////////
5832  // Electronic Board Back Al Plane
5833  const Int_t kelectboardbackvertexnumber = 8;
5834  Double_t xelectboardback[kelectboardbackvertexnumber];
5835  Double_t yelectboardback[kelectboardbackvertexnumber];
5836  xelectboardback[0] = 0.0;
5837  xelectboardback[1] = xelectboardback[0];
5838  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5839  xelectboardback[3] = xelectboardback[2];
5840  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5841  xelectboardback[5] = xelectboardback[4];
5842  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5843  xelectboardback[7] = xelectboardback[6];
5844  
5845  yelectboardback[0] = 0.0;
5846  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5847  yelectboardback[2] = yelectboardback[1];
5848  yelectboardback[3] = yelectboardback[0];
5849  yelectboardback[4] = yelectboardback[3];
5850  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5851  yelectboardback[6] = yelectboardback[5];
5852  yelectboardback[7] = yelectboardback[4];
5853  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5854  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5855                                                                         xelectboardback,yelectboardback); 
5856  electboardbackshape->DefineSection(0,0.0);
5857  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5858  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5859                                                                                          electboardbackshape,fSSDSupportRingAl);
5860  electboardback->SetLineColor(fColorAl);
5861  // Electronic Board Kapton Layer
5862  const Int_t kelectlayervertexnumber = 8;
5863  Double_t xelectlayer[kelectlayervertexnumber];
5864  Double_t yelectlayer[kelectlayervertexnumber];
5865  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5866  xelectlayer[1] = xelectlayer[0];
5867  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5868  xelectlayer[3] = xelectlayer[2];
5869  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5870      
5871  yelectlayer[0] = 0.0;
5872  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5873  yelectlayer[2] = yelectlayer[1];
5874  yelectlayer[3] = yelectlayer[0];
5875  yelectlayer[4] = yelectlayer[3];
5876  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5877  yelectlayer[6] = yelectlayer[5];
5878  yelectlayer[7] = yelectlayer[4];
5879  TGeoXtru* electlayershape = new TGeoXtru(2);
5880  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5881  electlayershape->DefineSection(0,0.0);
5882  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5883  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5884                                                                                          electlayershape,fSSDKaptonFlexMedium);
5885  electlayer->SetLineColor(fColorKapton);
5886  // JMD Connector Female
5887  const Int_t kjmdconnectorvertexnumber = 6;
5888  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5889  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5890  xjmdconnectorvertex[0] = 0.0; 
5891  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5892  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5893  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5894  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5895  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5896
5897  yjmdconnectorvertex[0] = 0.0; 
5898  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5899  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5900  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5901  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5902  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5903  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5904  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5905                                                                   yjmdconnectorvertex); 
5906  jmdconnectorshape->DefineSection(0,0.0);
5907  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
5908  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
5909                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
5910  jmdconnector->SetLineColor(fColorG10);
5911  // Top Cable Connector
5912  const Int_t kcableconnectorvertexnumber = 8;
5913  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
5914  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
5915  xconnectorvertex[0] = 0.0;
5916  xconnectorvertex[1] = xconnectorvertex[0];
5917  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
5918  xconnectorvertex[3] = xconnectorvertex[2];
5919  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
5920                                          - fgkEndCapCardCableConnectorLength[2];
5921  xconnectorvertex[5] = xconnectorvertex[4];
5922  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
5923  xconnectorvertex[7] = xconnectorvertex[6];
5924
5925  yconnectorvertex[0] = 0.0;
5926  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
5927  yconnectorvertex[2] = yconnectorvertex[1];
5928  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
5929  yconnectorvertex[4] = yconnectorvertex[3];
5930  yconnectorvertex[5] = yconnectorvertex[1];
5931  yconnectorvertex[6] = yconnectorvertex[5];
5932  yconnectorvertex[7] = yconnectorvertex[0];
5933  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
5934  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
5935                                                                     yconnectorvertex); 
5936  cableconnectorshape->DefineSection(0,0.0);
5937  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
5938  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
5939                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
5940  cableconnector->SetLineColor(fColorG10);
5941  // Strip Connection
5942  TGeoBBox* endcapstripconnectionshape = 
5943                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
5944                                                                                          0.5*fgkEndCapStripConnectionThickness,
5945                                                                                          0.5*fgkEndCapStripConnectionWidth);
5946  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
5947                                                                                                         endcapstripconnectionshape,
5948                                                                                                         fSSDSupportRingAl);
5949  endcapstripconnection->SetLineColor(fColorAl);
5950  // Interface Card B
5951  const Int_t kcardBvertexnumber = 12; 
5952  Double_t xcardBvertexnumber[kcardBvertexnumber];
5953  Double_t ycardBvertexnumber[kcardBvertexnumber];
5954
5955  xcardBvertexnumber[0]  = 0.0;
5956  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
5957  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
5958  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
5959  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
5960  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
5961  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
5962  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
5963  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
5964  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
5965  xcardBvertexnumber[10] = xcardBvertexnumber[7];
5966  xcardBvertexnumber[11] = xcardBvertexnumber[10];
5967  
5968  ycardBvertexnumber[0]  = 0.0;
5969  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
5970  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
5971  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
5972  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
5973  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
5974  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
5975  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
5976  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
5977  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
5978  ycardBvertexnumber[10] = ycardBvertexnumber[9];
5979  ycardBvertexnumber[11] = ycardBvertexnumber[0];
5980
5981  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
5982  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
5983  interfacecardBshape->DefineSection(0,0.);
5984  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
5985  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
5986                                                                                          fSSDMountingBlockMedium);
5987  interfacecardB->SetLineColor(46);
5988  // Interface Card B Electronic Board
5989  const Int_t kelectboardcardBvertexnumber = 14; 
5990  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
5991  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
5992
5993  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
5994  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
5995  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
5996  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
5997  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
5998  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
5999  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6000  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6001  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6002  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6003  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6004  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6005  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6006  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6007
6008  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6009  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6010  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6011  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6012  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6013  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6014  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6015  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6016  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6017  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6018  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6019  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6020  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6021  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6022
6023  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6024  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6025                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6026  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6027  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6028                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6029  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6030                                                                                           fSSDSupportRingAl);
6031  electboardcardB->SetLineColor(fColorAl);
6032  // Generating Stiffener 2
6033  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6034                                                                                            0.5*fgkEndCapStiffenerThickness,
6035                                                                                            0.5*fgkEndCapStiffenerLength);
6036  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6037  endcapstiffener->SetLineColor(fColorAl);   
6038  // Generating Mother Interface Card B Container
6039  const Int_t kinterfacecardBmothervertexnumber = 10;
6040  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6041  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6042
6043  xinterfacecardBmothervertex[0] = 0.0;
6044  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6045  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6046                                                                 + fgkEndCapInterfaceCardBThickness;
6047  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6048  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6049                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6050  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6051  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6052  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6053  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6054                                                                 + fgkEndCapCardJMDConnectorLength[0];
6055  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6056
6057  yinterfacecardBmothervertex[0] = 0.0;
6058  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6059                                                                 + fgkEndCapInterfaceCardBWidth[1]
6060                                                                 + fgkEndCapInterfaceCardBWidth[2];
6061  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6062  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6063  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6064  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6065  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6066  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6067                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6068                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6069  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6070  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6071  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6072  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6073                                                                                   xinterfacecardBmothervertex,
6074                                                                                   yinterfacecardBmothervertex);
6075  interfacecardBmothershape->DefineSection(0,-1.e-15);
6076  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6077  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6078                                                                                                    interfacecardBmothershape,fSSDAir);
6079  electboardcardB->SetLineColor(fColorAl);
6080  // Positioning Volumes Mother Interface Card B Container 
6081  TGeoRotation* interfacecardBrot = new TGeoRotation();
6082  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6083  interfacecardBrot->SetAngles(90.,-90.,-90.);
6084  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6085  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6086  TGeoRotation* electboardcardBrot = new TGeoRotation();
6087  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6088  electboardcardBrot->SetAngles(90.,90.,-90.);
6089  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6090  TGeoCombiTrans* electboardcardBcombitrans = 
6091                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6092  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6093  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6094  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6095  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6096  TGeoTranslation* jmdconnectorcardBtrans[3];
6097  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6098  for(Int_t i=0; i<3; i++){
6099    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6100                                                          + fgkEndCapCardJMDConnectorLength[0], 
6101                                                            fgkEndCapCardElectBoardLayerWidth[1],
6102                                                            0.5*fgkEndCapCardJMDConnectorThickness
6103                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6104                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6105                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6106    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6107                                                                                                            *jmdconnectorcardBrot);
6108    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6109  }
6110  // Mother Supply Card Container 
6111  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6112  // Interface Card Container
6113  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6114  // Placing Volumes in Mother Supply Card Container
6115  // JMD Connector Positioning
6116  TGeoTranslation* jmdconnectortrans[2];
6117  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6118  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6119                                                                                         fgkEndCapCardElectBoardBackLength[0]
6120                                           -                                             fgkEndCapCardJMDConnectorThickness
6121                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6122  TGeoRotation* jmdconnectorot = new TGeoRotation();
6123  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6124                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6125                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6126                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6127                                                                       fgkEndCapCardJMDConnectorThickness
6128                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6129  jmdconnectorot->SetAngles(90.,180.,-90);
6130  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6131                                                                                 * jmdconnectorot);
6132  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6133  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6134  // Top Cable Connector Placing
6135  TGeoRotation* cableconnectorot[2];
6136  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6137  TGeoTranslation* cableconnectortrans[3];
6138  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6139  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6140  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6141  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6142  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6143                                                                                                                            *cableconnectorot[0]);
6144  TGeoHMatrix* cableconnectormatrix[2];
6145  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6146                                                         new TGeoHMatrix((*cableconnectorot[1])
6147                                                                                    *(*cableconnectorcombitrans));
6148  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6149                                            -                               fgkEndCapCardCableConnectorThickness,
6150                                                                                 fgkEndCapCardCableConnectorLength[0]
6151                                            +                            fgkEndCapCardCableConnectorToLayer);
6152  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6153                                            -                2.*fgkEndCapCardCableConnectorThickness
6154                                            -                            fgkEndCapCardCableConnectorDistance,
6155                                                                                 fgkEndCapCardCableConnectorLength[0]
6156                                            +                            fgkEndCapCardCableConnectorToLayer);
6157  for(Int_t i=0; i<2; i++){
6158         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6159     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6160  }
6161  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6162  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6163  electboardbackrot->SetAngles(90.,-90.,-90.);
6164  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6165                                                         +                fgkEndCapCardJMDConnectorLength[0]
6166                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6167  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6168                                                                                                                            *electboardbackrot);
6169  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6170  // Electronic Board Kapton Layer Positioning
6171  TGeoRotation* electlayerrot = new TGeoRotation();
6172  TGeoTranslation* electlayertrans[2];
6173  TGeoCombiTrans* electlayercombitrans[2];
6174  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6175  electlayerrot->SetAngles(90.,-90.,-90.);
6176  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6177                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6178  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6179                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6180                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6181  for(Int_t i=0; i<2; i++){
6182         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6183         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6184  }
6185  // Placing Volumes in Mother Interface Card Container
6186  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6187  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6188  for(Int_t i=0; i<2; i++){
6189         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6190  }
6191  /////////////////////////////////////////////////////////////
6192  // Generation of Card Interface Container
6193  /////////////////////////////////////////////////////////////
6194  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6195                                                   - fgkEndCapCardJMDConnectorLength[0]
6196                                                   - fgkEndCapInterfaceCardBThickness
6197                                                   - 9.*fgkEndCapStripConnectionThickness
6198                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6199  const Int_t kcardinterfacecontainervertexnumber = 14;
6200  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6201  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6202  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6203                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6204  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6205  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6206                                                                    + fgkEndCapStripConnectionThickness
6207                                                                    - fgkEndCapCardElectBoardLayerThickness
6208                                                                    - fgkEndCapCardCableConnectorWidth[0];
6209  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6210  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6211  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6212  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6213                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6214  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6215  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6216                                                                    + fgkEndCapInterfaceCardBThickness;
6217  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6218  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6219                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6220  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6221  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6222                                    - fgkEndCapInterfaceElectBoardCardBThickness
6223                                                                    + fgkEndCapCardJMDConnectorLength[0]
6224                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6225  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6226
6227  ycardinterfacecontainervertex[0]  = 0.;
6228  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6229                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6230                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6231  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6232  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6233                                                                    - fgkEndCapStripConnectionWidth;
6234  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6235  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6236  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6237  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6238                                                                    + fgkEndCapInterfaceCardBWidth[1]
6239                                                                    + fgkEndCapInterfaceCardBWidth[2];
6240  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6241  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6242  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6243  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6244  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6245  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6246  
6247  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6248  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6249                                                                                   xcardinterfacecontainervertex,
6250                                                                                   ycardinterfacecontainervertex);
6251  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6252                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6253  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6254                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6255  TGeoVolume** cardinterfacecontainer;
6256  cardinterfacecontainer = new TGeoVolume*[4];
6257  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6258                                                                                         interfacecardmothershape,fSSDAir); 
6259  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6260                                                                                         interfacecardmothershape,fSSDAir); 
6261  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6262                                                                                         interfacecardmothershape,fSSDAir); 
6263  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6264                                                                                         interfacecardmothershape,fSSDAir); 
6265  /////////////////////////////////
6266  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6267  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6268  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6269  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6270  /////////////////////////////////
6271  TGeoRotation* endcapstripconnectionrot[2];
6272  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6273  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6274  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6275  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6276                                                                         *                                 (*endcapstripconnectionrot[0]));
6277  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6278  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6279                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6280                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6281                                                                                         -endcapstripconnectionshape->GetDZ(),
6282                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6283  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6284  TGeoTranslation* cardinterfacetrans[9];
6285  TGeoHMatrix* cardinterfacematrix[9]; 
6286  for(Int_t i=0; i<7; i++){ 
6287         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6288                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6289                                                                                                 0.0,0.0);  
6290         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6291                                                    *                             (*endcapstripconnectionmatrix));
6292  }
6293  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6294                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6295                                                                                                 0.0,0.0);  
6296  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6297                                                 *                                 (*endcapstripconnectionmatrix));
6298  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6299                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6300                                                                                                 0.0,0.0);  
6301  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6302                                                 *                                 (*endcapstripconnectionmatrix));
6303
6304  for(Int_t i=0; i<4; i++){
6305         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6306                                                                            cardinterfacematrix[7]);                             
6307         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6308                                                                            cardinterfacematrix[8]);                             
6309  }
6310  TGeoTranslation* mothersupplycardtrans = 
6311                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6312                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6313                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6314  TGeoHMatrix* mothersupplycardmatrix[7];
6315  Int_t index[4] = {1,1,1,1};
6316  for(Int_t i=0; i<7; i++){
6317         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6318                                                         *                                 (*mothersupplycardtrans));
6319         for(Int_t j=0; j<4; j++){
6320                 switch(j){
6321                         case 0: //Layer5 EndCap Left Side  
6322                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6323                                                                                                    cardinterfacematrix[i]);                             
6324                                 if(i!=0){
6325                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6326                                                                                                            mothersupplycardmatrix[i]);                  
6327                                         index[j]++;
6328
6329                                 }
6330                         break;
6331                         case 1: //Layer5 EndCap Rigth Side  
6332                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6333                                                                                                    cardinterfacematrix[i]);                     
6334                                 if(i>0&&i<6){
6335                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6336                                                                                                            mothersupplycardmatrix[i]);                  
6337                                         index[j]++;
6338                                 }
6339                         break;
6340                         case 2: //Layer6 EndCap Left Side  
6341                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6342                                                                                                    cardinterfacematrix[i]);                             
6343                                 if(i!=6){
6344                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6345                                                                                                            mothersupplycardmatrix[i]);                  
6346                                         index[j]++;
6347                                 }
6348                         break;
6349                         case 3: //Layer6 EndCap Right Side  
6350                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6351                                                                                                    cardinterfacematrix[i]);                             
6352                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6353                                                                                                    mothersupplycardmatrix[i]);                  
6354                                 index[j]++;
6355                         break;
6356                 }
6357         }
6358  }
6359  // Positioning Interface 
6360  TGeoTranslation* motherinterfacecardtrans = 
6361                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6362                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6363                                                          -fgkEndCapCardElectBoardLayerThickness
6364                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6365  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6366                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6367  // Positioning Interface Card B 
6368  TGeoTranslation* interfacecardBmothertrans = 
6369                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6370                                                                                 + 2.*fgkEndCapStripConnectionThickness
6371                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6372                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6373                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6374  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6375                                                                                                                          interfacecardBmothertrans);
6376  // Positioning Stiffener 
6377  TGeoTranslation* endcapstiffenertrans = 
6378                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6379                                                                            +    2.0*fgkEndCapStripConnectionThickness
6380                                                                            +    fgkEndCapInterfaceCardBThickness
6381                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6382                                                                            +    stiffenertransx
6383                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6384                                                                                         endcapstiffenershape->GetDZ()
6385                                                                            -    0.5*(fgkEndCapStiffenerLength
6386                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6387  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6388  /////////////////////////////////////////////////////////////
6389  // Deallocating memory
6390  /////////////////////////////////////////////////////////////
6391  delete interfacecardBrot;
6392  delete interfacecardBtrans;
6393  delete electboardcardBtrans;
6394  delete electboardcardBrot; 
6395  delete jmdconnectorcardBrot;
6396  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6397  delete jmdconnectorot;
6398  delete jmdconnectortrans[1];
6399  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6400  delete cableconnectorcombitrans;
6401  delete electboardbacktrans;
6402  delete electboardbackrot;
6403  delete electlayerrot;
6404  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6405  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6406  delete mothersupplycardtrans;
6407  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6408  /////////////////////////////////////////////////////////////
6409  return cardinterfacecontainer;
6410  }
6411  ////////////////////////////////////////////////////////////////////////////////
6412  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6413   /////////////////////////////////////////////////////////////
6414   // Method returning EndCap Mother Volume
6415   /////////////////////////////////////////////////////////////
6416   const Int_t kendcapcoverplatesmallholenumber = 9;
6417   Double_t endcapmotherorigin[3];
6418   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6419                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6420                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6421   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6422                                           -                      fgkEndCapCoverPlateWidth[2]
6423                                           -       (kendcapcoverplatesmallholenumber-1)
6424                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6425                                           +  0.5*(fgkEndCapSideCoverLength[2]
6426                                           +               fgkEndCapCoverPlateWidth[1]
6427                                           -       fgkEndCapCoverPlateWidth[0])
6428                                           -      (fgkEndCapCoverPlateWidth[1]
6429                                           -       fgkEndCapCoverPlateWidth[0]);
6430   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6431                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6432                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6433                                                 +      fgkEndCapSideCoverWidth[1]
6434                                                 +      fgkEndCapSideCoverThickness
6435                                                 +      fgkEndCapKaptonFoilThickness);
6436   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6437                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6438                                                           +              2.0* fgkEndCapSideCoverThickness),
6439                                                                          0.5* (fgkEndCapSideCoverLength[2]
6440                                                           +                    fgkEndCapCoverPlateWidth[1]
6441                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6442                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6443                                                       +                                    fgkEndCapSideCoverWidth[1]
6444                                                           +                                       fgkEndCapSideCoverThickness
6445                                                       +                                   fgkEndCapKaptonFoilThickness),
6446                                                                                          endcapmotherorigin);
6447   TGeoVolume** endcapassembly;  
6448   endcapassembly = new TGeoVolume*[4];
6449   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6450                                                                                         endcapmothershape,fSSDAir); 
6451   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6452                                                                                         endcapmothershape,fSSDAir); 
6453   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6454                                                                                         endcapmothershape,fSSDAir); 
6455   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6456                                                                                         endcapmothershape,fSSDAir); 
6457  /////////////////////////////////
6458  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6459  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6460  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6461  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6462  /////////////////////////////////
6463   /////////////////////////////////////////////////////
6464   // Placing Endcap Cover Plate
6465   /////////////////////////////////////////////////////
6466   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6467   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6468   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6469   TGeoCombiTrans* endcapcoverplatecombitrans = 
6470                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6471                                                                                          endcapcoverplaterot);
6472   TGeoTranslation* endcapcoverplatetrans = 
6473                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6474   TGeoHMatrix* endcapcoverplatematrix = 
6475                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6476                                                                           *       (*endcapcoverplatecombitrans));
6477   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6478   /////////////////////////////////////////////////////
6479   // Placing Endcap Side Cover
6480   /////////////////////////////////////////////////////
6481   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6482   TGeoRotation* endcapsidecoverot[2];
6483   TGeoCombiTrans* endcapsidecovercombitrans[3];
6484   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6485   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6486   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6487                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6488                                                                                         - fgkEndCapCoverPlateWidth[2]
6489                                                                                     - (kendcapcoverplatesmallholenumber-1)
6490                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6491                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6492                                                                                         + fgkEndCapSideCoverLength[2],
6493                                                                                           0.5*(fgkEndCapSideCoverThickness
6494                                                                                         + fgkEndCapCoverPlateThickness)
6495                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6496                                                                                           endcapsidecoverot[0]);
6497   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6498   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6499                                                                                                         0.5*fgkEndCapCoverPlateThickness
6500                                                                                                         -fgkEndCapSideCoverWidth[1],
6501                                                                                                         endcapsidecoverot[1]);
6502   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6503                                                                                                         +fgkEndCapCoverPlateLength[3]
6504                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6505                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6506                                                                                                         0.5*fgkEndCapCoverPlateThickness
6507                                                                                                         -fgkEndCapSideCoverWidth[1],
6508                                                                                                         endcapsidecoverot[1]);
6509   TGeoHMatrix* endcapsidecovermatrix[2];
6510   for(Int_t i=0; i<2; i++){
6511    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6512                                                         *                                 (*endcapsidecovercombitrans[0]));
6513         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6514                                                                                                                 endcapsidecovermatrix[i]);
6515   }
6516   /////////////////////////////////////////////////////
6517   // Placing Endcap Cooling Tube
6518   /////////////////////////////////////////////////////
6519   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6520   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6521   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6522   TGeoCombiTrans* endcapccolingtubecombitrans 
6523                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6524                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6525                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6526                                                 - fgkEndCapCoolingTubeToCoverSide,
6527                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6528                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6529   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6530                                                                                                           endcapccolingtubecombitrans);
6531   /////////////////////////////////////////////////////
6532   // Placing Screws 
6533   /////////////////////////////////////////////////////
6534   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6535                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6536   Int_t screwcoverplatedgesnumber[2] = {20,20};
6537   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6538                                                                                 fgkEndCapCoverPlateThickness
6539                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6540   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6541                                                                                                  screwcoverplatedgesnumber,
6542                                                                                                  screwcoverplatesection);
6543   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6544                                                                                            screwcoverplateshape,
6545                                                                                            fSSDCoolingTubePhynox); 
6546   screwcoverplate->SetLineColor(12);
6547   Double_t transx[4] = {0,
6548                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6549                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6550                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6551                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6552                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6553   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6554 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6555   TGeoTranslation*** endcapcoverplatescrewtrans;
6556   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6557   Int_t index = 0;
6558   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6559         endcapcoverplatescrewtrans[i] = 
6560                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6561     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6562                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6563         if(index==1||index==9||index==28||index==36){
6564                         endcapcoverplatescrewtrans[i][j] = 
6565                                 new TGeoTranslation(transx[i],
6566                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6567                                                                         fgkEndCapSideCoverThickness);
6568                 }
6569                 else{
6570                         endcapcoverplatescrewtrans[i][j] = 
6571                                 new TGeoTranslation(transx[i],
6572                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6573                                                                         0.);
6574                 }
6575             if(index!=19) 
6576                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6577                                                                                           endcapcoverplatescrewtrans[i][j]);
6578         }
6579   }
6580   /////////////////////////////////////////////////////
6581   // Placing Cover Plate Clips 
6582   /////////////////////////////////////////////////////
6583   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6584                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6585                                                                                                          0.5*fgkEndCapSideCoverThickness);
6586   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6587                                                                                                         endcapcoverplateclipshape,
6588                                                                                                         fSSDCoolingTubePhynox);
6589   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6590                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6591                                                                                                          0.5*fgkEndCapSideCoverThickness);
6592   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6593                                                                                                         endcapcoverplatedownclipshape,
6594                                                                                                         fSSDCoolingTubePhynox);
6595   TGeoTranslation* endcapcoverplatecliptrans[4];
6596   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6597                                                            -                     fgkEndCapCoverPlateLength[0]
6598                                                            -                     fgkEndCapSideCoverThickness,
6599                                                                                                          0.0,
6600                                                                                                  0.5*(fgkEndCapSideCoverThickness
6601                                                            +                                              fgkEndCapCoverPlateThickness));
6602   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6603                                                            -                     fgkEndCapCoverPlateLength[0]
6604                                                            -                     fgkEndCapSideCoverThickness,
6605                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6606                                                            *                                     fgkEndCapSideCoverWidth[5],
6607                                                                                                  0.5*(fgkEndCapSideCoverThickness
6608                                                            +                                              fgkEndCapCoverPlateThickness));
6609   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6610                                                            -                     fgkEndCapCoverPlateLength[0]
6611                                                            +                                     fgkEndCapCoverPlateLength[1]
6612                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6613                                                            -                                     fgkEndCapCoverPlateClipLength
6614                                                            +                                 fgkEndCapSideCoverThickness,
6615                                                                                                          0.0,
6616                                                                                                  0.5*(fgkEndCapSideCoverThickness
6617                                                            +                                              fgkEndCapCoverPlateThickness));
6618   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6619                                                            -                     fgkEndCapCoverPlateLength[0]
6620                                                            +                                     fgkEndCapCoverPlateLength[1]
6621                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6622                                                            -                                     fgkEndCapCoverPlateClipLength
6623                                                            +                                 fgkEndCapSideCoverThickness,
6624                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6625                                                            *                                     fgkEndCapSideCoverWidth[5],
6626                                                                                                  0.5*(fgkEndCapSideCoverThickness
6627                                                            +                                              fgkEndCapCoverPlateThickness));
6628   endcapcoverplateclip->SetLineColor(fColorPhynox);
6629   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6630   for(Int_t i=0; i<4; i++) 
6631         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6632                                                                                                    endcapcoverplatecliptrans[i]);  
6633   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6634   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6635                                                                    -                     fgkEndCapCoverPlateLength[0]
6636                                                                    -                     fgkEndCapSideCoverThickness,
6637                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6638                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6639                                                                                                         0.5*(fgkEndCapSideCoverThickness
6640                                                                +                                         fgkEndCapCoverPlateThickness)
6641                                                                    -                     fgkEndCapSideCoverWidth[1]
6642                                                                    -                                     fgkEndCapSideCoverThickness);
6643   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6644                                                                    -                     fgkEndCapCoverPlateLength[0]
6645                                                                    -                     fgkEndCapSideCoverThickness,
6646                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6647                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6648                                                                    +                            fgkEndCapSideCoverLength[2]
6649                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6650                                                                                                         0.5*(fgkEndCapSideCoverThickness
6651                                                                +                                         fgkEndCapCoverPlateThickness)
6652                                                                    -                     fgkEndCapSideCoverWidth[1]
6653                                                                    -                                     fgkEndCapSideCoverThickness);
6654   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6655                                                                    -                     fgkEndCapCoverPlateLength[0]
6656                                                                    +                     fgkEndCapSideCoverThickness
6657                                                                    +                     fgkEndCapCoverPlateLength[1]
6658                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6659                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6660                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6661                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6662                                                                                                         0.5*(fgkEndCapSideCoverThickness
6663                                                                +                                         fgkEndCapCoverPlateThickness)
6664                                                                    -                     fgkEndCapSideCoverWidth[1]
6665                                                                    -                                     fgkEndCapSideCoverThickness);
6666   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6667                                                                    -                     fgkEndCapCoverPlateLength[0]
6668                                                                    +                     fgkEndCapSideCoverThickness
6669                                                                    +                     fgkEndCapCoverPlateLength[1]
6670                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6671                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6672                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6673                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6674                                                                    +                                 fgkEndCapSideCoverLength[2]
6675                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6676                                                                                                         0.5*(fgkEndCapSideCoverThickness
6677                                                                +                                         fgkEndCapCoverPlateThickness)
6678                                                                    -                     fgkEndCapSideCoverWidth[1]
6679                                                                    -                                     fgkEndCapSideCoverThickness);
6680   for(Int_t i=0; i<4; i++)
6681         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6682                                                                                                    endcapcoverplatedowncliptrans[i]);
6683   /////////////////////////////////////////////////////
6684   // Placing Kapton Foil
6685   /////////////////////////////////////////////////////
6686   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6687                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6688                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6689   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6690                                                                                                 endcapkaptonfoilshape,
6691                                                                                                 fSSDKaptonFlexMedium);
6692   endcapkaptonfoil->SetLineColor(8);
6693   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6694                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6695                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6696                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6697                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6698                                                                              -                     fgkEndCapSideCoverWidth[1]
6699                                                                                  -                     fgkEndCapSideCoverThickness);
6700   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6701   /////////////////////////////////////////////////////////////
6702   // Placing Electronic Tubes
6703   /////////////////////////////////////////////////////////////
6704   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6705                                                                              - fgkEndCapInterfaceCardBThickness
6706                                                                              - 9.*fgkEndCapStripConnectionThickness
6707                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6708                                                                                fgkEndCapKaptonFoilWidth
6709                                                                              - fgkEndCapInterfaceCardBThickness
6710                                                                              - 9.*fgkEndCapStripConnectionThickness
6711                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6712                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6713   TGeoVolume* endcapeffectivecables[2];
6714   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6715                                                                                          fgkEndCapEffectiveCableRadiusMax,
6716                                                                                          endcapeffectivecableswidth[0],
6717                                                                                          10,"EndCapEffectiveCables1"); 
6718   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6719                                                                                          fgkEndCapEffectiveCableRadiusMax,
6720                                                                                          endcapeffectivecableswidth[1],
6721                                                                                          25,"EndCapEffectiveCables2"); 
6722   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6723   TGeoTranslation* endcapeffectivecablestrans[2];
6724   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6725                                           -                                                        0.5*endcapeffectivecableswidth[0]
6726                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6727                                           -                                                               fgkEndCapCoverPlateWidth[2]
6728                                           -                                             (kendcapcoverplatesmallholenumber-1)
6729                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6730                                           +                                             fgkEndCapSideCoverLength[2],
6731                                           -                     0.5*fgkEndCapCoverPlateThickness
6732                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6733                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6734                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6735   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6736                                           -                                                        0.5*endcapeffectivecableswidth[1]
6737                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6738                                           -                                                               fgkEndCapCoverPlateWidth[2]
6739                                           -                                             (kendcapcoverplatesmallholenumber-1)
6740                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6741                                           +                                         fgkEndCapSideCoverLength[2],
6742                                           -                     0.5*fgkEndCapCoverPlateThickness
6743                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6744                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6745                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6746   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6747   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6748   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6749                                                                                                                    *endcapeffectivecablesrot);
6750   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6751                                                                                                                    *endcapeffectivecablesrot);
6752 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6753 //                                                                                                        endcapeffectivecablescombitrans[0]);
6754   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6755                                                                                                           endcapeffectivecablescombitrans[1]);
6756   /////////////////////////////////////////////////////////////
6757   // Placing End Cap Cards
6758   /////////////////////////////////////////////////////////////
6759   TGeoVolume** endcapcards = GetEndCapCards();
6760   TGeoRotation* endcapcardsrot[2];
6761   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6762   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6763   TGeoTranslation* endcapcardstrans[2]; 
6764   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6765                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6766   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6767   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6768   TGeoHMatrix* endcapcardsmatrix[2];
6769   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6770   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6771                                                   - fgkEndCapCardJMDConnectorLength[0]
6772                                                   - fgkEndCapInterfaceCardBThickness
6773                                                   - 9.*fgkEndCapStripConnectionThickness
6774                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6775   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6776                                           -                                             fgkEndCapCoverPlateLength[0]
6777                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6778                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6779                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6780                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6781                                           -                                                               fgkEndCapInterfaceCardBThickness
6782                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6783                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6784                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6785                                           -                                                               fgkEndCapCoverPlateWidth[2]
6786                                           -                                             (kendcapcoverplatesmallholenumber-1)
6787                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6788                                           +                     fgkEndCapKaptonFoilWidth,
6789                                                                                           0.5*fgkEndCapCoverPlateThickness
6790                                           -                                                     fgkEndCapSideCoverWidth[1]);
6791   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6792   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6793    /////////////////////////////////////////////////////////////
6794   // Deallocating memory
6795   /////////////////////////////////////////////////////////////
6796   delete endcapcoverplaterot;
6797   delete endcapcoverplatecombitrans;
6798   delete endcapcoverplatetrans;
6799   for(Int_t i=0; i<3; i++){
6800    delete endcapsidecovercombitrans[i];
6801    if(i<2) delete endcapsidecoverot[i]; 
6802   }
6803   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6804   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6805   delete endcapcardsmatrix[0];
6806   return endcapassembly;
6807  } 
6808  ////////////////////////////////////////////////////////////////////////////////
6809  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6810                                                                                                                         Double_t radiusmax, 
6811                                                                                                                         Double_t width, 
6812                                                                                                                         Int_t ncables,
6813                                                                                                                         const char* volname){
6814   /////////////////////////////////////////////////////////////
6815   // Generating EndCap High Voltage Tubes 
6816   /////////////////////////////////////////////////////////////
6817   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6818   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
6819
6820   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6821   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6822                                                                                                    effectiveouteradius,0.5*width);
6823   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6824                                                                                                 effectiveinnertubeshape,
6825                                                                                                 fSSDStiffenerConnectorMedium);
6826   effectiveinnertube->SetLineColor(41);
6827   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6828                                                                                                 effectiveoutertubeshape,
6829                                                                                                 fSSDKaptonChipCableMedium);
6830   effectiveoutertube->SetLineColor(39);
6831   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6832   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6833   effectivemothertube->AddNode(effectiveinnertube,1);
6834   effectivemothertube->AddNode(effectiveoutertube,1);
6835   return effectivemothertube;
6836  } 
6837  ////////////////////////////////////////////////////////////////////////////////
6838  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6839   /////////////////////////////////////////////////////////////
6840   // Generating EndCap Support Layer 5 and Layer 6 
6841   /////////////////////////////////////////////////////////////
6842   const Int_t knedges = 5;
6843   ///////////////////////////////////////////////
6844   // Setting the vertices for TGeoXtru Up Volume
6845   ///////////////////////////////////////////////
6846   const Int_t klayernumber = 2;
6847   Double_t xupvertex[klayernumber][knedges+3];
6848   Double_t yupvertex[klayernumber][knedges+3];
6849   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6850   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6851   Double_t middlepsi[klayernumber] = {0.0,0.0};
6852   for(Int_t i=0; i<klayernumber; i++){
6853         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6854         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6855         xupvertex[i][2] = -xupvertex[i][1];
6856         xupvertex[i][3] = -xupvertex[i][0];
6857
6858         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6859         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6860         yupvertex[i][2] =  yupvertex[i][1];
6861         yupvertex[i][3] =  yupvertex[i][0];
6862         
6863     middledgeangle[i] = upedgeangle[i]/knedges;
6864     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6865     for(Int_t j=1; j<knedges; j++){
6866                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6867                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6868         }
6869   }
6870   ////////////////////////////////////
6871   // Generating Up TGeoXtru
6872   ////////////////////////////////////
6873   TGeoXtru* upendcapsupportshape[klayernumber];
6874   TGeoVolume* upendcapsupport[klayernumber]; 
6875   char upendcapsupportname[100]; 
6876   for(Int_t i=0; i<klayernumber; i++){
6877    upendcapsupportshape[i] = new TGeoXtru(2);
6878    snprintf(upendcapsupportname,100,"UpEndCapSupportPieceLayer%i",i+5);
6879    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6880    upendcapsupportshape[i]->DefineSection(0,0.);
6881    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6882    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6883                                                                         fSSDSupportRingAl);
6884    upendcapsupport[i]->SetLineColor(5);
6885   }
6886   ///////////////////////////////////////////////
6887   // Setting the vertices for TGeoXtru Down Volume
6888   ///////////////////////////////////////////////
6889   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6890   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6891   for(Int_t i=0; i<klayernumber; i++){
6892         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6893         xdownvertex[i][1] =  xupvertex[i][0];
6894         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6895         ydownvertex[i][1] =  yupvertex[i][0];
6896         for(Int_t j=0; j<knedges; j++){
6897                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6898                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6899         } 
6900         for(Int_t j=0; j<knedges; j++){
6901                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6902                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6903                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6904                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
6905         }
6906   }
6907   ////////////////////////////////////
6908   // Generating Down TGeoXtru
6909   ////////////////////////////////////  
6910   TGeoXtru* downendcapsupportshape[klayernumber];
6911   TGeoVolume* downendcapsupport[klayernumber]; 
6912   char downendcapsupportname[100]; 
6913   for(Int_t i=0; i<klayernumber; i++){
6914         downendcapsupportshape[i] = new TGeoXtru(2);
6915         snprintf(downendcapsupportname,100,"DownEndCapSupportPieceLayer%i",i+5);
6916         downendcapsupportshape[i] = new TGeoXtru(2);
6917         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
6918     if(i==0){
6919                 downendcapsupportshape[i]->DefineSection(0,0.);
6920                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
6921     }
6922         else{
6923                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
6924                                                                  -                 fgkEndCapSupportLowWidth[i]);
6925                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6926         }
6927     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
6928                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
6929         downendcapsupport[i]->SetLineColor(5);
6930   }
6931   ///////////////////////////////////////////////
6932   // Setting TGeoPgon Volume
6933   ///////////////////////////////////////////////
6934   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6935                                                                                                    fgkSSDLay6LadderNumber};
6936   TGeoPgon* endcapsupportmothershape[klayernumber];
6937   TGeoVolume** endcapsupportmother;
6938   endcapsupportmother = new TGeoVolume*[klayernumber];
6939   char endcapsupportmothername[100];
6940   for(Int_t i=0; i<klayernumber; i++){
6941         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6942         snprintf(endcapsupportmothername,100,"EndCapSupportMotherLayer%i",i+5);
6943         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
6944     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
6945                                                                                           ydownvertex[i][0],yupvertex[i][1]);
6946     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
6947                                                                                         fSSDAir);       
6948   }
6949   ////////////////////////////////////
6950   TGeoRotation** endcapsupportrot[klayernumber];
6951   for(Int_t i=0; i<2; i++){
6952         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
6953         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6954            endcapsupportrot[i][j] = new TGeoRotation();
6955            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
6956        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
6957        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
6958         }
6959   }
6960   return endcapsupportmother;
6961  } 
6962  ////////////////////////////////////////////////////////////////////////////////
6963  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
6964   /////////////////////////////////////////////////////////////
6965   // Setting End Cap Support Layer 5 and 6. 
6966   /////////////////////////////////////////////////////////////
6967   const Int_t kendcapcoverplatesmallholenumber = 9;
6968   const Int_t klayernumber = 2;
6969   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6970                                                                                                    fgkSSDLay6LadderNumber};
6971   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
6972                                                                                 360.0/kssdlayladdernumber[1]};
6973   TGeoVolume** endcapsupport = EndCapSupport();
6974   TGeoVolume** endcapassembly = GetEndCapAssembly();
6975   TGeoPgon* endcapsupportshape[klayernumber];
6976   Double_t* radiusmin[klayernumber];
6977   Double_t* radiusmax[klayernumber];
6978   for(Int_t i=0; i<klayernumber; i++){
6979     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
6980         radiusmin[i] = endcapsupportshape[i]->GetRmin();
6981         radiusmax[i] = endcapsupportshape[i]->GetRmax();
6982   }  
6983   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
6984   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
6985                                                                           endcapassemblyshape->GetDY(),
6986                                                                           endcapassemblyshape->GetDZ()};
6987   ///////////////////////////////////////////////
6988   // Setting TGeoPgon Volume for Mother Container
6989   ///////////////////////////////////////////////
6990   TGeoPgon* endcapsupportsystemshape[klayernumber];
6991   char endcapsupportsystemothername[100];
6992   for(Int_t i=0; i<klayernumber; i++){
6993         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6994         snprintf(endcapsupportsystemothername,100,"EndCapSupportSystemLayer%i",i+5);
6995         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
6996                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
6997                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6998                                                                                            +2.*endcapassemblycenter[2])
6999                                                                                            /CosD(0.5*upedgeangle[i]));  
7000     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7001                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7002                                                                                              - fgkEndCapCoverPlateWidth[0]),
7003                                                                                            *radiusmin[i],
7004                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7005                                                                                            +2.*endcapassemblycenter[2])
7006                                                                                            /CosD(0.5*upedgeangle[i]));
7007   }
7008   fgkEndCapSupportSystem = new TGeoVolume*[4];
7009   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7010                                                                           endcapsupportsystemshape[0],fSSDAir); 
7011   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7012                                                                           endcapsupportsystemshape[0],fSSDAir); 
7013   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7014                                                                           endcapsupportsystemshape[1],fSSDAir); 
7015   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7016                                                                           endcapsupportsystemshape[1],fSSDAir); 
7017   ///////////////////////////////////////////////
7018   TGeoTranslation* endcapassemblytrans[klayernumber];
7019   for(Int_t i=0; i<klayernumber; i++)
7020         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7021                                                                            -  fgkEndCapSideCoverThickness
7022                                                                            +  endcapassemblycenter[0],
7023                                                                            -  0.5*fgkEndCapCoverPlateThickness
7024                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7025                                                                            +  2.0*endcapassemblycenter[2]
7026                                                                            +  0.5*fgkEndCapSupportLength[i]
7027                                                                            /  TanD(0.5*upedgeangle[i]),
7028                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7029                                                                            -  fgkEndCapCoverPlateWidth[2]
7030                                                                            - (kendcapcoverplatesmallholenumber-1)
7031                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7032   TGeoRotation** endcapassemblyrot[klayernumber];
7033   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7034   for(Int_t i=0; i<klayernumber; i++){
7035    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7036    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7037    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7038    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7039    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7040    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7041    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7042    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7043         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7044         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7045    }
7046   }
7047   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7048                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7049   for(Int_t i=0; i<2*klayernumber; i++){
7050         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7051                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7052                                                                                                                                            endcapassemblymatrix[1][j+2]);
7053         }
7054         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7055   }
7056    /////////////////////////////////////////////////////////////
7057   // Deallocating memory
7058   /////////////////////////////////////////////////////////////
7059   for(Int_t i=0; i<klayernumber; i++){
7060         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7061                 delete endcapassemblyrot[i][j];
7062         }
7063         delete [] endcapassemblyrot[i];
7064         delete endcapassemblymatrix[i][0];
7065         delete endcapassemblymatrix[i][1];
7066   }
7067   /////////////////////////////////////////////////////////////
7068   }
7069   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7070   /////////////////////////////////////////////////////////////
7071   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7072   /////////////////////////////////////////////////////////////
7073   if (! moth) {
7074     AliError("Can't insert end cap support of layer5, mother is null!\n");
7075     return;
7076   };
7077   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7078   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7079   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7080                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7081                                                                            +            fgkEndCapSupportCenterLay5Position
7082                                                                            -            fgkEndCapSideCoverLength[2]);
7083   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7084                                                                                                 fgkEndCapSideCoverLength[2]
7085                                                                            -        fgkEndCapSupportCenterLay5Position
7086                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7087   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7088   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7089   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7090         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7091   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7092   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7093    /////////////////////////////////////////////////////////////
7094   // Deallocating memory
7095   /////////////////////////////////////////////////////////////
7096   delete endcapsupportsystemrot;
7097   delete endcapsupportsystemITSCentertrans[1];
7098  }
7099   /////////////////////////////////////////////////////////////
7100   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7101   /////////////////////////////////////////////////////////////
7102   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7103   /////////////////////////////////////////////////////////////
7104   if (! moth) {
7105     AliError("Can't insert end cap support of layer6, mother is null!\n");
7106     return;
7107   };
7108   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7109   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7110   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7111                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7112                                                                            +            fgkEndCapSupportCenterLay6Position
7113                                                                            -            fgkEndCapSideCoverLength[2]);
7114   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7115                                                                                                 fgkEndCapSideCoverLength[2]
7116                                                                            -        fgkEndCapSupportCenterLay6Position
7117                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7118   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7119   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7120   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7121         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7122   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7123   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7124    /////////////////////////////////////////////////////////////
7125   // Deallocating memory
7126   /////////////////////////////////////////////////////////////
7127   delete endcapsupportsystemrot;
7128   delete endcapsupportsystemITSCentertrans[1];
7129  }
7130  ////////////////////////////////////////////////////////////////////////////////
7131  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7132   /////////////////////////////////////////////////////////////
7133   // Setting Ladder Support of Layer 5. 
7134   /////////////////////////////////////////////////////////////
7135   if (! moth) {
7136     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7137     return;
7138   };
7139   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7140   fMotherVol = moth;
7141   TGeoTranslation* centerITSRingSupportLay5trans[2];
7142   for(Int_t i=0; i<2; i++){
7143         centerITSRingSupportLay5trans[i] = 
7144                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7145     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7146   }
7147  }
7148  ////////////////////////////////////////////////////////////////////////////////
7149  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7150   /////////////////////////////////////////////////////////////
7151   // Setting Ladder Support of Layer 6. 
7152   /////////////////////////////////////////////////////////////
7153   if (! moth) {
7154     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7155     return;
7156   };
7157   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7158   fMotherVol = moth;
7159   TGeoTranslation* centerITSRingSupportLay6trans[2];
7160   for(Int_t i=0; i<2; i++){
7161         centerITSRingSupportLay6trans[i] = 
7162                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7163     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7164   }
7165  }
7166  ////////////////////////////////////////////////////////////////////////////////
7167  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7168   /////////////////////////////////////////////////////////////
7169   // Setting Ladder Support of Layer 6. 
7170   /////////////////////////////////////////////////////////////
7171   if (! moth) {
7172     AliError("Can't insert SSD Cone, mother is null!\n");
7173     return;
7174   };
7175   if(!fSSDCone) SetSSDCone();
7176   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7177                                                                 +                                         fgkSSDCentralAL3SupportLength);
7178     moth->AddNode(fSSDCone,1,ssdconetrans);
7179 }
7180  ////////////////////////////////////////////////////////////////////////////////
7181  void AliITSv11GeometrySSD::SetSSDCone(){
7182   /////////////////////////////////////////////////////////////
7183   // Method generating SSDCone 
7184   /////////////////////////////////////////////////////////////
7185   if(!fCreateMaterials) CreateMaterials();
7186   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7187   Double_t ssdpconesectionradiusmax[16];
7188   Double_t ssdpconesectionradiusmin[16];
7189   Double_t ssdpconezsection[16];
7190   TGeoPcon* ssdpconelittleholeshape[8];
7191   TGeoVolume* ssdpconelittlehole[8];
7192   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7193   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7194   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7195                                                       / SinD(fgkSSDPConeAngle)
7196                                                           + ssdpconesectionradiusmin[0];
7197   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7198                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7199                                                           / SinD(fgkSSDPConeAngle);
7200   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7201   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7202                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7203   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7204   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7205                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7206   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7207   ssdpconelittlehole[0]->SetLineColor(4);
7208   /////////////////////////////////////////////////////////////
7209   ssdpconezsection[2] = ssdpconezsection[1];  
7210   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7211   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7212   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7213                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7214                                                           / SinD(fgkSSDPConeAngle);
7215   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7216                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7217   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7218                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7219   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7220                                                                    * TMath::RadToDeg();
7221   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7222                                                                                                           60.-ssdpconelittleholeangle,2);    
7223   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7224                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7225   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7226   ssdpconelittlehole[1]->SetLineColor(4);
7227   TGeoRotation* ssdconelittleholerot[6];
7228   for(Int_t i=0; i<6; i++){
7229         ssdconelittleholerot[i] = new TGeoRotation();
7230     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7231   }
7232   /////////////////////////////////////////////////////////////
7233   ssdpconezsection[4] = ssdpconezsection[3];  
7234   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7235   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7236   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7237                                                           * CosD(fgkSSDPConeAngle)
7238                                                           / SinD(fgkSSDPConeAngle);
7239   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7240   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7241                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7242   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7243   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7244                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7245   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7246   ssdpconelittlehole[2]->SetLineColor(4);
7247   ///////////////////////////////////////////////////
7248   ssdpconezsection[6] = ssdpconezsection[5];  
7249   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7250   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7251   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7252                                                           -ssdpconezsection[0]
7253                                                           * CosD(fgkSSDPConeAngle)
7254                                                           / SinD(fgkSSDPConeAngle);
7255   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7256   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7257                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7258   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7259                                                                    * TMath::RadToDeg();
7260   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7261                                                                                                           45.-ssdpconemiddleholeangle,2);    
7262   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7263                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7264   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7265   ssdpconelittlehole[3]->SetLineColor(4);
7266   TGeoRotation* ssdconemiddleholerot[8];
7267   for(Int_t i=0; i<8; i++){
7268         ssdconemiddleholerot[i] = new TGeoRotation();
7269     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7270   }
7271   /////////////////////////////////////////////////////////////
7272   ssdpconezsection[8] = ssdpconezsection[7];  
7273   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7274   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7275   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7276                                                           * CosD(fgkSSDPConeAngle)
7277                                                           / SinD(fgkSSDPConeAngle);
7278   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7279   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7280                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7281   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7282   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7283                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7284   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7285   ssdpconelittlehole[4]->SetLineColor(4);
7286   /////////////////////////////////////////////////////////////
7287   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7288   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7289                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7290                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7291                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7292                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7293   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7294   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7295                                                                                  * TMath::RadToDeg();
7296   ssdpconezsection[10] = ssdpconezsection[9];
7297   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7298   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7299   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7300                                                           * CosD(fgkSSDPConeAngle)
7301                                                           / SinD(fgkSSDPConeAngle);
7302   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7303   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7304                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7305   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7306                                                                                         ssdpconetrapezoidsectionangle,2);    
7307   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7308                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7309   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7310   ssdpconelittlehole[5]->SetLineColor(4);
7311   TGeoRotation* ssdconeupradiusrot[8];
7312   for(Int_t i=0; i<8; i++){
7313         ssdconeupradiusrot[i] = new TGeoRotation();
7314     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7315   }
7316   /////////////////////////////////////////////////////////////
7317   ssdpconezsection[12] = ssdpconezsection[11];
7318   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7319   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7320   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7321   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7322   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7323   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7324   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7325                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7326   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7327   ssdpconelittlehole[6]->SetLineColor(4);
7328   /////////////////////////////////////////////////////////////
7329   ssdpconezsection[14] = 0.0;
7330   ssdpconezsection[15] = ssdpconezsection[0];
7331   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7332   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7333   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7334   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7335   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7336   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7337                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7338   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7339   ssdpconelittlehole[7]->SetLineColor(4);
7340   /////////////////////////////////////////////////////////////
7341   TGeoTube* ssdtubeconeshape[2];
7342   TGeoVolume* ssdtubecone[2];
7343   TGeoTranslation* ssdtubeconetrans[2];
7344   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7345                                                                            fgkSSDPConeExternalRadius,
7346                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7347   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7348                                                                            0.5*ssdpconezsection[0]); 
7349   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7350   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7351   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7352                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7353                                           + ssdpconezsection[13]);
7354   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7355   ssdtubecone[0]->SetLineColor(4);
7356   ssdtubecone[1]->SetLineColor(4);
7357   /////////////////////////////////////////////////////////////
7358   // Mother Volume Container
7359   /////////////////////////////////////////////////////////////
7360   Double_t ssdconemotherradiusmin[8];
7361   Double_t ssdconemotherradiusmax[8];
7362   Double_t ssdconemothersection[8]; 
7363   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7364   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7365   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7366   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7367   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7368   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7369   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7370   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7371   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7372   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7373   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7374   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7375   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7376   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7377   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7378   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7379   ssdconemothersection[0] = 0.0;
7380   ssdconemothersection[1] = ssdpconezsection[0];
7381   ssdconemothersection[2] = ssdpconezsection[0];
7382   ssdconemothersection[3] = ssdpconezsection[11];
7383   ssdconemothersection[4] = ssdpconezsection[11];
7384   ssdconemothersection[5] = ssdpconezsection[13];
7385   ssdconemothersection[6] = ssdpconezsection[13];
7386   ssdconemothersection[7] = fgkSSDPConeLength;
7387   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7388   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7389                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7390   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7391   /////////////////////////////////////////////////////////////
7392   //Placing the Volumes into Mother 
7393   /////////////////////////////////////////////////////////////
7394   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7395   for(Int_t i=0; i<6; i++){
7396         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7397   }
7398   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7399   for(Int_t i=0; i<8; i++){
7400     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7401   }
7402   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7403   for(Int_t i=0; i<8; i++){
7404     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7405   }
7406   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7407   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7408   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7409   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7410   /////////////////////////////////////////////////////////////
7411   // ITS General Support
7412   /////////////////////////////////////////////////////////////
7413   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7414                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7415   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7416   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7417                                                                              - fgkSSDCentralAL3SupportLength);
7418   ssdcentralsupport->SetLineColor(4);
7419   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7420   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7421                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7422   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7423   TGeoTranslation* ssdcentralal3supportrans[3]; 
7424   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7425   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7426                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7427   ssdcentralal3support->SetLineColor(4);
7428   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7429   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7430   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7431   Double_t ssdpconcentralradiusmin[2];
7432   Double_t ssdpconcentralradiusmax[2];
7433   Double_t ssdpconcentralsection[2];
7434   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7435   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7436   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7437   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7438   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7439   ssdpconcentralsection[1] = 0.;
7440   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7441                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7442   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7443   ssdpconcentralal3->SetLineColor(4);
7444   fSSDCone->AddNode(ssdpconcentralal3,1);
7445   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7446   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7447   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7448                                                                 -2.*fgkSSDCentralAL3SupportLength);
7449   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7450                                                                                                                      *ssdcentralal3supportrot);
7451   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7452   TGeoRotation* ssdconemotherot = new TGeoRotation();
7453   ssdconemotherot->SetAngles(90.,180.,-90.);
7454   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7455                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7456   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7457   fSSDCone->AddNode(ssdconemother,1);
7458   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7459   /////////////////////////////////////////////////////////////
7460   // Deallocating memory
7461   /////////////////////////////////////////////////////////////
7462   delete ssdcentralal3supportrot;
7463   delete ssdcentralal3supportrans[2];
7464   delete ssdconemotherot;
7465   delete ssdconemothertrans;
7466   /////////////////////////////////////////////////////////////
7467  }
7468  ////////////////////////////////////////////////////////////////////////////////
7469  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7470   /////////////////////////////////////////////////////////////
7471   // Setting SSD Cables
7472   /////////////////////////////////////////////////////////////
7473   if (! moth) {
7474     AliError("Can't insert SSD Cables, mother is null!\n");
7475     return;
7476   };
7477   TGeoVolume* ssdcables = SetSSDCables();
7478   moth->AddNode(ssdcables,1);
7479 }
7480  ////////////////////////////////////////////////////////////////////////////////
7481  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7482   /////////////////////////////////////////////////////////////
7483   // Method generating SSDCables
7484   /////////////////////////////////////////////////////////////
7485   // SSD Layer 5 Cables
7486   //////////////////////////////////////////////////////////////////////////////////////////////////
7487   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7488   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7489   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7490   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7491   //////////////////////////////////////////////////////////////////////////////////////////////////
7492   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7493   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7494                                                                             -  fgkSSDLowerPConeRadius)
7495                                                                             * TanD(fgkSSDPConeAngle);
7496   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7497                                                                               + fgkEndCapSupportCenterLay5Position
7498                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7499   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7500                                                                            - ssdcableslay5startconedistance; 
7501   ssdcablelay5rightsidelength *= ssdcablesfactor;
7502   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7503   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7504                                                                                                 ssdcableslay5rightsideradiusmax,
7505                                                                                                 0.5*ssdcablelay5rightsidelength); 
7506   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7507                                                                                                          ssdcablelay5rightubeshape,
7508                                                                                                          fSSDCopper);
7509   ssdcablelay5righttube->SetLineColor(9);
7510   TGeoTranslation* ssdcablelay5rightrans = 
7511                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7512                                                                                  +              fgkEndCapSupportCenterLay5Position
7513                                                                                  +      0.5*ssdcablelay5rightsidelength);
7514   ////////////////////////////////////
7515   //  Double_t cablescapacity[20];
7516   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7517   ////////////////////////////////////
7518   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7519   ////////////////////////////////////
7520   // TGeoPCone Volumes
7521   ///////////////////////////////////
7522   TGeoPcon* ssdcableslay5pconshape[3];
7523   TGeoVolume* ssdcableslay5pcon[3]; 
7524   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7525   Double_t ssdcableslay5pconzsection[6];
7526   Double_t ssdcableslay5pconrmin[6];
7527   Double_t ssdcableslay5pconrmax[6];
7528   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7529   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7530   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7531   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7532   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7533                                                            + fgkEndCapSupportCenterLay5Position
7534                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7535   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7536                                                            + fgkSSDCentralAL3SupportLength
7537                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7538                                                            * TanD(fgkSSDPConeAngle);      
7539   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7540                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7541   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7542                                                            ssdcableslay5pconshape[0],fSSDCopper);
7543   ssdcableslay5pcon[0]->SetLineColor(9);
7544   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7545 ////////////////////////////////////
7546 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7547 ////////////////////////////////////
7548   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7549   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7550                                                            + fgkSSDCentralAL3SupportLength
7551                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7552                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7553   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7554                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7555                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7556   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7557                                                                                    ssdcableangle,2);   
7558   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7559   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7560   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7561                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7562   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7563   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7564   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7565                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7566   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7567   ssdcableslay5pcon[1]->SetLineColor(9);
7568   ////////////////////////////////////
7569   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7570                                                                                    ssdcableangle,2);   
7571   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7572   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7573   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7574   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7575   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7576   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7577                                                            * TanD(fgkSSDPConeAngle)
7578                                                            + 0.5*fgkSSDCentralSupportLength
7579                                                            + fgkSSDCentralAL3SupportLength;
7580   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7581   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7582                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7583   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7584   ssdcableslay5pcon[2]->SetLineColor(9);
7585 ////////////////////////////////////
7586   TGeoRotation* ssdcableslay5pconrot[4];        
7587   for(Int_t i=0; i<4; i++){
7588    ssdcableslay5pconrot[i] = new TGeoRotation();
7589    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7590    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7591    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7592   }
7593   ////////////////////////////////////
7594   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7595   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7596   ////////////////////////////////////
7597   // Positioning Left SSD Cables Part
7598   ////////////////////////////////////
7599   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7600                                                                                                         - 0.5*ssdcablelay5rightsidelength
7601                                                                                                         - fgkEndCapSupportCenterLay5Position
7602                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7603   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7604   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7605   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7606   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7607   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7608   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7609         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7610         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7611     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7612   }
7613   ////////////////////////////////////
7614   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7615   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7616   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7617   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7618   /////////////////////////////////////////////////////////////
7619   // Water Tubes Layer 5
7620   /////////////////////////
7621   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7622                                                                                      ssdcableslay5rightsideradiusmax
7623                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7624                                                                                      0.5*ssdcablelay5rightsidelength); 
7625   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7626                                                                                                          ssdcablelay5rightubewatershape,
7627                                                                                                          fSSDCoolingTubeWater);
7628   ssdcablelay5rightwatertube->SetLineColor(7);
7629   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7630   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7631   ////////////////////////////////////
7632   // TGeoPCone Water Volumes Layer 
7633   ///////////////////////////////////
7634   TGeoPcon* ssdcableslay5pconwatershape[3];
7635   TGeoVolume* ssdcableslay5pconwater[3]; 
7636   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7637   Double_t ssdcableslay5pconwaterzsection[6];
7638   Double_t ssdcableslay5pcwateronrmin[6];
7639   Double_t ssdcableslay5pconwaterrmax[6];
7640   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7641   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7642                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7643   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7644   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7645                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7646   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7647   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7648   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7649                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7650   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7651                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7652   ssdcableslay5pconwater[0]->SetLineColor(7);
7653   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7654   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7655 ////////////////////////////////////
7656   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7657   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7658   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7659                                                                                                 ssdcableangle,2);   
7660   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7661   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7662                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7663   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7664   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7665                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7666   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7667                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7668   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7669                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7670   ssdcableslay5pconwater[1]->SetLineColor(7);
7671 ////////////////////////////////////
7672   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7673                                                                                                 ssdcableangle,2);   
7674   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7675   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7676                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7677   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7678   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7679                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7680   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7681   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7682   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7683                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7684   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7685                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7686   ssdcableslay5pconwater[2]->SetLineColor(7);
7687 ////////////////////////////////////
7688   TGeoRotation* ssdcableslay5pconwaterot[4];    
7689   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7690   for(Int_t i=0; i<4; i++){
7691    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7692    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7693    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7694         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7695         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7696         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7697         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7698         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7699   }
7700   /////////////////////////
7701   // SSD Layer 6 Cables
7702   /////////////////////////
7703   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7704   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7705   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7706   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7707                                                                                                 ssdcableslay6rightsideradiusmax,
7708                                                                                                 0.5*ssdcablelay6rightsidelength); 
7709   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7710                                                                                                          ssdcablelay6rightubeshape,
7711                                                                                                          fSSDCopper);
7712   ssdcablelay6righttube->SetLineColor(9);
7713   TGeoTranslation* ssdcablelay6rightrans = 
7714                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7715                                                                                  +              fgkEndCapSupportCenterLay6Position
7716                                                                                  +      0.5*ssdcablelay6rightsidelength);
7717   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7718                                                                                                         - 0.5*ssdcablelay6rightsidelength
7719                                                                                                         - fgkEndCapSupportCenterLay6Position
7720                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7721   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7722   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7723   ////////////////////////////////////
7724   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7725   ////////////////////////////////////
7726   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7727                                                                                    ssdcableangle,2);   
7728   TGeoVolume* ssdcableslay6pcon;
7729   Double_t ssdcableslay6pconrmin[2];
7730   Double_t ssdcableslay6pconrmax[2];
7731   Double_t ssdcableslay6pconzsection[2];
7732   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7733   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7734   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7735   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7736   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7737                                                            + fgkEndCapSupportCenterLay6Position
7738                                                            + ssdcablelay6rightsidelength;
7739   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7740   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7741                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7742   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7743                                                            ssdcableslay6pconshape,fSSDCopper);
7744   ssdcableslay6pcon->SetLineColor(9);
7745   for(Int_t i=0; i<4; i++){
7746    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7747    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7748   }
7749   ////////////////////////////////////
7750   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7751   /////////////////////////
7752   // Water Tubes Layer 6
7753   /////////////////////////
7754   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7755                                                                                                                   ssdcableslay6rightsideradiusmax
7756                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7757                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7758   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7759                                                                                                          ssdcablelay6righwatertubeshape,
7760                                                                                                          fSSDCoolingTubeWater);
7761   ssdcablelay6rightwatertube->SetLineColor(7);
7762   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7763   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7764   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7765                                                                                    ssdcableangle,2);   
7766   TGeoVolume* ssdcableslay6waterpcon;
7767   Double_t ssdcableslay6waterpconrmin[2];
7768   Double_t ssdcableslay6waterpconrmax[2];
7769   Double_t ssdcableslay6waterpconzsection[2];
7770   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7771   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7772                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7773   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7774   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7775   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7776                                                            + fgkEndCapSupportCenterLay6Position
7777                                                            + ssdcablelay6rightsidelength;
7778   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7779   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7780                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7781   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7782                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7783   ssdcableslay6waterpcon->SetLineColor(7);
7784   TGeoRotation* ssdcableslay6pconwaterot[4];    
7785   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7786   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7787   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7788   for(Int_t i=0; i<4; i++){
7789    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7790    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7791    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7792                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7793    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7794    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7795   }
7796   ////////////////////////////////////////
7797   // From ITS Ring to Patch Panel3-RB26
7798   ////////////////////////////////////////
7799   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7800   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7801   Double_t ssdcablepatchpanel3RB26zsection[2];
7802   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeight+2.8;
7803   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7804                                                                           + fgkSSDCablesLay5RightSideHeight
7805                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7806   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7807   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7808                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7809                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7810   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7811                                                                                  + fgkSSDCentralAL3SupportLength
7812                                                                                  + fgkSSDPConeZLength[0];
7813   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7814   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7815                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7816                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7817   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7818                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7819   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7820                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7821   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7822   TGeoRotation* ssdcablepatchpanel3B26rot[4];
7823   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7824   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7825   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7826                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7827   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7828   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7829                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7830   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7831   ////////////////////////////////////
7832   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7833   ////////////////////////////////////////
7834   //  ITS Ring Cables RB26 Part
7835   ////////////////////////////////////////
7836   Double_t ssdcableitsring3BB26pconzsection[2];
7837   Double_t ssdcableitsring3BB26pconrmin[2];
7838   Double_t ssdcableitsring3BB26pconrmax[2];
7839   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7840                                                                           + fgkSSDCentralAL3SupportLength
7841                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7842   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7843   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7844   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7845                                                                   + fgkSSDCablesLay5RightSideHeight
7846                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7847   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7848   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7849   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7850   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7851                                                                    -              0.5*ssdcableangle,ssdcableangle
7852                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7853                                                                    -                             fgkSSDCableAngle),2);
7854   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7855                                                                    -              0.5*ssdcableangle,ssdcableangle
7856                                                                    +                      3.0*fgkSSDCableAngle
7857                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7858   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7859                                                                    -              0.5*ssdcableangle,ssdcableangle
7860                                                                    -                      fgkSSDCableAngle
7861                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7862   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7863                                                                    -              0.5*ssdcableangle,ssdcableangle
7864                                                                    +                      3.0*fgkSSDCableAngle
7865                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7866   for(Int_t i=0;i<4;i++)
7867         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7868                                                          ssdcableitsring3BB26pconrmin[j],
7869                                                          ssdcableitsring3BB26pconrmax[j]); 
7870   TGeoVolume* ssdcableitsring3BB26pcon[4];
7871   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7872                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7873   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7874                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7875   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7876                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7877   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7878                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7879   for(Int_t i=0;i<4;i++){
7880         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7881         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7882 }
7883   ////////////////////////////////////
7884   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7885   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7886   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7887   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7888   ////////////////////////////////////////
7889   // From ITS Ring to Patch Panel2-RB24
7890   ////////////////////////////////////////
7891   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7892   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7893   Double_t ssdcablepatchpanel3RB24zsection[2];
7894   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7895   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7896   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7897   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7898                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7899                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7900                                                                           + 0.5*fgkSSDPatchPanelHeight;
7901   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7902                                                                          -  fgkSSDCentralAL3SupportLength
7903                                                                          -  fgkSSDPConeZLength[0];
7904   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
7905   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
7906                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7907                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7908   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
7909                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
7910   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
7911                                                                                                 ssdcablepatchpanel3RB24pconshape,
7912                                                                                                 fSSDCopper);
7913   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
7914   TGeoRotation* ssdcablepatchpanel3B24rot[4];
7915   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
7916   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
7917   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
7918                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7919   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
7920   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
7921                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7922   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
7923   ////////////////////////////////////
7924   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
7925   ////////////////////////////////////////
7926   //  ITS Ring Cables RB24 Part
7927   ////////////////////////////////////////
7928   Double_t ssdcableitsring3BB24pconzsection[2];
7929   Double_t ssdcableitsring3BB24pconrmin[2];
7930   Double_t ssdcableitsring3BB24pconrmax[2];
7931   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
7932   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
7933   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7934   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
7935                                                                   + fgkSSDCablesLay5RightSideHeight
7936                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7937   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
7938   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
7939   TGeoPcon* ssdcableitsring3BB24pconshape[4];
7940   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7941                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7942                                                                    -                             fgkSSDCableAngle),2);
7943   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
7944                                                                      ssdcableangle-fgkSSDCableAngle
7945                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7946   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7947                                                                    -                      fgkSSDCableAngle
7948                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
7949   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
7950                                                                                                   ssdcableangle-fgkSSDCableAngle
7951                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7952   for(Int_t i=0;i<4;i++)
7953         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
7954                                                          ssdcableitsring3BB24pconrmin[j],
7955                                                          ssdcableitsring3BB24pconrmax[j]); 
7956   TGeoVolume* ssdcableitsring3BB24pcon[4];
7957   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
7958                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
7959   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
7960                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
7961   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
7962                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
7963   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
7964                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
7965   for(Int_t i=0;i<4;i++){
7966         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
7967         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
7968 }
7969   ////////////////////////////////////
7970   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
7971   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
7972   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
7973   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
7974   ////////////////////////////////////
7975   // Volumes for Material Budget 
7976   ////////////////////////////////////
7977   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
7978                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
7979                                                                                                          ssdcableslay6rightsideradiusmax
7980                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
7981                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
7982   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
7983                                                                                                          ssdcablelay6materialbudgetubeshape,
7984                                                                                                          fSSDCopper);
7985   ssdcablelay6materialbudgetube->SetLineColor(9);
7986   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
7987   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
7988
7989   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
7990                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
7991   TGeoVolume* ssdcablelay6materialbudgetpcon;
7992   Double_t ssdcablelay6materialbudgetpconrmin[2];
7993   Double_t ssdcablelay6materialbudgetpconrmax[2];
7994   Double_t ssdcablelay6materialbudgetpconzsection[2];
7995   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
7996                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7997   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
7998                                                                                 + fgkSSDCableMaterialBudgetHeight;
7999   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8000   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8001   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8002                                                                                         + fgkEndCapSupportCenterLay6Position
8003                                                                                         + ssdcablelay6rightsidelength;
8004   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8005   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8006                                                   ssdcablelay6materialbudgetpconzsection[i],
8007                                                   ssdcablelay6materialbudgetpconrmin[i],
8008                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8009   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8010                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8011   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8012   for(Int_t i=0; i<4; i++){
8013    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8014    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8015   }
8016 ////////////////////////////////////
8017  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8018   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8019   Double_t ssdcablesvolume = 0.0;
8020   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8021   std::cout << ssdcablesvolume << std::endl;*/
8022   return ssdcablesmother;
8023  }
8024  ////////////////////////////////////////////////////////////////////////////////
8025 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3 const * const vertexpos[4] , const Double_t* width, 
8026                                             Double_t height, const char* shapename, Int_t isign) const{
8027   /////////////////////////////////////////////////////////////
8028   // Method generating an Arb shape 
8029   /////////////////////////////////////////////////////////////
8030   const Int_t kvertexnumber = 8;
8031   const Int_t ktransvectnumber = 2;
8032   TVector3 vertex[kvertexnumber];
8033   TVector3 transvector[2];
8034   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
8035   /////////////////////////////////////////////////////////////
8036   //Setting the vertices for TGeoArb8
8037   /////////////////////////////////////////////////////////////
8038   vertex[0] = *vertexpos[0];
8039   vertex[1] = *vertexpos[1];
8040   vertex[2] = vertex[1]; 
8041   vertex[3] = vertex[0]; 
8042   vertex[4] = *vertexpos[2];
8043   vertex[5] = *vertexpos[3];
8044   vertex[6] = vertex[5];
8045   vertex[7] = vertex[4];
8046
8047   // NB: order of points is clockwise
8048   if (isign < 0) {
8049     vertex[2] -= transvector[0];
8050     vertex[3] -= transvector[0];
8051     vertex[6] -= transvector[1];
8052     vertex[7] -= transvector[1];
8053   }
8054   else {
8055     vertex[0] += transvector[0];
8056     vertex[1] += transvector[0];
8057     vertex[4] += transvector[1];
8058     vertex[5] += transvector[1];
8059   }
8060
8061   /////////////////////////////////////////////////////////////
8062   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8063   for(Int_t i = 0; i<kvertexnumber;i++) {
8064     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
8065   }
8066
8067   return arbshape;
8068
8069 ///////////////////////////////////////////////////////////////////////////////
8070 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8071                                                                 Double_t rmax, Int_t nedges, Double_t height){
8072   /////////////////////////////////////////////////////////////
8073   // Method generating Arc shape 
8074   /////////////////////////////////////////////////////////////
8075         const Int_t kvertexnumber = 2*nedges+2;
8076         TGeoXtru* arcshape = new TGeoXtru(2);   
8077         TVector3** vertexposition[2];
8078         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8079         Double_t angle = 0.;
8080     for(Int_t i=0; i<nedges+1; i++){ 
8081                 angle = 90.+0.5*phi-i*(phi/nedges);
8082                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8083                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8084         }
8085         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8086         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8087         for(Int_t i=0; i<kvertexnumber; i++){ 
8088                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8089                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8090                 }
8091                 else if(i>=1&&i<nedges+2)
8092                 {
8093                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8094                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8095                 }
8096         else
8097                 {
8098                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8099                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8100                 }
8101     }
8102   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8103   arcshape->DefineSection(0,-0.5*height);
8104   arcshape->DefineSection(1,0.5*height);
8105   /////////////////////////////////////////////////////////////
8106   // Deallocating memory
8107   /////////////////////////////////////////////////////////////
8108   for(Int_t i=0; i<2; i++){
8109         for(Int_t j=0; j<nedges+1; j++)
8110                 delete vertexposition[i][j];
8111         delete [] vertexposition[i];
8112   }
8113   delete [] xvertexpoints;
8114   delete [] yvertexpoints;
8115   /////////////////////////////////////////////////////////////
8116         return arcshape;
8117 }
8118 ////////////////////////////////////////////////////////////////////////////////
8119 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(const Double_t* radius,const Int_t* edgesnumber,const Double_t* section) const {
8120   ///////////////////////////////////////////////////////////////////////
8121   // Method Generating the Screw Shape  
8122   // radius[0]: outer radius
8123   // radius[1]: inner radius
8124   // edgesnumber[0]: outer number of edges
8125   // edgesnumber[1]: inner number of edges
8126   // section[0]: lower section position
8127   // section[1]: higher section position
8128   ///////////////////////////////////////////////////////////////////////
8129   Double_t outradius = radius[0];
8130   Double_t inradius = radius[1];
8131   Int_t outvertexnumber = edgesnumber[0];
8132   Int_t invertexnumber = edgesnumber[1];
8133   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8134   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8135   for(Int_t i=0; i<outvertexnumber; i++){
8136         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8137         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8138   }
8139   for(Int_t i=0; i<invertexnumber; i++){
8140         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8141         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8142   }
8143   TGeoXtru* screwshapeout = new TGeoXtru(2);
8144   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8145   screwshapeout->DefineSection(0,section[0]);
8146   screwshapeout->DefineSection(1,section[1]);
8147   TGeoXtru* screwshapein = new TGeoXtru(2);
8148   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8149   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8150   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8151   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8152   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8153   
8154   delete [] xscrewvertex;
8155   delete [] yscrewvertex;
8156   return screwshape;
8157 }
8158 ////////////////////////////////////////////////////////////////////////////////
8159 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, const Double_t *section) const {
8160   ///////////////////////////////////////////////////////////////////////
8161   // Method Generating the Hole Shape  
8162   // radius of the Hole
8163   // nedges: number of edges to approximate the circle
8164   ///////////////////////////////////////////////////////////////////////
8165   Double_t* xholevertex = new Double_t[nedges];
8166   Double_t* yholevertex = new Double_t[nedges];
8167   Double_t z  = 0.5*(section[0]+section[1]);
8168   Double_t dz = 0.5*(section[1]-section[0]);
8169   TGeoTranslation *tr = 0;
8170   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8171      tr = new TGeoTranslation(0.,0.,z);
8172      tr->RegisterYourself();
8173   }   
8174   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8175   for(Int_t i=0; i<nedges; i++){
8176         xholevertex[i] = radius*CosD(i*360./nedges);
8177         yholevertex[i] = radius*SinD(i*360./nedges);
8178   }
8179   TGeoXtru* holeshapeout = new TGeoXtru(2);
8180   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8181   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8182   holeshapeout->DefineSection(1,section[1]+0.01);
8183   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8184   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8185   
8186   delete [] xholevertex;
8187   delete [] yholevertex;
8188   return holeshape;
8189 }
8190 ////////////////////////////////////////////////////////////////////////////////
8191 TVector3* AliITSv11GeometrySSD::GetReflection(const TVector3* vector,const Double_t* param) const{
8192   /////////////////////////////////////////////////////////////
8193   // Given an axis specified by param, it gives the reflection of the point
8194   // respect to the axis
8195   /////////////////////////////////////////////////////////////
8196   TVector3* n = new TVector3(param[0],param[1],param[2]);
8197   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8198   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8199   /////////////////////////////////////////////////////////////
8200   // Deallocating memory
8201   /////////////////////////////////////////////////////////////
8202   delete n;
8203   /////////////////////////////////////////////////////////////
8204   return reflectedvector;
8205 }
8206 ////////////////////////////////////////////////////////////////////////////////
8207 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8208                                                        Double_t dx,
8209                                                        Double_t dy,
8210                                                        Double_t dz) const{
8211   /////////////////////////////////////////////////////////////
8212   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8213   /////////////////////////////////////////////////////////////
8214   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8215   const Double_t *vect = hmatrix->GetTranslation();
8216   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8217   hmatrix->SetTranslation(newvect);
8218   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8219   delete hmatrix;
8220   return matrix;
8221 }
8222 ////////////////////////////////////////////////////////////////////////////////
8223 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8224   /////////////////////////////////////////////////////////////
8225   // Method returning the Medium type 
8226   /////////////////////////////////////////////////////////////
8227   char ch[100];
8228   snprintf(ch,100, "ITS_%s",mediumName);
8229   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8230   if (! medium)
8231     AliError(Form("medium %s not found !\n", mediumName));
8232   return medium;
8233 }
8234 ////////////////////////////////////////////////////////////////////////////////
8235 void AliITSv11GeometrySSD::CreateMaterials(){
8236 ///////////////////////////////////
8237 // This part has to be modified
8238 ///////////////////////////////////
8239   ///////////////////////////////////
8240   // Silicon for Sensor
8241   /////////////////////////////////// 
8242   fSSDSensorMedium = GetMedium("SI$");
8243   ///////////////////////////////////
8244   // Silicon Mixture for Sensor
8245   /////////////////////////////////// 
8246   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8247   fSSDChipGlueMedium = GetMedium("EPOXY$");
8248   ///////////////////////////////////
8249   // Stiffener Components Materials
8250   /////////////////////////////////// 
8251   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8252   ///////////////////////////  
8253   // Stiffener Connectors 
8254   ///////////////////////////  
8255   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8256   ////////////////////////////////  
8257   // Stiffener 0603-1812 Capacitor
8258   ////////////////////////////////  
8259   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8260   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8261   fSSDStiffenerCapacitorCapMedium = GetMedium("NiSn$");
8262   ///////////////////////////  
8263   // Stiffener Hybrid Wire 
8264   ///////////////////////////  
8265   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8266   ///////////////////////////  
8267   // Al for Cooling Block
8268   ///////////////////////////  
8269   fSSDAlCoolBlockMedium = GetMedium("AL$");
8270   //////////////////////////////////////////////////////  
8271   // Kapton and Al for Chip Cable Flex and Ladder Cables
8272   //////////////////////////////////////////////////////  
8273   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8274   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8275   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8276   fSSDAlTraceFlexMedium = GetMedium("AL$");
8277   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8278   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8279   /////////////////////////////////////////////////////////////////  
8280   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8281   //////////////////////////////////////////////////////////////////  
8282   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8283   /////////////////////////////////////////////////////////////////  
8284   // G10 for Detector Leg, TubeHolder
8285   //////////////////////////////////////////////////////////////////  
8286   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8287   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8288   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8289   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8290   /////////////////////////////////////////////////////////////////  
8291   // Water and Phynox for Cooling Tube
8292   //////////////////////////////////////////////////////////////////  
8293   fSSDCoolingTubeWater = GetMedium("WATER$");
8294   fSSDCoolingTubePhynox = GetMedium("INOX$");
8295   /////////////////////////////////////////////////////////////////////
8296   // Material for Support Rings
8297   /////////////////////////////////////////////////////////////////////
8298   fSSDSupportRingAl = GetMedium("AL$");
8299   fSSDRohaCellCone = GetMedium("ROHACELL$");
8300   /////////////////////////////////////////////////////////////////////
8301   fSSDAir = GetMedium("SDD AIR$");
8302   fSSDCopper = GetMedium("COPPER$");
8303   fSSDSn = GetMedium("Sn$");
8304   fCreateMaterials = kTRUE;
8305 }
8306 /////////////////////////////////////////////////////////////////////
8307