]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Remowing shadow warnings
[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 "TGeoTube.h"
33 #include "TGeoBBox.h"
34 #include "TGeoXtru.h"
35 #include "TGeoTorus.h"
36 #include "TGeoPgon.h"
37 #include "TGeoPcon.h"
38 #include "TRotation.h"
39 #include "AliITSv11GeometrySSD.h"
40 /////////////////////////////////////////////////////////////////////////////////
41 // Names of the Sensitive Volumes of Layer 5 and Layer 6
42 /////////////////////////////////////////////////////////////////////////////////
43 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
45 /////////////////////////////////////////////////////////////////////////////////
46 //Parameters for SSD Geometry
47 /////////////////////////////////////////////////////////////////////////////////
48 // Variable for Vertical Disalignement of Modules
49 /////////////////////////////////////////////////////////////////////////////////
50 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
51 /////////////////////////////////////////////////////////////////////////////////
52 // Layer5 (lengths are in mm and angles in degrees)
53 /////////////////////////////////////////////////////////////////////////////////
54 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
55 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
56 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
57 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
58 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
59 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
60 /////////////////////////////////////////////////////////////////////////////////
61 // Layer6 (lengths are in mm and angles in degrees)
62 /////////////////////////////////////////////////////////////////////////////////
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
64 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
65 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
66 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
67 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
68 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
69 /////////////////////////////////////////////////////////////////////////////////
70 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
71 /////////////////////////////////////////////////////////////////////////////////
72 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
73 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
74 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
75 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
76 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
77 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
78 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
80 /////////////////////////////////////////////////////////////////////////////////
81 // Stiffener (lengths are in mm and angles in degrees)
82 /////////////////////////////////////////////////////////////////////////////////
83 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
84 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
85 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
86 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
87 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
88 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
89 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
94 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
97                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
98 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
101 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
102                                                                                                           0.25*fgkSSDStiffenerHeight;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
105 /////////////////////////////////////////////////////////////////////////////////
106 // Cooling Block (lengths are in mm and angles in degrees)
107 /////////////////////////////////////////////////////////////////////////////////
108 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
109 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
111                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
112 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
113                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
115                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
117                                                                                                                                          1.500*fgkmm;
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
119                                                                                                                                          0.300*fgkmm;
120 /////////////////////////////////////////////////////////////////////////////////
121 // SSD Sensor (lengths are in mm and angles in degrees)
122 /////////////////////////////////////////////////////////////////////////////////
123 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
124                                                                                                                  "SSDSensorSensitiveVol";
125 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
126 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
127 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
128 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
129                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
130 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
132 /////////////////////////////////////////////////////////////////////////////////
133 // Flex (lengths are in mm and angles in degrees)
134 /////////////////////////////////////////////////////////////////////////////////
135 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
136 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
137                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
138                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
139                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
140                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
141                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
143                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
144 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
145                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
146 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
147 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
149 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
150                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
151 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
152                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
153 /////////////////////////////////////////////////////////////////////////////////
154 // SSD Ladder Cable (lengths are in mm and angles in degrees)
155 /////////////////////////////////////////////////////////////////////////////////
156 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
157 /////////////////////////////////////////////////////////////////////////////////
158 // SSD Module (lengths are in mm and angles in degrees)
159 /////////////////////////////////////////////////////////////////////////////////
160 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
161                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
162 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
163                                                                                                                                         45.600*fgkmm;
164 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
165                                                                                                                                          5.075*fgkmm;
166 /////////////////////////////////////////////////////////////////////////////////
167 // Sensor Support (lengths are in mm and angles in degrees)
168 /////////////////////////////////////////////////////////////////////////////////
169 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
170                                                                                                                                          5.800*fgkmm;
171 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
172                                                                                                                                          2.000*fgkmm;
173 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
174                                                                                                      { 4.620*fgkmm, 5.180*fgkmm};
175 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
176                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
177 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
178                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
179                                                             +  fgkSSDSensorSideSupportThickness[0])
180                                                                 -  fgkSSDSensorSideSupportLength;
181 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
182                                                                                                                                     5.250*fgkmm;
183 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
184                                                                                                                                         1.680*fgkmm;
185 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
186                                                                   = {fgkSSDSensorSideSupportHeight[0]
187                                                                   +  fgkSSDSensorSideSupportThickness[0],
188                                                                          fgkSSDSensorSideSupportHeight[1]
189                                                                   +  fgkSSDSensorSideSupportThickness[1]};
190 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
191                                                                   =  {fgkSSDSensorSideSupportThickness[0],
192                                                                           fgkSSDSensorSideSupportThickness[1]};
193 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
194                                                                                                                                    19.000*fgkmm;
195 /////////////////////////////////////////////////////////////////////////////////
196 // Chip Cables (lengths are in mm and angles in degrees)
197 /////////////////////////////////////////////////////////////////////////////////
198 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
199                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
200 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
201                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
202                                                                   -  (fgkSSDSensorSideSupportHeight[1]
203                                                                   -   fgkSSDSensorSideSupportHeight[0])
204                                                                   -   fgkSSDCoolingBlockHoleCenter
205                                                                   -   fgkSSDStiffenerHeight
206                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
207                                                                           fgkSSDModuleCoolingBlockToSensor
208                                                                   -   fgkSSDCoolingBlockHoleCenter
209                                                                   -       fgkSSDStiffenerHeight
210                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
211 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
212                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
213 /////////////////////////////////////////////////////////////////////////////////
214 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
215 /////////////////////////////////////////////////////////////////////////////////
216 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
217                                                                                                                                         3.820*fgkmm;
218 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
219 //                                                                                                                                         3.780;
220 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
221                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
222 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
223                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
224 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
225                                                                                                                                 { 30.00, 90.00};
226 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
227                                                                                                                                          1.78*fgkmm;
228 /////////////////////////////////////////////////////////////////////////////////
229 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
230 /////////////////////////////////////////////////////////////////////////////////
231 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
232                                                                    = fgkSSDModuleSensorSupportDistance
233                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
235 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
236                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
237 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
238                                                                                                                                         1.630*fgkmm;
239 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
240 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
241                                                                         = fgkCarbonFiberTriangleLength
242                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
243                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
244                                                                         * TMath::DegToRad());
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
246                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
247                                                                         - fgkCarbonFiberSupportWidth)
248                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
249                                                                         - fgkCarbonFiberSupportWidth;
250 /////////////////////////////////////////////////////////////////////////////////
251 // Carbon Fiber Lower Support Parameters (lengths are in mm)
252 /////////////////////////////////////////////////////////////////////////////////
253 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
254                                                                                                                                           =  0.950*fgkmm;
255 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
256                                                                                                                                           =  1.600*fgkmm;
257 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
258                                                                                                                                           =  0.830*fgkmm;
259 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
260                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
261 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
262                                                                         = fgkCarbonFiberJunctionWidth
263                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
264                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
266                                                                         = {fgkCarbonFiberLowerSupportWidth
267                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
268                                                                            fgkCarbonFiberLowerSupportWidth
269                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
270                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
271 /////////////////////////////////////////////////////////////////////////////////
272 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
273 /////////////////////////////////////////////////////////////////////////////////
274 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
275                                                            {0.5 * (fgkSSDLay5LadderLength
276                                                                         -  fgkSSDLay5SensorsNumber
277                                                                         *  fgkCarbonFiberJunctionWidth
278                                                                         -  fgkCarbonFiberLowerSupportWidth),
279                                                                 0.5 * (fgkSSDLay5LadderLength
280                                                                         -  fgkSSDLay5SensorsNumber
281                                                                         *  fgkCarbonFiberJunctionWidth
282                                                                         +  fgkCarbonFiberLowerSupportWidth)};
283 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
284                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
285                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
286 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
287                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
288                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
289 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
290                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
291 /////////////////////////////////////////////////////////////////////////////////
292 // Cooling Tube Support (lengths are in mm and angles in degrees)
293 /////////////////////////////////////////////////////////////////////////////////
294 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
295 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
296                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
297 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
298 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
299 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
300 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
301                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
302 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
303                                                                                                                                           11.70*fgkmm;
304 /////////////////////////////////////////////////////////////////////////////////
305 // Cooling Tube (lengths are in mm and angles in degrees)
306 /////////////////////////////////////////////////////////////////////////////////
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
310                                                                                                         fgkCarbonFiberJunctionWidth;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
312                                                                          fgkSSDModuleSensorSupportDistance
313                                                                   +      fgkSSDCoolingBlockLength;
314 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
315 /////////////////////////////////////////////////////////////////////////////////
316 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
317 /////////////////////////////////////////////////////////////////////////////////
318 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
319                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
320 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
321                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
322 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
323                                                                                                                                           20.0*fgkmm;
324 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
325                                                                                                                                                     40.0;
326 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
327                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
328 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
329                                                                                                                                           2.5*fgkmm;
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
331                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
333                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
335                                                                                                                                           1.0*fgkmm;
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
337                                                                                                                                           6.0*fgkmm;
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
339                                                                                                                                           4.0*fgkmm;
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
341                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
342 /////////////////////////////////////////////////////////////////////////////////
343 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
344 /////////////////////////////////////////////////////////////////////////////////
345 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
346 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
347 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
350 /////////////////////////////////////////////////////////////////////////////////
351 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
352 /////////////////////////////////////////////////////////////////////////////////
353 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
356                                                                                                   -  fgkSSDMountingBlockHeight[1]
357                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
358                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
359                                                                                                   +  fgkSSDModuleVerticalDisalignment
360                                                                                                   -      fgkMountingBlockSupportDownHeight,
361                                                                                                          fgkSSDLay6RadiusMin
362                                                                                                   -  fgkSSDMountingBlockHeight[1]
363                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
364                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
365                                                                                                   +  fgkSSDModuleVerticalDisalignment
366                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
368                                                                                                     -  fgkSSDMountingBlockHeight[1]
369                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
370                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
371                                                                                                         +  fgkSSDModuleVerticalDisalignment
372                                                                                                         -  fgkMountingBlockSupportRadius[0],
373                                                                                                            fgkSSDLay6RadiusMax
374                                                                                                     -  fgkSSDMountingBlockHeight[1]
375                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
376                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
377                                                                                                         +  fgkSSDModuleVerticalDisalignment
378                                                                                                         -  fgkMountingBlockSupportRadius[1]};
379 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
380 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
381 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
382 /////////////////////////////////////////////////////////////////////////////////
383 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
384 /////////////////////////////////////////////////////////////////////////////////
385 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
386 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
387 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
388 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
389                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
390 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
391                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
392 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
393                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
400 /////////////////////////////////////////////////////////////////////////////////
401 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
402 /////////////////////////////////////////////////////////////////////////////////
403 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
404 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
405 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
406 /////////////////////////////////////////////////////////////////////////////////
407 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
408 /////////////////////////////////////////////////////////////////////////////////
409 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
410                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
411 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
412 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
413 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
414                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
415 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
416                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
418 /////////////////////////////////////////////////////////////////////////////////
419 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
420 /////////////////////////////////////////////////////////////////////////////////
421 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
422                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
423 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
424                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
425                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
426 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
427 /////////////////////////////////////////////////////////////////////////////////
428 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
429 /////////////////////////////////////////////////////////////////////////////////
430 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
431                                                                                                            {62.0*fgkmm,21.87*fgkmm};
432 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
433                                                                                                             {47.1*fgkmm,0.35*fgkmm};
434 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
435                                                                                                                                           1.0*fgkmm;
436 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
437 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
438                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
440                                                                                                                                          0.15*fgkmm;
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
442                                                                                                                                          19.0*fgkmm;
443 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
444                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
446                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
448                                                                                                                                           2.1*fgkmm;
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
450                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
452                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
454                                                                                                                                            19*fgkmm; 
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
456                                                                                                                                           1.0*fgkmm;
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
458                                                                                                                                           3.6*fgkmm;
459 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
460                                                                                                                                          61.0*fgkmm; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
462                                                                                                                                          5.97*fgkmm; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
464 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
465                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
466                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
467 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
468                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
469 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
470                                                                                                                                           1.0*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
472                                                                                                                                    = 0.15*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
474                                                                                                                                          20.0*fgkmm;
475 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
476 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
477 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
478 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
479 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
480 /////////////////////////////////////////////////////////////////////////////////
481 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
482 /////////////////////////////////////////////////////////////////////////////////
483 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
484 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
485 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
486 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
488 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
489 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
490 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
492 /////////////////////////////////////////////////////////////////////////////////
493 // SSD Cone Parameters (lengths are in mm and angles in degrees)
494 /////////////////////////////////////////////////////////////////////////////////
495 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
497 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
498 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
500 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
501 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
502 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
503 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
514 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
517 /////////////////////////////////////////////////////////////////////////////////
518 // SSD Cables Parameters (lengths are in mm and angles in degrees)
519 /////////////////////////////////////////////////////////////////////////////////
520 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
523 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
524 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
526 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
527 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
528 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
529 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
532 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
533 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
534 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
535 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
536 /////////////////////////////////////////////////////////////////////////////////
537 ClassImp(AliITSv11GeometrySSD)
538 /////////////////////////////////////////////////////////////////////////////////
539 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
540   AliITSv11Geometry(),
541   fSSDChipMedium(),
542   fSSDChipGlueMedium(),
543   fSSDStiffenerMedium(),
544   fSSDStiffenerConnectorMedium(),
545   fSSDStiffener0603CapacitorMedium(),
546   fSSDStiffener1812CapacitorMedium(),
547   fSSDStiffenerHybridWireMedium(),
548   fSSDKaptonFlexMedium(),
549   fSSDAlTraceFlexMedium(),
550   fSSDAlTraceLadderCableMedium(),
551   fSSDKaptonLadderCableMedium(),
552   fSSDKaptonChipCableMedium(),
553   fSSDAlTraceChipCableMedium(),
554   fSSDAlCoolBlockMedium(),
555   fSSDSensorMedium(),
556   fSSDSensorSupportMedium(),
557   fSSDCarbonFiberMedium(),
558   fSSDTubeHolderMedium(),
559   fSSDCoolingTubeWater(),
560   fSSDCoolingTubePhynox(),
561   fSSDSupportRingAl(),
562   fSSDMountingBlockMedium(),
563   fSSDRohaCellCone(),
564   fSSDAir(),
565   fSSDCopper(),
566   fCreateMaterials(kFALSE),
567   fTransformationMatrices(kFALSE),
568   fBasicObjects(kFALSE),
569   fcarbonfiberjunction(),
570   fcoolingtubesupport(),
571   fhybridmatrix(),
572   fssdcoolingblocksystem(),
573   fcoolingblocksystematrix(),
574   fssdstiffenerflex(),
575   fssdendflex(),
576   fendladdercoolingtubesupportmatrix(),
577   fendladdermountingblock(),
578   fendladdermountingblockclip(),
579   fSSDSensor5(),
580   fSSDSensor6(),
581   fSSDLayer5(), 
582   fSSDLayer6(),
583   fMotherVol(),
584   fLay5LadderSupportRing(),
585   fLay6LadderSupportRing(),
586   fgkEndCapSupportSystem(),
587   fSSDCone(),
588   fColorCarbonFiber(4),
589   fColorRyton(5),
590   fColorPhynox(14),
591   fColorSilicon(3),
592   fColorAl(38),
593   fColorKapton(6),
594   fColorPolyhamide(5),
595   fColorStiffener(9),
596   fColorEpoxy(30),
597   fColorWater(7),
598   fColorG10(41)
599 {
600   ////////////////////////
601   // Standard constructor
602   ////////////////////////
603 }
604 /////////////////////////////////////////////////////////////////////////////////
605 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
606   AliITSv11Geometry(s.GetDebug()),
607   fSSDChipMedium(s.fSSDChipMedium),
608   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
609   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
610   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
611   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
612   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
613   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
614   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
615   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
616   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
617   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
618   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
619   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
620   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
621   fSSDSensorMedium(s.fSSDSensorMedium),
622   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
623   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
624   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
625   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
626   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
627   fSSDSupportRingAl(s.fSSDSupportRingAl),
628   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
629   fSSDRohaCellCone(s.fSSDRohaCellCone),
630   fSSDAir(s.fSSDAir),
631   fSSDCopper(s.fSSDCopper),
632   fCreateMaterials(s.fCreateMaterials),
633   fTransformationMatrices(s.fTransformationMatrices),
634   fBasicObjects(s.fBasicObjects),
635   fcarbonfiberjunction(s.fcarbonfiberjunction),
636   fcoolingtubesupport(s.fcoolingtubesupport),
637   fhybridmatrix(s.fhybridmatrix),
638   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
639   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
640   fssdstiffenerflex(s.fssdstiffenerflex),
641   fssdendflex(s.fssdendflex),
642   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
643   fendladdermountingblock(s.fendladdermountingblock),
644   fendladdermountingblockclip(s.fendladdermountingblockclip),
645   fSSDSensor5(s.fSSDSensor5),
646   fSSDSensor6(s.fSSDSensor6),
647   fSSDLayer5(s.fSSDLayer5),     
648   fSSDLayer6(s.fSSDLayer6),
649   fMotherVol(s.fMotherVol),
650   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
651   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
652   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
653   fSSDCone(s.fSSDCone),
654   fColorCarbonFiber(s.fColorCarbonFiber),
655   fColorRyton(s.fColorRyton),
656   fColorPhynox(s.fColorPhynox),
657   fColorSilicon(s.fColorSilicon),
658   fColorAl(s.fColorAl),
659   fColorKapton(s.fColorKapton),
660   fColorPolyhamide(s.fColorPolyhamide),
661   fColorStiffener(s.fColorStiffener),
662   fColorEpoxy(s.fColorEpoxy),
663   fColorWater(s.fColorWater),
664   fColorG10(s.fColorG10)
665 {
666   ////////////////////////
667   // Copy Constructor
668   ////////////////////////
669 }
670 /////////////////////////////////////////////////////////////////////////////////
671 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
672 operator=(const AliITSv11GeometrySSD &s){
673   ////////////////////////
674   // Assignment operator
675   ////////////////////////
676   this->~AliITSv11GeometrySSD();
677   new(this) AliITSv11GeometrySSD(s); 
678   return *this;
679 /*      
680   if(&s == this) return *this;
681   fMotherVol = s.fMotherVol;
682   return *this;
683  */
684 }
685 ///////////////////////////////////////////////////////////////////////////////
686 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
687   ///////////////////////////////////////////////////////////////////////  
688   // Method generating the trasformation matrix for the whole SSD Geometry   
689   ///////////////////////////////////////////////////////////////////////  
690   // Setting some variables for Carbon Fiber Supportmatrix creation
691   //////////////////////////////////////////////////////////////////////
692   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
693                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
694   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
695                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
696                                                                  +      fgkCarbonFiberSupportWidth);
697   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
698                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
699   TGeoRotation* carbonfiberot[3];
700   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
701   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
702   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
703   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
704   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
705                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
706                                                   -  fgkCarbonFiberTriangleLength
707                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
708   ///////////////////////////////////////////
709   //Setting Local Translations and Rotations: 
710   ///////////////////////////////////////////
711   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
712   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
713                                                                          0.5*carbonfibersupportheight,NULL);    
714   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
715                                                                          2.*symmetryplaneposition+transvector[1],
716                                                                          transvector[2], carbonfiberot[2]);
717   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
718   /////////////////////////////////////////////////////////////
719   // Carbon Fiber Support Transformations
720   /////////////////////////////////////////////////////////////
721   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
722   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
723                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
724                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
725                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
726   }             
727   /////////////////////////////////////////////////////////////
728   // Carbon Fiber Junction Transformation
729   /////////////////////////////////////////////////////////////
730   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
731   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
732   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
733   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
734   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
735         localcarbonfiberjunctionmatrix[i] = 
736                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
737         localcarbonfiberjunctionrot[i] = 
738                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
739         localcarbonfiberjunctiontrans[i] = 
740                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
741   }
742   ///////////////////////
743   // Setting Translations
744   ///////////////////////
745   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
746   localcarbonfiberjunctiontrans[1][0] = 
747                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
748   localcarbonfiberjunctiontrans[2][0] = 
749                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
750                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
751                                  fgkCarbonFiberTriangleLength
752                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
753   localcarbonfiberjunctiontrans[0][1] = 
754                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
755   localcarbonfiberjunctiontrans[1][1] = 
756                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
757   localcarbonfiberjunctiontrans[2][1] = 
758                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
759   ////////////////////
760   // Setting Rotations
761   ////////////////////
762   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
763                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
764                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
765   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
766         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
767   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
768   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
769   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
770   ////////////////////////////////////////
771   // Setting Carbon Fiber Junction matrix 
772   ////////////////////////////////////////
773   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
774                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
775                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
776                         localcarbonfiberjunctionmatrix[i][j] = 
777                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
778                                                            *localcarbonfiberjunctionrot[i][j]);
779                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
780          }
781   }
782   /////////////////////////////////////////////////////////////
783   // Carbon Fiber Lower Support Transformations
784   /////////////////////////////////////////////////////////////
785   TGeoTranslation* localcarbonfiberlowersupportrans[2];
786   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
787                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
788                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
789                                                                          0.0);
790   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
791                                                                          fgkCarbonFiberJunctionWidth
792                                                                 -    fgkCarbonFiberLowerSupportWidth
793                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
794                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
795                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
796    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
797    fcarbonfiberlowersupportrans[0] = 
798                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
799    fcarbonfiberlowersupportrans[1] = 
800                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
801   /////////////////////////////////////////////////////////////
802   // SSD Sensor Support Transformations
803   /////////////////////////////////////////////////////////////
804   const Int_t kssdsensorsupportmatrixnumber = 3;
805   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
806   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
807   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
808   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
809         localssdsensorsupportmatrix[i] = 
810                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
811         localssdsensorsupportrot[i] = 
812                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
813         localssdsensorsupportrans[i] = 
814                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
815   }
816   ///////////////////////
817   // Setting Translations
818   ///////////////////////
819   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
820                                                                           0.5*fgkSSDSensorSideSupportWidth,
821                                                                           0.0);
822   localssdsensorsupportrans[1][0] = 
823                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
824   localssdsensorsupportrans[2][0] = 
825                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
826   localssdsensorsupportrans[0][1] = 
827                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
828                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
829                                                                                 0.0);
830   localssdsensorsupportrans[1][1] = 
831                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
832                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
833                                                                     -   fgkSSDModuleSensorSupportDistance,
834                                                                                 0.0);
835   localssdsensorsupportrans[2][1] = 
836                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
837                                                                         -    fgkSSDSensorCenterSupportPosition,
838                                                                                  0.5*fgkSSDSensorCenterSupportWidth
839                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
840                                                                                  fgkSSDSensorCenterSupportThickness[0]);
841   localssdsensorsupportrans[0][2] = 
842                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
843                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
844                                                                                  fgkCarbonFiberJunctionWidth
845                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
846                                                                         +    fgkSSDSensorCenterSupportLength
847                                                                         -    fgkSSDSensorCenterSupportThickness[0])
848                                                                         -    fgkSSDSensorCenterSupportPosition,
849                                                                              0.0);
850   localssdsensorsupportrans[1][2] = 
851                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
852   localssdsensorsupportrans[2][2] = 
853                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
854   ////////////////////
855   // Setting Rotations
856   ////////////////////
857   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
858                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
859                         localssdsensorsupportrot[i][j] = new TGeoRotation();
860   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
861         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
862         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
863   }
864   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
865   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
866   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
867   ////////////////////////////////////////
868   // SSD Sensor Support matrix 
869   ////////////////////////////////////////
870   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
871                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
872                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
873                         localssdsensorsupportmatrix[i][j] = 
874                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
875                                                            *localssdsensorsupportrot[i][j]);
876                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
877          }
878   }
879   /////////////////////////////////////////////////////////////
880   // SSD Cooling Tube Support Transformations
881   /////////////////////////////////////////////////////////////
882   const Int_t kcoolingtubesupportmatrixnumber = 2;
883   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
884   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
885   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
886   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
887                                                                                                         /fgkCoolingTubeSupportRmax);
888   localcoolingtubesupportrans[0] = 
889                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
890                                                 +  2.*(fgkCoolingTubeSupportLength
891                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
892                                                 +  fgkCarbonFiberTriangleLength
893                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
894   localcoolingtubesupportrans[1] = 
895                         new TGeoTranslation(fgkCarbonFiberJunctionLength
896                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
897                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
898                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
899                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
900                     -  0.5*(fgkCarbonFiberLowerSupportWidth
901                                         +          fgkSSDSensorCenterSupportLength
902                     -      fgkSSDSensorCenterSupportThickness[0])
903                                         +  0.5*fgkSSDSensorLength,
904                                         -  0.5*fgkCoolingTubeSupportHeight);  
905   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
906   localcoolingtubesupportrot[i] = new TGeoRotation();
907   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
908   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
909   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
910         localcoolingtubesupportmatrix[i] = 
911                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
912                                                    *localcoolingtubesupportrot[i]);
913   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
914   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
915                                                                 (*localcoolingtubesupportmatrix[0]));
916   /////////////////////////////////////////////////////////////
917   // End Ladder SSD Cooling Tube Support Transformations
918   /////////////////////////////////////////////////////////////
919   TGeoTranslation** localendladdercooltubetrans[2];
920   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
921   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
922   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
923   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
924                                                                                         -          (fgkCoolingTubeSupportLength
925                                                                                         -               fgkCoolingTubeSupportRmax),
926                                                                                                         fgkEndLadderMountingBlockPosition[0]
927                                                                                         -               fgkendladdercoolingsupportdistance[0]
928                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
929                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
930   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
931                                                                                         -          (fgkCoolingTubeSupportLength
932                                                                                         -               fgkCoolingTubeSupportRmax),
933                                                                                                         fgkEndLadderMountingBlockPosition[0]
934                                                                                         +               fgkendladdercoolingsupportdistance[1]
935                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
936                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
937   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
938                                                                                         -       fgkCoolingTubeSupportRmax)
939                                                                                         +               fgkCarbonFiberTriangleLength
940                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
941                                                                                                 0.0,
942                                                                                                 0.0);
943   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
944                                                                                                         fgkendladdercoolingsupportdistance[0]
945                                                                                         +               fgkendladdercoolingsupportdistance[1],
946                                                                                                         0.0);
947   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
948   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
949                                                                                         +               fgkCarbonFiberJunctionLength
950                                                                                         -               fgkCoolingTubeSupportLength,
951                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
952                                                                                         -       0.5*fgkCoolingTubeSupportWidth
953                                                                                                    -fgkendladdercoolingsupportdistance[2],
954                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
955   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
956                                                                                         +               fgkCoolingTubeSupportLength
957                                                                                         -               fgkCoolingTubeSupportRmax
958                                                                                         -               fgkCarbonFiberJunctionLength,
959                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
960                                                                                         -       0.5*fgkCoolingTubeSupportWidth
961                                                                                         -               fgkendladdercoolingsupportdistance[2],
962                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
963   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
964   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
965   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
966   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
967   (*localcoolingtubesupportrot[1]));
968   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
969   (*localcoolingtubesupportrot[1]));
970   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
971   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
972   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
973   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
974   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
975
976   fendladdercoolingtubesupportmatrix[1][0] =    
977                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
978                                                                                    *(*localcoolingtubesupportrot[1]));
979   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
980   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
981   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
982   /////////////////////////////////////////////////////////////
983   // SSD Cooling Tube Transformations
984   /////////////////////////////////////////////////////////////
985   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
986   localcoolingtuberot->SetAngles(0.,90.,0.);
987   TGeoTranslation** localcoolingtubetrans[4];
988   TVector3** localcoolingtubevect[4];
989   for(Int_t i=0; i<4; i++){
990         localcoolingtubevect[i] = new TVector3*[2];
991         localcoolingtubetrans[i] = new TGeoTranslation*[2];
992         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
993   }
994   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
995                                                   -fgkCarbonFiberTriangleLength),
996                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
997                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
998                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
999                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1000                                                   +      fgkSSDSensorCenterSupportLength
1001                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1002                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1003                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1004                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1005                                                   -  0.5*fgkCoolingTubeSupportWidth,
1006                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1007   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1008                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1009                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1010                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1011                                                   +  fgkCoolingTubeSupportWidth,
1012                                                   localcoolingtubevect[0][0]->Z());     
1013   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1014                                                          +                               fgkCarbonFiberTriangleLength,
1015                                                                                          localcoolingtubevect[0][0]->Y(),
1016                                                                                          localcoolingtubevect[0][0]->Z());
1017   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1018                                                          +                               fgkCarbonFiberTriangleLength,
1019                                                                                          localcoolingtubevect[0][1]->Y(),
1020                                                                                          localcoolingtubevect[0][1]->Z());
1021   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1022                                                   -     fgkCarbonFiberTriangleLength),
1023                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1024                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1025                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1026                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1027                                                   +      fgkSSDSensorCenterSupportLength
1028                                                   -      fgkSSDSensorCenterSupportThickness[0])
1029                                                   +  fgkSSDModuleStiffenerPosition[1]
1030                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1031                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1032   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1033                                                          +                               fgkCarbonFiberTriangleLength,
1034                                                                                          localcoolingtubevect[2][0]->Y(),
1035                                                                                          localcoolingtubevect[2][0]->Z());      
1036   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1037                                                   -     fgkCarbonFiberTriangleLength),
1038                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1039                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1040                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1041                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1042                                                   +      fgkSSDSensorCenterSupportLength
1043                                                   -      fgkSSDSensorCenterSupportThickness[0])
1044                                                   +      fgkSSDSensorLength
1045                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1046                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1047   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1048                                                   + fgkCarbonFiberTriangleLength,
1049                                                         localcoolingtubevect[3][0]->Y(),
1050                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1051   for(Int_t i=0; i<4; i++) 
1052         for(Int_t j=0; j<2; j++){
1053                 localcoolingtubetrans[i][j] = 
1054                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1055                                                                 localcoolingtubevect[i][j]->Y(),
1056                                                                 localcoolingtubevect[i][j]->Z());
1057                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1058                                                           *                                     (*localcoolingtuberot));
1059         }
1060   /////////////////////////////////////////////////////////////
1061   // SSD End Ladder Cooling Tube Transformations
1062   /////////////////////////////////////////////////////////////
1063   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1064   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1065   TGeoTranslation** localendlladdercoolingtubetrans[2];
1066   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1067   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1068   for(Int_t i=0; i<2; i++)      
1069         for(Int_t j=0; j<(i==0?6:4); j++)       
1070                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1071   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1072                                                                         -        fgkCoolingTubeSupportRmax)
1073                                                                         +        fgkCarbonFiberJunctionLength,
1074                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1075                                                                         -    fgkendladdercoolingsupportdistance[0]),
1076                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1077   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1078                                                                         -        fgkCoolingTubeSupportRmax)
1079                                                                         -        fgkCarbonFiberJunctionLength
1080                                                                         +    fgkCarbonFiberTriangleLength,
1081                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1082                                                                         -    fgkendladdercoolingsupportdistance[0]),
1083                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1084   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1085                                                                         -   fgkCoolingTubeSupportRmax)
1086                                                                         +       fgkCarbonFiberJunctionLength,
1087                                                                            fgkEndLadderMountingBlockPosition[0]
1088                                                                         -   fgkendladdercoolingsupportdistance[0]
1089                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1090                                                   +                             fgkendladdercoolingsupportdistance[1]
1091                                                   +                             fgkCoolingTubeSupportWidth),
1092                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1093   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1094                                                                         -        fgkCoolingTubeSupportRmax)
1095                                                                         -        fgkCarbonFiberJunctionLength
1096                                                                         +    fgkCarbonFiberTriangleLength,
1097                                                                            fgkEndLadderMountingBlockPosition[0]
1098                                                                         -   fgkendladdercoolingsupportdistance[0]
1099                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1100                                                   +                             fgkendladdercoolingsupportdistance[1]
1101                                                   +                             fgkCoolingTubeSupportWidth),
1102                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1103   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1104                                                                         -   fgkCoolingTubeSupportRmax)
1105                                                                         +       fgkCarbonFiberJunctionLength,
1106                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1107                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1108                                                   -                     fgkEndLadderMountingBlockPosition[0]
1109                                                   -                     fgkendladdercoolingsupportdistance[1]           
1110                                                   -                     fgkCoolingTubeSupportWidth),
1111                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1112   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1113                                                                         -        fgkCoolingTubeSupportRmax)
1114                                                                         -        fgkCarbonFiberJunctionLength
1115                                                                         +    fgkCarbonFiberTriangleLength,
1116                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1117                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1118                                                   -                     fgkEndLadderMountingBlockPosition[0]
1119                                                   -                     fgkendladdercoolingsupportdistance[1]           
1120                                                   -                     fgkCoolingTubeSupportWidth),
1121                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1122   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1123                                                                         -   fgkCoolingTubeSupportRmax)
1124                                                                         +       fgkCarbonFiberJunctionLength,
1125                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1126                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1127                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1128                                                         +                 fgkSSDSensorOverlap
1129                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1130                                                         -                 fgkendladdercoolingsupportdistance[2]
1131                                                         -                 fgkEndLadderMountingBlockPosition[1]
1132                                                         -                 fgkCoolingTubeSupportWidth)
1133                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1134                                                         -                 fgkendladdercoolingsupportdistance[2]
1135                                                         -                 fgkCoolingTubeSupportWidth,
1136                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1137   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1138                                                   -      fgkCoolingTubeSupportRmax)
1139                                                   -      fgkCarbonFiberJunctionLength
1140                                                   +    fgkCarbonFiberTriangleLength,
1141                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1142                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1143                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1144                                                         +                 fgkSSDSensorOverlap
1145                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1146                                                         -                 fgkendladdercoolingsupportdistance[2]
1147                                                         -                 fgkEndLadderMountingBlockPosition[1]
1148                                                         -                 fgkCoolingTubeSupportWidth)
1149                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1150                                                         -                 fgkendladdercoolingsupportdistance[2]
1151                                                         -                 fgkCoolingTubeSupportWidth,
1152                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1153   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1154                                                                         -   fgkCoolingTubeSupportRmax)
1155                                                                         +       fgkCarbonFiberJunctionLength,
1156                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1157                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1158                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1159   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1160                                                                         -        fgkCoolingTubeSupportRmax)
1161                                                                         -        fgkCarbonFiberJunctionLength
1162                                                                         +    fgkCarbonFiberTriangleLength,
1163                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1164                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1165                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1166   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1167   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1168   for(Int_t i=0; i<2; i++)
1169         for(Int_t j=0; j<(i==0?6:4); j++){
1170                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1171                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1172         }
1173   /////////////////////////////////////////////////////////////
1174   // SSD Hybrid Components Transformations
1175   /////////////////////////////////////////////////////////////
1176   const Int_t khybridmatrixnumber = 3;
1177   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1178   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1179                                             0.5*fgkSSDStiffenerWidth,
1180                                             0.5*fgkSSDStiffenerHeight);
1181   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1182                                             fgkSSDModuleStiffenerPosition[1],0.0);
1183
1184   localhybridtrans[2] = new TGeoTranslation(
1185                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1186                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1187                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1188                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1189                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1190                       -       fgkSSDSensorCenterSupportThickness[0]),
1191                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1192                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight)); 
1193   fhybridmatrix = new TGeoHMatrix();
1194   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1195   /////////////////////////////////////////////////////////////
1196   // SSD Cooling Block Transformations
1197   /////////////////////////////////////////////////////////////
1198   const Int_t kcoolingblockmatrixnumber = 4;    
1199   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1200   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1201                             -  fgkCoolingTubeSupportRmin),0.0,
1202                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1203   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1204                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1205                                0.0,fgkSSDStiffenerHeight);
1206   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1207   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1208   fcoolingblocksystematrix = new TGeoHMatrix();
1209   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1210       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1211   /////////////////////////////////////////////////////////////
1212   // SSD Stiffener Flex Transformations
1213   /////////////////////////////////////////////////////////////
1214   const Int_t klocalflexmatrixnumber = 4;
1215   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1216   for(Int_t i=0; i<fgkflexnumber; i++)    
1217       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1218   for(Int_t i=0; i<fgkflexnumber; i++)
1219       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1220             localflexmatrix[i][j] = new TGeoCombiTrans();
1221   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1222                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1223                                                                   -    fgkSSDStiffenerWidth;
1224   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1225                                         +0.5*fgkSSDStiffenerLength,
1226                                          0.5*fgkSSDStiffenerWidth,
1227                                         -0.5*fgkSSDStiffenerHeight
1228                                         -0.5*fgkSSDFlexHeight[0]);
1229   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1230                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1231                                         -0.5*fgkSSDStiffenerWidth,
1232                                         -0.5*fgkSSDStiffenerHeight
1233                                         -0.5*fgkSSDFlexHeight[0]);
1234   TGeoRotation* localflexrot = new TGeoRotation();
1235   localflexrot->SetAngles(180.,0.,0.);    
1236   localflexmatrix[1][0]->SetRotation(localflexrot);
1237   for(Int_t i=0; i<fgkflexnumber; i++)
1238       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1239             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1240   for(Int_t i=0; i<fgkflexnumber; i++){
1241       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1242       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1243             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1244   }
1245   /////////////////////////////////////////////////////////////
1246   // SSD End Flex Transformations
1247   /////////////////////////////////////////////////////////////
1248   TGeoRotation* localendflexrot = new TGeoRotation();
1249   localendflexrot->SetAngles(0.0,90.0,0.0);
1250   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1251   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1252                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1253   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1254                             * TMath::DegToRad()*ssdflexradiusmax
1255                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1256                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
1257   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1258                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1259                             +      fgkSSDFlexLength[2];
1260   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1261                               0.5*fgkSSDFlexWidth[0],
1262                               2.*fgkSSDStiffenerHeight
1263                             + 0.5*fgkSSDFlexHeight[0]);      
1264   localendflexmatrix->SetRotation(localendflexrot);
1265   for(Int_t i=0; i<fgkflexnumber; i++) 
1266       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1267   /////////////////////////////////////////////////////////////
1268   // End Ladder Carbon Fiber Junction
1269   /////////////////////////////////////////////////////////////
1270   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1271   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1272   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1273   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1274       localendladdercarbonfiberjunctionmatrix[i] 
1275             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1276       localendladdercarbonfiberjunctionrot[i] 
1277             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1278       localendladdercarbonfiberjunctiontrans[i] 
1279             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1280       fendladdercarbonfiberjunctionmatrix[i]
1281             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1282   }
1283   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1284       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1285             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1286             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1287       }
1288   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1289       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1290           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1291   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1292       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1293                               0.0,0.0);
1294       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1295                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1296                 *                     SinD(fgkCarbonFiberTriangleAngle),
1297                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1298   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1299   }
1300   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1301   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1302   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1303   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1304       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1305       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1306       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1307       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1308             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1309       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1310             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1311                                *localendladdercarbonfiberjunctionglobalrot[i]);
1312   }
1313   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1314       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1315             localendladdercarbonfiberjunctionmatrix[i][j] = 
1316                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1317                                      *localendladdercarbonfiberjunctionrot[i][j]);
1318            fendladdercarbonfiberjunctionmatrix[i][j] =
1319             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1320             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1321       }  
1322   /////////////////////////////////////////////////////////////
1323   // End Ladder Carbon Fiber Support
1324   /////////////////////////////////////////////////////////////
1325   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1326   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1327       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1328       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1329             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1330       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1331   }
1332   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1333       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1334             fendladdercarbonfibermatrix[i][j] = 
1335             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1336             *(*fcarbonfibersupportmatrix[j]));
1337   /////////////////////////////////////////////////////////////
1338   // End Ladder SSD Mounting Block
1339   /////////////////////////////////////////////////////////////
1340   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1341       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1342   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1343       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1344                                 +        fgkSSDMountingBlockLength[1])
1345                                 +  0.5*fgkCarbonFiberTriangleLength,
1346                                 fgkEndLadderMountingBlockPosition[i],
1347                                 -  fgkSSDMountingBlockHeight[1]
1348                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1349   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1350   endladdermountingblockrot->SetAngles(0.,90.,0.);
1351   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1352         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1353   /////////////////////////////////////////////////////////////
1354   // End Ladder SSD Mounting Block Clip Matrix 
1355   /////////////////////////////////////////////////////////////
1356   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1357         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1358   
1359   TGeoRotation* localendladdercliprot = new TGeoRotation();
1360   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1361   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1362                                                                                   -     fgkSSDMountingBlockLength[1])
1363                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1364   localendladdercliprot->SetAngles(90.,180.,-90.);
1365   TGeoCombiTrans* localendladderclipcombitrans = 
1366                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1367   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1368         for(Int_t j=0; j<2; j++){
1369                 fendladdermountingblockclipmatrix[i][j] = 
1370                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1371                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1372         }
1373   /////////////////////////////////////////////////////////////
1374   // End Ladder Carbon Fiber Lower Support
1375   /////////////////////////////////////////////////////////////
1376   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1377       fendladderlowersupptrans[i] = 
1378             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1379                         +  0.5*fgkSSDMountingBlockWidth),
1380                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1381   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1382                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1383                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1384                                                                          0.0);
1385   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1386  /////////////////////////////////////////////////////////////
1387   // Matrix for positioning Ladder into mother volume
1388   /////////////////////////////////////////////////////////////
1389   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1390   for(Int_t i=0; i<fgkladdernumber; i++) 
1391         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1392   TGeoRotation* localladdermotherrot = new TGeoRotation();
1393   localladdermotherrot->SetAngles(0.,90.,0.);  
1394   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1395   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1396   for(Int_t i=0; i<fgkladdernumber; i++){
1397         localladdermothertrans[i] = new TGeoTranslation(0.,
1398                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1399                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1400                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1401                                                           * fgkCarbonFiberJunctionWidth,0.);
1402         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1403                                                                                                                 *localladdermotherrot);
1404         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1405         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1406   }
1407   /////////////////////////////////////////////////////////////
1408   // Ladder Cables Matrices
1409   /////////////////////////////////////////////////////////////
1410   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1411                                              + fgkSSDFlexHeight[1];  
1412   Double_t ssdladdercabletransx[3];
1413   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1414                                                   *   SinD(2.*fgkSSDFlexAngle)
1415                                                   *       CosD(2.*fgkSSDFlexAngle);
1416   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1417                                                   -     ssdladdercabletransx[0]
1418                                                   /     SinD(2.*fgkSSDFlexAngle))
1419                                                   *     CosD(fgkSSDFlexAngle);                                          
1420   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1421                                                   *       TMath::DegToRad()*ssdflexradiusmax
1422                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1423                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1424                                                   -       fgkSSDLadderCableWidth)
1425                                                   *       CosD(2.*fgkSSDFlexAngle);
1426   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1427                                                   *     TanD(2.*fgkSSDFlexAngle),
1428                                                         ssdladdercabletransx[1]
1429                                                   *     TanD(fgkSSDFlexAngle),
1430                                                         ssdladdercabletransx[2]
1431                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1432   TGeoRotation* localladdercablerot[3]; 
1433   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1434   localladdercablerot[0]->SetAngles(90.,0.,0.);
1435   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1436   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1437                                                  *                        (*localladdercablerot[0]));
1438   ////////////////////////////////////////////
1439   // LocalLadderCableCombiTransMatrix
1440   ////////////////////////////////////////////
1441   const Int_t klocalladdersidecablesnumber = 2;
1442   const Int_t klocalladdercombitransnumber = 5;
1443   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1444   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1445          localladdercablecombitransmatrix[i] = 
1446                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1447   ///////////////////////////////////////////
1448   // Left Side Ladder Cables Transformations
1449   ///////////////////////////////////////////
1450   localladdercablecombitransmatrix[0][0]  =
1451                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1452                                                 0.,0.,NULL);
1453   localladdercablecombitransmatrix[0][1] = 
1454         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1455                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1456                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1457                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1458                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1459                                            + fgkSSDSensorCenterSupportLength
1460                                            - fgkSSDSensorCenterSupportThickness[0]),
1461                                            - (fgkSSDModuleCoolingBlockToSensor
1462                                            + 0.5*fgkCoolingTubeSupportHeight
1463                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1464                                            - fgkSSDChipHeight),NULL);
1465   localladdercablecombitransmatrix[0][2] = 
1466                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1467                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1468   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1469                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1470                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1471                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1472                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1473                                                                                                 new TGeoRotation("",180.,0.,0.));
1474   localladdercablecombitransmatrix[0][4] = 
1475                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1476                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1477                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1478                                                           0.,
1479                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1480                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1481                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1482                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1483   ///////////////////////////////////////////
1484   // Rigth Side Ladder Cables Transformations
1485   ///////////////////////////////////////////
1486   TGeoCombiTrans* localladdercablessdmodulematrix = 
1487         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1488                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1489                                                                          fgkSSDStiffenerWidth,
1490                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1491   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1492    localladdercablecombitransmatrix[1][i] = 
1493                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1494                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1495   ///////////////////////////////////////////
1496   // Setting LadderCableHMatrix
1497   ///////////////////////////////////////////
1498   Int_t beamaxistrans[2][3];
1499   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1500   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1501   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1502   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1503   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1504   beamaxistrans[1][2] = beamaxistrans[1][0];
1505   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1506   TGeoRotation* laddercablerot = new TGeoRotation();
1507   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1508   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1509   Double_t* laddercabletransvector;     
1510   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1511         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1512         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1513   }
1514   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1515         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1516                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1517                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1518                         localladdercablehmatrix[i][j]->MultiplyLeft(
1519                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1520         }
1521                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1522                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1523                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1524                                                                          laddercabletransvector[1]
1525                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1526                                         *                                fgkCarbonFiberJunctionWidth,
1527                                                                          laddercabletransvector[2]);
1528                 laddercablecombitrans->SetRotation(*laddercablerot);
1529                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1530                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1531         }
1532     fladdercablematrix[i][2] = 
1533                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1534                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1535         fladdercablematrix[i][3] = 
1536                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1537                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1538   }
1539   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1540         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1541                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1542   ///////////////////////////////////////////
1543   // Setting Ladder HMatrix
1544   ///////////////////////////////////////////
1545   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1546                                                                                                 fgkSSDLay6SensorsNumber};
1547   for(Int_t i=0; i<fgkladdernumber; i++){
1548         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1549         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1550                 fladdermatrix[i][j] = new TGeoHMatrix();
1551                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1552                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1553                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1554         }
1555   }
1556   ///////////////////////////////////////////
1557   // Setting SSD Sensor Matrix 
1558   ///////////////////////////////////////////
1559   TGeoCombiTrans* localssdsensorcombitrans[2];
1560   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1561   localssdsensorrot->SetAngles(0.,90.,0.);      
1562   TGeoTranslation* localssdsensortrans[2];
1563   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1564   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1565                                           -             (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1566                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1567                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1568                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1569                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1570                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1571                                           -             fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1572                                           +    (fgkSSDSensorSideSupportHeight[1]
1573                                           -             fgkSSDSensorSideSupportHeight[0]));
1574   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1575                                           -        (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1576                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1577                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1578                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1579                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1580                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1581                                                         -fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment);
1582   for(Int_t i=0; i<2; i++) 
1583         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1584                                                                                                          *localssdsensorrot);   
1585     for(Int_t i=0; i<fgkladdernumber; i++){
1586         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1587         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1588                 switch(i){
1589                         case 0: //Ladder of Layer5  
1590                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1591                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1592                                                                                                 *localssdsensorcombitrans[1])));
1593                         break;
1594                         case 1: //Ladder of Layer6 
1595                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1596                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1597                                                                                                 *localssdsensorcombitrans[0])));
1598                 break;
1599                 }
1600           }
1601   }     
1602   //////////////////////////
1603   // Setting SSD End Ladder  
1604   //////////////////////////
1605   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1606   for(Int_t i=0; i<2; i++){
1607         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1608         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1609         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1610         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1611         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1612         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1613         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1614         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1615    }
1616   /////////////////////////////////////////////////////
1617   // Setting the CombiTransformation to pass ITS center 
1618   /////////////////////////////////////////////////////
1619   Double_t itscentertransz[fgklayernumber];
1620   itscentertransz[0] = fgkSSDLay5LadderLength
1621                                          - fgkLay5CenterITSPosition;
1622   itscentertransz[1] = fgkSSDLay6LadderLength
1623                                          - fgkLay6CenterITSPosition;
1624   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1625                                                    + 0.5*fgkCoolingTubeSupportHeight;
1626   TGeoRotation* itscenterrot[3];
1627   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1628   itscenterrot[0]->SetAngles(90.,180.,-90.);
1629   itscenterrot[1]->SetAngles(0.,90.,0.);
1630   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1631   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1632   for(Int_t i=0; i<fgklayernumber; i++) 
1633         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1634                                                          itssensortransy,
1635                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1636                                                    - itscentertransz[i],itscenterrot[2]);
1637   TGeoRotation** locallayerrot[fgklayernumber];
1638   TGeoTranslation** locallayertrans[fgklayernumber];    
1639   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1640   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1641   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1642                                          - fgkLay5CenterITSPosition);
1643   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1644                                          - fgkLay6CenterITSPosition);
1645   const Int_t kssdlayladdernumber[fgklayernumber] = 
1646                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1647   for(Int_t i=0; i<fgklayernumber; i++){
1648     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1649     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1650         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1651         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1652   }
1653   Double_t layerladderangleposition[fgklayernumber] = 
1654                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1655   Double_t layerradius = 0.;
1656   for(Int_t i=0; i<fgklayernumber; i++){        
1657         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1658                 switch(i){
1659                         case 0: //Ladder of Layer5  
1660                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1661                         break;
1662                         case 1: //Ladder of Layer6 
1663                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1664                 break;
1665                 }
1666                 locallayerrot[i][j] = new TGeoRotation();
1667                 locallayertrans[i][j] = new TGeoTranslation();
1668                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1669                 locallayertrans[i][j]->SetTranslation(layerradius 
1670                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1671                                                             layerradius 
1672                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1673                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1674                                                                          *locallayerrot[i][j]);
1675                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1676                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1677                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1678         }
1679   }
1680   /////////////////////////////////////////////////////////////
1681   // Deallocating memory
1682   /////////////////////////////////////////////////////////////
1683   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1684         delete carbonfiberot[i];
1685         delete localcarbonfibersupportmatrix[i];
1686   }
1687   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1688      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1689        delete localcarbonfiberjunctionmatrix[i][j];
1690            delete localcarbonfiberjunctionrot[i][j];
1691            delete localcarbonfiberjunctiontrans[i][j];
1692            }
1693        delete [] localcarbonfiberjunctionmatrix[i];
1694        delete [] localcarbonfiberjunctionrot[i];
1695        delete [] localcarbonfiberjunctiontrans[i];
1696   }
1697   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1698            delete localcarbonfiberlowersupportrans[i];
1699   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1700      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1701        delete localssdsensorsupportmatrix[i][j];
1702            delete localssdsensorsupportrot[i][j];
1703            delete localssdsensorsupportrans[i][j];
1704            }
1705        delete [] localssdsensorsupportmatrix[i];
1706        delete [] localssdsensorsupportrot[i];
1707        delete [] localssdsensorsupportrans[i];
1708   }
1709   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1710         delete localcoolingtubesupportmatrix[i];
1711         delete localcoolingtubesupportrot[i];
1712         delete localcoolingtubesupportrans[i];
1713   }
1714   for(Int_t i=0; i<4; i++){
1715         for(Int_t j=0; j<2; j++){
1716                 delete localcoolingtubevect[i][j];
1717                 delete localcoolingtubetrans[i][j];
1718         }
1719         delete [] localcoolingtubevect[i];
1720         delete [] localcoolingtubetrans[i];
1721   }
1722  delete endladdermountingblockrot;
1723  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1724  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1725  for(Int_t i=0; i<fgkflexnumber; i++){
1726       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1727             delete localflexmatrix[i][j];
1728       delete [] localflexmatrix[i];
1729  }
1730  delete localendlladdercoolingtuberot;
1731  for(Int_t i=0; i<2; i++){
1732         for(Int_t j=0; j<(i==0?6:4); j++)
1733                 delete localendlladdercoolingtubetrans[i][j];
1734         delete [] localendlladdercoolingtubetrans[i];
1735   }
1736
1737  delete localflexrot;
1738  delete localendflexrot;
1739  delete localendflexmatrix;
1740  for(Int_t i=0; i<fgkladdernumber; i++){ 
1741         delete localladdermothertrans[i];
1742         delete localladdermothercombitrans[i];
1743   }
1744  delete localladdermotherrot;
1745  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1746       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1747             delete localendladdercarbonfiberjunctionmatrix[i][j];
1748             delete localendladdercarbonfiberjunctionrot[i][j];
1749             delete localendladdercarbonfiberjunctiontrans[i][j];
1750       }
1751       delete [] localendladdercarbonfiberjunctionmatrix[i];
1752       delete [] localendladdercarbonfiberjunctionrot[i];
1753       delete [] localendladdercarbonfiberjunctiontrans[i];
1754       delete localendladdercarbonfiberjunctionglobalrot[i];
1755       delete localendladdercarbonfiberjunctionglobaltrans[i];
1756       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1757  }
1758   for(Int_t i=0; i<2; i++){
1759         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1760         delete [] localendladdercooltubetrans[i];
1761   }
1762   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1763       delete localendladdercarbonfibertrans[i];
1764   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1765   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1766         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1767                 delete localladdercablecombitransmatrix[i][j];
1768                 delete []localladdercablecombitransmatrix[i];
1769   }
1770   delete localendladdercliprot;
1771   delete localendladdercliptrans;
1772   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1773         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1774                 delete localladdercablehmatrix[i][j];
1775         delete []localladdercablehmatrix[i];
1776   }
1777   delete laddercablerot;
1778   delete laddercabletrans;
1779   delete laddercablecombitrans;
1780   delete localladdercablessdmodulematrix;
1781   delete localssdsensorrot;     
1782   for(Int_t i=0; i<2; i++){
1783         delete localssdsensortrans[i];
1784         delete localssdsensorcombitrans[i];
1785   }
1786   for(Int_t i=0; i<fgklayernumber; i++){
1787         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1788                 delete locallayerrot[i][j];
1789                 delete locallayertrans[i][j];
1790                 delete locallayercombitrans[i][j];
1791     }
1792         delete [] locallayerrot[i];
1793         delete [] locallayertrans[i];
1794         delete [] locallayercombitrans[i];
1795         delete localbeamaxistrans[i];
1796   }
1797   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1798   for(Int_t i=0; i<fgkladdernumber; i++){
1799         for(Int_t j=0; j<fgkladdernumber; j++)
1800                 delete ladderglobalmatrix[i][j];
1801         delete [] ladderglobalmatrix[i];
1802   }
1803   /////////////////////////////////////////////////////////////
1804   fTransformationMatrices = kTRUE;      
1805 }
1806 ///////////////////////////////////////////////////////////////////////////////
1807 void AliITSv11GeometrySSD::CreateBasicObjects(){
1808   /////////////////////////////////////////////////////////////  
1809   // Method generating the Objects of SSD Geometry    
1810   /////////////////////////////////////////////////////////////
1811   // SSD Sensor
1812   ///////////////////////////////////
1813   SetSSDSensor();
1814   /////////////////////////////////////////////////////////////  
1815   // Carbon Fiber Support    
1816   /////////////////////////////////////////////////////////////  
1817   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1818   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1819       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1820   /////////////////////////////////////////////////////////////
1821   // Carbon Fiber Junction 
1822   /////////////////////////////////////////////////////////////
1823   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth);
1824   /////////////////////////////////////////////////////////////
1825   // Carbon Fiber Lower Support
1826   /////////////////////////////////////////////////////////////
1827   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1828   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1829         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1830   /////////////////////////////
1831   // SSD Sensor Support
1832   /////////////////////////////
1833   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1834                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1835   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1836                                                                          fgkSSDSensorSideSupportThickness[1]};
1837   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1838         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1839                                                                                            fgkSSDSensorSideSupportHeight[i],
1840                                                                                            fgkSSDSensorSideSupportWidth,
1841                                                                                            sidesupporthickness);  
1842         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1843                                                                                            fgkSSDSensorCenterSupportHeight[i],
1844                                                                                            fgkSSDSensorCenterSupportWidth,
1845                                                                                            sidesupporthickness);
1846   }
1847   /////////////////////////////////////////////////////////////
1848   // SSD Cooling Tube Support
1849   /////////////////////////////////////////////////////////////
1850   Int_t edgesnumber = 16;
1851   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1852   /////////////////////////////////////////////////////////////
1853   // SSD Hybrid
1854   /////////////////////////////////////////////////////////////
1855   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1856   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1857         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1858   /////////////////////////////////////////////////////////////
1859   // SSD Cooling Block System
1860   /////////////////////////////////////////////////////////////
1861   fssdcoolingblocksystem = GetCoolingBlockSystem();
1862    /////////////////////////////////////////////////////////////
1863   // SSD Cooling Tube
1864   /////////////////////////////////////////////////////////////
1865   TList* coolingtubelist = GetCoolingTubeList();        
1866   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1867         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1868   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1869         fendladdercoolingtube[i] = 
1870                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1871   /////////////////////////////////////////////////////////////
1872   // SSD Flex  
1873   /////////////////////////////////////////////////////////////
1874   fssdstiffenerflex = GetSSDStiffenerFlex();
1875   fssdendflex = GetSSDEndFlex();
1876   ///////////////////////////////////
1877   // End Ladder Carbon Fiber Junction
1878   ///////////////////////////////////
1879   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1880                                                    fendladdercarbonfiberjunction[i] = 
1881                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1882   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1883     fendladdercarbonfiberjunction[i][0] = 
1884                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]);
1885     fendladdercarbonfiberjunction[i][1] = 
1886                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]);
1887   }
1888   ///////////////////////////////////
1889   // End Ladder Mounting Block
1890   ///////////////////////////////////
1891   fendladdermountingblock = GetSSDMountingBlock();
1892   ///////////////////////////////////
1893   // End Ladder Mounting Block
1894   ///////////////////////////////////
1895   fendladdermountingblockclip = GetMountingBlockClip();
1896   ///////////////////////////////////
1897   // Ladder Support 
1898   ///////////////////////////////////
1899   TList* laddersupportlist = GetMountingBlockSupport(20);
1900   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1901   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1902   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1903   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1904   /////////////////////////////////////////////////////////////
1905   // Deallocating memory
1906   /////////////////////////////////////////////////////////////
1907   delete carbonfibersupportlist;
1908   delete carbonfiberlowersupportlist;
1909   delete ssdhybridcomponentslist;
1910   delete laddersupportlist;
1911   /////////////////////////////////////////////////////////////
1912   fBasicObjects = kTRUE;
1913 }
1914 /////////////////////////////////////////////////////////////////////////////////
1915 void AliITSv11GeometrySSD::SetSSDSensor(){
1916   ////////////////////////////////////////////////////////////////
1917   // Method generating SSD Sensors: it sets the private variables
1918   // fSSDSensor5, fSSDSensor6  
1919   ////////////////////////////////////////////////////////////////
1920   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1921   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1922   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1923                                                 0.5*ssdsensitivewidth,
1924                                                 0.5*fgkSSDSensorHeight,
1925                                                 0.5*ssdsensitivelength);
1926   TGeoVolume* ssdsensorsensitiveLay5 = 
1927         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1928   TGeoVolume* ssdsensorsensitiveLay6 = 
1929         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1930   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1931   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1932   TGeoBBox* ssdsensorinsensitiveshape[2];
1933   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1934                                                 0.5*fgkSSDSensorInsensitiveWidth,
1935                                                 0.5*fgkSSDSensorHeight,
1936                                                 0.5*fgkSSDSensorLength);
1937   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1938                                                 0.5*ssdsensitivewidth,
1939                                                 0.5*fgkSSDSensorHeight,
1940                                                 0.5*fgkSSDSensorInsensitiveWidth);
1941   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1942                                              "SSDSensorInsensitive2"};
1943   TGeoVolume* ssdsensorinsensitive[2];
1944   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1945       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1946                      fSSDSensorMedium);
1947       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1948   }
1949   /////////////////////////////////////////////////////////////
1950   // Virtual Volume containing SSD Sensor  
1951   /////////////////////////////////////////////////////////////
1952   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1953                                                                                              0.5*fgkSSDSensorWidth,
1954                                                                                              0.5*fgkSSDSensorHeight,
1955                                                                                              0.5*fgkSSDSensorLength);
1956   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1957                                                                                  fSSDAir);      
1958   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1959                                                                                  fSSDAir);      
1960   /////////////////////////////////////////////////////////////
1961   for(Int_t i=0; i<4; i++){ 
1962             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1963             ssdsensorinsensitive[1],i<2?1:2,
1964                         new TGeoTranslation(
1965                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1966       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1967                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1968       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1969             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1970             ssdsensorinsensitive[1],i<2?1:2,
1971                         new TGeoTranslation(
1972                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1973       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1974                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1975       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1976   }
1977     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1978     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1979 }
1980 ///////////////////////////////////////////////////////////////////////////////
1981 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1982   /////////////////////////////////////////////////////////////  
1983   // Method generating the Carbon Fiber Support   
1984   /////////////////////////////////////////////////////////////  
1985   const Int_t kvertexnumber = 4;
1986   const Int_t kshapesnumber = 2;
1987   TVector3** vertexposition[kshapesnumber];
1988   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1989   Double_t carbonfibersupportxaxisEdgeproj = 
1990                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1991         *       TMath::DegToRad());
1992   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1993                                  /                         fgkCarbonFiberSupportXAxisLength);
1994   /////////////////////
1995   //Vertex Positioning
1996   ////////////////////
1997   vertexposition[0][0] = new TVector3();
1998   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1999                                                                           fgkCarbonFiberSupportYAxisLength);
2000   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2001                                                                           carbonfibersupportxaxisEdgeproj
2002                                            *                      TMath::Tan(theta));
2003   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2004                                            -                      carbonfibersupportxaxisEdgeproj,
2005                                                                           fgkCarbonFiberSupportYAxisLength
2006                                            -                      vertexposition[0][2]->Y());
2007   ////////////////////////////////////////////////////
2008   //Setting the parameters for Isometry Transformation
2009   ////////////////////////////////////////////////////
2010   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2011                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2012                                                                  +      fgkCarbonFiberSupportWidth);
2013   Double_t* param = new Double_t[4]; 
2014   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2015   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2016                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2017                                                           (GetReflection(vertexposition[0][j],param))->Y());
2018   char* carbonfibersupportshapename[kshapesnumber] = 
2019                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2020   char* carbonfibersupportname[kshapesnumber] = 
2021                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2022   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2023   TGeoVolume* carbonfibersupport[kshapesnumber];
2024   TList* carbonfibersupportlist = new TList();
2025   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2026   Double_t carbonfibersupportheight = 
2027           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2028           *TMath::DegToRad());
2029   for(Int_t i = 0; i< kshapesnumber; i++){
2030    carbonfibersupportshape[i] = 
2031                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2032                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2033    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2034                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2035    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2036    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2037    }
2038   /////////////////////////////////////////////////////////////
2039   // Deallocating memory
2040   /////////////////////////////////////////////////////////////
2041   for(Int_t i=0; i< kshapesnumber; i++){
2042      for(Int_t j=0; j< kvertexnumber; j++)
2043            delete vertexposition[i][j];
2044        delete [] vertexposition[i];
2045   }
2046   delete [] param;
2047   /////////////////////////////////////////////////////////////
2048    return carbonfibersupportlist;
2049 }
2050 /////////////////////////////////////////////////////////////////////////////////
2051 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2052   /////////////////////////////////////////////////////////////
2053   // Method generating SSD Carbon Fiber Junction
2054   /////////////////////////////////////////////////////////////
2055   const Int_t kvertexnumber = 6;
2056   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2057   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2058                                                           *  TMath::DegToRad()),-1.,0.};
2059   TVector3* vertex[kvertexnumber];
2060   vertex[0] = new TVector3();
2061   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2062                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2063                         *                         TMath::DegToRad()),
2064                                                   fgkCarbonFiberJunctionEdge[0]
2065                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2066                         *                         TMath::DegToRad()));
2067   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2068                                                    fgkCarbonFiberJunctionEdge[1]);
2069   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2070   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2071   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2072   Double_t xvertexpoints[6], yvertexpoints[6];
2073   for(Int_t i=0; i<kvertexnumber; i++) 
2074           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2075   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2076   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2077   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2078   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2079                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2080   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2081   /////////////////////////////////////////////////////////////
2082   // Deallocating memory
2083   /////////////////////////////////////////////////////////////
2084   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2085   ///////////////////////////////////////////////////////////// 
2086   return carbonfiberjunction;
2087 }
2088 ////////////////////////////////////////////////////////////////////////////////
2089 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2090   /////////////////////////////////////////////////////////////
2091   // Method generating the Carbon Fiber Lower Support   
2092   /////////////////////////////////////////////////////////////  
2093   const Int_t kvertexnumber = 4;
2094   const Int_t kshapesnumber = 2;
2095   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2096                                                                 fgkCarbonFiberLowerSupportWidth};
2097   TVector3** vertexposition[kshapesnumber];
2098   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2099                                                  new TVector3*[kvertexnumber];
2100   //First Shape Vertex Positioning
2101   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2102   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2103                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2104   vertexposition[0][2] = new TVector3();
2105   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2106   //Second Shape Vertex Positioning
2107   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2108                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2109                                  /                              fgkCarbonFiberTriangleLength);
2110   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2111                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2112                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2113   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2114                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2115                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2116   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2117   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2118                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2119   char* carbonfiberlowersupportshapename[kshapesnumber] = 
2120                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2121   char* carbonfiberlowersupportname[kshapesnumber] = 
2122                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2123   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2124   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2125   TList* carbonfiberlowersupportlist = new TList();
2126   for(Int_t i = 0; i< kshapesnumber; i++){ 
2127         carbonfiberlowersupportshape[i] = 
2128                                                                 GetArbShape(vertexposition[i],width,
2129                                                                                         fgkCarbonFiberLowerSupportHeight,
2130                                                                                         carbonfiberlowersupportshapename[i]);
2131     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2132                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2133         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2134     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2135   }
2136   /////////////////////////////////////////////////////////////
2137   // Deallocating memory
2138   /////////////////////////////////////////////////////////////
2139   for(Int_t i=0; i< kshapesnumber; i++){
2140      for(Int_t j=0; j< kvertexnumber; j++)
2141            delete vertexposition[i][j];
2142        delete [] vertexposition[i];
2143   }
2144   /////////////////////////////////////////////////////////////
2145   return carbonfiberlowersupportlist;
2146 }
2147 ///////////////////////////////////////////////////////////////////////////////
2148 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2149                                                                  Double_t width, Double_t* thickness)const{
2150   /////////////////////////////////////////////////////////////
2151   // Method generating the Sensor Support   
2152   /////////////////////////////////////////////////////////////  
2153         const Int_t kvertexnumber = 6;
2154         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2155     TVector3* vertexposition[kvertexnumber];
2156         vertexposition[0] = new TVector3();     
2157         vertexposition[1] = new TVector3(0.0,length);   
2158         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2159         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2160         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2161         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2162         Double_t xvertexpoints[6], yvertexpoints[6];
2163         for(Int_t i=0; i<kvertexnumber; i++) 
2164                 xvertexpoints[i] = vertexposition[i]->X(), 
2165                 yvertexpoints[i] = vertexposition[i]->Y();
2166     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2167     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2168     ssdsensorsupportshape->DefineSection(1,0.5*width);
2169     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2170                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2171   /////////////////////////////////////////////////////////////
2172   // Deallocating memory
2173   /////////////////////////////////////////////////////////////
2174         for (Int_t i=0; i<kvertexnumber; i++)
2175                 delete vertexposition[i];
2176   /////////////////////////////////////////////////////////////
2177     return ssdsensorsupport;
2178 }
2179 ////////////////////////////////////////////////////////////////////////////////
2180 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2181   /////////////////////////////////////////////////////////////
2182   // Method generating the Cooling Tube Support
2183   /////////////////////////////////////////////////////////////
2184   if(nedges%2!=0) nedges--;     
2185   const Int_t kvertexnumber = nedges+5;
2186   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2187                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2188   Double_t angle = 90.+phi;
2189   Double_t psi = 90.-phi;
2190   ///////////////////////////////////////
2191   // Vertex Positioning for TGeoXTru
2192   ///////////////////////////////////////
2193   TVector3** vertexposition = new TVector3*[kvertexnumber];
2194   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2195                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2196   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2197                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2198   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2199                                                                    fgkCoolingTubeSupportRmax);
2200   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2201                                                                    fgkCoolingTubeSupportRmax);
2202   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2203                                                                     vertexposition[1]->Y());
2204   for(Int_t i=0; i<nedges; i++)
2205         vertexposition[i+5] = 
2206                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2207                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2208   ///////////////////////////////////////////////////////////////////////
2209   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2210   ///////////////////////////////////////////////////////////////////////
2211   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2212   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2213   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2214   for(Int_t i=0; i<kvertexnumber; i++){
2215         xvertexpoints[i] = vertexposition[i]->X();
2216         yvertexpoints[i] = vertexposition[i]->Y();
2217   } 
2218   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2219                                                                                         yvertexpoints);
2220   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2221   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2222   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2223                                                                           coolingtubesupportarcshape,
2224                                                                                   fSSDTubeHolderMedium);
2225   coolingtubesupportarc->SetLineColor(fColorG10);
2226   //////////////////////////////////////////////////////////////////////////
2227   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2228   //////////////////////////////////////////////////////////////////////////
2229   TGeoTubeSeg* coolingtubesupportsegshape = 
2230                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2231                                                                                         fgkCoolingTubeSupportRmax,
2232                                                                                         0.5*fgkCoolingTubeSupportWidth,
2233                                                                                         phi,360-phi);
2234   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2235                                                                                         coolingtubesupportsegshape,
2236                                                                                         fSSDTubeHolderMedium);
2237   coolingtubesupportseg->SetLineColor(fColorG10);
2238   //////////////////////////////////////////////////////////////////////////
2239   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2240   //////////////////////////////////////////////////////////////////////////
2241   Double_t* boxorigin = new Double_t[3];
2242   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2243   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2244   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2245                                                                                  0.5*fgkCoolingTubeSupportHeight,
2246                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2247   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2248                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2249   coolingtubesupportbox->SetLineColor(fColorG10);
2250   //////////////////////////////////////////////////////////////////////////
2251   // Cooling Tube for Cooling Tube Support 
2252   //////////////////////////////////////////////////////////////////////////
2253   TGeoXtru* coolingtubearcshape[2];
2254   coolingtubearcshape[0] = new TGeoXtru(2);     
2255   Double_t* xvert = new Double_t[nedges+2];
2256   Double_t* yvert = new Double_t[nedges+2];
2257   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2258   ////////////////////////////////////////
2259   // Positioning the vertices for TGeoXTru
2260   ////////////////////////////////////////
2261   xvert[0] = 0., yvert[0] = 0.;
2262   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2263   for(Int_t i=0; i< nedges; i++)
2264                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2265                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2266   ////////////////////////////////////////
2267   // Defining TGeoXTru PolyGone
2268   ////////////////////////////////////////
2269   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2270   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2271   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2272   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2273                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2274   TGeoVolume* coolingtubearc[2];
2275   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2276                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2277   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2278                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2279   coolingtubearc[0]->SetLineColor(fColorWater);
2280   coolingtubearc[1]->SetLineColor(fColorPhynox);
2281   ////////////////////////////////////////////
2282   // Defining TGeoTubeSeg Part of Cooling Tube
2283   ////////////////////////////////////////////
2284   TGeoTubeSeg* coolingtubesegshape[2];
2285   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2286                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2287   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2288                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2289   TGeoVolume* coolingtubeseg[2];
2290   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2291                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2292   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2293                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2294   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2295   coolingtubeseg[1]->SetLineColor(fColorWater);
2296   /////////////////////////////////////////////////////////////
2297   // Virtual Volume containing Cooling Tube Support  
2298   /////////////////////////////////////////////////////////////
2299   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2300   const Int_t kvirtualvertexnumber = 8;
2301   TVector3* virtualvertex[kvirtualvertexnumber];
2302    ////////////////////////////////////////
2303   // Positioning the vertices for TGeoXTru
2304   ////////////////////////////////////////
2305   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2306   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2307   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2308   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2309   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2310   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2311   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2312   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2313   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2314   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2315         xmothervertex[i] = virtualvertex[i]->X(),
2316         ymothervertex[i] = virtualvertex[i]->Y();
2317   ////////////////////////////////////////
2318   // Defining TGeoXTru PolyGone
2319   ////////////////////////////////////////
2320   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2321                                                                                                                                          ymothervertex);
2322   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2323   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2324   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2325                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2326   ////////////////////////////////////////
2327   // Positioning Volumes in Virtual Volume
2328   ////////////////////////////////////////
2329   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2330   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2331   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2332   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2333   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2334   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2335   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2336   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2337   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2338   /////////////////////////////////////////////////////////////
2339   // Deallocating memory
2340   /////////////////////////////////////////////////////////////
2341   delete [] vertexposition;
2342   delete xvertexpoints;
2343   delete yvertexpoints;
2344   delete xvert;
2345   delete yvert;
2346   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2347         delete virtualvertex[i];
2348   /////////////////////////////////////////////////////////////
2349         return virtualcoolingtubesupport;
2350 }
2351 /////////////////////////////////////////////////////////////////////////////////
2352 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2353   /////////////////////////////////////////////////////////////
2354   // Method generating List containing SSD Hybrid Components   
2355   /////////////////////////////////////////////////////////////
2356   TList* ssdhybridlist = new TList();
2357   const Int_t kssdstiffenernumber = 2;
2358   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2359                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2360                                                                   -    fgkSSDStiffenerWidth;
2361   Double_t ssdchipcablesradius[kssdstiffenernumber];
2362   for(Int_t i=0; i<kssdstiffenernumber; i++)
2363           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2364                                -  fgkSSDChipCablesHeight[0]
2365                                -  fgkSSDChipCablesHeight[1]);
2366   /////////////////////////////////////////////////////////////
2367   // Mother Volumes Containers 
2368   /////////////////////////////////////////////////////////////
2369   const Int_t kmothernumber = 2;
2370   const Int_t kmothervertexnumber = 12;
2371   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2372   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2373   ///////////////////////
2374   // Setting the vertices 
2375   ///////////////////////
2376   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2377   xmothervertex[0][1]  = xmothervertex[0][0]; 
2378   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2379   xmothervertex[0][3]  = xmothervertex[0][2];
2380   xmothervertex[0][4]  = xmothervertex[0][0];
2381   xmothervertex[0][5]  = xmothervertex[0][4];
2382   xmothervertex[0][6]  = -xmothervertex[0][0];
2383   xmothervertex[0][7]  = xmothervertex[0][6];
2384   xmothervertex[0][8]  = -xmothervertex[0][2];
2385   xmothervertex[0][9]  = xmothervertex[0][8];
2386   xmothervertex[0][10] = xmothervertex[0][7];
2387   xmothervertex[0][11] = xmothervertex[0][10];
2388   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2389   for(Int_t i = 0; i<kmothernumber; i++){
2390       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2391                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2392       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2393       ymothervertex[i][2]  = ymothervertex[i][1];
2394       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2395       ymothervertex[i][4]  = ymothervertex[i][3];
2396       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2397       ymothervertex[i][6]  = ymothervertex[i][5];
2398       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2399       ymothervertex[i][8]  = ymothervertex[i][7];
2400       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2401       ymothervertex[i][10] = ymothervertex[i][9];
2402       ymothervertex[i][11] = ymothervertex[i][0];
2403   }
2404   TGeoXtru* ssdhybridmothershape[kmothernumber];
2405   TGeoVolume* ssdhybridmother[kmothernumber];
2406   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2407   for(Int_t i=0; i<kmothernumber; i++){
2408       ssdhybridmothershape[i] = new TGeoXtru(2);
2409       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2410                                           ymothervertex[i]);
2411       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2412                                                -fgkSSDChipCablesHeight[i+2]);
2413       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2414       ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2415                                           fSSDAir);
2416    }   
2417   /////////////////////////////////////////////////////////////
2418   // SSD Stiffener   
2419   /////////////////////////////////////////////////////////////
2420   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2421                                              0.5*fgkSSDStiffenerLength,
2422                                              0.5*fgkSSDStiffenerWidth,
2423                                              0.5*fgkSSDStiffenerHeight);
2424   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2425                                             fSSDStiffenerMedium);  
2426   ssdstiffener->SetLineColor(fColorStiffener); 
2427   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2428   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2429       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2430   /////////////////////////////////////////////////////////////
2431   // SSD Chip System    
2432   /////////////////////////////////////////////////////////////
2433   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2434   Double_t ssdchipseparation = fgkSSDSensorLength
2435                              - 2.*fgkSSDModuleStiffenerPosition[1]
2436                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2437                              - 0.5*fgkSSDChipWidth);
2438   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2439                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2440   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2441                                       - 0.5*ssdchipsystemlength,
2442                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2443                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2444 ////////////////////////////
2445 // Capacitor 0603-2200 nF
2446 ///////////////////////////
2447   const Int_t knapacitor0603number = 5;
2448   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2449                                                                                          0.5*fgkSSDCapacitor0603Length,
2450                                                                                          0.5*fgkSSDCapacitor0603Width,
2451                                                                                          0.5*fgkSSDCapacitor0603Height);
2452   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2453                                              fSSDStiffener0603CapacitorMedium); 
2454   capacitor0603->SetLineColor(fColorAl);
2455   for(Int_t i=0; i<kmothernumber; i++){
2456       for(Int_t j=0; j<kssdstiffenernumber; j++){
2457             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2458             for(Int_t k=1; k<knapacitor0603number+1; k++){
2459                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2460                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2461                                              j*ssdstiffenerseparation
2462                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2463                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2464                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2465             }
2466       } 
2467       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2468       ssdhybridlist->Add(ssdhybridmother[i]);
2469   }    
2470 /////////////////////////////////////////////////////////////
2471 // Mother Volume Containing Capacitor Part 
2472 /////////////////////////////////////////////////////////////
2473   const Int_t kcapacitormothernumber = 8;
2474   Double_t xcapacitorvertex[kcapacitormothernumber];
2475   Double_t ycapacitorvertex[kcapacitormothernumber];  
2476   ///////////////////////
2477   // Setting the vertices 
2478   ///////////////////////
2479   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2480   xcapacitorvertex[1] = xcapacitorvertex[0];   
2481   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2482   xcapacitorvertex[3] = xcapacitorvertex[2];   
2483   xcapacitorvertex[4] = xcapacitorvertex[0];   
2484   xcapacitorvertex[5] = xcapacitorvertex[0];   
2485   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2486   xcapacitorvertex[7] = xcapacitorvertex[6];   
2487   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2488   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2489   ycapacitorvertex[2] = ycapacitorvertex[1];   
2490   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2491   ycapacitorvertex[4] = ycapacitorvertex[3];   
2492   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2493   ycapacitorvertex[6] = ycapacitorvertex[5];   
2494   ycapacitorvertex[7] = ycapacitorvertex[0];   
2495   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2496   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2497                                               ycapacitorvertex);
2498   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2499   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2500   TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2501                                           fSSDAir);
2502 ////////////////////////////
2503 // Connector 
2504 ///////////////////////////
2505   const Int_t kssdconnectornumber = 2;
2506   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2507   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2508   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2509                                    +  fgkSSDConnectorAlHeight};  
2510   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2511   TGeoVolume* ssdconnector[kssdconnectornumber];
2512   for(Int_t i=0; i<kssdconnectornumber; i++){
2513       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2514                                           0.5*fgkSSDConnectorWidth,
2515                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2516                            +              i*fgkSSDConnectorNiHeight),
2517                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2518       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2519                                        i==0 ? fSSDAlTraceFlexMedium 
2520                                             : fSSDStiffenerConnectorMedium);      
2521       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2522   }
2523   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2524   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2525                        +  fgkSSDConnectorPosition[0]
2526                        -  fgkSSDConnectorSeparation
2527                        -  1.5*fgkSSDConnectorLength,
2528                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2529                        -  fgkSSDConnectorPosition[1]
2530                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2531   ssdconnectortrans[1] = new TGeoTranslation(
2532                        -  ssdstiffenershape->GetDX()
2533                        +  fgkSSDConnectorPosition[0]
2534                        -  0.5*fgkSSDConnectorLength,
2535                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2536                        -  fgkSSDConnectorPosition[1]
2537                        -  ssdconnectorshape[0]->GetDY(),0.0);
2538   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2539                        -  fgkSSDConnectorPosition[0]
2540                        +  fgkSSDConnectorSeparation
2541                        +  1.5*fgkSSDConnectorLength,
2542                           -(ssdstiffenershape->GetDY()
2543                        -  fgkSSDConnectorPosition[1]
2544                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2545   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2546                        -  fgkSSDConnectorPosition[0]
2547                        +  0.5*fgkSSDConnectorLength,
2548                           -(ssdstiffenershape->GetDY()
2549                        -  fgkSSDConnectorPosition[1]
2550                        -  ssdconnectorshape[0]->GetDY()),0.0);
2551   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2552       for(Int_t j=0; j<kssdconnectornumber; j++)
2553             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2554 ////////////////////////////
2555 // Capacitor 1812-330 nF
2556 /////////////////////////// 
2557   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2558   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2559                                                                                          0.5*fgkSSDCapacitor1812Length,
2560                                                                                          0.5*fgkSSDCapacitor1812Width,
2561                                                                                          0.5*fgkSSDCapacitor1812Height,
2562             ssdcapacitor1812origin);
2563   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2564                                              fSSDStiffener1812CapacitorMedium); 
2565   capacitor1812->SetLineColor(fColorAl);
2566   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2567                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2568                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2569   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2570 ////////////////////////////
2571 //Hybrid Wire
2572 ////////////////////////////
2573   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2574                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2575                                  - fgkSSDConnectorSeparation;
2576   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2577                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2578   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2579                                          + TMath::Power(wirey,2));
2580   Double_t wireangle = TMath::ATan(wirex/wirey);
2581   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2582                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2583   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2584                                              fSSDStiffenerHybridWireMedium); 
2585   hybridwire->SetLineColor(fColorPhynox);
2586   TGeoCombiTrans* hybridwirecombitrans[2];
2587   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2588                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2589                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2590                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2591                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2592                                    ssdstiffenershape->GetDZ()
2593                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2594                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2595   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2596                             0.0,
2597                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2598                             0.0,        
2599                             new TGeoRotation("HybridWireRot2",
2600                           - wireangle*TMath::RadToDeg(),0.,0.));
2601   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2602   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2603   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2604   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2605   ssdhybridlist->Add(ssdhybridcapacitormother);
2606   /////////////////////////////////////////////////////////////
2607   // Deallocating memory
2608   /////////////////////////////////////////////////////////////
2609   delete hybridwirecombitrans[0];
2610   delete hybridwirecombitrans[1];
2611   delete ssdchipsystemlist;
2612   return ssdhybridlist;
2613   /////////////////////////////////////////////////////////////
2614 }
2615 ///////////////////////////////////////////////////////////////////////////////
2616 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2617   /////////////////////////////////////////////////////////////
2618   // SSD Cooling Block System
2619   /////////////////////////////////////////////////////////////
2620   // SSD Cooling Block and Cooling Tube Transformations
2621   /////////////////////////////////////////////////////////////
2622   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2623   localcoolingblockrot->SetAngles(0.,90.,0.);
2624   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2625   TVector3* coolingblocktransvector;
2626   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2627                                                                 + fgkSSDCoolingBlockLength,
2628                                                                   fgkSSDSensorLength
2629                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2630                                                                 - fgkSSDCoolingBlockWidth);
2631   const Int_t kcoolingblocktransnumber = 2;
2632   const Int_t kcoolingblocknumber = 4;
2633   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2634   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2635   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2636   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2637   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2638   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2639                                         0.5*fgkSSDCoolingBlockWidth,
2640                                         fgkSSDCoolingBlockHoleCenter);
2641   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2642   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2643   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2644     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2645       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2646                                              j*coolingblocktransvector->Y(),
2647                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2648                                                     + fgkCoolingTubeRmax));
2649       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2650       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2651     }
2652   }
2653   /////////////////////////////////////////////////////////////
2654   // Virtual Volume containing CoolingBlock System   
2655   /////////////////////////////////////////////////////////////
2656   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2657   const Int_t kmothervertexnumber = 16;  
2658   Double_t xmothervertex[kmothervertexnumber];
2659   Double_t ymothervertex[kmothervertexnumber];
2660   ///////////////////////
2661   // Setting the vertices 
2662   ///////////////////////fgkCoolingTubeSupportRmax
2663   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2664   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2665                                    + fgkSSDCoolingBlockWidth;
2666   xmothervertex[2] = coolingblocktransvector->X()
2667                                    + fgkSSDCoolingBlockLength
2668                                    + 4*coolingtubedistance;
2669   ymothervertex[2] = ymothervertex[1];
2670   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2671   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2672   ymothervertex[4] = ymothervertex[0];
2673   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2674   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2675   ymothervertex[6] = ymothervertex[5]; 
2676   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2677                                    - fgkSSDCoolingBlockWidth; 
2678   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2679   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2680                                    - coolingtubedistance;
2681   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2682   ymothervertex[10] = ymothervertex[9];
2683   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2684   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2685   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2686   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2687   ymothervertex[14] = ymothervertex[13];
2688   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2689   //////////////////////////////////////////////////////////
2690   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2691                                                                         xmothervertex,ymothervertex);
2692   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2693                                                                                            + fgkCoolingTubeRmax));
2694   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2695                                                                                            + fgkCoolingTubeRmax));
2696   TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2697                                                           coolingsystemothershape,fSSDAir);
2698   /////////////////////////////////////////////////////////////
2699   // SSD Cooling Tube Part 
2700   /////////////////////////////////////////////////////////////
2701   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2702   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2703                                                                                  0.5*fgkSSDCoolingBlockWidth); 
2704   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2705                                                                          0.5*fgkSSDCoolingBlockWidth);
2706   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2707   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2708                                                                         fSSDCoolingTubePhynox);
2709   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2710                                                                         fSSDCoolingTubeWater);
2711   coolingtube[0]->SetLineColor(fColorPhynox);
2712   coolingtube[1]->SetLineColor(fColorWater);
2713   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2714   /////////////////////////////////////////////////////////////
2715   // Adding Cooling block to mother volume
2716   /////////////////////////////////////////////////////////////
2717    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2718         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2719         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2720         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2721   }
2722   /////////////////////////////////////////////////////////////
2723   // Deallocating memory
2724   /////////////////////////////////////////////////////////////
2725         delete coolingblocktransvector;
2726         delete localcoolingblockrot;
2727         delete localcoolingtubetrans;
2728         delete localcoolingtuberot;
2729   /////////////////////////////////////////////////////////////
2730   // Checking overlaps  
2731   /////////////////////////////////////////////////////////////
2732         //coolingsystemother->CheckOverlaps(0.01);
2733   /////////////////////////////////////////////////////////////
2734         return coolingsystemother;
2735 }
2736 /////////////////////////////////////////////////////////////////////////////////
2737 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2738   /////////////////////////////////////////////////////////////
2739   // SSD Flex
2740   /////////////////////////////////////////////////////////////
2741   const Int_t kssdflexlayernumber = 2;
2742   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2743   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2744   const Int_t kmothervertexnumber = 17; 
2745   Double_t xmothervertex[kmothervertexnumber];
2746   Double_t ymothervertex[kmothervertexnumber];
2747   /////////////////////////////////////////////
2748   // Auxiliary variables for vertex positioning
2749   /////////////////////////////////////////////
2750   const Int_t kssdflexboxnumber = 5;
2751   Double_t ssdflexboxlength[kssdflexboxnumber];
2752   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2753                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2754                                           *     fgkSSDChipSeparationLength
2755                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2756                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2757   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2758   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2759                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2760   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2761   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2762                                           -     ssdflexboxlength[1];
2763   Double_t ssdflexboxwidth[kssdflexboxnumber];
2764   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2765   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2766   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2767   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2768   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2769   ///////////////////////
2770   // Setting the vertices 
2771   ///////////////////////
2772   xmothervertex[0]  = 0.0;
2773   xmothervertex[1]  = xmothervertex[0];
2774   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2775   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2776                                         + ssdflexboxlength[4];
2777   xmothervertex[4]  = xmothervertex[3];
2778   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2779   xmothervertex[6]  = xmothervertex[5];
2780   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2781   xmothervertex[8]  = xmothervertex[7];
2782   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2783   xmothervertex[10] = xmothervertex[9]; 
2784   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2785   xmothervertex[12] = xmothervertex[11];
2786   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2787   xmothervertex[14] = xmothervertex[13];
2788   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2789   xmothervertex[16] = xmothervertex[15];
2790   ymothervertex[0]  = 0.0;
2791   ymothervertex[1]  = fgkSSDFlexWidth[1];
2792   ymothervertex[2]  = fgkSSDFlexWidth[0];
2793   ymothervertex[3]  = ymothervertex[2];
2794   ymothervertex[4]  = ymothervertex[0];
2795   ymothervertex[5]  = ymothervertex[4];
2796   ymothervertex[6]  = ssdflexboxwidth[2];
2797   ymothervertex[7]  = ymothervertex[6];
2798   ymothervertex[8]  = ymothervertex[0];
2799   ymothervertex[9]  = ymothervertex[8];
2800   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2801   ymothervertex[11] = ymothervertex[10];
2802   ymothervertex[12] = ymothervertex[0];
2803   ymothervertex[13] = ymothervertex[12];
2804   ymothervertex[14] = ymothervertex[7];
2805   ymothervertex[15] = ymothervertex[14];
2806   ymothervertex[16] = ymothervertex[0];
2807   /////////////////////////////////////////////////////////////
2808   // First Mother Volume containing SSDFlex
2809   /////////////////////////////////////////////////////////////
2810   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2811   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2812                                                                     ymothervertex);
2813   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2814   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2815   TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2816                                                                                          fSSDAir);
2817   /////////////////////////////////////////////////////////////
2818   // SSDFlex Layer Shapes
2819   /////////////////////////////////////////////////////////////
2820   for(Int_t i=0; i<kssdflexlayernumber; i++){
2821         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2822                                                                    ymothervertex);
2823     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2824         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2825   }
2826   /////////////////////////////////////
2827   // Setting Layers into Mother Volume
2828   /////////////////////////////////////
2829   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2830   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2831                                                                                                  fSSDKaptonFlexMedium};
2832   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2833                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2834   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2835   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2836   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2837         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2838                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2839                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2840         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2841     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2842                                          +                                         fgkSSDFlexHeight[1])); 
2843     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2844   }
2845   //ssdflexmother->CheckOverlaps(0.01);
2846   return ssdflexmother;
2847 }
2848 /////////////////////////////////////////////////////////////////////////////////
2849 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2850   /////////////////////////////////////////////////////////////
2851   // Method generating SSD End Flex   
2852   /////////////////////////////////////////
2853   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2854                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2855   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2856                                                 * TMath::DegToRad()*ssdflexradiusmax
2857                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2858                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2859   const Int_t knedges = 20;  
2860   const Int_t karcnumber = 2;
2861   TVector3* vertexposition[karcnumber*(knedges+1)];
2862   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2863   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2864   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2865   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2866                                                                                  - 90.0*TMath::DegToRad()};
2867   TVector3* referencetrans[karcnumber];
2868   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2869                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2870                                                                    radius[0]);
2871   referencetrans[1] = new TVector3(referencetrans[0]->X()
2872                                         +              fgkSSDFlexLength[2],
2873      -              fgkSSDStiffenerHeight);
2874 for(Int_t i=0; i<karcnumber; i++){
2875         for(Int_t j=0; j<knedges+1; j++){
2876                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2877                                                                                                radius[i]*SinD(angle[i]));
2878                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2879         }       
2880   }
2881   ///////////////////////
2882   // Setting the vertices 
2883   ///////////////////////
2884   const Int_t kendflexlayernumber = 4;
2885   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2886   TVector3** vertex[kendflexlayernumber];
2887   for(Int_t i=0; i<kendflexlayernumber; i++) 
2888                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2889   TVector3* transvector[kendflexlayernumber+1];
2890   TVector3* deltatransvector = new TVector3();  
2891   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2892   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2893                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2894   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2895         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2896                                         *                 CosD(fgkSSDFlexAngle),
2897                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2898                                         *         SinD(fgkSSDFlexAngle),0.0);   
2899         *transvector[i] = *transvector[i-1]+*deltatransvector;
2900   }
2901   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2902   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2903   for(Int_t i=0; i<karcnumber; i++){
2904         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2905                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2906                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2907                                               /radius[i];
2908         }
2909   }
2910   for(Int_t i=0; i<kendflexlayernumber; i++){
2911         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2912         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2913         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2914                 if(j<(knedges+1)){
2915                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2916                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2917                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2918                         *vertex[i][j+2] += *referencetrans[0];
2919                         vertex[i][4*(knedges+1)-j+1] = 
2920                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2921                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2922                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2923                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2924                 }
2925                 else{
2926                 
2927                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2928                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2929                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2930                         *vertex[i][j+2] += *referencetrans[1];
2931                         vertex[i][4*(knedges+1)-j+1] = 
2932                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2933                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2934                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2935                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2936            }
2937         }
2938   }
2939   /////////////////////////////////////////////////////////////
2940   // First Mother Volume containing SSDEndFlex
2941   /////////////////////////////////////////////////////////////
2942   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2943   Double_t xmothervertex[kendflexvertexnumber];
2944   Double_t ymothervertex[kendflexvertexnumber];
2945   xmothervertex[0] = vertex[0][0]->X(); 
2946   ymothervertex[0] = vertex[0][0]->Y();
2947   for(Int_t i=1; i<kendflexvertexnumber; i++){
2948         if(i<2*(knedges+1)+2){
2949                 xmothervertex[i] = vertex[3][i]->X();
2950                 ymothervertex[i] = vertex[3][i]->Y();
2951         }
2952         else{
2953                 xmothervertex[i] = vertex[0][i]->X();
2954                 ymothervertex[i] = vertex[0][i]->Y();
2955         }
2956   }
2957   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2958                                                                            xmothervertex,ymothervertex);
2959   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2960   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2961   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2962                                                                  ssdendflexmothershape,fSSDAir);        
2963   //////////////////////////////////////
2964   // End Flex TGeoXtru Layer Definition 
2965   //////////////////////////////////////
2966   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2967   TGeoVolume* ssdendflex[kendflexlayernumber];
2968   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2969   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2970   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2971   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2972   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2973                                                                                                         fSSDKaptonFlexMedium};
2974   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2975                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2976   for(Int_t i=0; i<kendflexlayernumber; i++){
2977         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2978                 xvertex[i][j] = vertex[i][j]->X();
2979                 yvertex[i][j] = vertex[i][j]->Y();
2980         }
2981   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2982   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2983   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2984   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2985                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2986   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2987   ssdendflexmother->AddNode(ssdendflex[i],1);
2988   }
2989   /////////////////////////////////////////////////////////////
2990   // Deallocating memory
2991   /////////////////////////////////////////////////////////////
2992   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2993   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2994   for(Int_t i=0; i<kendflexlayernumber; i++){
2995         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2996         delete [] vertex[i];
2997   }
2998   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2999   delete deltatransvector;
3000   /////////////////////////////////////////////////////////////
3001   //ssdendflexmother->CheckOverlaps(0.01);
3002   return ssdendflexmother;
3003 }
3004 ///////////////////////////////////////////////////////////////////////////////
3005 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3006   /////////////////////////////////////////////////////////////
3007   // Method generating the Mounting Block
3008   /////////////////////////////////////////////////////////////  
3009   const Int_t kvertexnumber = 8;
3010   Double_t xvertex[kvertexnumber];
3011   Double_t yvertex[kvertexnumber];
3012   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3013   xvertex[1] = xvertex[0];
3014   xvertex[2] = -xvertex[0];
3015   xvertex[3] = xvertex[2];
3016   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3017                          -                                 fgkSSDMountingBlockLength[2]);
3018   xvertex[5] = xvertex[4];
3019   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3020                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3021                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3022   xvertex[7] = xvertex[6];
3023   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3024                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3025                          -  fgkSSDModuleVerticalDisalignment;
3026   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3027   yvertex[2] = yvertex[1]; 
3028   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3029   yvertex[4] = yvertex[3];
3030   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3031                          - fgkSSDMountingBlockHeight[0];
3032   yvertex[6] = yvertex[5];
3033   yvertex[7] = yvertex[0];
3034   ///////////////////////////////////////////////////////////////////////
3035   // TGeoXTru Volume definition for Mounting Block Part
3036   ///////////////////////////////////////////////////////////////////////
3037   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3038   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3039   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3040   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3041   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3042                                                                           ssdmountingblockshape,
3043                                                                                   fSSDMountingBlockMedium);
3044   ssdmountingblock->SetLineColor(fColorG10);
3045   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3046   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3047   TGeoRotation* mountingblockrot = new TGeoRotation();
3048   mountingblockrot->SetAngles(90.,180.,-90.);
3049   mountingblockcombitrans->SetRotation(*mountingblockrot);
3050   /////////////////////////////////////////////////////////////
3051   // Generating the Mounting Block Screw Vertices 
3052   /////////////////////////////////////////////////////////////  
3053   const Int_t kscrewvertexnumber = 15;
3054   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3055                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3056                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3057                                  * TMath::RadToDeg();
3058   Double_t phi0 = 90.+alpha;
3059   Double_t phi = 270.-2*alpha;
3060   Double_t deltaphi = phi/kscrewvertexnumber;   
3061   TVector3* screwvertex[kscrewvertexnumber+1];
3062   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3063         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3064                                    *CosD(phi0+i*deltaphi),
3065                                    fgkSSDMountingBlockScrewHoleRadius[0]
3066                                    *SinD(phi0+i*deltaphi));
3067   Double_t xscrewvertex[kscrewvertexnumber+6];
3068   Double_t yscrewvertex[kscrewvertexnumber+6];
3069   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3070   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3071                                   -               fgkSSDMountingBlockScrewHoleEdge);
3072   xscrewvertex[1] = xscrewvertex[0];
3073   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3074   xscrewvertex[2] = screwvertex[0]->X();
3075   yscrewvertex[2] = yscrewvertex[1];
3076   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3077         xscrewvertex[i+3] = screwvertex[i]->X();        
3078         yscrewvertex[i+3] = screwvertex[i]->Y();        
3079   } 
3080   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3081   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3082   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3083   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3084   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3085   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3086   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3087   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3088                                                         +                                  fgkSSDMountingBlockHeight[2]);
3089   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3090                                                                                 ssdmountingblockscrewshape,
3091                                                                                             fSSDMountingBlockMedium);
3092   ssdmountingblockscrew->SetLineColor(fColorG10);
3093   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3094   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3095   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3096                                                                         -                                yscrewvertex[1],
3097                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3098                                                                         -                                fgkSSDMountingBlockHeight[2]
3099                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3100                                                                         +                                fgkSSDMountingBlockHeight[2]
3101                                                                         -                                yvertex[0]));
3102   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3103                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3104                                                                                                                  yscrewvertex[1]
3105                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3106                                                                                                          +fgkSSDMountingBlockHeight[2]
3107                                                                                                          -yvertex[0]));
3108   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3109                                                                                                           yscrewvertex[1],
3110                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3111                                                                         +                                 fgkSSDMountingBlockHeight[2]
3112                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3113                                                                         +                                 fgkSSDMountingBlockHeight[2]
3114                                                                         -                                 yvertex[0]));
3115   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3116                                                                                                          yscrewvertex[1],
3117                                                                         -                                yscrewvertex[1]
3118                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3119                                                                         +                                fgkSSDMountingBlockHeight[2]
3120                                                                         -                                yvertex[0]));
3121   TGeoRotation* ssdmountingblockscrewrot[4];
3122   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3123         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3124     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3125     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3126   for(Int_t i=1; i<4; i++) 
3127         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3128   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3129   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3130   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3131   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3132                                                          +                                xvertex[0],yscrewvertex[1]
3133                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3134                                                          +                                fgkSSDMountingBlockHeight[2]
3135                                                          -                                yvertex[0]),0.);      
3136   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3137   for(Int_t i=0; i<4; i++){
3138         ssdmountingblockscrewmatrix[i] = 
3139                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3140         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3141   }
3142   ///////////////////////////////////////////////////////////////////////
3143   // TGeoXtru for Mother Volume 
3144   ///////////////////////////////////////////////////////////////////////
3145   const Int_t kvertexmothernumber = 12;
3146   Double_t xmothervertex[kvertexmothernumber];
3147   Double_t ymothervertex[kvertexmothernumber];
3148   for(Int_t i=0; i<6; i++){
3149         xmothervertex[i] = xvertex[i];
3150         ymothervertex[i] = yvertex[i];
3151   } 
3152   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3153   ymothervertex[6]  = ymothervertex[5];
3154   xmothervertex[7]  = xmothervertex[6];
3155   ymothervertex[7]  = ymothervertex[4];
3156   xmothervertex[8]  = xmothervertex[7]
3157                                         + 0.5*(fgkSSDMountingBlockLength[1]
3158                                         -          fgkSSDMountingBlockLength[2]);
3159   ymothervertex[8]  = ymothervertex[4];
3160   xmothervertex[9]  = xmothervertex[8];
3161   ymothervertex[9]  = ymothervertex[2];
3162   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3163   ymothervertex[10] = ymothervertex[1];
3164   xmothervertex[11] = xmothervertex[10];
3165   ymothervertex[11] = ymothervertex[0];  
3166   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3167   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3168   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3169   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3170   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3171                                                                           ssdmountingblockmothershape,
3172                                                                                   fSSDAir);
3173   /////////////////////////////////////////////////////////////
3174   // Placing the Volumes into Mother Volume 
3175   /////////////////////////////////////////////////////////////
3176   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3177   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3178   for(Int_t i=0; i<4; i++) 
3179         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3180                                                                         ssdmountingblockscrewmatrix[i]);
3181   /////////////////////////////////////////////////////////////
3182   // Deallocating memory
3183   /////////////////////////////////////////////////////////////
3184   delete mountingblockrot;
3185   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3186   delete ssdmountingblockglobalrot; 
3187   delete ssdmountingblockglobaltrans; 
3188   /////////////////////////////////////////////////////////////
3189   return ssdmountingblockmother;
3190 }
3191 ///////////////////////////////////////////////////////////////////////////////
3192  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3193   /////////////////////////////////////////////////////////////
3194   // Method generating the Mounting Block Clip 
3195   /////////////////////////////////////////////////////////////  
3196   const Int_t kmothervertexnumber = 10;
3197   Double_t xmothervertex[kmothervertexnumber];
3198   Double_t ymothervertex[kmothervertexnumber];
3199   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3200                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3201   xmothervertex[1] = xmothervertex[0];
3202   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3203                                    - fgkMountingBlockClibScrewRadius);
3204   xmothervertex[3] = xmothervertex[2]; 
3205   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3206   xmothervertex[5] = xmothervertex[4]; 
3207   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3208   xmothervertex[7] = xmothervertex[6]; 
3209   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3210   xmothervertex[9] = xmothervertex[8]; 
3211   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3212                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3213                                    - fgkSSDModuleVerticalDisalignment;
3214   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3215   ymothervertex[2] = ymothervertex[1];
3216   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3217                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3218                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3219   ymothervertex[4] = ymothervertex[3];
3220   ymothervertex[5] = ymothervertex[2];
3221   ymothervertex[6] = ymothervertex[5];
3222   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3223   ymothervertex[8] = ymothervertex[7];
3224   ymothervertex[9] = ymothervertex[0];
3225   ///////////////////////////////////////////////////////////////////////
3226   // TGeoXTru Volume definition for Mounting Block Clip Part
3227   ///////////////////////////////////////////////////////////////////////
3228   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3229   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3230   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3231   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3232   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3233                                                                           ssdmountingblockclipshape,fSSDAir);
3234   ssdmountingblockclip->SetLineColor(4);
3235   ///////////////////////////////////////////////////////////////////////
3236   // TGeoXTru Volume definition for Clip 
3237   ///////////////////////////////////////////////////////////////////////
3238   const Int_t kclipvertexnumber = 6;
3239   Double_t xclipvertex[kclipvertexnumber];
3240   Double_t yclipvertex[kclipvertexnumber];
3241   xclipvertex[0] = xmothervertex[0];
3242   xclipvertex[1] = xclipvertex[0];
3243   xclipvertex[2] = xmothervertex[6];
3244   xclipvertex[3] = xclipvertex[2];
3245   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3246   xclipvertex[5] = xclipvertex[4];
3247   yclipvertex[0] = ymothervertex[0];
3248   yclipvertex[1] = ymothervertex[1];
3249   yclipvertex[2] = yclipvertex[1];
3250   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3251   yclipvertex[4] = yclipvertex[3];
3252   yclipvertex[5] = yclipvertex[0];
3253   TGeoXtru* clipshape = new TGeoXtru(2);
3254   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3255   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3256   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3257                                                          +   fgkMountingBlockClibWidth);
3258   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3259   clip->SetLineColor(18);
3260   ///////////////////////////////////////////////////////////////////////
3261   // Ladder Support Piece  
3262   ///////////////////////////////////////////////////////////////////////
3263   const Int_t ksupportvertexnumber = 4;
3264   Double_t xsupportvertex[ksupportvertexnumber];
3265   Double_t ysupportvertex[ksupportvertexnumber];
3266   xsupportvertex[0] = xclipvertex[5];
3267   xsupportvertex[1] = xsupportvertex[0];
3268   xsupportvertex[2] = xmothervertex[9];
3269   xsupportvertex[3] = xsupportvertex[2];
3270   ysupportvertex[0] = yclipvertex[0];
3271   ysupportvertex[1] = yclipvertex[3];
3272   ysupportvertex[2] = ysupportvertex[1];
3273   ysupportvertex[3] = ysupportvertex[0];
3274   TGeoXtru* supportshape = new TGeoXtru(2);
3275   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3276   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3277   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3278   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3279   support->SetLineColor(9);
3280   ///////////////////////////////////////////////////////////////////////
3281   // TGeoXTru Volume definition for Screw   
3282   ///////////////////////////////////////////////////////////////////////
3283   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3284                                                 0.5*fgkMountingBlockClibScrewRadius};
3285   Int_t edgesnumber[2] = {50,6};
3286   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3287                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3288   TGeoXtru* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3289   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3290   clipscrew->SetLineColor(12);
3291   TGeoRotation* screwrot = new TGeoRotation();
3292   screwrot->SetAngles(0.,90.,0.);
3293   TGeoTranslation* screwtrans = new TGeoTranslation();
3294   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3295                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3296                                                          0.5*fgkSSDMountingBlockWidth+
3297                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3298   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3299   ///////////////////////////////////////////////////////////////////////
3300   // Placing the Volumes
3301   ///////////////////////////////////////////////////////////////////////
3302   ssdmountingblockclip->AddNode(clip,1);
3303   ssdmountingblockclip->AddNode(support,1);
3304   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3305   /////////////////////////////////////////////////////////////
3306   // Deallocating memory
3307   /////////////////////////////////////////////////////////////  
3308   delete screwtrans;
3309   delete screwrot;
3310   /////////////////////////////////////////////////////////////
3311   return ssdmountingblockclip;
3312 }
3313 ///////////////////////////////////////////////////////////////////////////////
3314 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3315   /////////////////////////////////////////////////////////////
3316   // Method generating the Cooling Tube 
3317   /////////////////////////////////////////////////////////////  
3318    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3319    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3320                                                                                                 new     TGeoTube*[2];
3321    // Ladder Cooling Tubes
3322    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3323                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3324                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth));
3325    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3326                                                                                  coolingtubeshape[0][0]->GetDz());
3327    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3328                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3329                                                   -                                       fgkSSDSensorOverlap));
3330    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3331                                                                                  coolingtubeshape[1][0]->GetDz());
3332    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3333                                                                                  0.5*fgkSSDModuleStiffenerPosition[1]);
3334    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3335                                                                                  coolingtubeshape[2][0]->GetDz());
3336    // End Ladder Cooling Tubes  
3337    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3338    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3339         endladdercoolingtubeshape[i] = new      TGeoTube*[2];
3340    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3342                                                   -                     fgkendladdercoolingsupportdistance[0]));
3343    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3344                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3345    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3346                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3347                                                   +                     fgkendladdercoolingsupportdistance[1]
3348                                                   -                     fgkCoolingTubeSupportWidth));
3349    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3350                                                                         endladdercoolingtubeshape[1][0]->GetDz());
3351    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3352                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3353                                                   -                     fgkEndLadderMountingBlockPosition[0]
3354                                                   -                     fgkendladdercoolingsupportdistance[1]           
3355                                                   -                     fgkCoolingTubeSupportWidth));
3356    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3357                                                                         endladdercoolingtubeshape[2][0]->GetDz());
3358    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3359                                                           0.50 * (fgkMountingBlockToSensorSupport
3360                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3361                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3362                                                         +                 fgkSSDSensorOverlap
3363                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3364                                                         -                 fgkendladdercoolingsupportdistance[2]
3365                                                         -                 fgkEndLadderMountingBlockPosition[1]
3366                                                         -                 fgkCoolingTubeSupportWidth));
3367    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3368                                                                         endladdercoolingtubeshape[3][0]->GetDz());
3369    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3370                                                           0.50 * fgkendladdercoolingsupportdistance[2]);
3371    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3372                                                                         endladdercoolingtubeshape[4][0]->GetDz());
3373    // Ladder Cooling Tubes
3374    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3375    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3376                                                                                          new TGeoVolume*[2];
3377    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3378                                                                           fSSDCoolingTubePhynox);
3379    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3380                                                                           fSSDCoolingTubeWater);
3381    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3382                                                                           fSSDCoolingTubePhynox);
3383    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3384                                                                           fSSDCoolingTubeWater);
3385    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3386                                                                           fSSDCoolingTubePhynox);
3387    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3388                                                                           fSSDCoolingTubeWater);
3389    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3390         coolingtube[i][0]->SetLineColor(fColorPhynox);
3391         coolingtube[i][1]->SetLineColor(fColorWater);
3392    }
3393    // End Ladder Cooling Tubes  
3394    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3395    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3396    endladdercoolingtube[i] = new TGeoVolume*[2];
3397    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3398                                                                 endladdercoolingtubeshape[0][0],
3399                                                                 fSSDCoolingTubePhynox);
3400    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3401                                                                 endladdercoolingtubeshape[0][1],
3402                                                                 fSSDCoolingTubeWater);
3403    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3404                                                                 endladdercoolingtubeshape[1][0],
3405                                                                 fSSDCoolingTubePhynox);
3406    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3407                                                                 endladdercoolingtubeshape[1][1],
3408                                                                 fSSDCoolingTubeWater);
3409    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3410                                                                 endladdercoolingtubeshape[2][0],
3411                                                                 fSSDCoolingTubePhynox);
3412    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3413                                                                 endladdercoolingtubeshape[2][1],
3414                                                                 fSSDCoolingTubeWater);
3415    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3416                                                                 endladdercoolingtubeshape[3][0],
3417                                                                 fSSDCoolingTubePhynox);
3418    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3419                                                                 endladdercoolingtubeshape[3][1],
3420                                                                 fSSDCoolingTubeWater);
3421    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3422                                                                 endladdercoolingtubeshape[4][0],
3423                                                                 fSSDCoolingTubePhynox);
3424    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3425                                                                 endladdercoolingtubeshape[4][1],
3426                                                                 fSSDCoolingTubeWater);
3427    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3428         endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3429         endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3430    }
3431   /////////////////////////////////////////////////////////////
3432   // Virtual Volume containing Cooling Tubes
3433   /////////////////////////////////////////////////////////////
3434   // Ladder Cooling Tubes
3435   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3436   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3437   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3438                                                                                         coolingtubeshape[i][0]->GetRmax(),
3439                                                                                         coolingtubeshape[i][0]->GetDz());
3440   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3441   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3442                                                                           fSSDAir);
3443   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3444                                                                           fSSDAir);
3445   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3446                                                                           fSSDAir);
3447   // End Ladder Cooling Tubes
3448   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3449   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3450   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3451                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3452                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3453   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3454   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3455                                                                           endladdervirtualcoolingtubeshape[0],
3456                                                                           fSSDAir);
3457   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3458                                                                           endladdervirtualcoolingtubeshape[1],
3459                                                                           fSSDAir);
3460   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3461                                                                           endladdervirtualcoolingtubeshape[2],
3462                                                                           fSSDAir);
3463   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3464                                                                           endladdervirtualcoolingtubeshape[3],
3465                                                                           fSSDAir);
3466   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3467                                                                           endladdervirtualcoolingtubeshape[4],
3468                                                                           fSSDAir);
3469   TList* coolingtubelist = new TList();
3470   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3471         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3472         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3473     coolingtubelist->Add(virtualcoolingtube[i]);
3474   }
3475         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3476         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3477     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3478         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3479         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3480     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3481         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3482         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3483     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3484         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3485         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3486     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3487         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3488         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3489     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3490   return coolingtubelist;
3491 }
3492 ///////////////////////////////////////////////////////////////////////////////
3493 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3494   /////////////////////////////////////////////////////////////
3495   // Method generating SSD Cooling Block    
3496   /////////////////////////////////////////////////////////////
3497   const Int_t kvertexnumber = 8;
3498   ///////////////////////////////////////
3499   // Vertex Positioning for TGeoXTru
3500   ///////////////////////////////////////
3501   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3502   vertexposition[0] = new TVector3(0.0,0.0);
3503   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3504   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3505                                           vertexposition[1]->Y());
3506   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3507                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3508   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3509   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3510                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3511   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3512                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3513                                         - fgkSSDCoolingBlockHoleLength[0]
3514                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3515                                           fgkSSDCoolingBlockHeight[0]
3516                                         - fgkSSDCoolingBlockHoleRadius[1],
3517                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3518   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3519                                         - fgkSSDCoolingBlockHoleLength[0]),
3520                                           vertexposition[6]->Y());
3521   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3522                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3523   Double_t phi = 180.-alpha;
3524   Double_t psi = 180.+2.*alpha;
3525   Double_t deltapsi = psi/nedges;
3526   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3527   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3528                                                   fgkSSDCoolingBlockHoleCenter);
3529   for(Int_t i=0; i<nedges+1; i++){
3530         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3531                                                                                                radius*SinD(phi+i*deltapsi));
3532    *vertexposition[kvertexnumber+i] += (*transvector);
3533   }
3534   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3535   for(Int_t i=0; i<kvertexnumber; i++)
3536     vertexposition[kvertexnumber+nedges+1+i] = 
3537                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3538   ///////////////////////////////////////////////////////////////////////
3539   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3540   ///////////////////////////////////////////////////////////////////////
3541   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3542   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3543   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3544   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3545         xvertexpoints[i] = vertexposition[i]->X();
3546         yvertexpoints[i] = vertexposition[i]->Y();
3547   } 
3548   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3549                                                                                         yvertexpoints);
3550   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3551   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3552   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3553                                                                           ssdcoolingblockshape,
3554                                                                                   fSSDAlCoolBlockMedium);
3555   ssdcoolingblock->SetLineColor(fColorAl);
3556   /////////////////////////////////////////////////////////////
3557   // Deallocating memory
3558   /////////////////////////////////////////////////////////////
3559   delete [] vertexposition;
3560   delete xvertexpoints;
3561   delete yvertexpoints;
3562   /////////////////////////////////////////////////////////////
3563   return ssdcoolingblock;
3564 }
3565 /////////////////////////////////////////////////////////////////////////////////
3566 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3567   ///////////////////////////////////////////////////////
3568   const Int_t kssdchipcablesnumber    = 2;
3569   const Int_t kssdchipcableslaynumber = 2;
3570   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3571   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3572   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3573   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3574                                                  -  fgkSSDChipCablesHeight[0]
3575                                                  -  fgkSSDChipCablesHeight[1]);
3576   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3577   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3578   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3579                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3580                                                           - ssdchipcablesradius[0]
3581                                                           - fgkSSDChipCablesWidth[1]
3582                                                           - fgkSSDChipCablesWidth[2]);
3583   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3584                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3585                                                           +      fgkSSDChipCablesHeight[1]
3586                                                           +      fgkSSDSensorHeight);
3587   ///////////////////////////////////////////////////////
3588   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3589   ///////////////////////////////////////////////////////
3590   TVector3** vertexposition[kssdchipcableslaynumber];
3591   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3592                                                                                                   new TVector3*[4*(nedges+1)+4];
3593   Double_t ratio[4];
3594   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3595   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3596                    /  ssdchipcablesradius[0]; 
3597   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3598                    /  ssdchipcablesradius[0];
3599   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3600                    +  fgkSSDChipCablesHeight[1])
3601                    /  ssdchipcablesradius[0];
3602   Double_t phi = 180.;
3603   Double_t deltaphi = 180./nedges;
3604   Double_t angle = 0.0;
3605   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3606   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3607   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3608         xvertexpoints[i] = new Double_t[kvertexnumber];
3609         yvertexpoints[i] = new Double_t[kvertexnumber];
3610   }  
3611   TVector3* vertex = new TVector3();
3612   TVector3* transvector[kssdchipcableslaynumber];
3613   transvector[0] = new TVector3(fgkSSDChipWidth,
3614                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3615   transvector[1] = new TVector3();
3616   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3617   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3618   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3619                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3620                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3621   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3622         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3623         transvector[1]->SetY(ssdchipcablesradius[0]
3624                                  +               fgkSSDChipCablesHeight[0]
3625                                  +               fgkSSDChipCablesHeight[1]);  
3626         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3627                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3628                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3629                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3630                                                          - i*fgkSSDChipCablesHeight[0]);
3631                 vertexposition[i][2*(nedges+1)+2] = 
3632                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3633                                 +                                fgkSSDChipCablesWidth[1]
3634                                 +                                fgkSSDChipCablesWidth[2],
3635                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3636                                 +                                fgkSSDChipCablesHeight[1]));
3637         vertexposition[i][2*(nedges+1)+3] = 
3638                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3639                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3640                                 -                                fgkSSDChipCablesHeight[i]);
3641             for(Int_t j=0; j<nedges+1; j++){            
3642                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3643                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3644                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3645                         vertexposition[0][(nedges+1)*i+j+2] = 
3646                                                 new TVector3(*vertex+*transvector[i]);
3647                         vertexposition[1][(nedges+1)*i+j+2] = 
3648                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3649                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3650                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3651                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3652                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3653                                                 new TVector3(vertex->X()*ratio[2*i+1]
3654                                                         +                        transvector[i]->X(),
3655                                                                                  vertex->Y()*ratio[2*i+1]
3656                                                         +                transvector[i]->Y());
3657                 }
3658         }
3659         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3660                 for(Int_t j=0; j<kvertexnumber; j++){   
3661                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3662                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3663                 }
3664                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3665                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3666                                                                                 xvertexpoints[i],yvertexpoints[i]);
3667                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3668                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3669                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3670                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3671                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3672                                                           (kssdchipcablesnumber*k+i)%2==0?
3673                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3674                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3675         }
3676         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3677                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3678   }
3679   /////////////////////////////////////////////////////////////
3680   // Mother Volume definition 
3681   /////////////////////////////////////////////////////////////
3682   Double_t ssdchipseparation = fgkSSDSensorLength
3683                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3684                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3685                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3686   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3687   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3688                                                           +fgkSSDChipCablesWidth[1]
3689                                                           +fgkSSDChipCablesWidth[2]);
3690   Double_t dy = fgkSSDChipCablesLength[1];
3691   Double_t dz = SSDChipCablesHeigth;
3692   TGeoBBox* ssdchipcablesmotherbox = new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3693   TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3694                           ssdchipcablesmotherbox,fSSDAir);
3695   /////////////////////////////////////////////////////////////
3696   // Rotation and Translation Definition for positioning 
3697   /////////////////////////////////////////////////////////////
3698   TGeoRotation* ssdchipcablesrot[5];
3699   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3700   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3701   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3702   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3703   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3704   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3705                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3706   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3707   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3708   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3709   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3710   /////////////////////////////////////////////////////////////
3711   // Deallocating memory
3712   /////////////////////////////////////////////////////////////
3713   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3714         delete [] xvertexpoints[i];
3715         delete [] yvertexpoints[i];
3716   }
3717   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3718   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3719   delete vertex; 
3720   delete ssdchipcablesrot[0];
3721   delete ssdchipcablesrot[1];
3722   delete ssdchipcablesrot[3];
3723   /////////////////////////////////////////////////////////////
3724   return ssdchipcablesmother;
3725 }
3726 ///////////////////////////////////////////////////////////////////////////////
3727 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3728   /////////////////////////////////////////////////////////////
3729   // SSD Chip Assembly
3730   /////////////////////////////////////////////////////////////
3731   TGeoVolume* ssdchipassembly = GetSSDChips();
3732   TList* ssdchipsystemlist = new TList();
3733 //  const Int_t knedges = 20;
3734   const Int_t knedges = 5;
3735   const Int_t kchipsystemnumber = 2;
3736   /////////////////////////////////////////////////////////////
3737   // Mother Volume containing SSDChipSystem
3738   /////////////////////////////////////////////////////////////
3739   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3740   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3741   const Int_t kmothervertexnumber = 12;  
3742   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3743   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3744   Double_t ssdchipcablesradius[kchipsystemnumber];
3745   Double_t ssdchipseparation = fgkSSDSensorLength
3746                              - 2.*fgkSSDModuleStiffenerPosition[1]
3747                              - 2.*(fgkSSDStiffenerWidth
3748                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3749   for(Int_t i=0; i<kchipsystemnumber; i++)
3750         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3751                                                    -  fgkSSDChipCablesHeight[0]
3752                                                    -  fgkSSDChipCablesHeight[1]);
3753   ///////////////////////
3754   // Setting the vertices 
3755   ///////////////////////
3756   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3757   xmothervertex[0][1]  = xmothervertex[0][0];  
3758   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3759                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3760   xmothervertex[0][3]  = xmothervertex[0][2];  
3761   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3762   xmothervertex[0][5]  = xmothervertex[0][4];  
3763   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3764   xmothervertex[0][7]  = xmothervertex[0][6]; 
3765   xmothervertex[0][8]  = 0.0;  
3766   xmothervertex[0][9]  = xmothervertex[0][8];  
3767   xmothervertex[0][10] = xmothervertex[0][4];  
3768   xmothervertex[0][11] = xmothervertex[0][10];  
3769   for(Int_t i=0; i<kmothervertexnumber; i++) 
3770         xmothervertex[1][i] = xmothervertex[0][i]; 
3771   for(Int_t i=0; i<kchipsystemnumber; i++){
3772         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3773                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3774         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3775         ymothervertex[i][2]  = ymothervertex[i][1];
3776         ymothervertex[i][3]  = ymothervertex[i][0];
3777         ymothervertex[i][4]  = ymothervertex[i][0];
3778         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3779         ymothervertex[i][6]  = ymothervertex[i][5];
3780         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3781         ymothervertex[i][8]  = ymothervertex[i][7];
3782         ymothervertex[i][9]  = ymothervertex[i][5];
3783         ymothervertex[i][10] = ymothervertex[i][5];
3784         ymothervertex[i][11] = ymothervertex[i][4];
3785   }
3786   //////////////////////////////////////////////////////////
3787   TGeoVolume* chipsystemother[kchipsystemnumber];
3788   const char* chipsytemothername[kchipsystemnumber] = 
3789                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3790   for(Int_t i=0; i<kchipsystemnumber; i++){
3791     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3792                                                                         xmothervertex[i],ymothervertex[i]);
3793     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3794                                                                                   -0.5*fgkSSDChipHeight);
3795     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3796     chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3797                                                           chipsystemothershape[i],fSSDAir);
3798   }
3799   /////////////////////////////////////////////////////////////
3800   // SSD Chip Cables
3801   /////////////////////////////////////////////////////////////
3802   TGeoVolume* ssdchipcables[kchipsystemnumber];
3803   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3804   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3805   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3806   //////////////////
3807   for(Int_t i=0; i<kchipsystemnumber; i++){
3808                 ssdchipcables[i] = 
3809                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3810                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3811                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3812                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3813   }
3814   for(Int_t i=0; i<kchipsystemnumber; i++){
3815         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3816                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3817                 ssdchipcablesrot[i][j] = new TGeoRotation();
3818                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3819                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3820                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3821                                                   +                fgkSSDChipSeparationLength),
3822                                                                                         0.5*fgkSSDChipWidth,
3823                                                   -                                     0.5*fgkSSDChipHeight
3824                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3825                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3826                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3827                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3828         }
3829         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3830         ssdchipsystemlist->Add(chipsystemother[i]);     
3831   }
3832   /////////////////////////////////////////////////////////////
3833   // Deallocating memory
3834   /////////////////////////////////////////////////////////////
3835   for(Int_t i=0; i<kchipsystemnumber; i++){
3836         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3837                 delete ssdchipcablesrot[i][j];
3838                 delete ssdchipcablestrans[i][j];
3839         }
3840         delete ssdchipcablesrot[i];
3841         delete ssdchipcablestrans[i];
3842   }
3843   /////////////////////////////////////////////////////////////
3844   return ssdchipsystemlist;
3845 }
3846 ///////////////////////////////////////////////////////////////////////////////
3847 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3848   /////////////////////////////////////////////////////////////
3849   // SSD Chip Assembly Generation    
3850   /////////////////////////////////////////////////////////////
3851   const Int_t kssdchiprownumber = 2;
3852   TGeoBBox* ssdchipcompshape[2];
3853   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3854                                                                                 0.5*fgkSSDChipLength,
3855                                                                                 0.5*fgkSSDChipWidth,
3856                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3857   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3858                                                                                 0.5*fgkSSDChipLength,
3859                                                                                 0.5*fgkSSDChipWidth,
3860                                                                                 0.5*fgkSSDChipGlueHeight);
3861   TGeoVolume* ssdchipcomp[2];
3862   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3863   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3864                                                                   fSSDChipGlueMedium);
3865   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3866   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3867   TGeoTranslation* ssdchipcomptrans[2];
3868   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3869   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3870   /////////////////////////////////////////////////////////////
3871   // Virtual Volume containing SSDChip   
3872   /////////////////////////////////////////////////////////////
3873   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3874                                                                                                                  0.5*fgkSSDChipWidth,
3875                                                                                                                  0.5*fgkSSDChipHeight);
3876   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3877   /////////////////////////////////////////////////////////////
3878   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3879   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3880                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3881                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3882                                    -  0.5*fgkSSDChipWidth)};
3883   /////////////////////////////////////////////////////////////
3884   // Virtual Volume containing SSDChipAssembly   
3885   /////////////////////////////////////////////////////////////
3886   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3887   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3888   Double_t xmothervertex[kssdmothervertexnumber];
3889   Double_t ymothervertex[kssdmothervertexnumber];
3890   ///////////////////////
3891   // Setting the vertices 
3892   ///////////////////////
3893   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3894   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3895                                    - ymothervertex[0];
3896   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3897   ymothervertex[2] = ymothervertex[1];
3898   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3899   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3900   ymothervertex[4] = ymothervertex[0];
3901   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3902   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3903                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3904   ymothervertex[6] = ymothervertex[5];
3905   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3906                                    - fgkSSDChipWidth;
3907   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3908   ymothervertex[8] = ymothervertex[7];
3909   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3910   ymothervertex[9] = ymothervertex[6];
3911   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3912   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3913   //////////////////////////////////////////////////////////
3914   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3915                                                                         xmothervertex,ymothervertex);
3916   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3917   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3918   TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3919                                                           ssdchipmothershape,fSSDAir);
3920    /////////////////////////////////////////////////////////////
3921   for(Int_t i=0; i<kssdchiprownumber; i++)
3922     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3923                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3924                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3925   return ssdchipmother;
3926 }
3927 /////////////////////////////////////////////////////////////////////////////////
3928 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3929   /////////////////////////////////////////////////////////////
3930   // Method returning a List containing pointers to Ladder Cable Volumes    
3931   /////////////////////////////////////////////////////////////
3932   const Int_t kladdercablesegmentnumber = 2;
3933   /////////////////////////////////////////
3934   // LadderSegmentBBox Volume
3935   /////////////////////////////////////////
3936   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3937   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3938                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3939   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3940                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3941                                                                            0.5*fgkSSDFlexWidth[0],
3942                                                                            0.5*fgkSSDLadderCableWidth,
3943                                                                            0.5*fgkSSDFlexHeight[i]); 
3944   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3945                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3946   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3947   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3948                         laddercablesegmentbbox[i] =
3949                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3950                                                                                  laddercablesegmentbboxshape[i],
3951                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3952             fSSDKaptonLadderCableMedium));
3953                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3954                                                                                                                    fColorPolyhamide);
3955   }
3956   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3957   laddercablesegmentbboxtrans[0] = 
3958                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3959                                                                                            0.5*fgkSSDFlexWidth[0],
3960                                                                                            0.5*fgkSSDLadderCableWidth,
3961                                                                                            0.5*fgkSSDFlexHeight[0]);
3962   laddercablesegmentbboxtrans[1] = 
3963                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3964                                                                                            0.5*fgkSSDFlexWidth[0],
3965                                                                                            0.5*fgkSSDLadderCableWidth,
3966                                                                                            fgkSSDFlexHeight[0]
3967                                                                                            +0.5*fgkSSDFlexHeight[1]);
3968   TGeoVolume* laddercablesegmentbboxassembly = 
3969                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3970   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3971                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3972                                                                                             laddercablesegmentbboxtrans[i]);
3973 /////////////////////////////////////////
3974 // LadderSegmentArb8 Volume
3975 /////////////////////////////////////////
3976   const Int_t kvertexnumber = 4;
3977   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3978   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3979                                                                                                   new TVector3*[kvertexnumber];
3980 //Shape Vertex Positioning
3981   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3982         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3983         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3984                                                                                                                   i*fgkSSDFlexHeight[0]);
3985         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3986                                                                                    +                         fgkSSDFlexHeight[1]
3987                                                                                    +                      i*fgkSSDFlexHeight[0]);
3988         laddercablesegmentvertexposition[i][3] = 
3989                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3990                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3991   }
3992   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3993                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3994   char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3995                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3996   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3997   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3998                                         GetArbShape(laddercablesegmentvertexposition[i],
3999                                                                 laddercablesegmentwidth[i],
4000                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4001                                                                 laddercablesegmentarbshapename[i]);
4002   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4003                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4004   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4005   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4006                          laddercablesegmentarb[i] =
4007                                                    new TGeoVolume(laddercablesegmentarbname[i],
4008                                                                                   laddercablesegmentarbshape[i],
4009                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4010             fSSDKaptonLadderCableMedium)); 
4011                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4012                                                                                                                    fColorPolyhamide);
4013 }
4014   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4015   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4016                                                                                                  90.,90,-90.);   
4017   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4018                                                                                                   0.,90.,0.);    
4019   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4020                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4021                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4022                                                          + fgkSSDFlexWidth[0],0.,0.,
4023                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4024                                                      *(*laddercablesegmentarbrot[0])));
4025   TGeoVolume* laddercablesegmentarbassembly = 
4026                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4027   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4028   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4029                                                                                    laddercablesegmentarbcombitrans);
4030 /////////////////////////////////////////
4031 // End Ladder Cable Volume
4032 /////////////////////////////////////////
4033   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4034   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4035                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4036   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4037                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4038                                                                            0.5*ssdendladdercablelength,
4039                                                                            0.5*fgkSSDLadderCableWidth,
4040                                                                            0.5*fgkSSDFlexHeight[i]);
4041   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4042                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4043   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4044   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4045                         ladderendcablesegmentbbox[i] =
4046                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4047                                                                                  ladderendcablesegmentbboxshape[i],
4048                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4049             fSSDKaptonLadderCableMedium));
4050                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4051                                                                                                                    fColorPolyhamide);
4052   }
4053   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4054   ladderendcablesegmentbboxtrans[0] = 
4055                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4056                                                                                            0.5*ssdendladdercablelength,
4057                                                                                            0.5*fgkSSDLadderCableWidth,
4058                                                                                            0.5*fgkSSDFlexHeight[0]);
4059   ladderendcablesegmentbboxtrans[1] = 
4060                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4061                                                                                            0.5*ssdendladdercablelength,
4062                                                                                            0.5*fgkSSDLadderCableWidth,
4063                                                                                            fgkSSDFlexHeight[0]
4064                                                                                            +0.5*fgkSSDFlexHeight[1]);
4065   TGeoVolume* ladderendcablesegmentbboxassembly = 
4066                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4067   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4068                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4069                                                                                             ladderendcablesegmentbboxtrans[i]);
4070 /////////////////////////////////////////
4071   TList* laddercablesegmentlist = new TList();
4072   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4073   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4074   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4075   return laddercablesegmentlist;
4076   }
4077 /////////////////////////////////////////////////////////////////////////////////
4078 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4079   /////////////////////////////////////////////////////////////
4080   // Method generating Ladder Cable Volumes Assemblies    
4081   /////////////////////////////////////////////////////////////
4082   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4083   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4084   for(Int_t i=0; i<n; i++){
4085          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4086                                                         i*(fgkCarbonFiberJunctionWidth),
4087                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4088                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4089     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4090         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4091   }
4092   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4093                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4094                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4095                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4096   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4097   return laddercable;
4098 }
4099 /////////////////////////////////////////////////////////////////////////////////
4100 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4101   /////////////////////////////////////////////////////////////
4102   // Method generating Ladder Cable Volumes Assembly   
4103   /////////////////////////////////////////////////////////////
4104   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4105   char laddercabletransname[30];
4106   for(Int_t i=0; i<n; i++){ 
4107         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4108     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4109         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4110   }
4111   return laddercableassembly;
4112 }
4113 /////////////////////////////////////////////////////////////////////////////////
4114 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4115   /////////////////////////////////////////////////////////////
4116   // Method generating Ladder Cable List Assemblies  
4117   /////////////////////////////////////////////////////////////  
4118   const Int_t kladdercableassemblynumber = 2;
4119   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4120   TGeoVolume* ladderCable[kladdercableassemblynumber];
4121   char laddercableassemblyname[30];
4122   TList* laddercableassemblylist = new TList();
4123   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4124         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4125         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4126         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4127                                          new TGeoCombiTrans((n-1)
4128                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4129                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4130                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4131         laddercableassemblylist->Add(ladderCable[i]);
4132 }
4133   return laddercableassemblylist;
4134 }
4135 ///////////////////////////////////////////////////////////////////////////////
4136 void AliITSv11GeometrySSD::SetLadderSegment(){
4137   /////////////////////////////////////////////////////////////
4138   // Method Generating Ladder Segment Array
4139   /////////////////////////////////////////////////////////////
4140   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4141   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4142   if(!fCreateMaterials) CreateMaterials();
4143   if(!fTransformationMatrices) CreateTransformationMatrices();
4144   if(!fBasicObjects) CreateBasicObjects();
4145   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4146   // Placing Carbon Fiber Support       
4147         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4148                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4149                                                                                         fcarbonfibersupportmatrix[j]);  
4150                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4151                                                                                         fcarbonfibersupportmatrix[j]);
4152   }
4153   // Placing Carbon Fiber Junction
4154     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4155         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4156                                                                    fcarbonfiberjunctionmatrix[j]);
4157   // Placing Carbon Fiber Lower Support
4158         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4159                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4160                                                            fcarbonfiberlowersupportrans[j]);    
4161   // Placing SSD Sensor Support
4162     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4163         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4164                                                                      fssdsensorsupport[1][i],
4165                                                            j+1,fssdsensorsupportmatrix[j]);
4166   // Placing SSD Cooling Tube Support 
4167         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4168                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4169                                                                    fcoolingtubesupportmatrix[j]);
4170   // Placing SSD Cooling Tube  
4171         for(Int_t j=0; j<2; j++)
4172                 for(Int_t k=0; k<2; k++){
4173                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4174                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4175                 }
4176   // Placing SSD Hybrid
4177     switch(i){
4178         case 0: 
4179                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4180                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4181                 break;
4182     case 1:
4183                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4184                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4185                 break;
4186         }
4187         // Placing Cooling Block System
4188     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4189         // Placing SSD Flex
4190         for(Int_t j=0; j<fgkflexnumber; j++){
4191       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4192       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4193         }
4194    }
4195 }
4196 ///////////////////////////////////////////////////////////////////////////////
4197 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4198   /////////////////////////////////////////////////////////////
4199   // Method Generating End Ladder
4200   /////////////////////////////////////////////////////////////
4201   // End Ladder Carbon Fiber Junction 
4202   /////////////////////////////////////////////////////////////
4203   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4204   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4205   if(!fCreateMaterials) CreateMaterials();
4206   if(!fTransformationMatrices) CreateTransformationMatrices();
4207   if(!fBasicObjects) CreateBasicObjects();
4208   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4209         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4210                 fendladdersegment[i]->AddNode(j==2 ? 
4211                                                         fendladdercarbonfiberjunction[i][1] : 
4212                                                         fendladdercarbonfiberjunction[i][0],
4213                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4214   }
4215   /////////////////////////////////////////////////////////////
4216   // End Ladder Carbon Fiber Support 
4217   /////////////////////////////////////////////////////////////
4218   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4219       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4220                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4221                   fendladdercarbonfibermatrix[i][j]);   
4222           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4223                   fendladdercarbonfibermatrix[i][j]);   
4224       }
4225   /////////////////////////////////////////////////////////////
4226   // End Ladder Mounting Block
4227   /////////////////////////////////////////////////////////////
4228   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4229        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4230                                      fendladdermountingblockcombitrans[i]);
4231   /////////////////////////////////////////////////////////////
4232   // End Ladder Mounting Block Clip
4233   /////////////////////////////////////////////////////////////
4234   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4235         for(Int_t j=0; j<2; j++)
4236                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4237                                               fendladdermountingblockclipmatrix[i][j]);
4238   /////////////////////////////////////////////////////////////
4239   // End Ladder Lower Supports
4240   /////////////////////////////////////////////////////////////
4241   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4242                                 fendladderlowersupptrans[0]);
4243   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4244                                 fendladderlowersupptrans[1]);
4245   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4246                                 fendladderlowersupptrans[2]);
4247   /////////////////////////////////////////////////////////////
4248   // End Ladder Cooling Tube Support
4249   /////////////////////////////////////////////////////////////
4250   for(Int_t i=0; i<2; i++) 
4251         for(Int_t j=0; j<(i==0?4:2); j++)   
4252                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4253                                               fendladdercoolingtubesupportmatrix[i][j]);
4254   /////////////////////////////////////////////////////////////
4255   // End Ladder Cooling Tube Support
4256   /////////////////////////////////////////////////////////////
4257   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                    
4258   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                    
4259   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4260   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4261   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4262   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4263   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4264   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4265   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4266   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                                                                    
4267 }
4268 ///////////////////////////////////////////////////////////////////////////////
4269 void AliITSv11GeometrySSD::SetLadder(){
4270   /////////////////////////////////////////////////////////////
4271   // Method Generating Ladder of Layer 5 and 6
4272   /////////////////////////////////////////////////////////////  
4273   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4274                                                                                                 fgkSSDLay6SensorsNumber};
4275   /////////////////////////////////////////////////////////////////////////////                                         
4276   /// Generating Ladder Mother Volume Containing Ladder 
4277   /////////////////////////////////////////////////////////////////////////////          
4278   TGeoXtru* laddershape[fgkladdernumber];       
4279   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4280   const Int_t kmothervertexnumber = 8;  
4281   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4282   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4283   ///////////////////////
4284   // Setting the vertices 
4285   ///////////////////////
4286   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4287                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4288   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4289   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
4290                                           -  fgkSSDModuleVerticalDisalignment;
4291   xmothervertex[0][1] = xmothervertex[0][0];
4292   ymothervertex[0][1] = 0.0;
4293   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4294                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4295   ymothervertex[0][2] = ymothervertex[0][1];
4296   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4297   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4298   xmothervertex[0][4] = -xmothervertex[0][3];
4299   ymothervertex[0][4] = ymothervertex[0][3];
4300   xmothervertex[0][5] = -xmothervertex[0][2];
4301   ymothervertex[0][5] = ymothervertex[0][2];
4302   xmothervertex[0][6] = -xmothervertex[0][1];
4303   ymothervertex[0][6] = ymothervertex[0][1];
4304   xmothervertex[0][7] = -xmothervertex[0][0];
4305   ymothervertex[0][7] = ymothervertex[0][0];
4306   for(Int_t i=0; i<kmothervertexnumber; i++){
4307         xmothervertex[1][i] = xmothervertex[0][i];
4308         ymothervertex[1][i] = ymothervertex[0][i];
4309   }
4310   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4311   for(Int_t i=0; i<fgkladdernumber; i++){
4312         laddershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
4313                                                                     ymothervertex[i]);
4314     laddershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4315     laddershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4316                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4317     fladder[i] = new TGeoVolume(laddername[i],laddershape[i],fSSDAir);
4318         fladder[i]->SetLineColor(4);
4319  }
4320 ///////////////////////////////////////////////////////////////////////////
4321  if(!fCreateMaterials) CreateMaterials();
4322  if(!fTransformationMatrices) CreateTransformationMatrices();
4323  if(!fBasicObjects) CreateBasicObjects();
4324  SetLadderSegment(); 
4325  SetEndLadderSegment();
4326   for(Int_t i=0; i<fgkladdernumber; i++){
4327         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4328         //////////////////////////                                              
4329         /// Placing Ladder Segment
4330         //////////////////////////              
4331                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4332                                                                      fladdersegment[i==0 ? 1 : 0],
4333                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4334         //////////////////////////                                              
4335         /// Placing SSD Sensor
4336         //////////////////////////              
4337                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4338                                                         fssdsensormatrix[i][j]);
4339         }
4340         ///////////////////////////////                                         
4341         /// Placing End Ladder Segment
4342         ///////////////////////////////         
4343     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4344         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4345    }
4346 /////////////////////////////////////////////////////////////////////////////                                           
4347 /// Placing Ladder Cables
4348 /////////////////////////////////////////////////////////////////////////////           
4349   Int_t sidecablenumber[2][2];
4350   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4351   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4352   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4353   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4354   Double_t carbonfibertomoduleposition[3];
4355   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4356   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4357                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4358          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4359          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4360          -            fgkSSDSensorCenterSupportThickness[0]);
4361   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4362                                                                  +   0.5*fgkCoolingTubeSupportHeight
4363          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4364   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4365   Double_t ssdendladdercablelength[4];
4366   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4367                                                          + fgkSSDSensorLength
4368                                                          - fgkSSDModuleStiffenerPosition[1]
4369                                                          - fgkSSDStiffenerWidth 
4370                                                          - fgkSSDFlexWidth[0]
4371                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4372   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4373                                                          + fgkSSDModuleStiffenerPosition[1]
4374                                                          + fgkSSDStiffenerWidth
4375                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4376   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4377                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4378                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4379                                                          - kendladdercablecorrection;
4380   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4381                                                          + carbonfibertomoduleposition[1]
4382                                                          - fgkSSDModuleStiffenerPosition[1]
4383                                                          - fgkSSDStiffenerWidth)
4384                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4385   TList* laddercableassemblylist[4];
4386   const Int_t kendladdercablesnumber = 4;
4387   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4388         for(Int_t j=0; j<kendladdercablesnumber; j++){
4389                 laddercableassemblylist[j] = 
4390                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4391                                                                    ssdendladdercablelength[j]);
4392             fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4393                                                                         j<2?1:2,fladdercablematrix[i][j]);
4394   }
4395 }
4396 ////////////////////////////////////////////////////////////////////////////////
4397 void AliITSv11GeometrySSD::SetLayer(){
4398 ////////////////////////////////////////////////////////////////////////////////
4399   // Creating Ladder of Layer 5 and Layer 6
4400   /////////////////////////////////////////////////////////////
4401   if(!fCreateMaterials) CreateMaterials();
4402   if(!fTransformationMatrices) CreateTransformationMatrices();
4403   if(!fBasicObjects) CreateBasicObjects();
4404   SetLadder(); // Generating the ladder of Layer5 and Layer6
4405   const Int_t kssdlayladdernumber[fgklayernumber] = 
4406                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4407   /////////////////////////////////////////////////////////////
4408   // Generating mother volumes for Layer5 and Layer6
4409   /////////////////////////////////////////////////////////////
4410   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4411   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4412   Int_t *ladderindex[fgklayernumber];
4413   Int_t index[fgklayernumber] = {8,9};
4414   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4415   for(Int_t i=0; i<fgklayernumber; i++) 
4416         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4417                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4418                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4419                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4420                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4421         }
4422   /////////////////////////////////////////////////////////////
4423   // Deallocating memory
4424   /////////////////////////////////////////////////////////////
4425   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4426 }
4427 ////////////////////////////////////////////////////////////////////////////////
4428 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4429   /////////////////////////////////////////////////////////////
4430   // Insert the layer 5 in the mother volume. 
4431   /////////////////////////////////////////////////////////////
4432   if (! moth) {
4433     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4434     return;
4435   };
4436   if(!fSSDLayer5) SetLayer();
4437   fMotherVol = moth;
4438   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4439                                                                                 + fgkLay5CenterITSPosition);
4440   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4441  }
4442 ////////////////////////////////////////////////////////////////////////////////
4443 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4444   /////////////////////////////////////////////////////////////
4445   // Insert the layer 6 in the mother volume. 
4446   /////////////////////////////////////////////////////////////
4447   if (! moth) {
4448     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4449     return;
4450   };
4451   if(!fSSDLayer6) SetLayer();
4452   fMotherVol = moth;
4453   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4454                                                                                 + fgkLay6CenterITSPosition);
4455   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4456  }
4457  ////////////////////////////////////////////////////////////////////////////////
4458  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4459   /////////////////////////////////////////////////////////////
4460   // Method generating the Arc structure of Ladder Support 
4461   /////////////////////////////////////////////////////////////
4462   const Int_t kssdlayladdernumber[fgklayernumber] = 
4463                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4464   Double_t mountingsupportedge[fgklayernumber];
4465   Double_t mountingblockratio[fgklayernumber];
4466   Double_t theta[fgklayernumber];
4467   Double_t phi[fgklayernumber];
4468   Double_t psi0[fgklayernumber];
4469   Double_t deltapsi[fgklayernumber];
4470   TVector3* mountingsupportedgevector[fgklayernumber];
4471   for(Int_t i=0; i<fgklayernumber; i++){
4472         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4473     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4474                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4475                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4476                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4477                                                           / kssdlayladdernumber[i])));
4478     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4479     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4480         mountingsupportedgevector[i] = new TVector3();
4481     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4482         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4483                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4484                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4485     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4486     deltapsi[i] = (theta[i]+phi[i])/nedges;
4487   }
4488   TVector3** vertex[fgklayernumber];
4489   TList* vertexlist[fgklayernumber];
4490   Int_t indexedge[fgklayernumber] = {0,0};
4491   for(Int_t i=0; i<fgklayernumber; i++){
4492         vertex[i] = new TVector3*[nedges+1];
4493         vertexlist[i] = new TList();
4494   } 
4495   for(Int_t i=0; i<fgklayernumber; i++){
4496         for(Int_t j=0; j<nedges+1; j++){
4497                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4498                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4499                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4500                 vertexlist[i]->Add(vertex[i][j]);
4501         }
4502         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4503   }
4504   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4505   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4506   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4507   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4508   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4509   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4510   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4511   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4512   for(Int_t i=0; i<fgklayernumber; i++){
4513     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4514     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4515     xcentervertex[i] = new Double_t[indexedge[i]+3];
4516     ycentervertex[i] = new Double_t[indexedge[i]+3];
4517         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4518         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4519         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4520         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4521         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4522                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4523                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4524                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4525                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4526                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4527                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4528                 if(j<indexedge[i]+1){
4529                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4530                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4531                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4532                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4533                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4534                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4535                 }
4536         }
4537         xsidevertex[i][1] = xsidevertex[i][0]; 
4538         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4539         xsidevertex[i][2] = xsidevertex[i][3]; 
4540         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4541         xcentervertex[i][1] = xcentervertex[i][0]; 
4542         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4543         xcentervertex[i][2] = xcentervertex[i][3]; 
4544         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4545         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4546         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4547         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4548         ycenterlowervertex[i][0] = ysidevertex[i][0];
4549         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4550         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4551   }
4552   /////////////////////////////////////////////////////////////
4553   // Building the Arc Structure of Ladder Supports 
4554   /////////////////////////////////////////////////////////////
4555   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4556   TGeoXtru* centermountingsupportshape[fgklayernumber];
4557   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4558   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4559   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4560   TGeoVolume* centermountingblocksupport[fgklayernumber];
4561   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4562   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4563   char sidemountingblockname[40];
4564   char centermountingblockname[40];
4565   char sideladdersupportpiecename[40];
4566   char centerladdersupportpiecename[40];
4567   for(Int_t i=0; i<fgklayernumber; i++){ 
4568         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4569         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4570         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4571         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4572         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4573     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4574                                                                                                 xsidevertex[i],ysidevertex[i]);
4575     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4576                                                                                                          -fgkMountingBlockSupportWidth[0]);
4577     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4578     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4579                                                                           sidemountingblocksupportshape[i],
4580                                                                                   fSSDAlCoolBlockMedium);
4581         sidemountingblocksupport[i]->SetLineColor(9);
4582         centermountingsupportshape[i] = new TGeoXtru(2);
4583     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4584                                                                                                 xcentervertex[i],ycentervertex[i]);
4585         centermountingsupportshape[i]->DefineSection(0,0.);
4586     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4587                                                                                                   -fgkMountingBlockSupportWidth[0]);
4588     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4589                                                                           centermountingsupportshape[i],
4590                                                                                   fSSDAlCoolBlockMedium);
4591         centermountingblocksupport[i]->SetLineColor(9);
4592         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4593     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4594                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4595         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4596                                                                                                          -fgkMountingBlockSupportWidth[0]);
4597     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4598     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4599                                                                           sideladdersupportpieceshape[i],
4600                                                                                   fSSDCarbonFiberMedium);
4601         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4602         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4603     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4604                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4605         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4606     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4607                                                                                                   -fgkMountingBlockSupportWidth[0]);
4608     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4609                                                                           centerladdersupportpieceshape[i],
4610                                                                                   fSSDCarbonFiberMedium);
4611         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4612   }
4613   /////////////////////////////////////////////////////////////
4614   // Building the Up Structure of Ladder Supports 
4615   /////////////////////////////////////////////////////////////
4616   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4617   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4618   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4619   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4620   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4621   //////////////////////////////////////////////////////////
4622   // Setting the volume for TGeoXtru Mounting Block Piece  
4623   //////////////////////////////////////////////////////////
4624   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4625   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4626   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4627   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4628   TGeoVolume* mountingblockpieceup[fgklayernumber];
4629   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4630   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4631   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4632   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4633   char mountingblockpiecedownname[34];
4634   char mountingblockpieceupname[34];
4635   for(Int_t i=0; i<fgklayernumber; i++){
4636     ///////////////////////////
4637     // Mounting Block Down Vertex
4638     ///////////////////////////
4639         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4640     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4641         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4642         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4643                                                                                 + fgkMountingBlockSupportDownHeight;
4644         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4645         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4646                                                                                 + fgkSSDMountingBlockHeight[1]
4647                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4648                                                                                 - fgkSSDModuleCoolingBlockToSensor
4649                                                                                 - fgkSSDModuleVerticalDisalignment;
4650         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4651         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4652         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4653         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4654         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4655         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4656         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4657         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4658                                                                                 + fgkSSDMountingBlockHeight[2]
4659                                                                                 - fgkSSDMountingBlockHeight[0];
4660         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4661         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4662         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4663         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4664         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4665                                                                                                          mountingblockpiecedownyvertex[i]);
4666         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4667         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4668         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4669                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4670         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4671     ///////////////////////////
4672     // Mounting Block Up Vertex
4673     ///////////////////////////
4674         mountingblockpieceupshape[i] = new TGeoXtru(2);
4675         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4676         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4677         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4678                                                                                 + fgkMountingBlockSupportUpHeight[i];
4679         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4680         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4681                                                                                 + fgkSSDMountingBlockHeight[1]
4682                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4683                                                                                 - fgkSSDModuleCoolingBlockToSensor
4684                                                                                 - fgkSSDModuleVerticalDisalignment;
4685         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4686         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4687         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4688         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4689         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4690         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4691         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4692         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4693                                                                                 + fgkSSDMountingBlockHeight[2]
4694                                                                                 - fgkSSDMountingBlockHeight[0];
4695         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4696         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4697         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4698         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4699         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4700                                                                                                          mountingblockpieceupyvertex[i]);
4701         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4702         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4703         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4704                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4705         mountingblockpieceup[i]->SetLineColor(fColorG10);
4706  }
4707   ///////////////////////////////////////////////////////////////////
4708   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4709   ///////////////////////////////////////////////////////////////////
4710   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4711   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4712   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4713   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4714   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4715   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4716   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4717   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4718   char mountingblocksupportrapezoidowname[40];
4719   char mountingblocksupportrapezoidupname[40];
4720   Double_t scalefactor = 3./4.;
4721   for(Int_t i=0; i<fgklayernumber; i++){
4722   ////////////////////////////////////////////
4723   // Mounting Block Support Down Trapezoid Vertex 
4724   ////////////////////////////////////////////
4725         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4726         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4727                                                                                                  - mountingsupportedge[i];
4728         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4729         mountingblocksupportrapezoidownxvertex[i][1] = 
4730                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4731         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4732                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4733                                                                                              - mountingblockpiecedownyvertex[i][0]);
4734         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4735         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4736         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4737         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4738         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4739         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4740         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4741                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4742         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4743                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4744         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4745         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4746         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4747                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4748         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4749   ////////////////////////////////////////////
4750   // Mounting Block Support Up Trapezoid Vertex 
4751   ////////////////////////////////////////////
4752         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4753         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4754                                                                                                  - mountingsupportedge[i];
4755         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4756         mountingblocksupportrapezoidupxvertex[i][1] = 
4757                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4758         mountingblocksupportrapezoidupyvertex[i][1] = 
4759                                                                                                mountingblockpieceupyvertex[i][0]
4760                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4761                                                                                              - mountingblockpieceupyvertex[i][0]);
4762         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4763         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4764         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4765         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4766         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4767         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4768         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4769                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4770         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4771                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4772         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4773         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4774         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4775                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4776         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4777   }
4778   ///////////////////////////////////////////////////////////////////
4779   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4780   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4781   Double_t boxoriginup[fgklayernumber][2][3];
4782   Double_t boxorigindown[fgklayernumber][2][3];
4783   char mountingblocksupportboxdownname[34];
4784   char mountingblocksupportboxupname[34];
4785   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4786   mountingblocksupportrot->SetAngles(90.,180.,-90);
4787   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4788   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4789   TGeoHMatrix* laddersupportmatrix[2];
4790   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4791   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4792   /////////////////////////////////////////////////////////////
4793   // Creating Mother Volume for Containment
4794   /////////////////////////////////////////////////////////////
4795   Double_t *xmothervertex[fgklayernumber];
4796   Double_t *ymothervertex[fgklayernumber];
4797   for(Int_t i=0; i<fgklayernumber; i++){
4798         xmothervertex[i] = new Double_t[8];
4799         ymothervertex[i] = new Double_t[8];
4800   }  
4801   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4802   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4803   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4804   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4805   char upmotheladdersupportname[30];
4806   char downmotheladdersupportname[30];
4807   for(Int_t i=0; i<fgklayernumber; i++){
4808         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4809                                                     -  mountingsupportedge[i];
4810         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4811         xmothervertex[i][1] = xmothervertex[i][0];
4812         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4813                                                         + fgkMountingBlockSupportWidth[0];
4814         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4815         ymothervertex[i][2] = ymothervertex[i][1];
4816         xmothervertex[i][3] = xmothervertex[i][2];
4817         ymothervertex[i][3] = -ymothervertex[i][0];
4818         xmothervertex[i][4] = -xmothervertex[i][0];
4819         ymothervertex[i][4] = ymothervertex[i][3];
4820         xmothervertex[i][5] = xmothervertex[i][4];
4821         ymothervertex[i][5] = -ymothervertex[i][1];
4822         xmothervertex[i][6] = -xmothervertex[i][2];
4823         ymothervertex[i][6] = ymothervertex[i][5];
4824         xmothervertex[i][7] = xmothervertex[i][6];
4825         ymothervertex[i][7] = ymothervertex[i][0];
4826         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4827         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4828     downmotherladdersupportshape[i] = new TGeoXtru(2);
4829         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4830         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4831     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4832                                                                    +                       fgkMountingBlockSupportDownHeight
4833                                                                    +                       fgkSSDMountingBlockHeight[1]
4834                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4835                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4836                                                                    -                       2.*fgkSSDModuleVerticalDisalignment);
4837     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4838                                                                           downmotherladdersupportshape[i],fSSDAir);
4839     upmotherladdersupportshape[i] = new TGeoXtru(2);
4840         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4841         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4842     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4843                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4844                                                                    +                       fgkSSDMountingBlockHeight[1]
4845                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4846                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4847                                                                    -               2.*fgkSSDModuleVerticalDisalignment);
4848     upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4849                                                                                           upmotherladdersupportshape[i],fSSDAir);
4850   }
4851   for(Int_t i=0; i<fgklayernumber; i++){
4852         /////////////////////////
4853         // Setting the box origin
4854         /////////////////////////
4855         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4856         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4857                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4858         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4859                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4860   
4861         boxorigindown[i][1][0] = 0.0;
4862         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4863         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4864                                                    -      fgkMountingBlockSupportWidth[0]);
4865                                                    
4866         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4867         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4868                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4869         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4870                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4871   
4872         boxoriginup[i][1][0] = 0.0;
4873         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4874                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4875         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4876                                                  - fgkMountingBlockSupportWidth[0]);
4877   
4878         /////////////////////////
4879     // Setting the boxes    
4880         /////////////////////////
4881         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4882                                                                                  +  fgkSSDMountingBlockLength[0]),
4883                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4884                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4885                                                                                         boxorigindown[i][0]);
4886     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4887                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4888                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4889                                                                                  -  fgkMountingBlockSupportWidth[0]),
4890                                                                                         boxorigindown[i][1]);
4891                                                                                         
4892         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4893                                                                                  +  fgkSSDMountingBlockLength[0]),
4894                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4895                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4896                                                                                         boxoriginup[i][0]);
4897                                                                                         
4898         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4899                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4900                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4901                                                                      -  fgkMountingBlockSupportWidth[0]),
4902                                                                                         boxoriginup[i][1]);
4903         ///////////////////////////////////////
4904     // Adding the Volumes to Mother Volume    
4905         ///////////////////////////////////////
4906         for(Int_t j=0; j<2; j++){
4907                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4908                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4909                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4910                                                                                   mountingblocksupportboxdownshape[i][j],
4911                                                                                   fSSDCarbonFiberMedium);
4912                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4913                                                                                   mountingblocksupportboxupshape[i][j],
4914                                                                                   fSSDCarbonFiberMedium);
4915                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4916                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4917                 for(Int_t k=0; k<2; k++){
4918                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4919                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4920                 }
4921         }
4922         for(Int_t k=0; k<2; k++){
4923                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4924                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4925                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4926                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4927             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4928                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4929                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4930                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4931                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4932                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4933                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4934                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4935         }
4936   }
4937   TList* laddersupportlist = new TList();
4938   laddersupportlist->Add(downmotherladdersupport[0]); 
4939   laddersupportlist->Add(upmotherladdersupport[0]); 
4940   laddersupportlist->Add(downmotherladdersupport[1]); 
4941   laddersupportlist->Add(upmotherladdersupport[1]); 
4942   /////////////////////////////////////////////////////////////
4943   // Deallocating memory
4944   /////////////////////////////////////////////////////////////
4945   for(Int_t i=0; i<fgklayernumber; i++){
4946         for(Int_t j=0; j<nedges+1; j++)
4947                 delete vertex[i][j];
4948         delete mountingsupportedgevector[i];
4949         delete [] vertex[i];
4950         delete vertexlist[i];
4951         delete [] xsidevertex[i];
4952         delete [] ysidevertex[i];
4953         delete [] xcentervertex[i];
4954         delete [] ycentervertex[i];
4955         delete [] xsidelowervertex[i];
4956         delete [] ysidelowervertex[i];
4957         delete [] xcenterlowervertex[i];
4958         delete [] ycenterlowervertex[i];
4959   }
4960   delete xsidevertex;
4961   delete ysidevertex;
4962   delete xcentervertex;
4963   delete ycentervertex;
4964   delete xsidelowervertex;
4965   delete ysidelowervertex;
4966   delete xcenterlowervertex;
4967   delete ycenterlowervertex;
4968   delete globalrefladdersupportrot;
4969   delete mountingblocksupportrot;
4970   /////////////////////
4971   return laddersupportlist;     
4972 }
4973  ////////////////////////////////////////////////////////////////////////////////
4974 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4975 //////////////////////////////////////////
4976 // Method Generating Ladder Support Ring
4977 //////////////////////////////////////////
4978   if(!fCreateMaterials) CreateMaterials();
4979   if(!fTransformationMatrices) CreateTransformationMatrices();
4980   if(!fBasicObjects) CreateBasicObjects();
4981   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4982   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4983     const Int_t kssdlayladdernumber[fgklayernumber] = 
4984                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4985   Double_t mountingsupportedge[fgklayernumber];
4986   Double_t mountingblockratio[fgklayernumber];
4987   Double_t theta[fgklayernumber];
4988   Double_t phi[fgklayernumber];
4989   for(Int_t i=0; i<fgklayernumber; i++){
4990         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4991     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4992                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4993                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4994                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4995                                                           / kssdlayladdernumber[i])));
4996     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4997                          / fgkMountingBlockSupportRadius[i]);
4998     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4999   }
5000   TGeoRotation* globalrot = new TGeoRotation();
5001   globalrot->SetAngles(0.,-90.,0.); 
5002   TGeoRotation** laddersupportrot[fgklayernumber];
5003   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5004   for(Int_t i=0; i<fgklayernumber; i++){                
5005         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5006         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5007         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5008                 laddersupportrot[i][j] = new TGeoRotation();
5009                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5010                 switch(i){
5011                         case 0: //Ladder of Layer5  
5012                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5013                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5014                                                                             laddersupportmatrix[i][j]); 
5015                         break;
5016                         case 1: //Ladder of Layer6 
5017                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5018                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5019                                                                               laddersupportmatrix[i][j]); 
5020                         break;
5021                 }
5022     }
5023   }
5024   /////////////////////////////////////////////////////////////
5025   // Creating Lower Ladder Support 
5026   /////////////////////////////////////////////////////////////
5027   TVector3** ringsupportvertex[fgklayernumber];         
5028   Double_t angle = 360./nedges;
5029   for(Int_t i=0; i<fgklayernumber; i++){
5030     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5031         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5032                                                         *                          TMath::Cos(theta[i]));
5033         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5034                                                         -                          mountingsupportedge[i],
5035                                                                                    ringsupportvertex[i][0]->Y());
5036         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5037                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5038     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5039         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5040            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5041            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5042            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5043            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5044         }
5045         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5046     for(Int_t j=0; j<nedges+1; j++){
5047                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5048                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5049                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5050         }
5051   }
5052   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5053   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5054   for(Int_t i=0; i<fgklayernumber; i++){
5055         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5056         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5057         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5058                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5059                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5060         }
5061   }
5062   char lowerladdersupportname[30];
5063   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5064   TGeoVolume* lowerladdersupport[fgklayernumber];
5065   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5066   lowerladdersupportrot->SetAngles(90.,180.,-90);
5067   for(Int_t i=0; i<fgklayernumber; i++){
5068         lowerladdersupportshape[i] = new TGeoXtru(2);
5069         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5070                                                                                           xmothervertex[i],ymothervertex[i]);
5071         lowerladdersupportshape[i]->DefineSection(0,0.);
5072     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5073         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5074     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5075                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5076         lowerladdersupport[i]->SetLineColor(fColorAl);
5077         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5078         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5079   }
5080   /////////////////////////////////////////////////////////////
5081   // Deallocating memory
5082   /////////////////////////////////////////////////////////////
5083   for(Int_t i=0; i<fgklayernumber; i++){
5084         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5085                 delete ringsupportvertex[i][j];
5086         delete [] ringsupportvertex[i];
5087   }
5088   for(Int_t i=0; i<fgklayernumber; i++){
5089         delete [] xmothervertex[i];
5090         delete [] ymothervertex[i];
5091   }
5092   delete xmothervertex;
5093   delete ymothervertex; 
5094   delete globalrot;
5095   for(Int_t i=0; i<fgklayernumber; i++){
5096         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5097                 delete laddersupportrot[i][j];
5098         delete [] laddersupportrot[i];
5099   }
5100  }  
5101  ////////////////////////////////////////////////////////////////////////////////
5102  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5103   /////////////////////////////////////////////////////////////
5104   // Method generating Endcap CoverPlate
5105   /////////////////////////////////////////////////////////////
5106   // Holes Definition 
5107   ///////////////////
5108   Int_t nendcapcoverplateholedges = 30;
5109   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5110   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5111                                                           0.5*fgkEndCapCoverPlateThickness};
5112   TGeoXtru* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5113                                                                                                               nendcapcoverplateholedges,holesection);
5114   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5115                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5116   endcapcoverplatesmallhole->SetLineColor(6);
5117   TGeoXtru* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5118                                                                                                               nendcapcoverplateholedges,holesection);
5119   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5120                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5121   endcapcoverplatebighole->SetLineColor(6);
5122   //////////////////////////
5123   // Screw Piece Definition 
5124   //////////////////////////
5125   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5126   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5127                                                                                                       CosD(0.5*smallscrewangle),
5128                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5129   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5130                                                                                                 endcapsmallscrewpieceshape,
5131                                                                                                 fSSDCoolingTubePhynox);
5132   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5133   ///////////////////
5134   // Box Definition 
5135   ///////////////////
5136   TGeoBBox* endcapcoverplateboxshape[4];
5137   TGeoVolume* endcapcoverplatebox[4];
5138   Double_t boxorigin[5][3];
5139   boxorigin[0][0] = 0.;
5140   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5141   boxorigin[0][2] = 0.;
5142
5143   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5144   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5145   boxorigin[1][2] = 0.;
5146
5147   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5148                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5149   boxorigin[2][1] = boxorigin[1][1];
5150   boxorigin[2][2] = 0.;
5151
5152   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5153                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5154   boxorigin[3][1] = boxorigin[1][1];
5155   boxorigin[3][2] = 0.;
5156
5157   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5158                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5159                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5160                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5161
5162   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5163                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5164                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5165                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5166                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5167
5168   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5169                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5170                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5171                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5172                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5173
5174   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5175                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5176                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5177                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5178                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5179   
5180   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5181                                                                            fSSDAlCoolBlockMedium);
5182   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5183                                                                            fSSDAlCoolBlockMedium);
5184   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5185                                                                            fSSDAlCoolBlockMedium);
5186   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5187                                                                            fSSDAlCoolBlockMedium);
5188   endcapcoverplatebox[0]->SetLineColor(6);
5189   endcapcoverplatebox[1]->SetLineColor(6);
5190   endcapcoverplatebox[2]->SetLineColor(6);
5191   endcapcoverplatebox[3]->SetLineColor(6);
5192   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5193   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5194                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5195                                                                                         0.5*fgkEndCapCoverPlateThickness,
5196                                                                                         endcapfillingboxorigin);
5197   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5198                                                                            fSSDAlCoolBlockMedium);
5199   endcapfillingbox->SetLineColor(6);
5200   ////////////////////////////
5201   // Contour Xtru Definition 
5202   ////////////////////////////
5203   const Int_t kcontourvertexnumber = 10;
5204   Double_t xcontourvertex[kcontourvertexnumber];
5205   Double_t ycontourvertex[kcontourvertexnumber];
5206   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5207   xcontourvertex[1] = xcontourvertex[0];
5208   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5209   xcontourvertex[3] = xcontourvertex[2];
5210   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5211   xcontourvertex[5] = xcontourvertex[4];
5212   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5213   xcontourvertex[7] = xcontourvertex[6];
5214   xcontourvertex[8] = xcontourvertex[4];
5215   xcontourvertex[9] = xcontourvertex[8];
5216   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5217                                         - (kendcapcoverplatesmallholenumber[1]-1)
5218                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5219   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5220                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5221   ycontourvertex[2] = ycontourvertex[1];
5222   ycontourvertex[3] = ycontourvertex[0];
5223   ycontourvertex[4] = ycontourvertex[3];
5224   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5225   ycontourvertex[6] = ycontourvertex[5];
5226   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5227                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5228                                         + fgkEndCapCoverPlateSmallHoleRadius;
5229   ycontourvertex[8] = ycontourvertex[7];
5230   ycontourvertex[9] = ycontourvertex[0];
5231   TGeoXtru* contourshape = new TGeoXtru(2);
5232   contourshape->DefinePolygon(kcontourvertexnumber,xcontourvertex,ycontourvertex);  
5233   contourshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5234   contourshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5235   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5236                                                                            fSSDAlCoolBlockMedium);
5237   contour->SetLineColor(6);
5238   /////////////////////////////
5239   // Hole Contour Xtru Definition 
5240   ////////////////////////////
5241   const Int_t kholecontourvertexnumber = 10;
5242   Double_t xholecontourvertex[2][kcontourvertexnumber];
5243   Double_t yholecontourvertex[2][kcontourvertexnumber];
5244   xholecontourvertex[0][0] = xcontourvertex[0];
5245   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5246   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5247   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5248   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5249                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5250                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5251   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5252   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5253                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5254   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5255   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5256   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5257   
5258   yholecontourvertex[0][0] = ycontourvertex[1];
5259   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5260   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5261   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5262   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5263   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5264                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5265   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5266   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5267   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5268   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5269
5270   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5271   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5272   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5273   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5274   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5275                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5276                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5277   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5278   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5279                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5280   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5281   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5282   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5283   
5284   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5285                                                    - fgkEndCapCoverPlateWidth[0]);
5286   yholecontourvertex[1][1] = ycontourvertex[0];
5287   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5288   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5289   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5290   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5291                                                    - fgkEndCapCoverPlateWidth[0]
5292                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5293   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5294   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5295   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5296   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5297
5298   TGeoXtru* holecontourshape[2];
5299   holecontourshape[0] = new TGeoXtru(2);
5300   holecontourshape[0]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[0],
5301                                                                   yholecontourvertex[0]);  
5302   holecontourshape[0]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5303   holecontourshape[0]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5304
5305   holecontourshape[1] = new TGeoXtru(2);
5306   holecontourshape[1]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[1],
5307                                                                   yholecontourvertex[1]);  
5308   holecontourshape[1]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5309   holecontourshape[1]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5310
5311   TGeoVolume* holecontour[2];
5312   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",holecontourshape[0],
5313                                                                   fSSDAlCoolBlockMedium);
5314   holecontour[0]->SetLineColor(6);
5315   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",holecontourshape[1],
5316                                                                   fSSDAlCoolBlockMedium);
5317   holecontour[1]->SetLineColor(6);
5318   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5319                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5320   TGeoTranslation*  bigholetrans[3];
5321   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5322                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5323   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5324                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5325                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5326   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5327                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5328   /////////////////////////////////
5329   // Mother Volume Xtru Definition 
5330   /////////////////////////////////
5331   const Int_t kmothervertexnumber = 12;
5332   Double_t xmothervertex[kmothervertexnumber];  
5333   Double_t ymothervertex[kmothervertexnumber];  
5334   xmothervertex[0]  = xcontourvertex[0];
5335   xmothervertex[1]  = xmothervertex[0];
5336   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5337   xmothervertex[3]  = xmothervertex[2];
5338   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5339   xmothervertex[5]  = xmothervertex[4];
5340   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5341   xmothervertex[7]  = xmothervertex[6];
5342   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5343                                         + fgkEndCapCoverPlateLength[2]; 
5344   xmothervertex[9]  = xmothervertex[8];
5345   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5346   xmothervertex[11] = xmothervertex[10];
5347   
5348   ymothervertex[0]  = ycontourvertex[0];
5349   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5350   ymothervertex[2]  = ymothervertex[1];
5351   ymothervertex[3]  = ycontourvertex[1];
5352   ymothervertex[4]  = ymothervertex[3];
5353   ymothervertex[5]  = ymothervertex[1];
5354   ymothervertex[6]  = ymothervertex[5];
5355   ymothervertex[7]  = ymothervertex[0];
5356   ymothervertex[8]  = ymothervertex[7];
5357   ymothervertex[9]  = ymothervertex[8]
5358                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5359   ymothervertex[10] = ymothervertex[9];
5360   ymothervertex[11] = ymothervertex[8];
5361   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5362   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5363   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5364   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5365   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5366   ////////////////////////////////////////
5367   // Adding Nodes
5368   ////////////////////////////////////////
5369 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5370   TGeoTranslation*** endcapcoverplatesmallholetrans;
5371   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5372   Double_t transx[4] = {0,
5373                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5374                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5375                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5376                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5377                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5378   Int_t index = 0;
5379   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5380         endcapcoverplatesmallholetrans[i] = 
5381                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5382     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5383                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5384             endcapcoverplatesmallholetrans[i][j] = 
5385                 new TGeoTranslation(transx[i],
5386                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5387             if(index!=10){ 
5388                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5389                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5390                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5391                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5392                 }
5393                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5394                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5395                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5396     }
5397   }
5398   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5399   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5400   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5401   mothercoverplate->AddNode(endcapfillingbox,1);
5402   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5403   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5404   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5405   mothercoverplate->AddNode(holecontour[0],1);
5406   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5407   mothercoverplate->AddNode(holecontour[1],1);  
5408   mothercoverplate->AddNode(contour,1);
5409   /////////////////////////////////
5410   return mothercoverplate;      
5411  }
5412  ////////////////////////////////////////////////////////////////////////////////
5413  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5414   /////////////////////////////////////////////////////////////
5415   // Getting EndCap Cooling Tube 
5416   /////////////////////////////////////////////////////////////
5417   TGeoTorus* endcapcoolingtubetorushape[5];
5418   TGeoVolume* endcapcoolingtubetorus[5];
5419   TGeoTube* endcapcoolingtubeshape[4];
5420   TGeoVolume* endcapcoolingtube[4];
5421   char endcapcoolingtubetorusname[30];
5422   char endcapcoolingtubename[30];
5423   TGeoTorus* endcapcoolingwatertubetorushape[5];
5424   TGeoVolume* endcapcoolingwatertubetorus[5];
5425   TGeoTube* endcapcoolingwatertubeshape[4];
5426   TGeoVolume* endcapcoolingwatertube[4];
5427   char endcapcoolingwatertubetorusname[30];
5428   char endcapcoolingwatertubename[30];
5429   for(Int_t i=0; i<5; i++){
5430         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5431         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5432         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5433         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5434         if(i==3){
5435                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5436                                                                                 fgkEndCapCoolingTubeRadiusMin,
5437                                                                                 fgkEndCapCoolingTubeRadiusMax,
5438                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5439                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5440                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5441                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5442     }
5443         else{
5444                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5445                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5446                                                                            fgkEndCapCoolingTubeRadiusMin,
5447                                                                            fgkEndCapCoolingTubeRadiusMax,
5448                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5449                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5450                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5451                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5452                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5453         }
5454         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5455                                                                                            endcapcoolingtubetorushape[i],
5456                                                                                            fSSDCoolingTubePhynox);
5457         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5458                                                                                                         endcapcoolingwatertubetorushape[i],
5459                                                                                                         fSSDCoolingTubeWater);
5460     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5461     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5462     if(i<4){
5463                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5464                                                                   fgkEndCapCoolingTubeRadiusMax,
5465                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5466                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5467                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5468         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5469                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5470         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5471                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5472                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5473                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5474         }
5475   }
5476   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5477   /////////////////////////////////////////
5478   // Transformation for Volume Positioning 
5479   /////////////////////////////////////////
5480   TGeoCombiTrans* coolingtubecombitrans[6];
5481   TGeoRotation* coolingtuberot[8];
5482   TGeoTranslation* coolingtubetrans[6];
5483   TGeoHMatrix* coolingtubematrix[4];
5484   TGeoCombiTrans* torustubecombitrans[4];
5485   TGeoRotation* torustuberot[7];
5486   TGeoTranslation* torustubetrans[4];
5487   TGeoHMatrix* torustubematrix[5];
5488   TGeoCombiTrans* coolingwatertubecombitrans[6];
5489   TGeoRotation* coolingwatertuberot[8];
5490   TGeoTranslation* coolingwatertubetrans[6];
5491   TGeoHMatrix* coolingwatertubematrix[4];
5492   TGeoCombiTrans* toruswatertubecombitrans[4];
5493   TGeoRotation* toruswatertuberot[7];
5494   TGeoTranslation* toruswatertubetrans[4];
5495   TGeoHMatrix* toruswatertubematrix[5];
5496   for(Int_t i=0; i<8; i++){
5497     if(i<6){
5498          coolingtubetrans[i] = new TGeoTranslation();
5499          coolingwatertubetrans[i] = new TGeoTranslation();
5500     }
5501     if(i<8){
5502          coolingtuberot[i] = new TGeoRotation();
5503          coolingwatertuberot[i] = new TGeoRotation();
5504     }
5505     if(i<4){
5506          torustubetrans[i] = new TGeoTranslation();
5507          toruswatertubetrans[i] = new TGeoTranslation();
5508     }
5509     if(i<7){
5510          torustuberot[i] = new TGeoRotation();
5511          toruswatertuberot[i] = new TGeoRotation();
5512         }
5513   }
5514   /////////////////////////////////////////
5515   // Transformation for Inox Volume Positioning 
5516   /////////////////////////////////////////
5517   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5518                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5519   coolingtuberot[0]->SetAngles(0.,90.,0.);
5520   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5521                                                                                                 *coolingtuberot[0]);
5522                                                                                                 
5523   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5524   coolingtuberot[1]->SetAngles(0.,90.,0.);
5525   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5526                                                                                                 *coolingtuberot[1]);
5527
5528   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5529                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5530                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5531                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5532                                                                           0.);
5533   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5534   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5535                                                                                                 *coolingtuberot[2]);
5536
5537   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5538                                            *                             (*coolingtubecombitrans[1]));
5539
5540   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5541                                                                          endcapcoolingtubeshape[1]->GetDz());
5542   torustuberot[0]->SetAngles(0.,90.,0.); 
5543   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5544
5545   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5546
5547   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5548                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5549   coolingtuberot[3]->SetAngles(0.,90.,0.);
5550   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5551                                                                                                 *coolingtuberot[3]);
5552   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5553   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5554   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5555   
5556   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5557                                                                         endcapcoolingtubeshape[2]->GetDz());
5558   torustuberot[1]->SetAngles(0.,90.,0.); 
5559   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5560   torustuberot[2]->SetAngles(180.,0.,0.); 
5561   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5562   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5563
5564   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5565                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5566   torustuberot[3]->SetAngles(0.,90.,0.); 
5567   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5568   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5569   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5570   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5571
5572   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5573                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5574   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5575   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5576                                                                                                 *coolingtuberot[5]);
5577   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5578   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5579   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5580   
5581   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5582                                                                         endcapcoolingtubeshape[0]->GetDz());
5583   torustuberot[5]->SetAngles(0.,90.,0.); 
5584   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5585   torustuberot[6]->SetAngles(-90.,0.,0.); 
5586   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5587   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5588   
5589   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5590                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5591   coolingtuberot[6]->SetAngles(0.,90.,0.);
5592   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5593                                                                                                 *coolingtuberot[6]);
5594   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5595   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5596   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5597     /////////////////////////////////////////
5598   // Transformation for Water Volume Positioning 
5599   /////////////////////////////////////////
5600   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5601                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5602   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5603   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5604                                                                                                      *coolingwatertuberot[0]);
5605
5606   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5607   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5608   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5609                                                                                                      *coolingwatertuberot[1]);
5610
5611   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5612                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5613                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5614                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5615                                                                               0.);
5616   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5617   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5618                                                                                                     *coolingwatertuberot[2]);
5619
5620   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5621                                            *                                 (*coolingwatertubecombitrans[1]));
5622                                            
5623   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5624                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5625   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5626   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5627                                                                                                    *toruswatertuberot[0]);
5628
5629   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5630                                                   *                                     (*toruswatertubecombitrans[0]));
5631
5632   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5633                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5634   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5635   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5636                                                                                                      *coolingwatertuberot[3]);
5637   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5638   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5639                                                         *                                 (*coolingwatertubecombitrans[3]));
5640   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5641
5642   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5643                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5644   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5645   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5646                                                                                                    *toruswatertuberot[1]);
5647   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5648   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5649                                                   *                 (*toruswatertubecombitrans[1]));
5650   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5651   
5652   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5653                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5654   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5655   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5656                                                                                                    *toruswatertuberot[3]);
5657   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5658   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5659                                                   *                                     (*toruswatertubecombitrans[2]));
5660   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5661
5662   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5663                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5664   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5665   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5666                                                                                                      *coolingwatertuberot[5]);
5667   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5668   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5669                                                         *                                 (*coolingwatertubecombitrans[4]));
5670   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5671   
5672   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5673                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5674   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5675   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5676                                                                                                    *toruswatertuberot[5]);
5677   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5678   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5679                                                   *                 (*toruswatertubecombitrans[3]));
5680   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5681   
5682   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5683                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5684   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5685   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5686                                                                                                      *coolingwatertuberot[6]);
5687   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5688   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5689                                                         *                                 (*coolingwatertubecombitrans[5]));
5690   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5691   /////////////////////////////////////////
5692   // Positioning Volumes
5693   /////////////////////////////////////////
5694   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5695   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5696   
5697   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5698   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5699
5700   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5701   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5702  
5703   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5704   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5705
5706   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5707   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5708
5709   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5710   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5711
5712   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5713   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5714
5715   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5716   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5717   
5718   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5719   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5720  
5721   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5722   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5723   /////////////////////////////////////////////////////////////
5724   // Deallocating memory
5725   /////////////////////////////////////////////////////////////
5726   for(Int_t i=0; i<8; i++){
5727     if(i<6){
5728          delete coolingtubetrans[i];
5729          delete coolingwatertubetrans[i];
5730          if(i!=0){
5731           delete coolingtubecombitrans[i];
5732           delete coolingwatertubecombitrans[i];
5733          }
5734         }
5735     if(i<8){
5736           delete coolingtuberot[i];
5737           delete coolingwatertuberot[i];
5738     }
5739     if(i<4){
5740                 delete torustubetrans[i];
5741                 delete toruswatertubetrans[i];
5742                 delete torustubecombitrans[i];
5743                 delete toruswatertubecombitrans[i];
5744         } 
5745     if(i<7){
5746          delete torustuberot[i];
5747          delete toruswatertuberot[i];
5748         }
5749   }
5750   /////////////////////////////////////////////////////////////
5751   return endcapcoolingtubemother;
5752  }
5753  ////////////////////////////////////////////////////////////////////////////////
5754  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5755   /////////////////////////////////////////////////////////////
5756   // Getting EndCap Cover Side 
5757   /////////////////////////////////////////////////////////////
5758   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5759   const Int_t kvertexnumber = 15; 
5760   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5761   xvertex[0]  = 0.0;
5762   xvertex[1]  = xvertex[0];
5763   xvertex[2]  = fgkEndCapSideCoverLength[0];
5764   xvertex[3]  = fgkEndCapSideCoverLength[1];
5765   xvertex[4]  = xvertex[3];
5766   xvertex[5]  = fgkEndCapSideCoverLength[2];
5767   xvertex[6]  = xvertex[5];
5768   xvertex[7]  = xvertex[2];
5769   xvertex[8]  = xvertex[7];
5770   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5771   xvertex[10] = xvertex[9];
5772   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5773                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5774                           * fgkEndCapSideCoverLength[4];
5775   xvertex[12] = xvertex[11];
5776   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5777                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5778                           * fgkEndCapSideCoverLength[4];
5779   xvertex[14] = xvertex[13];
5780   yvertex[0]  = 0.0;
5781   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5782   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5783   yvertex[3]  = yvertex[2];
5784   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5785   yvertex[5]  = yvertex[4];
5786   yvertex[6]  = yvertex[0];
5787   yvertex[7]  = yvertex[6];
5788   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5789   yvertex[9]  = yvertex[8];
5790   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5791   yvertex[11] = yvertex[10];
5792   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5793   yvertex[13] = yvertex[12];
5794   yvertex[14] = yvertex[6];
5795   TGeoXtru* endcapsidecovershape = new TGeoXtru(2);
5796   endcapsidecovershape->DefinePolygon(kvertexnumber,xvertex,yvertex); 
5797   endcapsidecovershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5798   endcapsidecovershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5799   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5800                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5801   endcapsidecover->SetLineColor(fColorPhynox);
5802   ////////////////////////////////////////////
5803   // Defininition of Mother Volume
5804   ////////////////////////////////////////////
5805   const Int_t kmothervertexnumber = 7;
5806   Double_t xmothervertex[kmothervertexnumber]; 
5807   Double_t ymothervertex[kmothervertexnumber]; 
5808   for(Int_t i=0; i<kmothervertexnumber; i++){
5809         xmothervertex[i] = xvertex[i];
5810         ymothervertex[i] = yvertex[i];
5811   }
5812   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5813   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5814   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5815   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5816   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5817                                                                 endcapsidecovermothershape,fSSDAir);
5818   ////////////////////////////////////////////
5819   endcapsidecovermother->AddNode(endcapsidecover,1);
5820   TGeoBBox* endcapsidecoverboxshape[4];
5821   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5822                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5823                                                                0.5*fgkEndCapSideCoverLength[4],
5824                                                                    0.5*fgkEndCapSideCoverThickness); 
5825   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5826                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5827                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5828                                                          -     fgkEndCapSideCoverLength[4]),
5829                                                                    0.5*fgkEndCapSideCoverThickness); 
5830   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5831                                                                0.5*fgkEndCapSideCoverLength[4],
5832                                                                    0.5*fgkEndCapSideCoverThickness); 
5833   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5834                                                                0.5*fgkEndCapSideCoverWidth[5],
5835                                                                    0.5*fgkEndCapSideCoverThickness); 
5836   TGeoVolume* endcapsidecoverbox[4];
5837   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5838   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5839   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5840   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5841   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5842 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5843   TGeoTranslation** endcapsidecoverboxtrans;
5844   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5845   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5846                                                          +                                         fgkEndCapSideCoverLength[0],
5847                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5848                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5849   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5850                                                          +                     xvertex[11],
5851                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5852                                                          +                     yvertex[12],0.);
5853   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5854                                                          +                     xvertex[11],
5855                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5856                                                          +                     yvertex[12]
5857                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5858                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5859   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5860   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5861   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5862   for(Int_t i=0; i<2; i++)
5863         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5864                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5865                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5866                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5867                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5868                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5869                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5870                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5871         }
5872   for(Int_t i=0; i<2; i++)
5873         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5874                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5875                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5876                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5877                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5878                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5879                                                         +fgkEndCapSideCoverLength[4]),0.0);
5880                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5881                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5882                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5883                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5884         }
5885         return endcapsidecovermother;
5886  } 
5887  ////////////////////////////////////////////////////////////////////////////////
5888  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5889  ////////////////////////////////////////////////////////////////////////////////
5890  // Method returning Interface Card A, Interface Card B, Supply Card 
5891  ////////////////////////////////////////////////////////////////////////////////
5892  /////////////////////
5893  // Supply Card
5894  /////////////////////
5895  // Electronic Board Back Al Plane
5896  const Int_t kelectboardbackvertexnumber = 8;
5897  Double_t xelectboardback[kelectboardbackvertexnumber];
5898  Double_t yelectboardback[kelectboardbackvertexnumber];
5899  xelectboardback[0] = 0.0;
5900  xelectboardback[1] = xelectboardback[0];
5901  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5902  xelectboardback[3] = xelectboardback[2];
5903  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5904  xelectboardback[5] = xelectboardback[4];
5905  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5906  xelectboardback[7] = xelectboardback[6];
5907  
5908  yelectboardback[0] = 0.0;
5909  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5910  yelectboardback[2] = yelectboardback[1];
5911  yelectboardback[3] = yelectboardback[0];
5912  yelectboardback[4] = yelectboardback[3];
5913  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5914  yelectboardback[6] = yelectboardback[5];
5915  yelectboardback[7] = yelectboardback[4];
5916  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5917  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5918                                                                         xelectboardback,yelectboardback); 
5919  electboardbackshape->DefineSection(0,0.0);
5920  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5921  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5922                                                                                          electboardbackshape,fSSDSupportRingAl);
5923  electboardback->SetLineColor(fColorAl);
5924  // Electronic Board Kapton Layer
5925  const Int_t kelectlayervertexnumber = 8;
5926  Double_t xelectlayer[kelectlayervertexnumber];
5927  Double_t yelectlayer[kelectlayervertexnumber];
5928  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5929  xelectlayer[1] = xelectlayer[0];
5930  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5931  xelectlayer[3] = xelectlayer[2];
5932  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5933      
5934  yelectlayer[0] = 0.0;
5935  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5936  yelectlayer[2] = yelectlayer[1];
5937  yelectlayer[3] = yelectlayer[0];
5938  yelectlayer[4] = yelectlayer[3];
5939  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5940  yelectlayer[6] = yelectlayer[5];
5941  yelectlayer[7] = yelectlayer[4];
5942  TGeoXtru* electlayershape = new TGeoXtru(2);
5943  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5944  electlayershape->DefineSection(0,0.0);
5945  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5946  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5947                                                                                          electlayershape,fSSDKaptonFlexMedium);
5948  electlayer->SetLineColor(fColorKapton);
5949  // JMD Connector Female
5950  const Int_t kjmdconnectorvertexnumber = 6;
5951  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5952  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5953  xjmdconnectorvertex[0] = 0.0; 
5954  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5955  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5956  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5957  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5958  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5959
5960  yjmdconnectorvertex[0] = 0.0; 
5961  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5962  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5963  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5964  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5965  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5966  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5967  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5968                                                                   yjmdconnectorvertex); 
5969  jmdconnectorshape->DefineSection(0,0.0);
5970  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
5971  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
5972                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
5973  jmdconnector->SetLineColor(fColorG10);
5974  // Top Cable Connector
5975  const Int_t kcableconnectorvertexnumber = 8;
5976  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
5977  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
5978  xconnectorvertex[0] = 0.0;
5979  xconnectorvertex[1] = xconnectorvertex[0];
5980  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
5981  xconnectorvertex[3] = xconnectorvertex[2];
5982  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
5983                                          - fgkEndCapCardCableConnectorLength[2];
5984  xconnectorvertex[5] = xconnectorvertex[4];
5985  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
5986  xconnectorvertex[7] = xconnectorvertex[6];
5987
5988  yconnectorvertex[0] = 0.0;
5989  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
5990  yconnectorvertex[2] = yconnectorvertex[1];
5991  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
5992  yconnectorvertex[4] = yconnectorvertex[3];
5993  yconnectorvertex[5] = yconnectorvertex[1];
5994  yconnectorvertex[6] = yconnectorvertex[5];
5995  yconnectorvertex[7] = yconnectorvertex[0];
5996  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
5997  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
5998                                                                     yconnectorvertex); 
5999  cableconnectorshape->DefineSection(0,0.0);
6000  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6001  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6002                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6003  cableconnector->SetLineColor(fColorG10);
6004  // Strip Connection
6005  TGeoBBox* endcapstripconnectionshape = 
6006                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6007                                                                                          0.5*fgkEndCapStripConnectionThickness,
6008                                                                                          0.5*fgkEndCapStripConnectionWidth);
6009  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6010                                                                                                         endcapstripconnectionshape,
6011                                                                                                         fSSDSupportRingAl);
6012  endcapstripconnection->SetLineColor(fColorAl);
6013  // Interface Card B
6014  const Int_t kcardBvertexnumber = 12; 
6015  Double_t xcardBvertexnumber[kcardBvertexnumber];
6016  Double_t ycardBvertexnumber[kcardBvertexnumber];
6017
6018  xcardBvertexnumber[0]  = 0.0;
6019  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6020  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6021  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6022  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6023  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6024  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6025  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6026  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6027  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6028  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6029  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6030  
6031  ycardBvertexnumber[0]  = 0.0;
6032  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6033  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6034  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6035  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6036  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6037  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6038  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6039  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6040  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6041  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6042  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6043
6044  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6045  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6046  interfacecardBshape->DefineSection(0,0.);
6047  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6048  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6049                                                                                          fSSDMountingBlockMedium);
6050  interfacecardB->SetLineColor(46);
6051  // Interface Card B Electronic Board
6052  const Int_t kelectboardcardBvertexnumber = 14; 
6053  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6054  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6055
6056  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6057  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6058  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6059  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6060  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6061  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6062  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6063  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6064  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6065  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6066  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6067  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6068  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6069  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6070
6071  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6072  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6073  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6074  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6075  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6076  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6077  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6078  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6079  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6080  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6081  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6082  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6083  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6084  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6085
6086  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6087  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6088                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6089  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6090  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6091                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6092  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6093                                                                                           fSSDSupportRingAl);
6094  electboardcardB->SetLineColor(fColorAl);
6095  // Generating Stiffener 2
6096  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6097                                                                                            0.5*fgkEndCapStiffenerThickness,
6098                                                                                            0.5*fgkEndCapStiffenerLength);
6099  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6100  endcapstiffener->SetLineColor(fColorAl);   
6101  // Generating Mother Interface Card B Container
6102  const Int_t kinterfacecardBmothervertexnumber = 10;
6103  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6104  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6105
6106  xinterfacecardBmothervertex[0] = 0.0;
6107  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6108  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6109                                                                 + fgkEndCapInterfaceCardBThickness;
6110  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6111  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6112                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6113  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6114  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6115  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6116  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6117                                                                 + fgkEndCapCardJMDConnectorLength[0];
6118  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6119
6120  yinterfacecardBmothervertex[0] = 0.0;
6121  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6122                                                                 + fgkEndCapInterfaceCardBWidth[1]
6123                                                                 + fgkEndCapInterfaceCardBWidth[2];
6124  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6125  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6126  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6127  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6128  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6129  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6130                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6131                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6132  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6133  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6134  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6135  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6136                                                                                   xinterfacecardBmothervertex,
6137                                                                                   yinterfacecardBmothervertex);
6138  interfacecardBmothershape->DefineSection(0,-1.e-15);
6139  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6140  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6141                                                                                                    interfacecardBmothershape,fSSDAir);
6142  electboardcardB->SetLineColor(fColorAl);
6143  // Positioning Volumes Mother Interface Card B Container 
6144  TGeoRotation* interfacecardBrot = new TGeoRotation();
6145  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6146  interfacecardBrot->SetAngles(90.,-90.,-90.);
6147  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6148  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6149  TGeoRotation* electboardcardBrot = new TGeoRotation();
6150  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6151  electboardcardBrot->SetAngles(90.,90.,-90.);
6152  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6153  TGeoCombiTrans* electboardcardBcombitrans = 
6154                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6155  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6156  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6157  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6158  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6159  TGeoTranslation* jmdconnectorcardBtrans[3];
6160  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6161  for(Int_t i=0; i<3; i++){
6162    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6163                                                          + fgkEndCapCardJMDConnectorLength[0], 
6164                                                            fgkEndCapCardElectBoardLayerWidth[1],
6165                                                            0.5*fgkEndCapCardJMDConnectorThickness
6166                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6167                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6168                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6169    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6170                                                                                                            *jmdconnectorcardBrot);
6171    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6172  }
6173  // Mother Supply Card Container 
6174  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6175  // Interface Card Container
6176  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6177  // Placing Volumes in Mother Supply Card Container
6178  // JMD Connector Positioning
6179  TGeoTranslation* jmdconnectortrans[2];
6180  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6181  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6182                                                                                         fgkEndCapCardElectBoardBackLength[0]
6183                                           -                                             fgkEndCapCardJMDConnectorThickness
6184                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6185  TGeoRotation* jmdconnectorot = new TGeoRotation();
6186  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6187                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6188                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6189                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6190                                                                       fgkEndCapCardJMDConnectorThickness
6191                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6192  jmdconnectorot->SetAngles(90.,180.,-90);
6193  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6194                                                                                 * jmdconnectorot);
6195  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6196  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6197  // Top Cable Connector Placing
6198  TGeoRotation* cableconnectorot[2];
6199  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6200  TGeoTranslation* cableconnectortrans[3];
6201  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6202  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6203  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6204  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6205  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6206                                                                                                                            *cableconnectorot[0]);
6207  TGeoHMatrix* cableconnectormatrix[2];
6208  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6209                                                         new TGeoHMatrix((*cableconnectorot[1])
6210                                                                                    *(*cableconnectorcombitrans));
6211  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6212                                            -                               fgkEndCapCardCableConnectorThickness,
6213                                                                                 fgkEndCapCardCableConnectorLength[0]
6214                                            +                            fgkEndCapCardCableConnectorToLayer);
6215  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6216                                            -                2.*fgkEndCapCardCableConnectorThickness
6217                                            -                            fgkEndCapCardCableConnectorDistance,
6218                                                                                 fgkEndCapCardCableConnectorLength[0]
6219                                            +                            fgkEndCapCardCableConnectorToLayer);
6220  for(Int_t i=0; i<2; i++){
6221         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6222     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6223  }
6224  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6225  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6226  electboardbackrot->SetAngles(90.,-90.,-90.);
6227  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6228                                                         +                fgkEndCapCardJMDConnectorLength[0]
6229                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6230  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6231                                                                                                                            *electboardbackrot);
6232  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6233  // Electronic Board Kapton Layer Positioning
6234  TGeoRotation* electlayerrot = new TGeoRotation();
6235  TGeoTranslation* electlayertrans[2];
6236  TGeoCombiTrans* electlayercombitrans[2];
6237  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6238  electlayerrot->SetAngles(90.,-90.,-90.);
6239  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6240                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6241  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6242                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6243                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6244  for(Int_t i=0; i<2; i++){
6245         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6246         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6247  }
6248  // Placing Volumes in Mother Interface Card Container
6249  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6250  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6251  for(Int_t i=0; i<2; i++){
6252         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6253  }
6254  /////////////////////////////////////////////////////////////
6255  // Generation of Card Interface Container
6256  /////////////////////////////////////////////////////////////
6257  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6258                                                   - fgkEndCapCardJMDConnectorLength[0]
6259                                                   - fgkEndCapInterfaceCardBThickness
6260                                                   - 9.*fgkEndCapStripConnectionThickness
6261                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6262  const Int_t kcardinterfacecontainervertexnumber = 14;
6263  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6264  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6265  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6266                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6267  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6268  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6269                                                                    + fgkEndCapStripConnectionThickness
6270                                                                    - fgkEndCapCardElectBoardLayerThickness
6271                                                                    - fgkEndCapCardCableConnectorWidth[0];
6272  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6273  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6274  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6275  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6276                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6277  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6278  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6279                                                                    + fgkEndCapInterfaceCardBThickness;
6280  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6281  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6282                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6283  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6284  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6285                                    - fgkEndCapInterfaceElectBoardCardBThickness
6286                                                                    + fgkEndCapCardJMDConnectorLength[0]
6287                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6288  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6289
6290  ycardinterfacecontainervertex[0]  = 0.;
6291  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6292                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6293                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6294  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6295  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6296                                                                    - fgkEndCapStripConnectionWidth;
6297  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6298  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6299  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6300  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6301                                                                    + fgkEndCapInterfaceCardBWidth[1]
6302                                                                    + fgkEndCapInterfaceCardBWidth[2];
6303  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6304  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6305  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6306  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6307  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6308  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6309  
6310  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6311  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6312                                                                                   xcardinterfacecontainervertex,
6313                                                                                   ycardinterfacecontainervertex);
6314  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6315                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6316  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6317                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6318  TGeoVolume** cardinterfacecontainer;
6319  cardinterfacecontainer = new TGeoVolume*[4];
6320  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6321                                                                                         interfacecardmothershape,fSSDAir); 
6322  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6323                                                                                         interfacecardmothershape,fSSDAir); 
6324  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6325                                                                                         interfacecardmothershape,fSSDAir); 
6326  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6327                                                                                         interfacecardmothershape,fSSDAir); 
6328  /////////////////////////////////
6329  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6330  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6331  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6332  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6333  /////////////////////////////////
6334  TGeoRotation* endcapstripconnectionrot[2];
6335  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6336  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6337  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6338  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6339                                                                         *                                 (*endcapstripconnectionrot[0]));
6340  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6341  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6342                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6343                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6344                                                                                         -endcapstripconnectionshape->GetDZ(),
6345                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6346  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6347  TGeoTranslation* cardinterfacetrans[9];
6348  TGeoHMatrix* cardinterfacematrix[9]; 
6349  for(Int_t i=0; i<7; i++){ 
6350         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6351                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6352                                                                                                 0.0,0.0);  
6353         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6354                                                    *                             (*endcapstripconnectionmatrix));
6355  }
6356  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6357                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6358                                                                                                 0.0,0.0);  
6359  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6360                                                 *                                 (*endcapstripconnectionmatrix));
6361  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6362                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6363                                                                                                 0.0,0.0);  
6364  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6365                                                 *                                 (*endcapstripconnectionmatrix));
6366
6367  for(Int_t i=0; i<4; i++){
6368         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6369                                                                            cardinterfacematrix[7]);                             
6370         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6371                                                                            cardinterfacematrix[8]);                             
6372  }
6373  TGeoTranslation* mothersupplycardtrans = 
6374                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6375                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6376                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6377  TGeoHMatrix* mothersupplycardmatrix[7];
6378  Int_t index[4] = {1,1,1,1};
6379  for(Int_t i=0; i<7; i++){
6380         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6381                                                         *                                 (*mothersupplycardtrans));
6382         for(Int_t j=0; j<4; j++){
6383                 switch(j){
6384                         case 0: //Layer5 EndCap Left Side  
6385                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6386                                                                                                    cardinterfacematrix[i]);                             
6387                                 if(i!=0){
6388                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6389                                                                                                            mothersupplycardmatrix[i]);                  
6390                                         index[j]++;
6391
6392                                 }
6393                         break;
6394                         case 1: //Layer5 EndCap Rigth Side  
6395                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6396                                                                                                    cardinterfacematrix[i]);                     
6397                                 if(i>0&&i<6){
6398                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6399                                                                                                            mothersupplycardmatrix[i]);                  
6400                                         index[j]++;
6401                                 }
6402                         break;
6403                         case 2: //Layer6 EndCap Left Side  
6404                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6405                                                                                                    cardinterfacematrix[i]);                             
6406                                 if(i!=6){
6407                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6408                                                                                                            mothersupplycardmatrix[i]);                  
6409                                         index[j]++;
6410                                 }
6411                         break;
6412                         case 3: //Layer6 EndCap Right Side  
6413                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6414                                                                                                    cardinterfacematrix[i]);                             
6415                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6416                                                                                                    mothersupplycardmatrix[i]);                  
6417                                 index[j]++;
6418                         break;
6419                 }
6420         }
6421  }
6422  // Positioning Interface 
6423  TGeoTranslation* motherinterfacecardtrans = 
6424                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6425                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6426                                                          -fgkEndCapCardElectBoardLayerThickness
6427                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6428  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6429                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6430  // Positioning Interface Card B 
6431  TGeoTranslation* interfacecardBmothertrans = 
6432                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6433                                                                                 + 2.*fgkEndCapStripConnectionThickness
6434                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6435                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6436                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6437  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6438                                                                                                                          interfacecardBmothertrans);
6439  // Positioning Stiffener 
6440  TGeoTranslation* endcapstiffenertrans = 
6441                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6442                                                                            +    2.0*fgkEndCapStripConnectionThickness
6443                                                                            +    fgkEndCapInterfaceCardBThickness
6444                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6445                                                                            +    stiffenertransx
6446                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6447                                                                                         endcapstiffenershape->GetDZ()
6448                                                                            -    0.5*(fgkEndCapStiffenerLength
6449                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6450  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6451  /////////////////////////////////////////////////////////////
6452  // Deallocating memory
6453  /////////////////////////////////////////////////////////////
6454  delete interfacecardBrot;
6455  delete interfacecardBtrans;
6456  delete electboardcardBtrans;
6457  delete electboardcardBrot; 
6458  delete jmdconnectorcardBrot;
6459  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6460  delete jmdconnectorot;
6461  delete jmdconnectortrans[1];
6462  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6463  delete cableconnectorcombitrans;
6464  delete electboardbacktrans;
6465  delete electboardbackrot;
6466  delete electlayerrot;
6467  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6468  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6469  delete mothersupplycardtrans;
6470  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6471  /////////////////////////////////////////////////////////////
6472  return cardinterfacecontainer;
6473  }
6474  ////////////////////////////////////////////////////////////////////////////////
6475  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6476   /////////////////////////////////////////////////////////////
6477   // Method returning EndCap Mother Volume
6478   /////////////////////////////////////////////////////////////
6479   const Int_t kendcapcoverplatesmallholenumber = 9;
6480   Double_t endcapmotherorigin[3];
6481   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6482                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6483                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6484   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6485                                           -                      fgkEndCapCoverPlateWidth[2]
6486                                           -       (kendcapcoverplatesmallholenumber-1)
6487                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6488                                           +  0.5*(fgkEndCapSideCoverLength[2]
6489                                           +               fgkEndCapCoverPlateWidth[1]
6490                                           -       fgkEndCapCoverPlateWidth[0])
6491                                           -      (fgkEndCapCoverPlateWidth[1]
6492                                           -       fgkEndCapCoverPlateWidth[0]);
6493   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6494                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6495                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6496                                                 +      fgkEndCapSideCoverWidth[1]
6497                                                 +      fgkEndCapSideCoverThickness
6498                                                 +      fgkEndCapKaptonFoilThickness);
6499   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6500                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6501                                                           +              2.0* fgkEndCapSideCoverThickness),
6502                                                                          0.5* (fgkEndCapSideCoverLength[2]
6503                                                           +                    fgkEndCapCoverPlateWidth[1]
6504                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6505                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6506                                                       +                                    fgkEndCapSideCoverWidth[1]
6507                                                           +                                       fgkEndCapSideCoverThickness
6508                                                       +                                   fgkEndCapKaptonFoilThickness),
6509                                                                                          endcapmotherorigin);
6510   TGeoVolume** endcapassembly;  
6511   endcapassembly = new TGeoVolume*[4];
6512   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6513                                                                                         endcapmothershape,fSSDAir); 
6514   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6515                                                                                         endcapmothershape,fSSDAir); 
6516   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6517                                                                                         endcapmothershape,fSSDAir); 
6518   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6519                                                                                         endcapmothershape,fSSDAir); 
6520  /////////////////////////////////
6521  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6522  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6523  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6524  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6525  /////////////////////////////////
6526   /////////////////////////////////////////////////////
6527   // Placing Endcap Cover Plate
6528   /////////////////////////////////////////////////////
6529   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6530   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6531   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6532   TGeoCombiTrans* endcapcoverplatecombitrans = 
6533                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6534                                                                                          endcapcoverplaterot);
6535   TGeoTranslation* endcapcoverplatetrans = 
6536                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6537   TGeoHMatrix* endcapcoverplatematrix = 
6538                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6539                                                                           *       (*endcapcoverplatecombitrans));
6540   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6541   /////////////////////////////////////////////////////
6542   // Placing Endcap Side Cover
6543   /////////////////////////////////////////////////////
6544   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6545   TGeoRotation* endcapsidecoverot[2];
6546   TGeoCombiTrans* endcapsidecovercombitrans[3];
6547   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6548   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6549   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6550                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6551                                                                                         - fgkEndCapCoverPlateWidth[2]
6552                                                                                     - (kendcapcoverplatesmallholenumber-1)
6553                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6554                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6555                                                                                         + fgkEndCapSideCoverLength[2],
6556                                                                                           0.5*(fgkEndCapSideCoverThickness
6557                                                                                         + fgkEndCapCoverPlateThickness)
6558                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6559                                                                                           endcapsidecoverot[0]);
6560   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6561   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6562                                                                                                         0.5*fgkEndCapCoverPlateThickness
6563                                                                                                         -fgkEndCapSideCoverWidth[1],
6564                                                                                                         endcapsidecoverot[1]);
6565   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6566                                                                                                         +fgkEndCapCoverPlateLength[3]
6567                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6568                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6569                                                                                                         0.5*fgkEndCapCoverPlateThickness
6570                                                                                                         -fgkEndCapSideCoverWidth[1],
6571                                                                                                         endcapsidecoverot[1]);
6572   TGeoHMatrix* endcapsidecovermatrix[2];
6573   for(Int_t i=0; i<2; i++){
6574    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6575                                                         *                                 (*endcapsidecovercombitrans[0]));
6576         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6577                                                                                                                 endcapsidecovermatrix[i]);
6578   }
6579   /////////////////////////////////////////////////////
6580   // Placing Endcap Cooling Tube
6581   /////////////////////////////////////////////////////
6582   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6583   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6584   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6585   TGeoCombiTrans* endcapccolingtubecombitrans 
6586                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6587                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6588                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6589                                                 - fgkEndCapCoolingTubeToCoverSide,
6590                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6591                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6592   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6593                                                                                                           endcapccolingtubecombitrans);
6594   /////////////////////////////////////////////////////
6595   // Placing Screws 
6596   /////////////////////////////////////////////////////
6597   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6598                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6599   Int_t screwcoverplatedgesnumber[2] = {20,20};
6600   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6601                                                                                 fgkEndCapCoverPlateThickness
6602                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6603   TGeoXtru* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6604                                                                                                  screwcoverplatedgesnumber,
6605                                                                                                  screwcoverplatesection);
6606   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6607                                                                                            screwcoverplateshape,
6608                                                                                            fSSDCoolingTubePhynox); 
6609   screwcoverplate->SetLineColor(12);
6610   Double_t transx[4] = {0,
6611                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6612                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6613                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6614                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6615                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6616   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6617 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6618   TGeoTranslation*** endcapcoverplatescrewtrans;
6619   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6620   Int_t index = 0;
6621   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6622         endcapcoverplatescrewtrans[i] = 
6623                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6624     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6625                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6626         if(index==1||index==9||index==28||index==36){
6627                         endcapcoverplatescrewtrans[i][j] = 
6628                                 new TGeoTranslation(transx[i],
6629                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6630                                                                         fgkEndCapSideCoverThickness);
6631                 }
6632                 else{
6633                         endcapcoverplatescrewtrans[i][j] = 
6634                                 new TGeoTranslation(transx[i],
6635                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6636                                                                         0.);
6637                 }
6638             if(index!=19) 
6639                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6640                                                                                           endcapcoverplatescrewtrans[i][j]);
6641         }
6642   }
6643   /////////////////////////////////////////////////////
6644   // Placing Cover Plate Clips 
6645   /////////////////////////////////////////////////////
6646   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6647                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6648                                                                                                          0.5*fgkEndCapSideCoverThickness);
6649   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6650                                                                                                         endcapcoverplateclipshape,
6651                                                                                                         fSSDCoolingTubePhynox);
6652   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6653                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6654                                                                                                          0.5*fgkEndCapSideCoverThickness);
6655   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6656                                                                                                         endcapcoverplatedownclipshape,
6657                                                                                                         fSSDCoolingTubePhynox);
6658   TGeoTranslation* endcapcoverplatecliptrans[4];
6659   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6660                                                            -                     fgkEndCapCoverPlateLength[0]
6661                                                            -                     fgkEndCapSideCoverThickness,
6662                                                                                                          0.0,
6663                                                                                                  0.5*(fgkEndCapSideCoverThickness
6664                                                            +                                              fgkEndCapCoverPlateThickness));
6665   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6666                                                            -                     fgkEndCapCoverPlateLength[0]
6667                                                            -                     fgkEndCapSideCoverThickness,
6668                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6669                                                            *                                     fgkEndCapSideCoverWidth[5],
6670                                                                                                  0.5*(fgkEndCapSideCoverThickness
6671                                                            +                                              fgkEndCapCoverPlateThickness));
6672   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6673                                                            -                     fgkEndCapCoverPlateLength[0]
6674                                                            +                                     fgkEndCapCoverPlateLength[1]
6675                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6676                                                            -                                     fgkEndCapCoverPlateClipLength
6677                                                            +                                 fgkEndCapSideCoverThickness,
6678                                                                                                          0.0,
6679                                                                                                  0.5*(fgkEndCapSideCoverThickness
6680                                                            +                                              fgkEndCapCoverPlateThickness));
6681   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6682                                                            -                     fgkEndCapCoverPlateLength[0]
6683                                                            +                                     fgkEndCapCoverPlateLength[1]
6684                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6685                                                            -                                     fgkEndCapCoverPlateClipLength
6686                                                            +                                 fgkEndCapSideCoverThickness,
6687                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6688                                                            *                                     fgkEndCapSideCoverWidth[5],
6689                                                                                                  0.5*(fgkEndCapSideCoverThickness
6690                                                            +                                              fgkEndCapCoverPlateThickness));
6691   endcapcoverplateclip->SetLineColor(fColorPhynox);
6692   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6693   for(Int_t i=0; i<4; i++) 
6694         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6695                                                                                                    endcapcoverplatecliptrans[i]);  
6696   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6697   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6698                                                                    -                     fgkEndCapCoverPlateLength[0]
6699                                                                    -                     fgkEndCapSideCoverThickness,
6700                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6701                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6702                                                                                                         0.5*(fgkEndCapSideCoverThickness
6703                                                                +                                         fgkEndCapCoverPlateThickness)
6704                                                                    -                     fgkEndCapSideCoverWidth[1]
6705                                                                    -                                     fgkEndCapSideCoverThickness);
6706   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6707                                                                    -                     fgkEndCapCoverPlateLength[0]
6708                                                                    -                     fgkEndCapSideCoverThickness,
6709                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6710                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6711                                                                    +                            fgkEndCapSideCoverLength[2]
6712                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6713                                                                                                         0.5*(fgkEndCapSideCoverThickness
6714                                                                +                                         fgkEndCapCoverPlateThickness)
6715                                                                    -                     fgkEndCapSideCoverWidth[1]
6716                                                                    -                                     fgkEndCapSideCoverThickness);
6717   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6718                                                                    -                     fgkEndCapCoverPlateLength[0]
6719                                                                    +                     fgkEndCapSideCoverThickness
6720                                                                    +                     fgkEndCapCoverPlateLength[1]
6721                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6722                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6723                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6724                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6725                                                                                                         0.5*(fgkEndCapSideCoverThickness
6726                                                                +                                         fgkEndCapCoverPlateThickness)
6727                                                                    -                     fgkEndCapSideCoverWidth[1]
6728                                                                    -                                     fgkEndCapSideCoverThickness);
6729   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6730                                                                    -                     fgkEndCapCoverPlateLength[0]
6731                                                                    +                     fgkEndCapSideCoverThickness
6732                                                                    +                     fgkEndCapCoverPlateLength[1]
6733                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6734                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6735                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6736                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6737                                                                    +                                 fgkEndCapSideCoverLength[2]
6738                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6739                                                                                                         0.5*(fgkEndCapSideCoverThickness
6740                                                                +                                         fgkEndCapCoverPlateThickness)
6741                                                                    -                     fgkEndCapSideCoverWidth[1]
6742                                                                    -                                     fgkEndCapSideCoverThickness);
6743   for(Int_t i=0; i<4; i++)
6744         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6745                                                                                                    endcapcoverplatedowncliptrans[i]);
6746   /////////////////////////////////////////////////////
6747   // Placing Kapton Foil
6748   /////////////////////////////////////////////////////
6749   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6750                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6751                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6752   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6753                                                                                                 endcapkaptonfoilshape,
6754                                                                                                 fSSDKaptonFlexMedium);
6755   endcapkaptonfoil->SetLineColor(8);
6756   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6757                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6758                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6759                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6760                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6761                                                                              -                     fgkEndCapSideCoverWidth[1]
6762                                                                                  -                     fgkEndCapSideCoverThickness);
6763   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6764   /////////////////////////////////////////////////////////////
6765   // Placing Electronic Tubes
6766   /////////////////////////////////////////////////////////////
6767   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6768                                                                              - fgkEndCapInterfaceCardBThickness
6769                                                                              - 9.*fgkEndCapStripConnectionThickness
6770                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6771                                                                                fgkEndCapKaptonFoilWidth
6772                                                                              - fgkEndCapInterfaceCardBThickness
6773                                                                              - 9.*fgkEndCapStripConnectionThickness
6774                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6775                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6776   TGeoVolume* endcapeffectivecables[2];
6777   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6778                                                                                          fgkEndCapEffectiveCableRadiusMax,
6779                                                                                          endcapeffectivecableswidth[0],
6780                                                                                          10,"EndCapEffectiveCables1"); 
6781   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6782                                                                                          fgkEndCapEffectiveCableRadiusMax,
6783                                                                                          endcapeffectivecableswidth[1],
6784                                                                                          25,"EndCapEffectiveCables2"); 
6785   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6786   TGeoTranslation* endcapeffectivecablestrans[2];
6787   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6788                                           -                                                        0.5*endcapeffectivecableswidth[0]
6789                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6790                                           -                                                               fgkEndCapCoverPlateWidth[2]
6791                                           -                                             (kendcapcoverplatesmallholenumber-1)
6792                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6793                                           +                                             fgkEndCapSideCoverLength[2],
6794                                           -                     0.5*fgkEndCapCoverPlateThickness
6795                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6796                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6797                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6798   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6799                                           -                                                        0.5*endcapeffectivecableswidth[1]
6800                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6801                                           -                                                               fgkEndCapCoverPlateWidth[2]
6802                                           -                                             (kendcapcoverplatesmallholenumber-1)
6803                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6804                                           +                                         fgkEndCapSideCoverLength[2],
6805                                           -                     0.5*fgkEndCapCoverPlateThickness
6806                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6807                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6808                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6809   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6810   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6811   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6812                                                                                                                    *endcapeffectivecablesrot);
6813   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6814                                                                                                                    *endcapeffectivecablesrot);
6815 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6816 //                                                                                                        endcapeffectivecablescombitrans[0]);
6817   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6818                                                                                                           endcapeffectivecablescombitrans[1]);
6819   /////////////////////////////////////////////////////////////
6820   // Placing End Cap Cards
6821   /////////////////////////////////////////////////////////////
6822   TGeoVolume** endcapcards = GetEndCapCards();
6823   TGeoRotation* endcapcardsrot[2];
6824   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6825   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6826   TGeoTranslation* endcapcardstrans[2]; 
6827   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6828                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6829   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6830   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6831   TGeoHMatrix* endcapcardsmatrix[2];
6832   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6833   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6834                                                   - fgkEndCapCardJMDConnectorLength[0]
6835                                                   - fgkEndCapInterfaceCardBThickness
6836                                                   - 9.*fgkEndCapStripConnectionThickness
6837                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6838   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6839                                           -                                             fgkEndCapCoverPlateLength[0]
6840                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6841                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6842                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6843                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6844                                           -                                                               fgkEndCapInterfaceCardBThickness
6845                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6846                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6847                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6848                                           -                                                               fgkEndCapCoverPlateWidth[2]
6849                                           -                                             (kendcapcoverplatesmallholenumber-1)
6850                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6851                                           +                     fgkEndCapKaptonFoilWidth,
6852                                                                                           0.5*fgkEndCapCoverPlateThickness
6853                                           -                                                     fgkEndCapSideCoverWidth[1]);
6854   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6855   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6856    /////////////////////////////////////////////////////////////
6857   // Deallocating memory
6858   /////////////////////////////////////////////////////////////
6859   delete endcapcoverplaterot;
6860   delete endcapcoverplatecombitrans;
6861   delete endcapcoverplatetrans;
6862   for(Int_t i=0; i<3; i++){
6863    delete endcapsidecovercombitrans[i];
6864    if(i<2) delete endcapsidecoverot[i]; 
6865   }
6866   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6867   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6868   delete endcapcardsmatrix[0];
6869   return endcapassembly;
6870  } 
6871  ////////////////////////////////////////////////////////////////////////////////
6872  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6873                                                                                                                         Double_t radiusmax, 
6874                                                                                                                         Double_t width, 
6875                                                                                                                         Int_t ncables,
6876                                                                                                                         char* volname){
6877   /////////////////////////////////////////////////////////////
6878   // Generating EndCap High Voltage Tubes 
6879   /////////////////////////////////////////////////////////////
6880   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6881   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
6882                                                            +             TMath::Power(radiusmax,2.)
6883                                -             TMath::Power(radiusmin,2.));
6884   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6885   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6886                                                                                                    effectiveouteradius,0.5*width);
6887   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6888                                                                                                 effectiveinnertubeshape,
6889                                                                                                 fSSDStiffenerConnectorMedium);
6890   effectiveinnertube->SetLineColor(41);
6891   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6892                                                                                                 effectiveoutertubeshape,
6893                                                                                                 fSSDKaptonChipCableMedium);
6894   effectiveoutertube->SetLineColor(39);
6895   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6896   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6897   effectivemothertube->AddNode(effectiveinnertube,1);
6898   effectivemothertube->AddNode(effectiveoutertube,1);
6899   return effectivemothertube;
6900  } 
6901  ////////////////////////////////////////////////////////////////////////////////
6902  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6903   /////////////////////////////////////////////////////////////
6904   // Generating EndCap Support Layer 5 and Layer 6 
6905   /////////////////////////////////////////////////////////////
6906   const Int_t knedges = 5;
6907   ///////////////////////////////////////////////
6908   // Setting the vertices for TGeoXtru Up Volume
6909   ///////////////////////////////////////////////
6910   const Int_t klayernumber = 2;
6911   Double_t xupvertex[klayernumber][knedges+3];
6912   Double_t yupvertex[klayernumber][knedges+3];
6913   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6914   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6915   Double_t middlepsi[klayernumber] = {0.0,0.0};
6916   for(Int_t i=0; i<klayernumber; i++){
6917         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6918         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6919         xupvertex[i][2] = -xupvertex[i][1];
6920         xupvertex[i][3] = -xupvertex[i][0];
6921
6922         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6923         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6924         yupvertex[i][2] =  yupvertex[i][1];
6925         yupvertex[i][3] =  yupvertex[i][0];
6926         
6927     middledgeangle[i] = upedgeangle[i]/knedges;
6928     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6929     for(Int_t j=1; j<knedges; j++){
6930                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6931                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6932         }
6933   }
6934   ////////////////////////////////////
6935   // Generating Up TGeoXtru
6936   ////////////////////////////////////
6937   TGeoXtru* upendcapsupportshape[klayernumber];
6938   TGeoVolume* upendcapsupport[klayernumber]; 
6939   char upendcapsupportname[30]; 
6940   for(Int_t i=0; i<klayernumber; i++){
6941    upendcapsupportshape[i] = new TGeoXtru(2);
6942    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
6943    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6944    upendcapsupportshape[i]->DefineSection(0,0.);
6945    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6946    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6947                                                                         fSSDSupportRingAl);
6948    upendcapsupport[i]->SetLineColor(5);
6949   }
6950   ///////////////////////////////////////////////
6951   // Setting the vertices for TGeoXtru Down Volume
6952   ///////////////////////////////////////////////
6953   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6954   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6955   for(Int_t i=0; i<klayernumber; i++){
6956         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6957         xdownvertex[i][1] =  xupvertex[i][0];
6958         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6959         ydownvertex[i][1] =  yupvertex[i][0];
6960         for(Int_t j=0; j<knedges; j++){
6961                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6962                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6963         } 
6964         for(Int_t j=0; j<knedges; j++){
6965                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6966                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6967                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6968                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
6969         }
6970   }
6971   ////////////////////////////////////
6972   // Generating Down TGeoXtru
6973   ////////////////////////////////////  
6974   TGeoXtru* downendcapsupportshape[klayernumber];
6975   TGeoVolume* downendcapsupport[klayernumber]; 
6976   char downendcapsupportname[30]; 
6977   for(Int_t i=0; i<klayernumber; i++){
6978         downendcapsupportshape[i] = new TGeoXtru(2);
6979     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
6980         downendcapsupportshape[i] = new TGeoXtru(2);
6981         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
6982     if(i==0){
6983                 downendcapsupportshape[i]->DefineSection(0,0.);
6984                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
6985     }
6986         else{
6987                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
6988                                                                  -                 fgkEndCapSupportLowWidth[i]);
6989                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6990         }
6991     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
6992                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
6993         downendcapsupport[i]->SetLineColor(5);
6994   }
6995   ///////////////////////////////////////////////
6996   // Setting TGeoPgon Volume
6997   ///////////////////////////////////////////////
6998   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6999                                                                                                    fgkSSDLay6LadderNumber};
7000   TGeoPgon* endcapsupportmothershape[klayernumber];
7001   TGeoVolume** endcapsupportmother;
7002   endcapsupportmother = new TGeoVolume*[klayernumber];
7003   char endcapsupportmothername[30];
7004   for(Int_t i=0; i<klayernumber; i++){
7005         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7006     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7007         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7008     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7009                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7010     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7011                                                                                         fSSDAir);       
7012   }
7013   ////////////////////////////////////
7014   TGeoRotation** endcapsupportrot[klayernumber];
7015   for(Int_t i=0; i<2; i++){
7016         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7017         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7018            endcapsupportrot[i][j] = new TGeoRotation();
7019            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7020        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7021        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7022         }
7023   }
7024   return endcapsupportmother;
7025  } 
7026  ////////////////////////////////////////////////////////////////////////////////
7027  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7028   /////////////////////////////////////////////////////////////
7029   // Setting End Cap Support Layer 5 and 6. 
7030   /////////////////////////////////////////////////////////////
7031   const Int_t kendcapcoverplatesmallholenumber = 9;
7032   const Int_t klayernumber = 2;
7033   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7034                                                                                                    fgkSSDLay6LadderNumber};
7035   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7036                                                                                 360.0/kssdlayladdernumber[1]};
7037   TGeoVolume** endcapsupport = EndCapSupport();
7038   TGeoVolume** endcapassembly = GetEndCapAssembly();
7039   TGeoPgon* endcapsupportshape[klayernumber];
7040   Double_t* radiusmin[klayernumber];
7041   Double_t* radiusmax[klayernumber];
7042   for(Int_t i=0; i<klayernumber; i++){
7043     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7044         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7045         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7046   }  
7047   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7048   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7049                                                                           endcapassemblyshape->GetDY(),
7050                                                                           endcapassemblyshape->GetDZ()};
7051   ///////////////////////////////////////////////
7052   // Setting TGeoPgon Volume for Mother Container
7053   ///////////////////////////////////////////////
7054   TGeoPgon* endcapsupportsystemshape[klayernumber];
7055   char endcapsupportsystemothername[30];
7056   for(Int_t i=0; i<klayernumber; i++){
7057         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7058     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7059         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7060                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7061                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7062                                                                                            +2.*endcapassemblycenter[2])
7063                                                                                            /CosD(0.5*upedgeangle[i]));  
7064     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7065                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7066                                                                                              - fgkEndCapCoverPlateWidth[0]),
7067                                                                                            *radiusmin[i],
7068                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7069                                                                                            +2.*endcapassemblycenter[2])
7070                                                                                            /CosD(0.5*upedgeangle[i]));
7071   }
7072   fgkEndCapSupportSystem = new TGeoVolume*[4];
7073   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7074                                                                           endcapsupportsystemshape[0],fSSDAir); 
7075   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7076                                                                           endcapsupportsystemshape[0],fSSDAir); 
7077   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7078                                                                           endcapsupportsystemshape[1],fSSDAir); 
7079   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7080                                                                           endcapsupportsystemshape[1],fSSDAir); 
7081   ///////////////////////////////////////////////
7082   TGeoTranslation* endcapassemblytrans[klayernumber];
7083   for(Int_t i=0; i<klayernumber; i++)
7084         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7085                                                                            -  fgkEndCapSideCoverThickness
7086                                                                            +  endcapassemblycenter[0],
7087                                                                            -  0.5*fgkEndCapCoverPlateThickness
7088                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7089                                                                            +  2.0*endcapassemblycenter[2]
7090                                                                            +  0.5*fgkEndCapSupportLength[i]
7091                                                                            /  TanD(0.5*upedgeangle[i]),
7092                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7093                                                                            -  fgkEndCapCoverPlateWidth[2]
7094                                                                            - (kendcapcoverplatesmallholenumber-1)
7095                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7096   TGeoRotation** endcapassemblyrot[klayernumber];
7097   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7098   for(Int_t i=0; i<klayernumber; i++){
7099    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7100    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7101    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7102    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7103    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7104    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7105    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7106    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7107         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7108         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7109    }
7110   }
7111   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7112                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7113   for(Int_t i=0; i<2*klayernumber; i++){
7114         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7115                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7116                                                                                                                                            endcapassemblymatrix[1][j+2]);
7117         }
7118         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7119   }
7120    /////////////////////////////////////////////////////////////
7121   // Deallocating memory
7122   /////////////////////////////////////////////////////////////
7123   for(Int_t i=0; i<klayernumber; i++){
7124         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7125                 delete endcapassemblyrot[i][j];
7126         }
7127         delete endcapassemblyrot[i];
7128         delete endcapassemblymatrix[i][0];
7129         delete endcapassemblymatrix[i][1];
7130   }
7131   /////////////////////////////////////////////////////////////
7132   }
7133   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7134   /////////////////////////////////////////////////////////////
7135   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7136   /////////////////////////////////////////////////////////////
7137   if (! moth) {
7138     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7139     return;
7140   };
7141   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7142   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7143   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7144                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7145                                                                            +            fgkEndCapSupportCenterLay5Position
7146                                                                            -            fgkEndCapSideCoverLength[2]);
7147   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7148                                                                                                 fgkEndCapSideCoverLength[2]
7149                                                                            -        fgkEndCapSupportCenterLay5Position
7150                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7151   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7152   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7153   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7154         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7155   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7156   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7157    /////////////////////////////////////////////////////////////
7158   // Deallocating memory
7159   /////////////////////////////////////////////////////////////
7160   delete endcapsupportsystemrot;
7161   delete endcapsupportsystemITSCentertrans[1];
7162  }
7163   /////////////////////////////////////////////////////////////
7164   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7165   /////////////////////////////////////////////////////////////
7166   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7167   /////////////////////////////////////////////////////////////
7168   if (! moth) {
7169     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7170     return;
7171   };
7172   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7173   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7174   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7175                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7176                                                                            +            fgkEndCapSupportCenterLay6Position
7177                                                                            -            fgkEndCapSideCoverLength[2]);
7178   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7179                                                                                                 fgkEndCapSideCoverLength[2]
7180                                                                            -        fgkEndCapSupportCenterLay6Position
7181                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7182   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7183   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7184   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7185         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7186   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7187   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7188    /////////////////////////////////////////////////////////////
7189   // Deallocating memory
7190   /////////////////////////////////////////////////////////////
7191   delete endcapsupportsystemrot;
7192   delete endcapsupportsystemITSCentertrans[1];
7193  }
7194  ////////////////////////////////////////////////////////////////////////////////
7195  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7196   /////////////////////////////////////////////////////////////
7197   // Setting Ladder Support of Layer 5. 
7198   /////////////////////////////////////////////////////////////
7199   if (! moth) {
7200     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7201     return;
7202   };
7203   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7204   fMotherVol = moth;
7205   TGeoTranslation* centerITSRingSupportLay5trans[2];
7206   for(Int_t i=0; i<2; i++){
7207         centerITSRingSupportLay5trans[i] = 
7208                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7209     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7210   }
7211  }
7212  ////////////////////////////////////////////////////////////////////////////////
7213  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7214   /////////////////////////////////////////////////////////////
7215   // Setting Ladder Support of Layer 6. 
7216   /////////////////////////////////////////////////////////////
7217   if (! moth) {
7218     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7219     return;
7220   };
7221   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7222   fMotherVol = moth;
7223   TGeoTranslation* centerITSRingSupportLay6trans[2];
7224   for(Int_t i=0; i<2; i++){
7225         centerITSRingSupportLay6trans[i] = 
7226                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7227     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7228   }
7229  }
7230  ////////////////////////////////////////////////////////////////////////////////
7231  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7232   /////////////////////////////////////////////////////////////
7233   // Setting Ladder Support of Layer 6. 
7234   /////////////////////////////////////////////////////////////
7235   if (! moth) {
7236     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7237     return;
7238   };
7239   if(!fSSDCone) SetSSDCone();
7240   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7241                                                                 +                                         fgkSSDCentralAL3SupportLength);
7242     moth->AddNode(fSSDCone,1,ssdconetrans);
7243 }
7244  ////////////////////////////////////////////////////////////////////////////////
7245  void AliITSv11GeometrySSD::SetSSDCone(){
7246   /////////////////////////////////////////////////////////////
7247   // Method generating SSDCone 
7248   /////////////////////////////////////////////////////////////
7249   if(!fCreateMaterials) CreateMaterials();
7250   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7251   Double_t ssdpconesectionradiusmax[16];
7252   Double_t ssdpconesectionradiusmin[16];
7253   Double_t ssdpconezsection[16];
7254   TGeoPcon* ssdpconelittleholeshape[8];
7255   TGeoVolume* ssdpconelittlehole[8];
7256   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7257   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7258   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7259                                                       / SinD(fgkSSDPConeAngle)
7260                                                           + ssdpconesectionradiusmin[0];
7261   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7262                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7263                                                           / SinD(fgkSSDPConeAngle);
7264   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7265   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7266                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7267   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7268   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7269                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7270   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7271   ssdpconelittlehole[0]->SetLineColor(4);
7272   /////////////////////////////////////////////////////////////
7273   ssdpconezsection[2] = ssdpconezsection[1];  
7274   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7275   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7276   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7277                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7278                                                           / SinD(fgkSSDPConeAngle);
7279   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7280                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7281   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7282                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7283   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7284                                                                    * TMath::RadToDeg();
7285   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7286                                                                                                           60.-ssdpconelittleholeangle,2);    
7287   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7288                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7289   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7290   ssdpconelittlehole[1]->SetLineColor(4);
7291   TGeoRotation* ssdconelittleholerot[6];
7292   for(Int_t i=0; i<6; i++){
7293         ssdconelittleholerot[i] = new TGeoRotation();
7294     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7295   }
7296   /////////////////////////////////////////////////////////////
7297   ssdpconezsection[4] = ssdpconezsection[3];  
7298   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7299   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7300   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7301                                                           * CosD(fgkSSDPConeAngle)
7302                                                           / SinD(fgkSSDPConeAngle);
7303   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7304   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7305                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7306   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7307   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7308                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7309   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7310   ssdpconelittlehole[2]->SetLineColor(4);
7311   ///////////////////////////////////////////////////
7312   ssdpconezsection[6] = ssdpconezsection[5];  
7313   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7314   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7315   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7316                                                           -ssdpconezsection[0]
7317                                                           * CosD(fgkSSDPConeAngle)
7318                                                           / SinD(fgkSSDPConeAngle);
7319   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7320   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7321                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7322   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7323                                                                    * TMath::RadToDeg();
7324   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7325                                                                                                           45.-ssdpconemiddleholeangle,2);    
7326   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7327                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7328   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7329   ssdpconelittlehole[3]->SetLineColor(4);
7330   TGeoRotation* ssdconemiddleholerot[8];
7331   for(Int_t i=0; i<8; i++){
7332         ssdconemiddleholerot[i] = new TGeoRotation();
7333     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7334   }
7335   /////////////////////////////////////////////////////////////
7336   ssdpconezsection[8] = ssdpconezsection[7];  
7337   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7338   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7339   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7340                                                           * CosD(fgkSSDPConeAngle)
7341                                                           / SinD(fgkSSDPConeAngle);
7342   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7343   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7344                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7345   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7346   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7347                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7348   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7349   ssdpconelittlehole[4]->SetLineColor(4);
7350   /////////////////////////////////////////////////////////////
7351   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7352   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7353                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7354                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7355                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7356                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7357   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7358   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7359                                                                                  * TMath::RadToDeg();
7360   ssdpconezsection[10] = ssdpconezsection[9];
7361   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7362   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7363   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7364                                                           * CosD(fgkSSDPConeAngle)
7365                                                           / SinD(fgkSSDPConeAngle);
7366   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7367   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7368                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7369   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7370                                                                                         ssdpconetrapezoidsectionangle,2);    
7371   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7372                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7373   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7374   ssdpconelittlehole[5]->SetLineColor(4);
7375   TGeoRotation* ssdconeupradiusrot[8];
7376   for(Int_t i=0; i<8; i++){
7377         ssdconeupradiusrot[i] = new TGeoRotation();
7378     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7379   }
7380   /////////////////////////////////////////////////////////////
7381   ssdpconezsection[12] = ssdpconezsection[11];
7382   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7383   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7384   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7385   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7386   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7387   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7388   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7389                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7390   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7391   ssdpconelittlehole[6]->SetLineColor(4);
7392   /////////////////////////////////////////////////////////////
7393   ssdpconezsection[14] = 0.0;
7394   ssdpconezsection[15] = ssdpconezsection[0];
7395   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7396   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7397   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7398   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7399   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7400   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7401                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7402   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7403   ssdpconelittlehole[7]->SetLineColor(4);
7404   /////////////////////////////////////////////////////////////
7405   TGeoTube* ssdtubeconeshape[2];
7406   TGeoVolume* ssdtubecone[2];
7407   TGeoTranslation* ssdtubeconetrans[2];
7408   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7409                                                                            fgkSSDPConeExternalRadius,
7410                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7411   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7412                                                                            0.5*ssdpconezsection[0]); 
7413   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7414   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7415   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7416                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7417                                           + ssdpconezsection[13]);
7418   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7419   ssdtubecone[0]->SetLineColor(4);
7420   ssdtubecone[1]->SetLineColor(4);
7421   /////////////////////////////////////////////////////////////
7422   // Mother Volume Container
7423   /////////////////////////////////////////////////////////////
7424   Double_t ssdconemotherradiusmin[8];
7425   Double_t ssdconemotherradiusmax[8];
7426   Double_t ssdconemothersection[8]; 
7427   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7428   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7429   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7430   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7431   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7432   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7433   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7434   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7435   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7436   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7437   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7438   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7439   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7440   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7441   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7442   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7443   ssdconemothersection[0] = 0.0;
7444   ssdconemothersection[1] = ssdpconezsection[0];
7445   ssdconemothersection[2] = ssdpconezsection[0];
7446   ssdconemothersection[3] = ssdpconezsection[11];
7447   ssdconemothersection[4] = ssdpconezsection[11];
7448   ssdconemothersection[5] = ssdpconezsection[13];
7449   ssdconemothersection[6] = ssdpconezsection[13];
7450   ssdconemothersection[7] = fgkSSDPConeLength;
7451   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7452   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7453                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7454   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7455   /////////////////////////////////////////////////////////////
7456   //Placing the Volumes into Mother 
7457   /////////////////////////////////////////////////////////////
7458   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7459   for(Int_t i=0; i<6; i++){
7460         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7461   }
7462   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7463   for(Int_t i=0; i<8; i++){
7464     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7465   }
7466   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7467   for(Int_t i=0; i<8; i++){
7468     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7469   }
7470   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7471   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7472   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7473   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7474   /////////////////////////////////////////////////////////////
7475   // ITS General Support
7476   /////////////////////////////////////////////////////////////
7477   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7478                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7479   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7480   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7481                                                                              - fgkSSDCentralAL3SupportLength);
7482   ssdcentralsupport->SetLineColor(4);
7483   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7484   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7485                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7486   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7487   TGeoTranslation* ssdcentralal3supportrans[3]; 
7488   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7489   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7490                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7491   ssdcentralal3support->SetLineColor(4);
7492   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7493   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7494   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7495   Double_t ssdpconcentralradiusmin[2];
7496   Double_t ssdpconcentralradiusmax[2];
7497   Double_t ssdpconcentralsection[2];
7498   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7499   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7500   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7501   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7502   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7503   ssdpconcentralsection[1] = 0.;
7504   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7505                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7506   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7507   ssdpconcentralal3->SetLineColor(4);
7508   fSSDCone->AddNode(ssdpconcentralal3,1);
7509   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7510   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7511   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7512                                                                 -2.*fgkSSDCentralAL3SupportLength);
7513   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7514                                                                                                                      *ssdcentralal3supportrot);
7515   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7516   TGeoRotation* ssdconemotherot = new TGeoRotation();
7517   ssdconemotherot->SetAngles(90.,180.,-90.);
7518   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7519                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7520   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7521   fSSDCone->AddNode(ssdconemother,1);
7522   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7523   /////////////////////////////////////////////////////////////
7524   // Deallocating memory
7525   /////////////////////////////////////////////////////////////
7526   delete ssdcentralal3supportrot;
7527   delete ssdcentralal3supportrans[2];
7528   delete ssdconemotherot;
7529   delete ssdconemothertrans;
7530   /////////////////////////////////////////////////////////////
7531  }
7532  ////////////////////////////////////////////////////////////////////////////////
7533  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7534   /////////////////////////////////////////////////////////////
7535   // Setting SSD Cables
7536   /////////////////////////////////////////////////////////////
7537   if (! moth) {
7538     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7539     return;
7540   };
7541   TGeoVolume* ssdcables = SetSSDCables();
7542   moth->AddNode(ssdcables,1);
7543 }
7544  ////////////////////////////////////////////////////////////////////////////////
7545  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7546   /////////////////////////////////////////////////////////////
7547   // Method generating SSDCables
7548   /////////////////////////////////////////////////////////////
7549   // SSD Layer 5 Cables
7550   //////////////////////////////////////////////////////////////////////////////////////////////////
7551   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7552   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7553   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7554   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7555   //////////////////////////////////////////////////////////////////////////////////////////////////
7556   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7557   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7558                                                                             -  fgkSSDLowerPConeRadius)
7559                                                                             * TanD(fgkSSDPConeAngle);
7560   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7561                                                                               + fgkEndCapSupportCenterLay5Position
7562                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7563   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7564                                                                            - ssdcableslay5startconedistance; 
7565   ssdcablelay5rightsidelength *= ssdcablesfactor;
7566   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7567   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7568                                                                                                 ssdcableslay5rightsideradiusmax,
7569                                                                                                 0.5*ssdcablelay5rightsidelength); 
7570   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7571                                                                                                          ssdcablelay5rightubeshape,
7572                                                                                                          fSSDCopper);
7573   ssdcablelay5righttube->SetLineColor(9);
7574   TGeoTranslation* ssdcablelay5rightrans = 
7575                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7576                                                                                  +              fgkEndCapSupportCenterLay5Position
7577                                                                                  +      0.5*ssdcablelay5rightsidelength);
7578   ////////////////////////////////////
7579   //  Double_t cablescapacity[20];
7580   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7581   ////////////////////////////////////
7582   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7583   ////////////////////////////////////
7584   // TGeoPCone Volumes
7585   ///////////////////////////////////
7586   TGeoPcon* ssdcableslay5pconshape[3];
7587   TGeoVolume* ssdcableslay5pcon[3]; 
7588   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7589   Double_t ssdcableslay5pconzsection[6];
7590   Double_t ssdcableslay5pconrmin[6];
7591   Double_t ssdcableslay5pconrmax[6];
7592   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7593   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7594   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7595   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7596   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7597                                                            + fgkEndCapSupportCenterLay5Position
7598                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7599   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7600                                                            + fgkSSDCentralAL3SupportLength
7601                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7602                                                            * TanD(fgkSSDPConeAngle);      
7603   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7604                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7605   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7606                                                            ssdcableslay5pconshape[0],fSSDCopper);
7607   ssdcableslay5pcon[0]->SetLineColor(9);
7608   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7609 ////////////////////////////////////
7610 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7611 ////////////////////////////////////
7612   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7613   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7614                                                            + fgkSSDCentralAL3SupportLength
7615                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7616                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7617   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7618                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7619                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7620   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7621                                                                                    ssdcableangle,2);   
7622   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7623   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7624   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7625                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7626   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7627   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7628   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7629                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7630   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7631   ssdcableslay5pcon[1]->SetLineColor(9);
7632   ////////////////////////////////////
7633   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7634                                                                                    ssdcableangle,2);   
7635   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7636   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7637   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7638   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7639   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7640   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7641                                                            * TanD(fgkSSDPConeAngle)
7642                                                            + 0.5*fgkSSDCentralSupportLength
7643                                                            + fgkSSDCentralAL3SupportLength;
7644   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7645   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7646                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7647   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7648   ssdcableslay5pcon[2]->SetLineColor(9);
7649 ////////////////////////////////////
7650   TGeoRotation* ssdcableslay5pconrot[4];        
7651   for(Int_t i=0; i<4; i++){
7652    ssdcableslay5pconrot[i] = new TGeoRotation();
7653    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7654    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7655    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7656   }
7657   ////////////////////////////////////
7658   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7659   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7660   ////////////////////////////////////
7661   // Positioning Left SSD Cables Part
7662   ////////////////////////////////////
7663   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7664                                                                                                         - 0.5*ssdcablelay5rightsidelength
7665                                                                                                         - fgkEndCapSupportCenterLay5Position
7666                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7667   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7668   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7669   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7670   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7671   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7672   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7673         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7674         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7675     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7676   }
7677   ////////////////////////////////////
7678   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7679   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7680   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7681   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7682   /////////////////////////////////////////////////////////////
7683   // Water Tubes Layer 5
7684   /////////////////////////
7685   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7686                                                                                      ssdcableslay5rightsideradiusmax
7687                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7688                                                                                      0.5*ssdcablelay5rightsidelength); 
7689   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7690                                                                                                          ssdcablelay5rightubewatershape,
7691                                                                                                          fSSDCoolingTubeWater);
7692   ssdcablelay5rightwatertube->SetLineColor(7);
7693   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7694   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7695   ////////////////////////////////////
7696   // TGeoPCone Water Volumes Layer 
7697   ///////////////////////////////////
7698   TGeoPcon* ssdcableslay5pconwatershape[3];
7699   TGeoVolume* ssdcableslay5pconwater[3]; 
7700   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7701   Double_t ssdcableslay5pconwaterzsection[6];
7702   Double_t ssdcableslay5pcwateronrmin[6];
7703   Double_t ssdcableslay5pconwaterrmax[6];
7704   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7705   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7706                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7707   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7708   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7709                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7710   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7711   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7712   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7713                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7714   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7715                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7716   ssdcableslay5pconwater[0]->SetLineColor(7);
7717   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7718   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7719 ////////////////////////////////////
7720   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7721   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7722   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7723                                                                                                 ssdcableangle,2);   
7724   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7725   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7726                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7727   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7728   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7729                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7730   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7731                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7732   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7733                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7734   ssdcableslay5pconwater[1]->SetLineColor(7);
7735 ////////////////////////////////////
7736   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7737                                                                                                 ssdcableangle,2);   
7738   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7739   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7740                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7741   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7742   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7743                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7744   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7745   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7746   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7747                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7748   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7749                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7750   ssdcableslay5pconwater[2]->SetLineColor(7);
7751 ////////////////////////////////////
7752   TGeoRotation* ssdcableslay5pconwaterot[4];    
7753   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7754   for(Int_t i=0; i<4; i++){
7755    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7756    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7757    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7758         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7759         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7760         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7761         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7762         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7763   }
7764   /////////////////////////
7765   // SSD Layer 6 Cables
7766   /////////////////////////
7767   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7768   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7769   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7770   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7771                                                                                                 ssdcableslay6rightsideradiusmax,
7772                                                                                                 0.5*ssdcablelay6rightsidelength); 
7773   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7774                                                                                                          ssdcablelay6rightubeshape,
7775                                                                                                          fSSDCopper);
7776   ssdcablelay6righttube->SetLineColor(9);
7777   TGeoTranslation* ssdcablelay6rightrans = 
7778                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7779                                                                                  +              fgkEndCapSupportCenterLay6Position
7780                                                                                  +      0.5*ssdcablelay6rightsidelength);
7781   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7782                                                                                                         - 0.5*ssdcablelay6rightsidelength
7783                                                                                                         - fgkEndCapSupportCenterLay6Position
7784                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7785   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7786   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7787   ////////////////////////////////////
7788   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7789   ////////////////////////////////////
7790   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7791                                                                                    ssdcableangle,2);   
7792   TGeoVolume* ssdcableslay6pcon;
7793   Double_t ssdcableslay6pconrmin[2];
7794   Double_t ssdcableslay6pconrmax[2];
7795   Double_t ssdcableslay6pconzsection[2];
7796   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7797   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7798   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7799   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7800   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7801                                                            + fgkEndCapSupportCenterLay6Position
7802                                                            + ssdcablelay6rightsidelength;
7803   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7804   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7805                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7806   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7807                                                            ssdcableslay6pconshape,fSSDCopper);
7808   ssdcableslay6pcon->SetLineColor(9);
7809   for(Int_t i=0; i<4; i++){
7810    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7811    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7812   }
7813   ////////////////////////////////////
7814   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7815   /////////////////////////
7816   // Water Tubes Layer 6
7817   /////////////////////////
7818   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7819                                                                                                                   ssdcableslay6rightsideradiusmax
7820                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7821                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7822   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7823                                                                                                          ssdcablelay6righwatertubeshape,
7824                                                                                                          fSSDCoolingTubeWater);
7825   ssdcablelay6rightwatertube->SetLineColor(7);
7826   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7827   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7828   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7829                                                                                    ssdcableangle,2);   
7830   TGeoVolume* ssdcableslay6waterpcon;
7831   Double_t ssdcableslay6waterpconrmin[2];
7832   Double_t ssdcableslay6waterpconrmax[2];
7833   Double_t ssdcableslay6waterpconzsection[2];
7834   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7835   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7836                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7837   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7838   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7839   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7840                                                            + fgkEndCapSupportCenterLay6Position
7841                                                            + ssdcablelay6rightsidelength;
7842   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7843   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7844                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7845   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7846                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7847   ssdcableslay6waterpcon->SetLineColor(7);
7848   TGeoRotation* ssdcableslay6pconwaterot[4];    
7849   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7850   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7851   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7852   for(Int_t i=0; i<4; i++){
7853    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7854    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7855    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7856                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7857    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7858    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7859   }
7860   ////////////////////////////////////////
7861   // From ITS Ring to Patch Panel3-RB26
7862   ////////////////////////////////////////
7863   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7864   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7865   Double_t ssdcablepatchpanel3RB26zsection[2];
7866   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
7867   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7868                                                                           + fgkSSDCablesLay5RightSideHeight
7869                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7870   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7871   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7872                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7873                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7874   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7875                                                                                  + fgkSSDCentralAL3SupportLength
7876                                                                                  + fgkSSDPConeZLength[0];
7877   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7878   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7879                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7880                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7881   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7882                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7883   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7884                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7885   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7886   TGeoRotation* ssdcablepatchpanel3B26rot[3];
7887   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7888   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7889   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7890                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7891   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7892   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7893                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7894   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7895   ////////////////////////////////////
7896   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7897   ////////////////////////////////////////
7898   //  ITS Ring Cables RB26 Part
7899   ////////////////////////////////////////
7900   Double_t ssdcableitsring3BB26pconzsection[2];
7901   Double_t ssdcableitsring3BB26pconrmin[2];
7902   Double_t ssdcableitsring3BB26pconrmax[2];
7903   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7904                                                                           + fgkSSDCentralAL3SupportLength
7905                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7906   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7907   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
7908   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7909                                                                   + fgkSSDCablesLay5RightSideHeight
7910                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7911   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7912   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7913   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7914   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7915                                                                    -              0.5*ssdcableangle,ssdcableangle
7916                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7917                                                                    -                             fgkSSDCableAngle),2);
7918   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7919                                                                    -              0.5*ssdcableangle,ssdcableangle
7920                                                                    +                      3.0*fgkSSDCableAngle
7921                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7922   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7923                                                                    -              0.5*ssdcableangle,ssdcableangle
7924                                                                    -                      fgkSSDCableAngle
7925                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7926   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7927                                                                    -              0.5*ssdcableangle,ssdcableangle
7928                                                                    +                      3.0*fgkSSDCableAngle
7929                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7930   for(Int_t i=0;i<4;i++)
7931         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7932                                                          ssdcableitsring3BB26pconrmin[j],
7933                                                          ssdcableitsring3BB26pconrmax[j]); 
7934   TGeoVolume* ssdcableitsring3BB26pcon[4];
7935   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7936                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7937   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7938                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7939   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7940                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7941   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7942                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7943   for(Int_t i=0;i<4;i++){
7944         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7945         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],i+1);
7946 }
7947   ////////////////////////////////////
7948   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7949   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7950   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7951   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7952   ////////////////////////////////////////
7953   // From ITS Ring to Patch Panel2-RB24
7954   ////////////////////////////////////////
7955   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7956   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7957   Double_t ssdcablepatchpanel3RB24zsection[2];
7958   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7959   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7960   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7961   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7962                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7963                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7964                                                                           + 0.5*fgkSSDPatchPanelHeigth;
7965   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7966                                                                          -  fgkSSDCentralAL3SupportLength
7967                                                                          -  fgkSSDPConeZLength[0];
7968   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
7969   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
7970                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7971                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7972   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
7973                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
7974   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
7975                                                                                                 ssdcablepatchpanel3RB24pconshape,
7976                                                                                                 fSSDCopper);
7977   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
7978   TGeoRotation* ssdcablepatchpanel3B24rot[3];
7979   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
7980   ssdcablepatchpanel3B24rot[0]->SetAngles(0.0,0.0,0.0);
7981   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
7982                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7983   ssdcablepatchpanel3B24rot[2]->SetAngles(180.0,0.0,0.0);
7984   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
7985                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7986   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
7987   ////////////////////////////////////
7988   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
7989   ////////////////////////////////////////
7990   //  ITS Ring Cables RB24 Part
7991   ////////////////////////////////////////
7992   Double_t ssdcableitsring3BB24pconzsection[2];
7993   Double_t ssdcableitsring3BB24pconrmin[2];
7994   Double_t ssdcableitsring3BB24pconrmax[2];
7995   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
7996   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
7997   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
7998   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
7999                                                                   + fgkSSDCablesLay5RightSideHeight
8000                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8001   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8002   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8003   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8004   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8005                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8006                                                                    -                             fgkSSDCableAngle),2);
8007   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8008                                                                      ssdcableangle-fgkSSDCableAngle
8009                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8010   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8011                                                                    -                      fgkSSDCableAngle
8012                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8013   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,
8014                                                                                                   ssdcableangle-fgkSSDCableAngle
8015                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8016   for(Int_t i=0;i<4;i++)
8017         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8018                                                          ssdcableitsring3BB24pconrmin[j],
8019                                                          ssdcableitsring3BB24pconrmax[j]); 
8020   TGeoVolume* ssdcableitsring3BB24pcon[4];
8021   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8022                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8023   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8024                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8025   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8026                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8027   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8028                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8029   for(Int_t i=0;i<4;i++){
8030         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8031         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],i+1);
8032 }
8033   ////////////////////////////////////
8034   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8035   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8036   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8037   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8038   ////////////////////////////////////
8039   // Volumes for Material Budget 
8040   ////////////////////////////////////
8041   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8042                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8043                                                                                                          ssdcableslay6rightsideradiusmax
8044                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8045                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8046   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8047                                                                                                          ssdcablelay6materialbudgetubeshape,
8048                                                                                                          fSSDCopper);
8049   ssdcablelay6materialbudgetube->SetLineColor(9);
8050   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8051   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8052
8053   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8054                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8055   TGeoVolume* ssdcablelay6materialbudgetpcon;
8056   Double_t ssdcablelay6materialbudgetpconrmin[2];
8057   Double_t ssdcablelay6materialbudgetpconrmax[2];
8058   Double_t ssdcablelay6materialbudgetpconzsection[2];
8059   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8060                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8061   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8062                                                                                 + fgkSSDCableMaterialBudgetHeight;
8063   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8064   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8065   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8066                                                                                         + fgkEndCapSupportCenterLay6Position
8067                                                                                         + ssdcablelay6rightsidelength;
8068   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8069   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8070                                                   ssdcablelay6materialbudgetpconzsection[i],
8071                                                   ssdcablelay6materialbudgetpconrmin[i],
8072                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8073   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8074                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8075   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8076   for(Int_t i=0; i<4; i++){
8077    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8078    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8079   }
8080 ////////////////////////////////////
8081  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8082   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8083   Double_t ssdcablesvolume = 0.0;
8084   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8085   std::cout << ssdcablesvolume << std::endl;*/
8086   return ssdcablesmother;
8087  }
8088  ////////////////////////////////////////////////////////////////////////////////
8089 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8090                                                                         Double_t height, char* shapename, Int_t isign) const{
8091   /////////////////////////////////////////////////////////////
8092   // Method generating an Arb shape 
8093   /////////////////////////////////////////////////////////////
8094   const Int_t kvertexnumber = 8;
8095   const Int_t ktransvectnumber = 2;
8096   TVector3* vertex[kvertexnumber];
8097   TVector3* transvector[2];
8098   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8099   /////////////////////////////////////////////////////////////
8100   //Setting the vertices for TGeoArb8
8101   /////////////////////////////////////////////////////////////
8102   vertex[0] = new TVector3(*vertexpos[0]);
8103   vertex[1] = new TVector3(*vertexpos[1]);
8104   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8105   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8106   vertex[4] = new TVector3(*vertexpos[2]);
8107   vertex[5] = new TVector3(*vertexpos[3]);
8108   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8109   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8110   /////////////////////////////////////////////////////////////
8111   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8112   for(Int_t i = 0; i<kvertexnumber;i++) 
8113                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8114   /////////////////////////////////////////////////////////////
8115   // Deallocating memory
8116   /////////////////////////////////////////////////////////////
8117   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8118   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8119   /////////////////////////////////////////////////////////////
8120   return arbshape;
8121
8122 ///////////////////////////////////////////////////////////////////////////////
8123 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8124                                                                 Double_t rmax, Int_t nedges, Double_t height){
8125   /////////////////////////////////////////////////////////////
8126   // Method generating Arc shape 
8127   /////////////////////////////////////////////////////////////
8128         const Int_t kvertexnumber = 2*nedges+2;
8129         TGeoXtru* arcshape = new TGeoXtru(2);   
8130         TVector3** vertexposition[2];
8131         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8132         Double_t angle = 0.;
8133     for(Int_t i=0; i<nedges+1; i++){ 
8134                 angle = 90.+0.5*phi-i*(phi/nedges);
8135                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8136                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8137         }
8138         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8139         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8140         for(Int_t i=0; i<kvertexnumber; i++){ 
8141                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8142                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8143                 }
8144                 else if(i>=1&&i<nedges+2)
8145                 {
8146                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8147                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8148                 }
8149         else
8150                 {
8151                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8152                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8153                 }
8154     }
8155   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8156   arcshape->DefineSection(0,-0.5*height);
8157   arcshape->DefineSection(1,0.5*height);
8158   /////////////////////////////////////////////////////////////
8159   // Deallocating memory
8160   /////////////////////////////////////////////////////////////
8161   for(Int_t i=0; i<2; i++){
8162         for(Int_t j=0; j<nedges+1; j++)
8163                 delete vertexposition[i][j];
8164         delete [] vertexposition[i];
8165   }
8166   delete [] xvertexpoints;
8167   delete [] yvertexpoints;
8168   /////////////////////////////////////////////////////////////
8169         return arcshape;
8170 }
8171 ////////////////////////////////////////////////////////////////////////////////
8172 TGeoXtru* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8173   ///////////////////////////////////////////////////////////////////////
8174   // Method Generating the Screw Shape  
8175   // radius[0]: outer radius
8176   // radius[1]: inner radius
8177   // edgesnumber[0]: outer number of edges
8178   // edgesnumber[1]: inner number of edges
8179   // section[0]: lower section position
8180   // section[1]: higher section position
8181   ///////////////////////////////////////////////////////////////////////
8182   Double_t outradius = radius[0];
8183   Double_t inradius = radius[1];
8184   Int_t outvertexnumber = edgesnumber[0];
8185   Int_t invertexnumber = edgesnumber[1];
8186   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8187   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8188   for(Int_t i=0; i<outvertexnumber+1; i++){
8189         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8190         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8191   }
8192   for(Int_t i=0; i<invertexnumber+1; i++){
8193         xscrewvertex[outvertexnumber+i+1] = inradius*CosD(90.-i*360./invertexnumber);
8194         yscrewvertex[outvertexnumber+i+1] = inradius*SinD(90.-i*360./invertexnumber);
8195   }
8196   TGeoXtru* screwshape = new TGeoXtru(2);
8197   screwshape->DefinePolygon(outvertexnumber+invertexnumber+2,xscrewvertex,yscrewvertex);
8198   screwshape->DefineSection(0,section[0]);
8199   screwshape->DefineSection(1,section[1]);
8200   delete [] xscrewvertex;
8201   delete [] yscrewvertex;
8202   return screwshape;
8203 }
8204 ////////////////////////////////////////////////////////////////////////////////
8205 TGeoXtru* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8206   ///////////////////////////////////////////////////////////////////////
8207   // Method Generating the Hole Shape  
8208   // radius of the Hole
8209   // nedges: number of edges to approximate the circle
8210   ///////////////////////////////////////////////////////////////////////
8211   Int_t vertexnumber = nedges+6;
8212   Double_t* xholevertex = new Double_t[vertexnumber];
8213   Double_t* yholevertex = new Double_t[vertexnumber];
8214   xholevertex[0] = radius;
8215   xholevertex[1] = xholevertex[0];
8216   xholevertex[2] = -xholevertex[1];
8217   xholevertex[3] = xholevertex[2];
8218   xholevertex[4] = xholevertex[0];
8219   yholevertex[0] = 0.;
8220   yholevertex[1] = -radius;
8221   yholevertex[2] = yholevertex[1];
8222   yholevertex[3] = -yholevertex[1];
8223   yholevertex[4] = yholevertex[3];
8224   for(Int_t i=0; i<nedges+1; i++){
8225         xholevertex[i+5] = radius*CosD(i*360./nedges);
8226         yholevertex[i+5] = radius*SinD(i*360./nedges);
8227   }
8228   TGeoXtru* holeshape = new TGeoXtru(2);
8229   holeshape->DefinePolygon(vertexnumber,xholevertex,yholevertex);
8230   holeshape->DefineSection(0,section[0]);
8231   holeshape->DefineSection(1,section[1]);
8232   delete [] xholevertex;
8233   delete [] yholevertex;
8234   return holeshape;
8235 }
8236 ////////////////////////////////////////////////////////////////////////////////
8237 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8238   /////////////////////////////////////////////////////////////
8239   // Given an axis specified by param, it gives the reflection of the point
8240   // respect to the axis
8241   /////////////////////////////////////////////////////////////
8242   TVector3* n = new TVector3(param[0],param[1],param[2]);
8243   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8244   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8245   /////////////////////////////////////////////////////////////
8246   // Deallocating memory
8247   /////////////////////////////////////////////////////////////
8248   delete n;
8249   /////////////////////////////////////////////////////////////
8250   return reflectedvector;
8251 }
8252 ////////////////////////////////////////////////////////////////////////////////
8253 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8254                                                        Double_t dx,
8255                                                        Double_t dy,
8256                                                        Double_t dz) const{
8257   /////////////////////////////////////////////////////////////
8258   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8259   /////////////////////////////////////////////////////////////
8260   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8261   const Double_t *vect = hmatrix->GetTranslation();
8262   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8263   hmatrix->SetTranslation(newvect);
8264   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8265   delete hmatrix;
8266   return matrix;
8267 }
8268 ////////////////////////////////////////////////////////////////////////////////
8269 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8270   /////////////////////////////////////////////////////////////
8271   // Method returning the Medium type 
8272   /////////////////////////////////////////////////////////////
8273   char ch[30];
8274   sprintf(ch, "ITS_%s",mediumName);
8275   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8276   if (! medium)
8277     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8278   return medium;
8279 }
8280 ////////////////////////////////////////////////////////////////////////////////
8281 void AliITSv11GeometrySSD::CreateMaterials(){
8282 ///////////////////////////////////
8283 // This part has to be modified
8284 ///////////////////////////////////
8285   ///////////////////////////////////
8286   // Silicon for Sensor
8287   /////////////////////////////////// 
8288   fSSDSensorMedium = GetMedium("SI$");
8289   ///////////////////////////////////
8290   // Silicon Mixture for Sensor
8291   /////////////////////////////////// 
8292   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8293   fSSDChipGlueMedium = GetMedium("EPOXY$");
8294   ///////////////////////////////////
8295   // Stiffener Components Materials
8296   /////////////////////////////////// 
8297   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8298   ///////////////////////////  
8299   // Stiffener Connectors 
8300   ///////////////////////////  
8301   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8302   ////////////////////////////////  
8303   // Stiffener 0603-1812 Capacitor
8304   ////////////////////////////////  
8305   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8306   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8307   ///////////////////////////  
8308   // Stiffener Hybrid Wire 
8309   ///////////////////////////  
8310   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8311   ///////////////////////////  
8312   // Al for Cooling Block
8313   ///////////////////////////  
8314   fSSDAlCoolBlockMedium = GetMedium("AL$");
8315   //////////////////////////////////////////////////////  
8316   // Kapton and Al for Chip Cable Flex and Ladder Cables
8317   //////////////////////////////////////////////////////  
8318   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8319   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8320   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8321   fSSDAlTraceFlexMedium = GetMedium("AL$");
8322   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8323   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8324   /////////////////////////////////////////////////////////////////  
8325   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8326   //////////////////////////////////////////////////////////////////  
8327   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8328   /////////////////////////////////////////////////////////////////  
8329   // G10 for Detector Leg, TubeHolder
8330   //////////////////////////////////////////////////////////////////  
8331   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8332   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8333   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8334   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8335   /////////////////////////////////////////////////////////////////  
8336   // Water and Phynox for Cooling Tube
8337   //////////////////////////////////////////////////////////////////  
8338   fSSDCoolingTubeWater = GetMedium("WATER$");
8339   fSSDCoolingTubePhynox = GetMedium("INOX$");
8340   /////////////////////////////////////////////////////////////////////
8341   // Material for Support Rings
8342   /////////////////////////////////////////////////////////////////////
8343   fSSDSupportRingAl = GetMedium("AL$");
8344   fSSDRohaCellCone = GetMedium("ROHACELL$");
8345   /////////////////////////////////////////////////////////////////////
8346   fSSDAir = GetMedium("SDD AIR$");
8347   fSSDCopper = GetMedium("COPPER$");
8348   fCreateMaterials = kTRUE;
8349 }
8350 /////////////////////////////////////////////////////////////////////