]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
6767ad39f165248190440b02ce4ca6b02904c977
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41 #include "Riostream.h"
42 /////////////////////////////////////////////////////////////////////////////////
43 // Names of the Sensitive Volumes of Layer 5 and Layer 6
44 /////////////////////////////////////////////////////////////////////////////////
45 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
47 /////////////////////////////////////////////////////////////////////////////////
48 //Parameters for SSD Geometry
49 /////////////////////////////////////////////////////////////////////////////////
50 // Variable for Vertical Disalignement of Modules
51 /////////////////////////////////////////////////////////////////////////////////
52 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
55 // For ladders:
56 const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.2*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
92 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
97 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
100 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
101 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
103                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
105 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
108                                                                                                           0.25*fgkSSDStiffenerHeight;
109 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
111 /////////////////////////////////////////////////////////////////////////////////
112 // Cooling Block (lengths are in mm and angles in degrees)
113 /////////////////////////////////////////////////////////////////////////////////
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
117                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
119                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
120 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
121                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
122 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
123                                                                                                                                          1.500*fgkmm;
124 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
125                                                                                                                                          0.300*fgkmm;
126 /////////////////////////////////////////////////////////////////////////////////
127 // SSD Sensor (lengths are in mm and angles in degrees)
128 /////////////////////////////////////////////////////////////////////////////////
129 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
130                                                                                                                  "SSDSensorSensitiveVol";
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
132 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
135                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
136 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
137 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
138 /////////////////////////////////////////////////////////////////////////////////
139 // Flex (lengths are in mm and angles in degrees)
140 /////////////////////////////////////////////////////////////////////////////////
141 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
143                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
144                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
145                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
146                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
147                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
149                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
151                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
152 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
153 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
154 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
155 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
156                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
157 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
158                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
159 /////////////////////////////////////////////////////////////////////////////////
160 // SSD Ladder Cable (lengths are in mm and angles in degrees)
161 /////////////////////////////////////////////////////////////////////////////////
162 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
163 /////////////////////////////////////////////////////////////////////////////////
164 // SSD Module (lengths are in mm and angles in degrees)
165 /////////////////////////////////////////////////////////////////////////////////
166 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
167                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
168 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
169                                                                                                                                         45.600*fgkmm;
170 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
171                                                                                                                                          5.075*fgkmm;
172 /////////////////////////////////////////////////////////////////////////////////
173 // Sensor Support (lengths are in mm and angles in degrees)
174 /////////////////////////////////////////////////////////////////////////////////
175 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
176                                                                                                                                          5.800*fgkmm;
177 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
178                                                                                                                                          2.000*fgkmm;
179 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
180                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
181                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
182 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
183 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
184 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
185                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
186 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
187                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
188                                                             +  fgkSSDSensorSideSupportThickness[0])
189                                                                 -  fgkSSDSensorSideSupportLength;
190 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
191                                                                                                                                     5.250*fgkmm;
192 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
193                                                                                                                                         1.680*fgkmm;
194 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
195                                                                   = {fgkSSDSensorSideSupportHeight[0]
196                                                                   +  fgkSSDSensorSideSupportThickness[0],
197                                                                          fgkSSDSensorSideSupportHeight[1]
198                                                                   +  fgkSSDSensorSideSupportThickness[1]};
199 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
200                                                                   =  {fgkSSDSensorSideSupportThickness[0],
201                                                                           fgkSSDSensorSideSupportThickness[1]};
202 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
203                                                                                                                                    19.000*fgkmm;
204 /////////////////////////////////////////////////////////////////////////////////
205 // Chip Cables (lengths are in mm and angles in degrees)
206 /////////////////////////////////////////////////////////////////////////////////
207 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
208                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
209 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
210                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
211                                                                   -  (fgkSSDSensorSideSupportHeight[1]
212                                                                   -   fgkSSDSensorSideSupportHeight[0])
213                                                                   -   fgkSSDModuleVerticalDisalignment
214                                                                   -   fgkSSDCoolingBlockHoleCenter
215                                                                   -   fgkSSDStiffenerHeight
216                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
217                                                                           fgkSSDModuleCoolingBlockToSensor
218                                                                   -   fgkSSDModuleVerticalDisalignment  
219                                                                   -   fgkSSDCoolingBlockHoleCenter
220                                                                   -       fgkSSDStiffenerHeight
221                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
222 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
223                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
224 /////////////////////////////////////////////////////////////////////////////////
225 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
226 /////////////////////////////////////////////////////////////////////////////////
227 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
228                                                                                                                                         3.820*fgkmm;
229 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
230 //                                                                                                                                         3.780;
231 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
232                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
233 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
234                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
235 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
236                                                                                                                                 { 30.00, 90.00};
237 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
238                                                                                                                                          1.78*fgkmm;
239 /////////////////////////////////////////////////////////////////////////////////
240 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
241 /////////////////////////////////////////////////////////////////////////////////
242 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
243                                                                    = fgkSSDModuleSensorSupportDistance
244                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
247                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
249                                                                                                                                         1.630*fgkmm;
250 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
251 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
252                                                                         = fgkCarbonFiberTriangleLength
253                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
254                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
255                                                                         * TMath::DegToRad());
256 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
257                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
258                                                                         - fgkCarbonFiberSupportWidth)
259                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
260                                                                         - fgkCarbonFiberSupportWidth;
261 /////////////////////////////////////////////////////////////////////////////////
262 // Carbon Fiber Lower Support Parameters (lengths are in mm)
263 /////////////////////////////////////////////////////////////////////////////////
264 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
266                                                                                                                                           =  0.950*fgkmm;
267 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
268                                                                                                                                           =  1.600*fgkmm;
269 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
270                                                                                                                                           =  0.830*fgkmm;
271 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
272                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
273 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
274                                                                         = fgkCarbonFiberJunctionWidth
275                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
276                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
277 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
278                                                                         = {fgkCarbonFiberLowerSupportWidth
279                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
280                                                                            fgkCarbonFiberLowerSupportWidth
281                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
282                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
283 /////////////////////////////////////////////////////////////////////////////////
284 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
285 /////////////////////////////////////////////////////////////////////////////////
286 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
287                                                            {0.5 * (fgkSSDLay5LadderLength
288                                                                         -  fgkSSDLay5SensorsNumber
289                                                                         *  fgkCarbonFiberJunctionWidth
290                                                                         -  fgkCarbonFiberLowerSupportWidth),
291                                                                 0.5 * (fgkSSDLay5LadderLength
292                                                                         -  fgkSSDLay5SensorsNumber
293                                                                         *  fgkCarbonFiberJunctionWidth
294                                                                         +  fgkCarbonFiberLowerSupportWidth)};
295 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
296                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
297                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
298 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
299                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
300                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
301 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
302                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
303 /////////////////////////////////////////////////////////////////////////////////
304 // Cooling Tube Support (lengths are in mm and angles in degrees)
305 /////////////////////////////////////////////////////////////////////////////////
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
308                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
312 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
313                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
314 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
315                                                                                                                                           11.70*fgkmm;
316 /////////////////////////////////////////////////////////////////////////////////
317 // Cooling Tube (lengths are in mm and angles in degrees)
318 /////////////////////////////////////////////////////////////////////////////////
319 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
321 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
322                                                                                                         fgkCarbonFiberJunctionWidth;
323 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
324                                                                          fgkSSDModuleSensorSupportDistance
325                                                                   +      fgkSSDCoolingBlockLength;
326 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
327 /////////////////////////////////////////////////////////////////////////////////
328 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
329 /////////////////////////////////////////////////////////////////////////////////
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
331                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
333                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
335                                                                                                                                           20.0*fgkmm;
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
337                                                                                                                                                     40.0;
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
339                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
341                                                                                                                                           2.5*fgkmm;
342 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
343                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
344 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
345                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
346 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
347                                                                                                                                           1.0*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
349                                                                                                                                           6.0*fgkmm;
350 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
351                                                                                                                                           4.0*fgkmm;
352 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
353                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
354 /////////////////////////////////////////////////////////////////////////////////
355 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
356 /////////////////////////////////////////////////////////////////////////////////
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
359 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
360 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
362 /////////////////////////////////////////////////////////////////////////////////
363 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
364 /////////////////////////////////////////////////////////////////////////////////
365 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
366 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
368                                                                                                   -  fgkSSDMountingBlockHeight[1]
369                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
370                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
371                                                                                                   -      fgkMountingBlockSupportDownHeight,
372                                                                                                          fgkSSDLay6RadiusMin
373                                                                                                   -  fgkSSDMountingBlockHeight[1]
374                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
375                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
376                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
377 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
378                                                                                                     -  fgkSSDMountingBlockHeight[1]
379                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
380                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
381                                                                                                         -  fgkMountingBlockSupportRadius[0],
382                                                                                                            fgkSSDLay6RadiusMax
383                                                                                                     -  fgkSSDMountingBlockHeight[1]
384                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
385                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
386                                                                                                         -  fgkMountingBlockSupportRadius[1]};
387 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
390 /////////////////////////////////////////////////////////////////////////////////
391 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
392 /////////////////////////////////////////////////////////////////////////////////
393 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
397                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
399                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
401                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
408 /////////////////////////////////////////////////////////////////////////////////
409 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
410 /////////////////////////////////////////////////////////////////////////////////
411 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
414 /////////////////////////////////////////////////////////////////////////////////
415 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
416 /////////////////////////////////////////////////////////////////////////////////
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
418                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
419 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
422                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
423 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
424                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
425 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
426 /////////////////////////////////////////////////////////////////////////////////
427 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
428 /////////////////////////////////////////////////////////////////////////////////
429 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
430                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
432                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
433                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
434 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
435 /////////////////////////////////////////////////////////////////////////////////
436 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
437 /////////////////////////////////////////////////////////////////////////////////
438 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
439                                                                                                            {62.0*fgkmm,21.87*fgkmm};
440 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
441                                                                                                             {47.0*fgkmm,0.35*fgkmm};
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
443                                                                                                                                           1.0*fgkmm;
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
446                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
448                                                                                                                                          0.15*fgkmm;
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
450                                                                                                                                          19.0*fgkmm;
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
452                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
454                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
456                                                                                                                                           2.1*fgkmm;
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
458                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
459 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
460                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
462                                                                                                                                            19*fgkmm; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
464                                                                                                                                           1.0*fgkmm;
465 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
466                                                                                                                                           3.6*fgkmm;
467 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
468                                                                                                                                          61.0*fgkmm; 
469 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
470                                                                                                                                          5.97*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
473                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
474                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
475 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
476                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
477 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
478                                                                                                                                           1.0*fgkmm; 
479 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
480                                                                                                                                    = 0.15*fgkmm; 
481 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
482                                                                                                                                          20.0*fgkmm;
483 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
488 /////////////////////////////////////////////////////////////////////////////////
489 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
490 /////////////////////////////////////////////////////////////////////////////////
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
500 /////////////////////////////////////////////////////////////////////////////////
501 // SSD Cone Parameters (lengths are in mm and angles in degrees)
502 /////////////////////////////////////////////////////////////////////////////////
503 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
508 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
525 /////////////////////////////////////////////////////////////////////////////////
526 // SSD Cables Parameters (lengths are in mm and angles in degrees)
527 /////////////////////////////////////////////////////////////////////////////////
528 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
533 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
536 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
542 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
544 /////////////////////////////////////////////////////////////////////////////////
545 ClassImp(AliITSv11GeometrySSD)
546 /////////////////////////////////////////////////////////////////////////////////
547 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
548   AliITSv11Geometry(),
549   fSSDChipMedium(),
550   fSSDChipGlueMedium(),
551   fSSDStiffenerMedium(),
552   fSSDStiffenerConnectorMedium(),
553   fSSDStiffener0603CapacitorMedium(),
554   fSSDStiffener1812CapacitorMedium(),
555   fSSDStiffenerHybridWireMedium(),
556   fSSDKaptonFlexMedium(),
557   fSSDAlTraceFlexMedium(),
558   fSSDAlTraceLadderCableMedium(),
559   fSSDKaptonLadderCableMedium(),
560   fSSDKaptonChipCableMedium(),
561   fSSDAlTraceChipCableMedium(),
562   fSSDAlCoolBlockMedium(),
563   fSSDSensorMedium(),
564   fSSDSensorSupportMedium(),
565   fSSDCarbonFiberMedium(),
566   fSSDTubeHolderMedium(),
567   fSSDCoolingTubeWater(),
568   fSSDCoolingTubePhynox(),
569   fSSDSupportRingAl(),
570   fSSDMountingBlockMedium(),
571   fSSDRohaCellCone(),
572   fSSDAir(),
573   fSSDCopper(),
574   fCreateMaterials(kFALSE),
575   fTransformationMatrices(kFALSE),
576   fBasicObjects(kFALSE),
577   fcarbonfiberjunction(),
578   fcoolingtubesupport(),
579   fhybridmatrix(),
580   fssdcoolingblocksystem(),
581   fcoolingblocksystematrix(),
582   fssdstiffenerflex(),
583   fssdendflex(),
584   fendladdercoolingtubesupportmatrix(),
585   fendladdermountingblock(),
586   fendladdermountingblockclip(),
587   fSSDSensor5(),
588   fSSDSensor6(),
589   fSSDLayer5(), 
590   fSSDLayer6(),
591   fMotherVol(),
592   fLay5LadderSupportRing(),
593   fLay6LadderSupportRing(),
594   fgkEndCapSupportSystem(),
595   fSSDCone(),
596   fColorCarbonFiber(4),
597   fColorRyton(5),
598   fColorPhynox(14),
599   fColorSilicon(3),
600   fColorAl(38),
601   fColorKapton(6),
602   fColorPolyhamide(5),
603   fColorStiffener(9),
604   fColorEpoxy(30),
605   fColorWater(7),
606   fColorG10(41)
607 {
608   ////////////////////////
609   // Standard constructor
610   ////////////////////////
611 }
612 /////////////////////////////////////////////////////////////////////////////////
613 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
614   AliITSv11Geometry(s.GetDebug()),
615   fSSDChipMedium(s.fSSDChipMedium),
616   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
617   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
618   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
619   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
620   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
621   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
622   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
623   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
624   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
625   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
626   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
627   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
628   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
629   fSSDSensorMedium(s.fSSDSensorMedium),
630   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
631   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
632   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
633   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
634   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
635   fSSDSupportRingAl(s.fSSDSupportRingAl),
636   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
637   fSSDRohaCellCone(s.fSSDRohaCellCone),
638   fSSDAir(s.fSSDAir),
639   fSSDCopper(s.fSSDCopper),
640   fCreateMaterials(s.fCreateMaterials),
641   fTransformationMatrices(s.fTransformationMatrices),
642   fBasicObjects(s.fBasicObjects),
643   fcarbonfiberjunction(s.fcarbonfiberjunction),
644   fcoolingtubesupport(s.fcoolingtubesupport),
645   fhybridmatrix(s.fhybridmatrix),
646   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
647   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
648   fssdstiffenerflex(s.fssdstiffenerflex),
649   fssdendflex(s.fssdendflex),
650   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
651   fendladdermountingblock(s.fendladdermountingblock),
652   fendladdermountingblockclip(s.fendladdermountingblockclip),
653   fSSDSensor5(s.fSSDSensor5),
654   fSSDSensor6(s.fSSDSensor6),
655   fSSDLayer5(s.fSSDLayer5),     
656   fSSDLayer6(s.fSSDLayer6),
657   fMotherVol(s.fMotherVol),
658   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
659   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
660   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
661   fSSDCone(s.fSSDCone),
662   fColorCarbonFiber(s.fColorCarbonFiber),
663   fColorRyton(s.fColorRyton),
664   fColorPhynox(s.fColorPhynox),
665   fColorSilicon(s.fColorSilicon),
666   fColorAl(s.fColorAl),
667   fColorKapton(s.fColorKapton),
668   fColorPolyhamide(s.fColorPolyhamide),
669   fColorStiffener(s.fColorStiffener),
670   fColorEpoxy(s.fColorEpoxy),
671   fColorWater(s.fColorWater),
672   fColorG10(s.fColorG10)
673 {
674   ////////////////////////
675   // Copy Constructor
676   ////////////////////////
677 }
678 /////////////////////////////////////////////////////////////////////////////////
679 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
680 operator=(const AliITSv11GeometrySSD &s){
681   ////////////////////////
682   // Assignment operator
683   ////////////////////////
684   this->~AliITSv11GeometrySSD();
685   new(this) AliITSv11GeometrySSD(s); 
686   return *this;
687 /*      
688   if(&s == this) return *this;
689   fMotherVol = s.fMotherVol;
690   return *this;
691  */
692 }
693 ///////////////////////////////////////////////////////////////////////////////
694 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
695   ///////////////////////////////////////////////////////////////////////  
696   // Method generating the trasformation matrix for the whole SSD Geometry   
697   ///////////////////////////////////////////////////////////////////////  
698   // Setting some variables for Carbon Fiber Supportmatrix creation
699   //////////////////////////////////////////////////////////////////////
700   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
701                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
702   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
703                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
704                                                                  +      fgkCarbonFiberSupportWidth);
705   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
706                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
707   TGeoRotation* carbonfiberot[3];
708   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
709   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
710   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
711   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
712   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
713                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
714                                                   -  fgkCarbonFiberTriangleLength
715                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
716   ///////////////////////////////////////////
717   //Setting Local Translations and Rotations: 
718   ///////////////////////////////////////////
719   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
720   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
721                                                                          0.5*carbonfibersupportheight,NULL);    
722   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
723                                                                          2.*symmetryplaneposition+transvector[1],
724                                                                          transvector[2], carbonfiberot[2]);
725   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
726   /////////////////////////////////////////////////////////////
727   // Carbon Fiber Support Transformations
728   /////////////////////////////////////////////////////////////
729   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
730   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
731                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
732                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
733                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
734   }             
735   /////////////////////////////////////////////////////////////
736   // Carbon Fiber Junction Transformation
737   /////////////////////////////////////////////////////////////
738   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
739   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
740   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
741   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
742   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
743         localcarbonfiberjunctionmatrix[i] = 
744                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
745         localcarbonfiberjunctionrot[i] = 
746                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
747         localcarbonfiberjunctiontrans[i] = 
748                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
749   }
750   ///////////////////////
751   // Setting Translations
752   ///////////////////////
753   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
754   localcarbonfiberjunctiontrans[1][0] = 
755                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
756   localcarbonfiberjunctiontrans[2][0] = 
757                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
758                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
759                                  fgkCarbonFiberTriangleLength
760                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
761   localcarbonfiberjunctiontrans[0][1] = 
762                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
763   localcarbonfiberjunctiontrans[1][1] = 
764                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
765   localcarbonfiberjunctiontrans[2][1] = 
766                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
767   ////////////////////
768   // Setting Rotations
769   ////////////////////
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
772                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
773   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
774         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
775   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
776   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
777   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
778   ////////////////////////////////////////
779   // Setting Carbon Fiber Junction matrix 
780   ////////////////////////////////////////
781   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
782                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
783                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
784                         localcarbonfiberjunctionmatrix[i][j] = 
785                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
786                                                            *localcarbonfiberjunctionrot[i][j]);
787                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
788          }
789   }
790   /////////////////////////////////////////////////////////////
791   // Carbon Fiber Lower Support Transformations
792   /////////////////////////////////////////////////////////////
793   TGeoTranslation* localcarbonfiberlowersupportrans[2];
794   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
795                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
796                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
797                                                                          0.0);
798   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
799                                                                          fgkCarbonFiberJunctionWidth
800                                                                 -    fgkCarbonFiberLowerSupportWidth
801                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
802                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
803                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
804    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
805    fcarbonfiberlowersupportrans[0] = 
806                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
807    fcarbonfiberlowersupportrans[1] = 
808                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
809   /////////////////////////////////////////////////////////////
810   // SSD Sensor Support Transformations
811   /////////////////////////////////////////////////////////////
812   const Int_t kssdsensorsupportmatrixnumber = 3;
813   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
814   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
815   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
816   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
817         localssdsensorsupportmatrix[i] = 
818                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
819         localssdsensorsupportrot[i] = 
820                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
821         localssdsensorsupportrans[i] = 
822                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
823   }
824   ///////////////////////
825   // Setting Translations
826   ///////////////////////
827   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
828                                                                           0.5*fgkSSDSensorSideSupportWidth,
829                                                                           0.0);
830   localssdsensorsupportrans[1][0] = 
831                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
832   localssdsensorsupportrans[2][0] = 
833                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
834   localssdsensorsupportrans[0][1] = 
835                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
836                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
837                                                                                 0.0);
838   localssdsensorsupportrans[1][1] = 
839                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
840                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
841                                                                     -   fgkSSDModuleSensorSupportDistance,
842                                                                                 0.0);
843   localssdsensorsupportrans[2][1] = 
844                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
845                                                                         -    fgkSSDSensorCenterSupportPosition,
846                                                                                  0.5*fgkSSDSensorCenterSupportWidth
847                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
848                                                                                  fgkSSDSensorCenterSupportThickness[0]);
849   localssdsensorsupportrans[0][2] = 
850                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
851                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
852                                                                                  fgkCarbonFiberJunctionWidth
853                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
854                                                                         +    fgkSSDSensorCenterSupportLength
855                                                                         -    fgkSSDSensorCenterSupportThickness[0])
856                                                                         -    fgkSSDSensorCenterSupportPosition,
857                                                                              0.0);
858   localssdsensorsupportrans[1][2] = 
859                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
860   localssdsensorsupportrans[2][2] = 
861                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
862   ////////////////////
863   // Setting Rotations
864   ////////////////////
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
866                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
867                         localssdsensorsupportrot[i][j] = new TGeoRotation();
868   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
869         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
870         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
871   }
872   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
873   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
874   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
875   ////////////////////////////////////////
876   // SSD Sensor Support matrix 
877   ////////////////////////////////////////
878   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
879                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
880                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
881                         localssdsensorsupportmatrix[i][j] = 
882                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
883                                                            *localssdsensorsupportrot[i][j]);
884                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
885          }
886   }
887   /////////////////////////////////////////////////////////////
888   // SSD Cooling Tube Support Transformations
889   /////////////////////////////////////////////////////////////
890   const Int_t kcoolingtubesupportmatrixnumber = 2;
891   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
892   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
893   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
894   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
895                                                                                                         /fgkCoolingTubeSupportRmax);
896   localcoolingtubesupportrans[0] = 
897                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
898                                                 +  2.*(fgkCoolingTubeSupportLength
899                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
900                                                 +  fgkCarbonFiberTriangleLength
901                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
902   localcoolingtubesupportrans[1] = 
903                         new TGeoTranslation(fgkCarbonFiberJunctionLength
904                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
905                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
906                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
907                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
908                     -  0.5*(fgkCarbonFiberLowerSupportWidth
909                                         +          fgkSSDSensorCenterSupportLength
910                     -      fgkSSDSensorCenterSupportThickness[0])
911                                         +  0.5*fgkSSDSensorLength,
912                                         -  0.5*fgkCoolingTubeSupportHeight);  
913   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
914   localcoolingtubesupportrot[i] = new TGeoRotation();
915   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
916   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
917   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
918         localcoolingtubesupportmatrix[i] = 
919                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
920                                                    *localcoolingtubesupportrot[i]);
921   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
922   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
923                                                                 (*localcoolingtubesupportmatrix[0]));
924   /////////////////////////////////////////////////////////////
925   // End Ladder SSD Cooling Tube Support Transformations
926   /////////////////////////////////////////////////////////////
927   TGeoTranslation** localendladdercooltubetrans[2];
928   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
929   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
930   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
931   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
932                                                                                         -          (fgkCoolingTubeSupportLength
933                                                                                         -               fgkCoolingTubeSupportRmax),
934                                                                                                         fgkEndLadderMountingBlockPosition[0]
935                                                                                         -               fgkendladdercoolingsupportdistance[0]
936                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
937                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
938   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
939                                                                                         -          (fgkCoolingTubeSupportLength
940                                                                                         -               fgkCoolingTubeSupportRmax),
941                                                                                                         fgkEndLadderMountingBlockPosition[0]
942                                                                                         +               fgkendladdercoolingsupportdistance[1]
943                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
944                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
945   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
946                                                                                         -       fgkCoolingTubeSupportRmax)
947                                                                                         +               fgkCarbonFiberTriangleLength
948                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
949                                                                                                 0.0,
950                                                                                                 0.0);
951   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
952                                                                                                         fgkendladdercoolingsupportdistance[0]
953                                                                                         +               fgkendladdercoolingsupportdistance[1],
954                                                                                                         0.0);
955   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
956   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
957                                                                                         +               fgkCarbonFiberJunctionLength
958                                                                                         -               fgkCoolingTubeSupportLength,
959                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
960                                                                                         -       0.5*fgkCoolingTubeSupportWidth
961                                                                                                    -fgkendladdercoolingsupportdistance[2],
962                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
963   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
964                                                                                         +               fgkCoolingTubeSupportLength
965                                                                                         -               fgkCoolingTubeSupportRmax
966                                                                                         -               fgkCarbonFiberJunctionLength,
967                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
968                                                                                         -       0.5*fgkCoolingTubeSupportWidth
969                                                                                         -               fgkendladdercoolingsupportdistance[2],
970                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
971   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
972   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
973   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
974   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
975   (*localcoolingtubesupportrot[1]));
976   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
977   (*localcoolingtubesupportrot[1]));
978   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
979   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
980   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
981   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
982   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
983
984   fendladdercoolingtubesupportmatrix[1][0] =    
985                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
986                                                                                    *(*localcoolingtubesupportrot[1]));
987   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
988   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
989   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
990   /////////////////////////////////////////////////////////////
991   // SSD Cooling Tube Transformations
992   /////////////////////////////////////////////////////////////
993   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
994   localcoolingtuberot->SetAngles(0.,90.,0.);
995   TGeoTranslation** localcoolingtubetrans[4];
996   TVector3** localcoolingtubevect[4];
997   for(Int_t i=0; i<4; i++){
998         localcoolingtubevect[i] = new TVector3*[2];
999         localcoolingtubetrans[i] = new TGeoTranslation*[2];
1000         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
1001   }
1002   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1003                                                   -fgkCarbonFiberTriangleLength),
1004                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1005                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1006                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1007                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1008                                                   +      fgkSSDSensorCenterSupportLength
1009                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1010                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1011                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1012                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1013                                                   -  0.5*fgkCoolingTubeSupportWidth,
1014                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1015   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1016                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1017                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1018                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1019                                                   +  fgkCoolingTubeSupportWidth,
1020                                                   localcoolingtubevect[0][0]->Z());     
1021   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1022                                                          +                               fgkCarbonFiberTriangleLength,
1023                                                                                          localcoolingtubevect[0][0]->Y(),
1024                                                                                          localcoolingtubevect[0][0]->Z());
1025   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1026                                                          +                               fgkCarbonFiberTriangleLength,
1027                                                                                          localcoolingtubevect[0][1]->Y(),
1028                                                                                          localcoolingtubevect[0][1]->Z());
1029   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1030                                                   -     fgkCarbonFiberTriangleLength),
1031                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1032                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1033                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1034                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1035                                                   +      fgkSSDSensorCenterSupportLength
1036                                                   -      fgkSSDSensorCenterSupportThickness[0])
1037                                                   +  fgkSSDModuleStiffenerPosition[1]
1038                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1039                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1040   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1041                                                          +                               fgkCarbonFiberTriangleLength,
1042                                                                                          localcoolingtubevect[2][0]->Y(),
1043                                                                                          localcoolingtubevect[2][0]->Z());      
1044   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1045                                                   -     fgkCarbonFiberTriangleLength),
1046                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1047                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1048                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1049                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1050                                                   +      fgkSSDSensorCenterSupportLength
1051                                                   -      fgkSSDSensorCenterSupportThickness[0])
1052                                                   +      fgkSSDSensorLength
1053                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1054                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1055   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1056                                                   + fgkCarbonFiberTriangleLength,
1057                                                         localcoolingtubevect[3][0]->Y(),
1058                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1059   for(Int_t i=0; i<4; i++) 
1060         for(Int_t j=0; j<2; j++){
1061                 localcoolingtubetrans[i][j] = 
1062                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1063                                                                 localcoolingtubevect[i][j]->Y(),
1064                                                                 localcoolingtubevect[i][j]->Z());
1065                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1066                                                           *                                     (*localcoolingtuberot));
1067         }
1068   /////////////////////////////////////////////////////////////
1069   // SSD End Ladder Cooling Tube Transformations
1070   /////////////////////////////////////////////////////////////
1071   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1072   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1073   TGeoTranslation** localendlladdercoolingtubetrans[2];
1074   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1075   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1076   for(Int_t i=0; i<2; i++)      
1077         for(Int_t j=0; j<(i==0?6:4); j++)       
1078                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1079   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1080                                                                         -        fgkCoolingTubeSupportRmax)
1081                                                                         +        fgkCarbonFiberJunctionLength,
1082                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1083                                                                         -    fgkendladdercoolingsupportdistance[0]),
1084                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1085   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1086                                                                         -        fgkCoolingTubeSupportRmax)
1087                                                                         -        fgkCarbonFiberJunctionLength
1088                                                                         +    fgkCarbonFiberTriangleLength,
1089                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1090                                                                         -    fgkendladdercoolingsupportdistance[0]),
1091                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1092   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1093                                                                         -   fgkCoolingTubeSupportRmax)
1094                                                                         +       fgkCarbonFiberJunctionLength,
1095                                                                            fgkEndLadderMountingBlockPosition[0]
1096                                                                         -   fgkendladdercoolingsupportdistance[0]
1097                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1098                                                   +                             fgkendladdercoolingsupportdistance[1]
1099                                                   +                             fgkCoolingTubeSupportWidth),
1100                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1101   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1102                                                                         -        fgkCoolingTubeSupportRmax)
1103                                                                         -        fgkCarbonFiberJunctionLength
1104                                                                         +    fgkCarbonFiberTriangleLength,
1105                                                                            fgkEndLadderMountingBlockPosition[0]
1106                                                                         -   fgkendladdercoolingsupportdistance[0]
1107                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1108                                                   +                             fgkendladdercoolingsupportdistance[1]
1109                                                   +                             fgkCoolingTubeSupportWidth),
1110                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1111   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1112                                                                         -   fgkCoolingTubeSupportRmax)
1113                                                                         +       fgkCarbonFiberJunctionLength,
1114                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1115                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1116                                                   -                     fgkEndLadderMountingBlockPosition[0]
1117                                                   -                     fgkendladdercoolingsupportdistance[1]           
1118                                                   -                     fgkCoolingTubeSupportWidth),
1119                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1120   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1121                                                                         -        fgkCoolingTubeSupportRmax)
1122                                                                         -        fgkCarbonFiberJunctionLength
1123                                                                         +    fgkCarbonFiberTriangleLength,
1124                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1125                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1126                                                   -                     fgkEndLadderMountingBlockPosition[0]
1127                                                   -                     fgkendladdercoolingsupportdistance[1]           
1128                                                   -                     fgkCoolingTubeSupportWidth),
1129                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1130   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1131                                                                         -   fgkCoolingTubeSupportRmax)
1132                                                                         +       fgkCarbonFiberJunctionLength,
1133                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1134                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1135                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1136                                                         +                 fgkSSDSensorOverlap
1137                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1138                                                         -                 fgkendladdercoolingsupportdistance[2]
1139                                                         -                 fgkEndLadderMountingBlockPosition[1]
1140                                                         -                 fgkCoolingTubeSupportWidth)
1141                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1142                                                         -                 fgkendladdercoolingsupportdistance[2]
1143                                                         -                 fgkCoolingTubeSupportWidth,
1144                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1145   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1146                                                   -      fgkCoolingTubeSupportRmax)
1147                                                   -      fgkCarbonFiberJunctionLength
1148                                                   +    fgkCarbonFiberTriangleLength,
1149                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1150                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1151                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1152                                                         +                 fgkSSDSensorOverlap
1153                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1154                                                         -                 fgkendladdercoolingsupportdistance[2]
1155                                                         -                 fgkEndLadderMountingBlockPosition[1]
1156                                                         -                 fgkCoolingTubeSupportWidth)
1157                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1158                                                         -                 fgkendladdercoolingsupportdistance[2]
1159                                                         -                 fgkCoolingTubeSupportWidth,
1160                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1161   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1162                                                                         -   fgkCoolingTubeSupportRmax)
1163                                                                         +       fgkCarbonFiberJunctionLength,
1164                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1165                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1166                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1167   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1168                                                                         -        fgkCoolingTubeSupportRmax)
1169                                                                         -        fgkCarbonFiberJunctionLength
1170                                                                         +    fgkCarbonFiberTriangleLength,
1171                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1172                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1173                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1174   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1175   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1176   for(Int_t i=0; i<2; i++)
1177         for(Int_t j=0; j<(i==0?6:4); j++){
1178                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1179                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1180         }
1181   /////////////////////////////////////////////////////////////
1182   // SSD Hybrid Components Transformations
1183   /////////////////////////////////////////////////////////////
1184   const Int_t khybridmatrixnumber = 3;
1185   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1186   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1187                                             0.5*fgkSSDStiffenerWidth,
1188                                             0.5*fgkSSDStiffenerHeight);
1189   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1190                                             fgkSSDModuleStiffenerPosition[1],0.0);
1191
1192   localhybridtrans[2] = new TGeoTranslation(
1193                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1194                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1195                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1196                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1197                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1198                       -       fgkSSDSensorCenterSupportThickness[0]),
1199                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1200                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1201                                           -       fgkSSDModuleVerticalDisalignment)); 
1202   fhybridmatrix = new TGeoHMatrix();
1203   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1204   /////////////////////////////////////////////////////////////
1205   // SSD Cooling Block Transformations
1206   /////////////////////////////////////////////////////////////
1207   const Int_t kcoolingblockmatrixnumber = 4;    
1208   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1209   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1210                             -  fgkCoolingTubeSupportRmin),0.0,
1211                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1212   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1213                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1214                                0.0,fgkSSDStiffenerHeight);
1215   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1216   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1217   fcoolingblocksystematrix = new TGeoHMatrix();
1218   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1219       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1220   /////////////////////////////////////////////////////////////
1221   // SSD Stiffener Flex Transformations
1222   /////////////////////////////////////////////////////////////
1223   const Int_t klocalflexmatrixnumber = 4;
1224   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1225   for(Int_t i=0; i<fgkflexnumber; i++)    
1226       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1227   for(Int_t i=0; i<fgkflexnumber; i++)
1228       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1229             localflexmatrix[i][j] = new TGeoCombiTrans();
1230   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1231                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1232                                                                   -    fgkSSDStiffenerWidth;
1233   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1234                                         +0.5*fgkSSDStiffenerLength,
1235                                          0.5*fgkSSDStiffenerWidth,
1236                                         -0.5*fgkSSDStiffenerHeight
1237                                         -0.5*fgkSSDFlexHeight[0]);
1238   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1239                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1240                                         -0.5*fgkSSDStiffenerWidth,
1241                                         -0.5*fgkSSDStiffenerHeight
1242                                         -0.5*fgkSSDFlexHeight[0]);
1243   TGeoRotation* localflexrot = new TGeoRotation();
1244   localflexrot->SetAngles(180.,0.,0.);    
1245   localflexmatrix[1][0]->SetRotation(localflexrot);
1246   for(Int_t i=0; i<fgkflexnumber; i++)
1247       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1248             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1249   for(Int_t i=0; i<fgkflexnumber; i++){
1250       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1251       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1252             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1253   }
1254   /////////////////////////////////////////////////////////////
1255   // SSD End Flex Transformations
1256   /////////////////////////////////////////////////////////////
1257   TGeoRotation* localendflexrot = new TGeoRotation();
1258   localendflexrot->SetAngles(0.0,90.0,0.0);
1259   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1260   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1261                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1262   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1263                             * TMath::DegToRad()*ssdflexradiusmax
1264                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1265                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1266                                                                                    - 0.1*fgkSSDFlexFullLength;
1267   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1268                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1269                             +      fgkSSDFlexLength[2];
1270   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1271                               0.5*fgkSSDFlexWidth[0],
1272                               2.*fgkSSDStiffenerHeight
1273                             + 0.5*fgkSSDFlexHeight[0]);      
1274   localendflexmatrix->SetRotation(localendflexrot);
1275   for(Int_t i=0; i<fgkflexnumber; i++) 
1276       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1277   /////////////////////////////////////////////////////////////
1278   // End Ladder Carbon Fiber Junction
1279   /////////////////////////////////////////////////////////////
1280   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1281   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1282   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1283   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1284       localendladdercarbonfiberjunctionmatrix[i] 
1285             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1286       localendladdercarbonfiberjunctionrot[i] 
1287             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1288       localendladdercarbonfiberjunctiontrans[i] 
1289             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1290       fendladdercarbonfiberjunctionmatrix[i]
1291             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1292   }
1293   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1294       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1295             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1296             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1297       }
1298   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1299       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1300           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1301   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1302       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1303                               0.0,0.0);
1304       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1305                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1306                 *                     SinD(fgkCarbonFiberTriangleAngle),
1307                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1308   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1309   }
1310   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1311   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1312   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1313   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1314       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1315       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1316       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1317       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1318             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1319       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1320             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1321                                *localendladdercarbonfiberjunctionglobalrot[i]);
1322   }
1323   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1324       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1325             localendladdercarbonfiberjunctionmatrix[i][j] = 
1326                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1327                                      *localendladdercarbonfiberjunctionrot[i][j]);
1328            fendladdercarbonfiberjunctionmatrix[i][j] =
1329             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1330             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1331       }  
1332   /////////////////////////////////////////////////////////////
1333   // End Ladder Carbon Fiber Support
1334   /////////////////////////////////////////////////////////////
1335   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1336   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1337       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1338       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1339             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1340       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1341   }
1342   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1343       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1344             fendladdercarbonfibermatrix[i][j] = 
1345             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1346             *(*fcarbonfibersupportmatrix[j]));
1347   /////////////////////////////////////////////////////////////
1348   // End Ladder SSD Mounting Block
1349   /////////////////////////////////////////////////////////////
1350   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1351       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1352   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1353       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1354                                 +        fgkSSDMountingBlockLength[1])
1355                                 +  0.5*fgkCarbonFiberTriangleLength,
1356                                 fgkEndLadderMountingBlockPosition[i],
1357                                 -  fgkSSDMountingBlockHeight[1]
1358                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1359   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1360   endladdermountingblockrot->SetAngles(0.,90.,0.);
1361   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1362         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1363   /////////////////////////////////////////////////////////////
1364   // End Ladder SSD Mounting Block Clip Matrix 
1365   /////////////////////////////////////////////////////////////
1366   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1367         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1368   
1369   TGeoRotation* localendladdercliprot = new TGeoRotation();
1370   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1371   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1372                                                                                   -     fgkSSDMountingBlockLength[1])
1373                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1374   localendladdercliprot->SetAngles(90.,180.,-90.);
1375   TGeoCombiTrans* localendladderclipcombitrans = 
1376                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1377   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1378         for(Int_t j=0; j<2; j++){
1379                 fendladdermountingblockclipmatrix[i][j] = 
1380                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1381                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1382         }
1383   /////////////////////////////////////////////////////////////
1384   // End Ladder Carbon Fiber Lower Support
1385   /////////////////////////////////////////////////////////////
1386   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1387       fendladderlowersupptrans[i] = 
1388             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1389                         +  0.5*fgkSSDMountingBlockWidth),
1390                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1391   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1392                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1393                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1394                                                                          0.0);
1395   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1396  /////////////////////////////////////////////////////////////
1397   // Matrix for positioning Ladder into mother volume
1398   /////////////////////////////////////////////////////////////
1399   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1400   for(Int_t i=0; i<fgkladdernumber; i++) 
1401         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1402   TGeoRotation* localladdermotherrot = new TGeoRotation();
1403   localladdermotherrot->SetAngles(0.,90.,0.);  
1404   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1405   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1406   for(Int_t i=0; i<fgkladdernumber; i++){
1407         localladdermothertrans[i] = new TGeoTranslation(0.,
1408                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1409                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1410                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1411                                                           * fgkCarbonFiberJunctionWidth,0.);
1412         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1413                                                                                                                 *localladdermotherrot);
1414         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1415         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1416   }
1417   /////////////////////////////////////////////////////////////
1418   // Ladder Cables Matrices
1419   /////////////////////////////////////////////////////////////
1420   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1421                                              + fgkSSDFlexHeight[1];  
1422   Double_t ssdladdercabletransx[3];
1423   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1424                                                   *   SinD(2.*fgkSSDFlexAngle)
1425                                                   *       CosD(2.*fgkSSDFlexAngle);
1426   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1427                                                   -     ssdladdercabletransx[0]
1428                                                   /     SinD(2.*fgkSSDFlexAngle))
1429                                                   *     CosD(fgkSSDFlexAngle);                                          
1430   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1431                                                   *       TMath::DegToRad()*ssdflexradiusmax
1432                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1433                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1434                                                   -       fgkSSDLadderCableWidth)
1435                                                   *       CosD(2.*fgkSSDFlexAngle);
1436   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1437                                                   *     TanD(2.*fgkSSDFlexAngle),
1438                                                         ssdladdercabletransx[1]
1439                                                   *     TanD(fgkSSDFlexAngle),
1440                                                         ssdladdercabletransx[2]
1441                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1442   TGeoRotation* localladdercablerot[3]; 
1443   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1444   localladdercablerot[0]->SetAngles(90.,0.,0.);
1445   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1446   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1447                                                  *                        (*localladdercablerot[0]));
1448   ////////////////////////////////////////////
1449   // LocalLadderCableCombiTransMatrix
1450   ////////////////////////////////////////////
1451   const Int_t klocalladdersidecablesnumber = 2;
1452   const Int_t klocalladdercombitransnumber = 5;
1453   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1454   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1455          localladdercablecombitransmatrix[i] = 
1456                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1457   ///////////////////////////////////////////
1458   // Left Side Ladder Cables Transformations
1459   ///////////////////////////////////////////
1460   localladdercablecombitransmatrix[0][0]  =
1461                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1462                                                 0.,0.,NULL);
1463   localladdercablecombitransmatrix[0][1] = 
1464         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1465                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1466                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1467                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1468                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1469                                            + fgkSSDSensorCenterSupportLength
1470                                            - fgkSSDSensorCenterSupportThickness[0]),
1471                                            - (fgkSSDModuleCoolingBlockToSensor
1472                                            + 0.5*fgkCoolingTubeSupportHeight
1473                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1474                                            - fgkSSDChipHeight),NULL);
1475   localladdercablecombitransmatrix[0][2] = 
1476                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1477                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1478   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1479                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1480                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1481                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1482                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1483                                                                                                 new TGeoRotation("",180.,0.,0.));
1484   localladdercablecombitransmatrix[0][4] = 
1485                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1486                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1487                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1488                                                           0.,
1489                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1490                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1491                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1492                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1493   ///////////////////////////////////////////
1494   // Rigth Side Ladder Cables Transformations
1495   ///////////////////////////////////////////
1496   TGeoCombiTrans* localladdercablessdmodulematrix = 
1497         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1498                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1499                                                                          fgkSSDStiffenerWidth,
1500                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1501   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1502    localladdercablecombitransmatrix[1][i] = 
1503                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1504                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1505   ///////////////////////////////////////////
1506   // Setting LadderCableHMatrix
1507   ///////////////////////////////////////////
1508   Int_t beamaxistrans[2][3];
1509   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1510   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1511   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1512   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1513   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1514   beamaxistrans[1][2] = beamaxistrans[1][0];
1515   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1516   TGeoRotation* laddercablerot = new TGeoRotation();
1517   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1518   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1519   Double_t* laddercabletransvector;     
1520   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1521         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1522         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1523   }
1524   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1525         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1526                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1527                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1528                         localladdercablehmatrix[i][j]->MultiplyLeft(
1529                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1530         }
1531                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1532                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1533                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1534                                                                          laddercabletransvector[1]
1535                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1536                                         *                                fgkCarbonFiberJunctionWidth,
1537                                                                          laddercabletransvector[2]);
1538                 laddercablecombitrans->SetRotation(*laddercablerot);
1539                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1540                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1541         }
1542     fladdercablematrix[i][2] = 
1543                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1544                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1545         fladdercablematrix[i][3] = 
1546                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1547                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1548   }
1549   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1550         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1551                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1552   ///////////////////////////////////////////
1553   // Setting Ladder HMatrix
1554   ///////////////////////////////////////////
1555   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1556                                                                                                 fgkSSDLay6SensorsNumber};
1557   for(Int_t i=0; i<fgkladdernumber; i++){
1558         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1559         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1560                 fladdermatrix[i][j] = new TGeoHMatrix();
1561                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1562                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1563                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1564         }
1565   }
1566   ///////////////////////////////////////////
1567   // Setting SSD Sensor Matrix 
1568   ///////////////////////////////////////////
1569   TGeoCombiTrans* localssdsensorcombitrans[2];
1570   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1571   localssdsensorrot->SetAngles(0.,90.,0.);      
1572   TGeoTranslation* localssdsensortrans[2];
1573   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1574   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1575                                          fgkCarbonFiberJunctionWidth 
1576                                          - fgkCarbonFiberLowerSupportWidth 
1577                                          - fgkLowerSupportToSensorZ,
1578                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1579                                           -             fgkSSDModuleCoolingBlockToSensor
1580                                           +    (fgkSSDSensorSideSupportHeight[1]
1581                                           -             fgkSSDSensorSideSupportHeight[0]));
1582   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1583                                          fgkCarbonFiberJunctionWidth 
1584                                          - fgkCarbonFiberLowerSupportWidth 
1585                                          - fgkLowerSupportToSensorZ,
1586                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1587                                                         -fgkSSDModuleCoolingBlockToSensor);
1588   for(Int_t i=0; i<2; i++) 
1589         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1590                                                                                                          *localssdsensorrot);   
1591     for(Int_t i=0; i<fgkladdernumber; i++){
1592         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1593         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1594                 switch(i){
1595                         case 0: //Ladder of Layer5  
1596                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1597                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1598                                                                                                 *localssdsensorcombitrans[1])));
1599                         break;
1600                         case 1: //Ladder of Layer6 
1601                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1602                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1603                                                                                                 *localssdsensorcombitrans[0])));
1604                 break;
1605                 }
1606           }
1607   }     
1608   //////////////////////////
1609   // Setting SSD End Ladder  
1610   //////////////////////////
1611   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1612   for(Int_t i=0; i<2; i++){
1613         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1614         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1615         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1616         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1617         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1618         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1619         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1620         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1621    }
1622   /////////////////////////////////////////////////////
1623   // Setting the CombiTransformation to pass ITS center 
1624   /////////////////////////////////////////////////////
1625   Double_t itscentertransz[fgklayernumber];
1626   itscentertransz[0] = fgkSSDLay5LadderLength
1627                                          - fgkLay5CenterITSPosition;
1628   itscentertransz[1] = fgkSSDLay6LadderLength
1629                                          - fgkLay6CenterITSPosition;
1630   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1631                                                    + 0.5*fgkCoolingTubeSupportHeight;
1632   TGeoRotation* itscenterrot[3];
1633   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1634   itscenterrot[0]->SetAngles(90.,180.,-90.);
1635   itscenterrot[1]->SetAngles(0.,90.,0.);
1636   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1637   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1638   for(Int_t i=0; i<fgklayernumber; i++) 
1639         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1640                                                          itssensortransy,
1641                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1642                                                    - itscentertransz[i],itscenterrot[2]);
1643   TGeoRotation** locallayerrot[fgklayernumber];
1644   TGeoTranslation** locallayertrans[fgklayernumber];    
1645   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1646   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1647   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1648                                          - fgkLay5CenterITSPosition);
1649   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1650                                          - fgkLay6CenterITSPosition);
1651   const Int_t kssdlayladdernumber[fgklayernumber] = 
1652                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1653   for(Int_t i=0; i<fgklayernumber; i++){
1654     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1655     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1656         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1657         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1658   }
1659   Double_t layerladderangleposition[fgklayernumber] = 
1660                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1661   Double_t layerradius = 0.;
1662   for(Int_t i=0; i<fgklayernumber; i++){        
1663         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1664                 switch(i){
1665                         case 0: //Ladder of Layer5  
1666                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1667                         break;
1668                         case 1: //Ladder of Layer6 
1669                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1670                 break;
1671                 }
1672                 locallayerrot[i][j] = new TGeoRotation();
1673                 locallayertrans[i][j] = new TGeoTranslation();
1674                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1675                 locallayertrans[i][j]->SetTranslation(layerradius 
1676                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1677                                                             layerradius 
1678                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1679                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1680                                                                          *locallayerrot[i][j]);
1681                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1682                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1683                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1684         }
1685   }
1686   /////////////////////////////////////////////////////////////
1687   // Deallocating memory
1688   /////////////////////////////////////////////////////////////
1689   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1690         delete carbonfiberot[i];
1691         delete localcarbonfibersupportmatrix[i];
1692   }
1693   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1694      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1695        delete localcarbonfiberjunctionmatrix[i][j];
1696            delete localcarbonfiberjunctionrot[i][j];
1697            delete localcarbonfiberjunctiontrans[i][j];
1698            }
1699        delete [] localcarbonfiberjunctionmatrix[i];
1700        delete [] localcarbonfiberjunctionrot[i];
1701        delete [] localcarbonfiberjunctiontrans[i];
1702   }
1703   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1704            delete localcarbonfiberlowersupportrans[i];
1705   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1706      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1707        delete localssdsensorsupportmatrix[i][j];
1708            delete localssdsensorsupportrot[i][j];
1709            delete localssdsensorsupportrans[i][j];
1710            }
1711        delete [] localssdsensorsupportmatrix[i];
1712        delete [] localssdsensorsupportrot[i];
1713        delete [] localssdsensorsupportrans[i];
1714   }
1715   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1716         delete localcoolingtubesupportmatrix[i];
1717         delete localcoolingtubesupportrot[i];
1718         delete localcoolingtubesupportrans[i];
1719   }
1720   for(Int_t i=0; i<4; i++){
1721         for(Int_t j=0; j<2; j++){
1722                 delete localcoolingtubevect[i][j];
1723                 delete localcoolingtubetrans[i][j];
1724         }
1725         delete [] localcoolingtubevect[i];
1726         delete [] localcoolingtubetrans[i];
1727   }
1728  delete endladdermountingblockrot;
1729  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1730  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1731  for(Int_t i=0; i<fgkflexnumber; i++){
1732       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1733             delete localflexmatrix[i][j];
1734       delete [] localflexmatrix[i];
1735  }
1736  delete localendlladdercoolingtuberot;
1737  for(Int_t i=0; i<2; i++){
1738         for(Int_t j=0; j<(i==0?6:4); j++)
1739                 delete localendlladdercoolingtubetrans[i][j];
1740         delete [] localendlladdercoolingtubetrans[i];
1741   }
1742
1743  delete localflexrot;
1744  delete localendflexrot;
1745  delete localendflexmatrix;
1746  for(Int_t i=0; i<fgkladdernumber; i++){ 
1747         delete localladdermothertrans[i];
1748         delete localladdermothercombitrans[i];
1749   }
1750  delete localladdermotherrot;
1751  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1752       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1753             delete localendladdercarbonfiberjunctionmatrix[i][j];
1754             delete localendladdercarbonfiberjunctionrot[i][j];
1755             delete localendladdercarbonfiberjunctiontrans[i][j];
1756       }
1757       delete [] localendladdercarbonfiberjunctionmatrix[i];
1758       delete [] localendladdercarbonfiberjunctionrot[i];
1759       delete [] localendladdercarbonfiberjunctiontrans[i];
1760       delete localendladdercarbonfiberjunctionglobalrot[i];
1761       delete localendladdercarbonfiberjunctionglobaltrans[i];
1762       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1763  }
1764   for(Int_t i=0; i<2; i++){
1765         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1766         delete [] localendladdercooltubetrans[i];
1767   }
1768   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1769       delete localendladdercarbonfibertrans[i];
1770   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1771   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1772         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1773                 delete localladdercablecombitransmatrix[i][j];
1774                 delete []localladdercablecombitransmatrix[i];
1775   }
1776   delete localendladdercliprot;
1777   delete localendladdercliptrans;
1778   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1779         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1780                 delete localladdercablehmatrix[i][j];
1781         delete []localladdercablehmatrix[i];
1782   }
1783   delete laddercablerot;
1784   delete laddercabletrans;
1785   delete laddercablecombitrans;
1786   delete localladdercablessdmodulematrix;
1787   delete localssdsensorrot;     
1788   for(Int_t i=0; i<2; i++){
1789         delete localssdsensortrans[i];
1790         delete localssdsensorcombitrans[i];
1791   }
1792   for(Int_t i=0; i<fgklayernumber; i++){
1793         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1794                 delete locallayerrot[i][j];
1795                 delete locallayertrans[i][j];
1796                 delete locallayercombitrans[i][j];
1797     }
1798         delete [] locallayerrot[i];
1799         delete [] locallayertrans[i];
1800         delete [] locallayercombitrans[i];
1801         delete localbeamaxistrans[i];
1802   }
1803   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1804   for(Int_t i=0; i<fgkladdernumber; i++){
1805         for(Int_t j=0; j<fgkladdernumber; j++)
1806                 delete ladderglobalmatrix[i][j];
1807         delete [] ladderglobalmatrix[i];
1808   }
1809   /////////////////////////////////////////////////////////////
1810   fTransformationMatrices = kTRUE;      
1811 }
1812 ///////////////////////////////////////////////////////////////////////////////
1813 void AliITSv11GeometrySSD::CreateBasicObjects(){
1814   /////////////////////////////////////////////////////////////  
1815   // Method generating the Objects of SSD Geometry    
1816   /////////////////////////////////////////////////////////////
1817   // SSD Sensor
1818   ///////////////////////////////////
1819   SetSSDSensor();
1820   /////////////////////////////////////////////////////////////  
1821   // Carbon Fiber Support    
1822   /////////////////////////////////////////////////////////////  
1823   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1824   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1825       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1826   /////////////////////////////////////////////////////////////
1827   // Carbon Fiber Junction 
1828   /////////////////////////////////////////////////////////////
1829   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1830   /////////////////////////////////////////////////////////////
1831   // Carbon Fiber Lower Support
1832   /////////////////////////////////////////////////////////////
1833   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1834   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1835         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1836   /////////////////////////////
1837   // SSD Sensor Support
1838   /////////////////////////////
1839   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1840                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1841   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1842                                                                          fgkSSDSensorSideSupportThickness[1]};
1843   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1844         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1845                                                                                            fgkSSDSensorSideSupportHeight[i],
1846                                                                                            fgkSSDSensorSideSupportWidth,
1847                                                                                            sidesupporthickness);  
1848         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1849                                                                                            fgkSSDSensorCenterSupportHeight[i],
1850                                                                                            fgkSSDSensorCenterSupportWidth,
1851                                                                                            sidesupporthickness);
1852   }
1853   /////////////////////////////////////////////////////////////
1854   // SSD Cooling Tube Support
1855   /////////////////////////////////////////////////////////////
1856   Int_t edgesnumber = 16;
1857   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1858   /////////////////////////////////////////////////////////////
1859   // SSD Hybrid
1860   /////////////////////////////////////////////////////////////
1861   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1862   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1863         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1864   /////////////////////////////////////////////////////////////
1865   // SSD Cooling Block System
1866   /////////////////////////////////////////////////////////////
1867   fssdcoolingblocksystem = GetCoolingBlockSystem();
1868    /////////////////////////////////////////////////////////////
1869   // SSD Cooling Tube
1870   /////////////////////////////////////////////////////////////
1871   TList* coolingtubelist = GetCoolingTubeList();        
1872   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1873         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1874   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1875         fendladdercoolingtube[i] = 
1876                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1877   /////////////////////////////////////////////////////////////
1878   // SSD Flex  
1879   /////////////////////////////////////////////////////////////
1880   fssdstiffenerflex = GetSSDStiffenerFlex();
1881   fssdendflex = GetSSDEndFlex();
1882   ///////////////////////////////////
1883   // End Ladder Carbon Fiber Junction
1884   ///////////////////////////////////
1885   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1886                                                    fendladdercarbonfiberjunction[i] = 
1887                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1888   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1889     fendladdercarbonfiberjunction[i][0] = 
1890                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1891     fendladdercarbonfiberjunction[i][1] = 
1892                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1893   }
1894   ///////////////////////////////////
1895   // End Ladder Mounting Block
1896   ///////////////////////////////////
1897   fendladdermountingblock = GetSSDMountingBlock();
1898   ///////////////////////////////////
1899   // End Ladder Mounting Block
1900   ///////////////////////////////////
1901   fendladdermountingblockclip = GetMountingBlockClip();
1902   ///////////////////////////////////
1903   // Ladder Support 
1904   ///////////////////////////////////
1905   TList* laddersupportlist = GetMountingBlockSupport(20);
1906   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1907   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1908   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1909   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1910   /////////////////////////////////////////////////////////////
1911   // Deallocating memory
1912   /////////////////////////////////////////////////////////////
1913   delete carbonfibersupportlist;
1914   delete carbonfiberlowersupportlist;
1915   delete ssdhybridcomponentslist;
1916   delete laddersupportlist;
1917   /////////////////////////////////////////////////////////////
1918   fBasicObjects = kTRUE;
1919 }
1920 /////////////////////////////////////////////////////////////////////////////////
1921 void AliITSv11GeometrySSD::SetSSDSensor(){
1922   ////////////////////////////////////////////////////////////////
1923   // Method generating SSD Sensors: it sets the private variables
1924   // fSSDSensor5, fSSDSensor6  
1925   ////////////////////////////////////////////////////////////////
1926   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1927   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1928   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1929                                                 0.5*ssdsensitivewidth,
1930                                                 0.5*fgkSSDSensorHeight,
1931                                                 0.5*ssdsensitivelength);
1932   TGeoVolume* ssdsensorsensitiveLay5 = 
1933         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1934   TGeoVolume* ssdsensorsensitiveLay6 = 
1935         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1936   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1937   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1938   TGeoBBox* ssdsensorinsensitiveshape[2];
1939   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1940                                                 0.5*fgkSSDSensorInsensitiveWidth,
1941                                                 0.5*fgkSSDSensorHeight,
1942                                                 0.5*fgkSSDSensorLength);
1943   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1944                                                 0.5*ssdsensitivewidth,
1945                                                 0.5*fgkSSDSensorHeight,
1946                                                 0.5*fgkSSDSensorInsensitiveWidth);
1947   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1948                                              "SSDSensorInsensitive2"};
1949   TGeoVolume* ssdsensorinsensitive[2];
1950   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1951       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1952                      fSSDSensorMedium);
1953       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1954   }
1955   /////////////////////////////////////////////////////////////
1956   // Virtual Volume containing SSD Sensor  
1957   /////////////////////////////////////////////////////////////
1958   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1959                                                                                              0.5*fgkSSDSensorWidth,
1960                                                                                              0.5*fgkSSDSensorHeight,
1961                                                                                              0.5*fgkSSDSensorLength);
1962   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1963                                                                                  fSSDAir);      
1964   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1965                                                                                  fSSDAir);      
1966   /////////////////////////////////////////////////////////////
1967   for(Int_t i=0; i<4; i++){ 
1968             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1969             ssdsensorinsensitive[1],i<2?1:2,
1970                         new TGeoTranslation(
1971                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1972       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1973                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1974       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1975             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1976             ssdsensorinsensitive[1],i<2?1:2,
1977                         new TGeoTranslation(
1978                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1979       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1980                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1981       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1982   }
1983     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1984     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1985 }
1986 ///////////////////////////////////////////////////////////////////////////////
1987 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1988   /////////////////////////////////////////////////////////////  
1989   // Method generating the Carbon Fiber Support   
1990   /////////////////////////////////////////////////////////////  
1991   const Int_t kvertexnumber = 4;
1992   const Int_t kshapesnumber = 2;
1993   TVector3** vertexposition[kshapesnumber];
1994   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1995   Double_t carbonfibersupportxaxisEdgeproj = 
1996                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1997         *       TMath::DegToRad());
1998   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1999                                  /                         fgkCarbonFiberSupportXAxisLength);
2000   /////////////////////
2001   //Vertex Positioning
2002   ////////////////////
2003   vertexposition[0][0] = new TVector3();
2004   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2005                                                                           fgkCarbonFiberSupportYAxisLength);
2006   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2007                                                                           carbonfibersupportxaxisEdgeproj
2008                                            *                      TMath::Tan(theta));
2009   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2010                                            -                      carbonfibersupportxaxisEdgeproj,
2011                                                                           fgkCarbonFiberSupportYAxisLength
2012                                            -                      vertexposition[0][2]->Y());
2013   ////////////////////////////////////////////////////
2014   //Setting the parameters for Isometry Transformation
2015   ////////////////////////////////////////////////////
2016   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2017                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2018                                                                  +      fgkCarbonFiberSupportWidth);
2019   Double_t* param = new Double_t[4]; 
2020   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2021   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2022     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2023                  (GetReflection(vertexposition[0][j],param))->Y());
2024   const char* carbonfibersupportshapename[kshapesnumber] = 
2025                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2026   const char* carbonfibersupportname[kshapesnumber] = 
2027                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2028   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2029   TGeoVolume* carbonfibersupport[kshapesnumber];
2030   TList* carbonfibersupportlist = new TList();
2031   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2032   Double_t carbonfibersupportheight = 
2033           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2034           *TMath::DegToRad());
2035   for(Int_t i = 0; i< kshapesnumber; i++){
2036    carbonfibersupportshape[i] = 
2037                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2038                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2039    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2040                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2041    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2042    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2043    }
2044   /////////////////////////////////////////////////////////////
2045   // Deallocating memory
2046   /////////////////////////////////////////////////////////////
2047   for(Int_t i=0; i< kshapesnumber; i++){
2048      for(Int_t j=0; j< kvertexnumber; j++)
2049            delete vertexposition[i][j];
2050        delete [] vertexposition[i];
2051   }
2052   delete [] param;
2053   /////////////////////////////////////////////////////////////
2054    return carbonfibersupportlist;
2055 }
2056 /////////////////////////////////////////////////////////////////////////////////
2057 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2058   /////////////////////////////////////////////////////////////
2059   // Method generating SSD Carbon Fiber Junction
2060   /////////////////////////////////////////////////////////////
2061   const Int_t kvertexnumber = 6;
2062   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2063   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2064                                             *  TMath::DegToRad()),-1.,0.,0.};
2065   TVector3* vertex[kvertexnumber];
2066   vertex[0] = new TVector3();
2067   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2068                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2069                         *                         TMath::DegToRad()),
2070                                                   fgkCarbonFiberJunctionEdge[0]
2071                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2072                         *                         TMath::DegToRad()));
2073   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2074                                                    fgkCarbonFiberJunctionEdge[1]);
2075   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2076   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2077   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2078   Double_t xvertexpoints[6], yvertexpoints[6];
2079   for(Int_t i=0; i<kvertexnumber; i++) 
2080           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2081   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2082   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2083   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2084   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2085                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2086   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2087   /////////////////////////////////////////////////////////////
2088   // Deallocating memory
2089   /////////////////////////////////////////////////////////////
2090   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2091   ///////////////////////////////////////////////////////////// 
2092   return carbonfiberjunction;
2093 }
2094 ////////////////////////////////////////////////////////////////////////////////
2095 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2096   /////////////////////////////////////////////////////////////
2097   // Method generating the Carbon Fiber Lower Support   
2098   /////////////////////////////////////////////////////////////  
2099   const Int_t kvertexnumber = 4;
2100   const Int_t kshapesnumber = 2;
2101   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2102                                                                 fgkCarbonFiberLowerSupportWidth};
2103   TVector3** vertexposition[kshapesnumber];
2104   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2105                                                  new TVector3*[kvertexnumber];
2106   //First Shape Vertex Positioning
2107   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2108   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2109                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2110   vertexposition[0][2] = new TVector3();
2111   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2112   //Second Shape Vertex Positioning
2113   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2114                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2115                                  /                              fgkCarbonFiberTriangleLength);
2116   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2117                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2118                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2119   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2120                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2121                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2122   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2123   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2124                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2125   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
2126                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2127   const char* carbonfiberlowersupportname[kshapesnumber] = 
2128                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2129   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2130   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2131   TList* carbonfiberlowersupportlist = new TList();
2132   for(Int_t i = 0; i< kshapesnumber; i++){ 
2133         carbonfiberlowersupportshape[i] = 
2134                                                                 GetArbShape(vertexposition[i],width,
2135                                                                                         fgkCarbonFiberLowerSupportHeight,
2136                                                                                         carbonfiberlowersupportshapename[i]);
2137     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2138                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2139         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2140     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2141   }
2142   /////////////////////////////////////////////////////////////
2143   // Deallocating memory
2144   /////////////////////////////////////////////////////////////
2145   for(Int_t i=0; i< kshapesnumber; i++){
2146      for(Int_t j=0; j< kvertexnumber; j++)
2147            delete vertexposition[i][j];
2148        delete [] vertexposition[i];
2149   }
2150   /////////////////////////////////////////////////////////////
2151   return carbonfiberlowersupportlist;
2152 }
2153 ///////////////////////////////////////////////////////////////////////////////
2154 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2155                                                                  Double_t width, Double_t* thickness)const{
2156   /////////////////////////////////////////////////////////////
2157   // Method generating the Sensor Support   
2158   /////////////////////////////////////////////////////////////  
2159         const Int_t kvertexnumber = 6;
2160         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2161     TVector3* vertexposition[kvertexnumber];
2162         vertexposition[0] = new TVector3();     
2163         vertexposition[1] = new TVector3(0.0,length);   
2164         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2165         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2166         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2167         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2168         Double_t xvertexpoints[6], yvertexpoints[6];
2169         for(Int_t i=0; i<kvertexnumber; i++) 
2170                 xvertexpoints[i] = vertexposition[i]->X(), 
2171                 yvertexpoints[i] = vertexposition[i]->Y();
2172     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2173     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2174     ssdsensorsupportshape->DefineSection(1,0.5*width);
2175     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2176                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2177   /////////////////////////////////////////////////////////////
2178   // Deallocating memory
2179   /////////////////////////////////////////////////////////////
2180         for (Int_t i=0; i<kvertexnumber; i++)
2181                 delete vertexposition[i];
2182   /////////////////////////////////////////////////////////////
2183     return ssdsensorsupport;
2184 }
2185 ////////////////////////////////////////////////////////////////////////////////
2186 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2187   /////////////////////////////////////////////////////////////
2188   // Method generating the Cooling Tube Support
2189   /////////////////////////////////////////////////////////////
2190   if(nedges%2!=0) nedges--;     
2191   const Int_t kvertexnumber = nedges+5;
2192   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2193                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2194   Double_t angle = 90.+phi;
2195   Double_t psi = 90.-phi;
2196   ///////////////////////////////////////
2197   // Vertex Positioning for TGeoXTru
2198   ///////////////////////////////////////
2199   TVector3** vertexposition = new TVector3*[kvertexnumber];
2200   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2201                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2202   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2203                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2204   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2205                                                                    fgkCoolingTubeSupportRmax);
2206   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2207                                                                    fgkCoolingTubeSupportRmax);
2208   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2209                                                                     vertexposition[1]->Y());
2210   for(Int_t i=0; i<nedges; i++)
2211         vertexposition[i+5] = 
2212                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2213                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2214   ///////////////////////////////////////////////////////////////////////
2215   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2216   ///////////////////////////////////////////////////////////////////////
2217   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2218   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2219   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2220   for(Int_t i=0; i<kvertexnumber; i++){
2221         xvertexpoints[i] = vertexposition[i]->X();
2222         yvertexpoints[i] = vertexposition[i]->Y();
2223   } 
2224   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2225                                                                                         yvertexpoints);
2226   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2227   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2228   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2229                                                                           coolingtubesupportarcshape,
2230                                                                                   fSSDTubeHolderMedium);
2231   coolingtubesupportarc->SetLineColor(fColorG10);
2232   //////////////////////////////////////////////////////////////////////////
2233   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2234   //////////////////////////////////////////////////////////////////////////
2235   TGeoTubeSeg* coolingtubesupportsegshape = 
2236                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2237                                                                                         fgkCoolingTubeSupportRmax,
2238                                                                                         0.5*fgkCoolingTubeSupportWidth,
2239                                                                                         phi,360-phi);
2240   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2241                                                                                         coolingtubesupportsegshape,
2242                                                                                         fSSDTubeHolderMedium);
2243   coolingtubesupportseg->SetLineColor(fColorG10);
2244   //////////////////////////////////////////////////////////////////////////
2245   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2246   //////////////////////////////////////////////////////////////////////////
2247   Double_t* boxorigin = new Double_t[3];
2248   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2249   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2250   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2251                                                                                  0.5*fgkCoolingTubeSupportHeight,
2252                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2253   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2254                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2255   coolingtubesupportbox->SetLineColor(fColorG10);
2256   //////////////////////////////////////////////////////////////////////////
2257   // Cooling Tube for Cooling Tube Support 
2258   //////////////////////////////////////////////////////////////////////////
2259   TGeoXtru* coolingtubearcshape[2];
2260   coolingtubearcshape[0] = new TGeoXtru(2);     
2261   Double_t* xvert = new Double_t[nedges+2];
2262   Double_t* yvert = new Double_t[nedges+2];
2263   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2264   ////////////////////////////////////////
2265   // Positioning the vertices for TGeoXTru
2266   ////////////////////////////////////////
2267   xvert[0] = 0., yvert[0] = 0.;
2268   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2269   for(Int_t i=0; i< nedges; i++)
2270                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2271                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2272   ////////////////////////////////////////
2273   // Defining TGeoXTru PolyGone
2274   ////////////////////////////////////////
2275   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2276   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2277   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2278   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2279                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2280   TGeoVolume* coolingtubearc[2];
2281   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2282                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2283   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2284                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2285   coolingtubearc[0]->SetLineColor(fColorWater);
2286   coolingtubearc[1]->SetLineColor(fColorPhynox);
2287   ////////////////////////////////////////////
2288   // Defining TGeoTubeSeg Part of Cooling Tube
2289   ////////////////////////////////////////////
2290   TGeoTubeSeg* coolingtubesegshape[2];
2291   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2292                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2293   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2294                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2295   TGeoVolume* coolingtubeseg[2];
2296   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2297                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2298   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2299                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2300   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2301   coolingtubeseg[1]->SetLineColor(fColorWater);
2302   /////////////////////////////////////////////////////////////
2303   // Virtual Volume containing Cooling Tube Support  
2304   /////////////////////////////////////////////////////////////
2305   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2306   const Int_t kvirtualvertexnumber = 8;
2307   TVector3* virtualvertex[kvirtualvertexnumber];
2308    ////////////////////////////////////////
2309   // Positioning the vertices for TGeoXTru
2310   ////////////////////////////////////////
2311   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2312   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2313   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2314   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2315   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2316   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2317   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2318   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2319   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2320   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2321         xmothervertex[i] = virtualvertex[i]->X(),
2322         ymothervertex[i] = virtualvertex[i]->Y();
2323   ////////////////////////////////////////
2324   // Defining TGeoXTru PolyGone
2325   ////////////////////////////////////////
2326   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2327                                                                                                                                          ymothervertex);
2328   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2329   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2330   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2331                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2332   ////////////////////////////////////////
2333   // Positioning Volumes in Virtual Volume
2334   ////////////////////////////////////////
2335   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2336   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2337   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2338   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2339   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2340   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2341   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2342   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2343   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2344   /////////////////////////////////////////////////////////////
2345   // Deallocating memory
2346   /////////////////////////////////////////////////////////////
2347   delete [] vertexposition;
2348   delete [] xvertexpoints;
2349   delete [] yvertexpoints;
2350   delete [] xvert;
2351   delete [] yvert;
2352   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2353         delete virtualvertex[i];
2354   /////////////////////////////////////////////////////////////
2355         return virtualcoolingtubesupport;
2356 }
2357 /////////////////////////////////////////////////////////////////////////////////
2358 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2359   /////////////////////////////////////////////////////////////
2360   // Method generating List containing SSD Hybrid Components   
2361   /////////////////////////////////////////////////////////////
2362   TList* ssdhybridlist = new TList();
2363   const Int_t kssdstiffenernumber = 2;
2364   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2365                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2366                                                                   -    fgkSSDStiffenerWidth;
2367   Double_t ssdchipcablesradius[kssdstiffenernumber];
2368   for(Int_t i=0; i<kssdstiffenernumber; i++)
2369           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2370                                -  fgkSSDChipCablesHeight[0]
2371                                -  fgkSSDChipCablesHeight[1]);
2372   /////////////////////////////////////////////////////////////
2373   // Mother Volumes Containers 
2374   /////////////////////////////////////////////////////////////
2375   const Int_t kmothernumber = 2;
2376   const Int_t kmothervertexnumber = 12;
2377   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2378   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2379   ///////////////////////
2380   // Setting the vertices 
2381   ///////////////////////
2382   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2383   xmothervertex[0][1]  = xmothervertex[0][0]; 
2384   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2385   xmothervertex[0][3]  = xmothervertex[0][2];
2386   xmothervertex[0][4]  = xmothervertex[0][0];
2387   xmothervertex[0][5]  = xmothervertex[0][4];
2388   xmothervertex[0][6]  = -xmothervertex[0][0];
2389   xmothervertex[0][7]  = xmothervertex[0][6];
2390   xmothervertex[0][8]  = -xmothervertex[0][2];
2391   xmothervertex[0][9]  = xmothervertex[0][8];
2392   xmothervertex[0][10] = xmothervertex[0][7];
2393   xmothervertex[0][11] = xmothervertex[0][10];
2394   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2395   for(Int_t i = 0; i<kmothernumber; i++){
2396       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2397                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2398       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2399       ymothervertex[i][2]  = ymothervertex[i][1];
2400       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2401       ymothervertex[i][4]  = ymothervertex[i][3];
2402       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2403       ymothervertex[i][6]  = ymothervertex[i][5];
2404       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2405       ymothervertex[i][8]  = ymothervertex[i][7];
2406       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2407       ymothervertex[i][10] = ymothervertex[i][9];
2408       ymothervertex[i][11] = ymothervertex[i][0];
2409   }
2410   TGeoXtru* ssdhybridmothershape[kmothernumber];
2411 //  TGeoVolume* ssdhybridmother[kmothernumber];
2412   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2413   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2414   for(Int_t i=0; i<kmothernumber; i++){
2415       ssdhybridmothershape[i] = new TGeoXtru(2);
2416       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2417                                           ymothervertex[i]);
2418       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2419                                                -fgkSSDChipCablesHeight[i+2]);
2420       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2421 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2422 //                                          fSSDAir);
2423       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2424    }   
2425   /////////////////////////////////////////////////////////////
2426   // SSD Stiffener   
2427   /////////////////////////////////////////////////////////////
2428   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2429                                              0.5*fgkSSDStiffenerLength,
2430                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2431                                              0.5*fgkSSDStiffenerHeight);
2432   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2433                                             fSSDStiffenerMedium);  
2434   ssdstiffener->SetLineColor(fColorStiffener); 
2435   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2436   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2437       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2438   /////////////////////////////////////////////////////////////
2439   // SSD Chip System    
2440   /////////////////////////////////////////////////////////////
2441   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2442   Double_t ssdchipseparation = fgkSSDSensorLength
2443                              - 2.*fgkSSDModuleStiffenerPosition[1]
2444                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2445                              - 0.5*fgkSSDChipWidth);
2446   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2447                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2448   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2449                                       - 0.5*ssdchipsystemlength,
2450                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2451                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2452 ////////////////////////////
2453 // Capacitor 0603-2200 nF
2454 ///////////////////////////
2455   const Int_t knapacitor0603number = 5;
2456   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2457                                                                                          0.5*fgkSSDCapacitor0603Length,
2458                                                                                          0.5*(fgkSSDCapacitor0603Width),
2459                                                                                          0.5*fgkSSDCapacitor0603Height);
2460   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2461                                              fSSDStiffener0603CapacitorMedium); 
2462   capacitor0603->SetLineColor(fColorAl);
2463   for(Int_t i=0; i<kmothernumber; i++){
2464       for(Int_t j=0; j<kssdstiffenernumber; j++){
2465             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2466             for(Int_t k=1; k<knapacitor0603number+1; k++){
2467                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2468                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2469                                            j*ssdstiffenerseparation
2470                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2471                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2472                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2473             }
2474       } 
2475       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2476       ssdhybridlist->Add(ssdhybridmother[i]);
2477   }    
2478 /////////////////////////////////////////////////////////////
2479 // Mother Volume Containing Capacitor Part 
2480 /////////////////////////////////////////////////////////////
2481   const Int_t kcapacitormothernumber = 8;
2482   Double_t xcapacitorvertex[kcapacitormothernumber];
2483   Double_t ycapacitorvertex[kcapacitormothernumber];  
2484   ///////////////////////
2485   // Setting the vertices 
2486   ///////////////////////
2487   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2488   xcapacitorvertex[1] = xcapacitorvertex[0];   
2489   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2490   xcapacitorvertex[3] = xcapacitorvertex[2];   
2491   xcapacitorvertex[4] = xcapacitorvertex[0];   
2492   xcapacitorvertex[5] = xcapacitorvertex[0];   
2493   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2494   xcapacitorvertex[7] = xcapacitorvertex[6];   
2495   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2496   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2497   ycapacitorvertex[2] = ycapacitorvertex[1];   
2498   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2499   ycapacitorvertex[4] = ycapacitorvertex[3];   
2500   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2501   ycapacitorvertex[6] = ycapacitorvertex[5];   
2502   ycapacitorvertex[7] = ycapacitorvertex[0];   
2503   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2504   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2505                                               ycapacitorvertex);
2506   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2507   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2508 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2509 //                                          fSSDAir);
2510   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2511 ////////////////////////////
2512 // Connector 
2513 ///////////////////////////
2514   const Int_t kssdconnectornumber = 2;
2515   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2516   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2517   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2518                                    +  fgkSSDConnectorAlHeight};  
2519   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2520   TGeoVolume* ssdconnector[kssdconnectornumber];
2521   for(Int_t i=0; i<kssdconnectornumber; i++){
2522       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2523                                           0.5*fgkSSDConnectorWidth,
2524                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2525                            +              i*fgkSSDConnectorNiHeight),
2526                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2527       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2528                                        i==0 ? fSSDAlTraceFlexMedium 
2529                                             : fSSDStiffenerConnectorMedium);      
2530       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2531   }
2532   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2533   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2534                        +  fgkSSDConnectorPosition[0]
2535                        -  fgkSSDConnectorSeparation
2536                        -  1.5*fgkSSDConnectorLength,
2537                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2538                        -  fgkSSDConnectorPosition[1]
2539                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2540   ssdconnectortrans[1] = new TGeoTranslation(
2541                        -  ssdstiffenershape->GetDX()
2542                        +  fgkSSDConnectorPosition[0]
2543                        -  0.5*fgkSSDConnectorLength,
2544                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2545                        -  fgkSSDConnectorPosition[1]
2546                        -  ssdconnectorshape[0]->GetDY(),0.0);
2547   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2548                        -  fgkSSDConnectorPosition[0]
2549                        +  fgkSSDConnectorSeparation
2550                        +  1.5*fgkSSDConnectorLength,
2551                           -(ssdstiffenershape->GetDY()
2552                        -  fgkSSDConnectorPosition[1]
2553                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2554   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2555                        -  fgkSSDConnectorPosition[0]
2556                        +  0.5*fgkSSDConnectorLength,
2557                           -(ssdstiffenershape->GetDY()
2558                        -  fgkSSDConnectorPosition[1]
2559                        -  ssdconnectorshape[0]->GetDY()),0.0);
2560   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2561       for(Int_t j=0; j<kssdconnectornumber; j++)
2562             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2563 ////////////////////////////
2564 // Capacitor 1812-330 nF
2565 /////////////////////////// 
2566   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2567   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2568                                                                                          0.5*fgkSSDCapacitor1812Length,
2569                                                                                          0.5*fgkSSDCapacitor1812Width,
2570                                                                                          0.5*fgkSSDCapacitor1812Height,
2571             ssdcapacitor1812origin);
2572   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2573                                              fSSDStiffener1812CapacitorMedium); 
2574   capacitor1812->SetLineColor(fColorAl);
2575   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2576                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2577                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2578   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2579 ////////////////////////////
2580 //Hybrid Wire
2581 ////////////////////////////
2582   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2583                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2584                                  - fgkSSDConnectorSeparation;
2585   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2586                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2587   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2588
2589   Double_t wireangle = TMath::ATan(wirex/wirey);
2590   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2591                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2592   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2593                                              fSSDStiffenerHybridWireMedium); 
2594   hybridwire->SetLineColor(fColorPhynox);
2595   TGeoCombiTrans* hybridwirecombitrans[2];
2596   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2597                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2598                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2599                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2600                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2601                                    ssdstiffenershape->GetDZ()
2602                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2603                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2604   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2605                             0.0,
2606                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2607                             0.0,        
2608                             new TGeoRotation("HybridWireRot2",
2609                           - wireangle*TMath::RadToDeg(),0.,0.));
2610   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2611   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2612   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2613   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2614   ssdhybridlist->Add(ssdhybridcapacitormother);
2615   /////////////////////////////////////////////////////////////
2616   // Deallocating memory
2617   /////////////////////////////////////////////////////////////
2618   delete hybridwirecombitrans[0];
2619   delete hybridwirecombitrans[1];
2620   delete ssdchipsystemlist;
2621   return ssdhybridlist;
2622   /////////////////////////////////////////////////////////////
2623 }
2624 ///////////////////////////////////////////////////////////////////////////////
2625 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2626   /////////////////////////////////////////////////////////////
2627   // SSD Cooling Block System
2628   /////////////////////////////////////////////////////////////
2629   // SSD Cooling Block and Cooling Tube Transformations
2630   /////////////////////////////////////////////////////////////
2631   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2632   localcoolingblockrot->SetAngles(0.,90.,0.);
2633   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2634   TVector3* coolingblocktransvector;
2635   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2636                                                                 + fgkSSDCoolingBlockLength,
2637                                                                   fgkSSDSensorLength
2638                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2639                                                                 - fgkSSDCoolingBlockWidth);
2640   const Int_t kcoolingblocktransnumber = 2;
2641   const Int_t kcoolingblocknumber = 4;
2642   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2643   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2644   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2645   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2646   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2647   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2648                                         0.5*fgkSSDCoolingBlockWidth,
2649                                         fgkSSDCoolingBlockHoleCenter);
2650   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2651   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2652   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2653     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2654       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2655                                              j*coolingblocktransvector->Y(),
2656                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2657                                                     + fgkCoolingTubeRmax));
2658       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2659       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2660     }
2661   }
2662   /////////////////////////////////////////////////////////////
2663   // Virtual Volume containing CoolingBlock System   
2664   /////////////////////////////////////////////////////////////
2665   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2666   const Int_t kmothervertexnumber = 16;  
2667   Double_t xmothervertex[kmothervertexnumber];
2668   Double_t ymothervertex[kmothervertexnumber];
2669   ///////////////////////
2670   // Setting the vertices 
2671   ///////////////////////fgkCoolingTubeSupportRmax
2672   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2673   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2674                                    + fgkSSDCoolingBlockWidth;
2675   xmothervertex[2] = coolingblocktransvector->X()
2676                                    + fgkSSDCoolingBlockLength
2677                                    + 4*coolingtubedistance;
2678   ymothervertex[2] = ymothervertex[1];
2679   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2680   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2681   ymothervertex[4] = ymothervertex[0];
2682   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2683   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2684   ymothervertex[6] = ymothervertex[5]; 
2685   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2686                                    - fgkSSDCoolingBlockWidth; 
2687   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2688   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2689                                    - coolingtubedistance;
2690   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2691   ymothervertex[10] = ymothervertex[9];
2692   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2693   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2694   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2695   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2696   ymothervertex[14] = ymothervertex[13];
2697   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2698   //////////////////////////////////////////////////////////
2699   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2700                                                                         xmothervertex,ymothervertex);
2701   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2702                                                                                            + fgkCoolingTubeRmax));
2703   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2704                                                                                            + fgkCoolingTubeRmax));
2705   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2706 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2707 //                                                        coolingsystemothershape,fSSDAir);
2708   /////////////////////////////////////////////////////////////
2709   // SSD Cooling Tube Part 
2710   /////////////////////////////////////////////////////////////
2711   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2712   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2713                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2714   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2715                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2716   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2717   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2718                                                                         fSSDCoolingTubePhynox);
2719   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2720                                                                         fSSDCoolingTubeWater);
2721   coolingtube[0]->SetLineColor(fColorPhynox);
2722   coolingtube[1]->SetLineColor(fColorWater);
2723   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2724   /////////////////////////////////////////////////////////////
2725   // Adding Cooling block to mother volume
2726   /////////////////////////////////////////////////////////////
2727    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2728         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2729         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2730         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2731   }
2732   /////////////////////////////////////////////////////////////
2733   // Deallocating memory
2734   /////////////////////////////////////////////////////////////
2735         delete coolingblocktransvector;
2736         delete localcoolingblockrot;
2737         delete localcoolingtubetrans;
2738         delete localcoolingtuberot;
2739   /////////////////////////////////////////////////////////////
2740   // Checking overlaps  
2741   /////////////////////////////////////////////////////////////
2742         //coolingsystemother->CheckOverlaps(0.01);
2743   /////////////////////////////////////////////////////////////
2744         return coolingsystemother;
2745 }
2746 /////////////////////////////////////////////////////////////////////////////////
2747 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2748   /////////////////////////////////////////////////////////////
2749   // SSD Flex
2750   /////////////////////////////////////////////////////////////
2751   const Int_t kssdflexlayernumber = 2;
2752   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2753   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2754   const Int_t kmothervertexnumber = 17; 
2755   Double_t xmothervertex[kmothervertexnumber];
2756   Double_t ymothervertex[kmothervertexnumber];
2757   /////////////////////////////////////////////
2758   // Auxiliary variables for vertex positioning
2759   /////////////////////////////////////////////
2760   const Int_t kssdflexboxnumber = 5;
2761   Double_t ssdflexboxlength[kssdflexboxnumber];
2762   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2763                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2764                                           *     fgkSSDChipSeparationLength
2765                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2766                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2767   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2768   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2769                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2770   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2771   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2772                                           -     ssdflexboxlength[1];
2773   Double_t ssdflexboxwidth[kssdflexboxnumber];
2774   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2775   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2776   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2777   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2778   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2779   ///////////////////////
2780   // Setting the vertices 
2781   ///////////////////////
2782   xmothervertex[0]  = 0.0;
2783   xmothervertex[1]  = xmothervertex[0];
2784   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2785   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2786                                         + ssdflexboxlength[4];
2787   xmothervertex[4]  = xmothervertex[3];
2788   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2789   xmothervertex[6]  = xmothervertex[5];
2790   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2791   xmothervertex[8]  = xmothervertex[7];
2792   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2793   xmothervertex[10] = xmothervertex[9]; 
2794   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2795   xmothervertex[12] = xmothervertex[11];
2796   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2797   xmothervertex[14] = xmothervertex[13];
2798   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2799   xmothervertex[16] = xmothervertex[15];
2800   ymothervertex[0]  = 0.0;
2801   ymothervertex[1]  = fgkSSDFlexWidth[1];
2802   ymothervertex[2]  = fgkSSDFlexWidth[0];
2803   ymothervertex[3]  = ymothervertex[2];
2804   ymothervertex[4]  = ymothervertex[0];
2805   ymothervertex[5]  = ymothervertex[4];
2806   ymothervertex[6]  = ssdflexboxwidth[2];
2807   ymothervertex[7]  = ymothervertex[6];
2808   ymothervertex[8]  = ymothervertex[0];
2809   ymothervertex[9]  = ymothervertex[8];
2810   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2811   ymothervertex[11] = ymothervertex[10];
2812   ymothervertex[12] = ymothervertex[0];
2813   ymothervertex[13] = ymothervertex[12];
2814   ymothervertex[14] = ymothervertex[7];
2815   ymothervertex[15] = ymothervertex[14];
2816   ymothervertex[16] = ymothervertex[0];
2817   /////////////////////////////////////////////////////////////
2818   // First Mother Volume containing SSDFlex
2819   /////////////////////////////////////////////////////////////
2820   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2821   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2822                                                                     ymothervertex);
2823   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2824   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2825   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2826 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2827 //                                                                                       fSSDAir);
2828   /////////////////////////////////////////////////////////////
2829   // SSDFlex Layer Shapes
2830   /////////////////////////////////////////////////////////////
2831   for(Int_t i=0; i<kssdflexlayernumber; i++){
2832         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2833                                                                    ymothervertex);
2834     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2835         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2836   }
2837   /////////////////////////////////////
2838   // Setting Layers into Mother Volume
2839   /////////////////////////////////////
2840   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2841   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2842                                                                                                  fSSDKaptonFlexMedium};
2843   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2844                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2845   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2846   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2847   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2848         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2849                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2850                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2851         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2852     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2853                                          +                                         fgkSSDFlexHeight[1])); 
2854     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2855   }
2856   return ssdflexmother;
2857 }
2858 /////////////////////////////////////////////////////////////////////////////////
2859 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2860   /////////////////////////////////////////////////////////////
2861   // Method generating SSD End Flex   
2862   /////////////////////////////////////////
2863   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2864                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2865   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2866                                                 * TMath::DegToRad()*ssdflexradiusmax
2867                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2868                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2869                                                         - 0.1*fgkSSDFlexFullLength;
2870   const Int_t knedges = 20;  
2871   const Int_t karcnumber = 2;
2872   TVector3* vertexposition[karcnumber*(knedges+1)];
2873   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2874   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2875   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2876   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2877                                                                                  - 90.0*TMath::DegToRad()};
2878   TVector3* referencetrans[karcnumber];
2879   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2880                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2881                                                                    radius[0]);
2882   referencetrans[1] = new TVector3(referencetrans[0]->X()
2883                                         +              fgkSSDFlexLength[2],
2884      -              fgkSSDStiffenerHeight);
2885 for(Int_t i=0; i<karcnumber; i++){
2886         for(Int_t j=0; j<knedges+1; j++){
2887                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2888                                                                                                radius[i]*SinD(angle[i]));
2889                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2890         }       
2891   }
2892   ///////////////////////
2893   // Setting the vertices 
2894   ///////////////////////
2895   const Int_t kendflexlayernumber = 4;
2896   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2897   TVector3** vertex[kendflexlayernumber];
2898   for(Int_t i=0; i<kendflexlayernumber; i++) 
2899                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2900   TVector3* transvector[kendflexlayernumber+1];
2901   TVector3* deltatransvector = new TVector3();  
2902   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2903   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2904                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2905   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2906         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2907                                         *                 CosD(fgkSSDFlexAngle),
2908                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2909                                         *         SinD(fgkSSDFlexAngle),0.0);   
2910         *transvector[i] = *transvector[i-1]+*deltatransvector;
2911   }
2912   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2913   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2914   for(Int_t i=0; i<karcnumber; i++){
2915         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2916                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2917                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2918                                               /radius[i];
2919         }
2920   }
2921   for(Int_t i=0; i<kendflexlayernumber; i++){
2922         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2923         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2924         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2925                 if(j<(knedges+1)){
2926                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2927                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2928                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2929                         *vertex[i][j+2] += *referencetrans[0];
2930                         vertex[i][4*(knedges+1)-j+1] = 
2931                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2932                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2933                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2934                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2935                 }
2936                 else{
2937                 
2938                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2939                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2940                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2941                         *vertex[i][j+2] += *referencetrans[1];
2942                         vertex[i][4*(knedges+1)-j+1] = 
2943                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2944                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2945                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2946                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2947            }
2948         }
2949   }
2950   /////////////////////////////////////////////////////////////
2951   // First Mother Volume containing SSDEndFlex
2952   /////////////////////////////////////////////////////////////
2953   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2954   Double_t xmothervertex[kendflexvertexnumber];
2955   Double_t ymothervertex[kendflexvertexnumber];
2956   xmothervertex[0] = vertex[0][0]->X(); 
2957   ymothervertex[0] = vertex[0][0]->Y();
2958   for(Int_t i=1; i<kendflexvertexnumber; i++){
2959         if(i<2*(knedges+1)+2){
2960                 xmothervertex[i] = vertex[3][i]->X();
2961                 ymothervertex[i] = vertex[3][i]->Y();
2962         }
2963         else{
2964                 xmothervertex[i] = vertex[0][i]->X();
2965                 ymothervertex[i] = vertex[0][i]->Y();
2966         }
2967   }
2968   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2969                                                                            xmothervertex,ymothervertex);
2970   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2971   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2972 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2973 //                                                               ssdendflexmothershape,fSSDAir);        
2974   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2975   //////////////////////////////////////
2976   // End Flex TGeoXtru Layer Definition 
2977   //////////////////////////////////////
2978   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2979   TGeoVolume* ssdendflex[kendflexlayernumber];
2980   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2981   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2982   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2983   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2984   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2985                                                                                                         fSSDKaptonFlexMedium};
2986   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2987                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2988   for(Int_t i=0; i<kendflexlayernumber; i++){
2989         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2990                 xvertex[i][j] = vertex[i][j]->X();
2991                 yvertex[i][j] = vertex[i][j]->Y();
2992         }
2993   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2994   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2995   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2996   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2997                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2998   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2999   ssdendflexmother->AddNode(ssdendflex[i],1);
3000   }
3001   /////////////////////////////////////////////////////////////
3002   // Deallocating memory
3003   /////////////////////////////////////////////////////////////
3004   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3005   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3006   for(Int_t i=0; i<kendflexlayernumber; i++){
3007         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3008         delete [] vertex[i];
3009   }
3010   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3011   delete deltatransvector;
3012   /////////////////////////////////////////////////////////////
3013   //ssdendflexmother->CheckOverlaps(0.01);
3014   return ssdendflexmother;
3015 }
3016 ///////////////////////////////////////////////////////////////////////////////
3017 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3018   /////////////////////////////////////////////////////////////
3019   // Method generating the Mounting Block
3020   /////////////////////////////////////////////////////////////  
3021   const Int_t kvertexnumber = 8;
3022   Double_t xvertex[kvertexnumber];
3023   Double_t yvertex[kvertexnumber];
3024   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3025   xvertex[1] = xvertex[0];
3026   xvertex[2] = -xvertex[0];
3027   xvertex[3] = xvertex[2];
3028   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3029                          -                                 fgkSSDMountingBlockLength[2]);
3030   xvertex[5] = xvertex[4];
3031   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3032                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3033                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3034   xvertex[7] = xvertex[6];
3035   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3036                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3037   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3038   yvertex[2] = yvertex[1]; 
3039   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3040   yvertex[4] = yvertex[3];
3041   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3042                          - fgkSSDMountingBlockHeight[0];
3043   yvertex[6] = yvertex[5];
3044   yvertex[7] = yvertex[0];
3045
3046   ///////////////////////////////////////////////////////////////////////
3047   // TGeoXTru Volume definition for Mounting Block Part
3048   ///////////////////////////////////////////////////////////////////////
3049   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3050   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3051   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3052   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3053   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3054                                                                           ssdmountingblockshape,
3055                                                                                   fSSDMountingBlockMedium);
3056   ssdmountingblock->SetLineColor(fColorG10);
3057   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3058   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3059   TGeoRotation* mountingblockrot = new TGeoRotation();
3060   mountingblockrot->SetAngles(90.,180.,-90.);
3061   mountingblockcombitrans->SetRotation(*mountingblockrot);
3062   /////////////////////////////////////////////////////////////
3063   // Generating the Mounting Block Screw Vertices 
3064   /////////////////////////////////////////////////////////////  
3065   const Int_t kscrewvertexnumber = 15;
3066   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3067                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3068                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3069                                  * TMath::RadToDeg();
3070   Double_t phi0 = 90.+alpha;
3071   Double_t phi = 270.-2*alpha;
3072   Double_t deltaphi = phi/kscrewvertexnumber;   
3073   TVector3* screwvertex[kscrewvertexnumber+1];
3074   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3075         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3076                                    *CosD(phi0+i*deltaphi),
3077                                    fgkSSDMountingBlockScrewHoleRadius[0]
3078                                    *SinD(phi0+i*deltaphi));
3079   Double_t xscrewvertex[kscrewvertexnumber+6];
3080   Double_t yscrewvertex[kscrewvertexnumber+6];
3081   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3082   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3083                                   -               fgkSSDMountingBlockScrewHoleEdge);
3084   xscrewvertex[1] = xscrewvertex[0];
3085   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3086   xscrewvertex[2] = screwvertex[0]->X();
3087   yscrewvertex[2] = yscrewvertex[1];
3088   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3089         xscrewvertex[i+3] = screwvertex[i]->X();        
3090         yscrewvertex[i+3] = screwvertex[i]->Y();        
3091   } 
3092   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3093   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3094   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3095   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3096   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3097   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3098   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3099   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3100                                                         +                                  fgkSSDMountingBlockHeight[2]);
3101   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3102                                                                                 ssdmountingblockscrewshape,
3103                                                                                             fSSDMountingBlockMedium);
3104   ssdmountingblockscrew->SetLineColor(fColorG10);
3105   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3106   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3107   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3108                                                                         -                                yscrewvertex[1],
3109                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3110                                                                         -                                fgkSSDMountingBlockHeight[2]
3111                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3112                                                                         +                                fgkSSDMountingBlockHeight[2]
3113                                                                         -                                yvertex[0]));
3114   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3115                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3116                                                                                                                  yscrewvertex[1]
3117                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3118                                                                                                          +fgkSSDMountingBlockHeight[2]
3119                                                                                                          -yvertex[0]));
3120   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3121                                                                                                           yscrewvertex[1],
3122                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3123                                                                         +                                 fgkSSDMountingBlockHeight[2]
3124                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3125                                                                         +                                 fgkSSDMountingBlockHeight[2]
3126                                                                         -                                 yvertex[0]));
3127   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3128                                                                                                          yscrewvertex[1],
3129                                                                         -                                yscrewvertex[1]
3130                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3131                                                                         +                                fgkSSDMountingBlockHeight[2]
3132                                                                         -                                yvertex[0]));
3133   TGeoRotation* ssdmountingblockscrewrot[4];
3134   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3135         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3136     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3137     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3138   for(Int_t i=1; i<4; i++) 
3139         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3140   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3141   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3142   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3143   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3144                                                          +                                xvertex[0],yscrewvertex[1]
3145                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3146                                                          +                                fgkSSDMountingBlockHeight[2]
3147                                                          -                                yvertex[0]),0.);      
3148   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3149   for(Int_t i=0; i<4; i++){
3150         ssdmountingblockscrewmatrix[i] = 
3151                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3152         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3153   }
3154   ///////////////////////////////////////////////////////////////////////
3155   // TGeoXtru for Mother Volume 
3156   ///////////////////////////////////////////////////////////////////////
3157   const Int_t kvertexmothernumber = 12;
3158   Double_t xmothervertex[kvertexmothernumber];
3159   Double_t ymothervertex[kvertexmothernumber];
3160   for(Int_t i=0; i<6; i++){
3161         xmothervertex[i] = xvertex[i];
3162         ymothervertex[i] = yvertex[i];
3163   } 
3164   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3165   ymothervertex[6]  = ymothervertex[5];
3166   xmothervertex[7]  = xmothervertex[6];
3167   ymothervertex[7]  = ymothervertex[4];
3168   xmothervertex[8]  = xmothervertex[7]
3169                                         + 0.5*(fgkSSDMountingBlockLength[1]
3170                                         -          fgkSSDMountingBlockLength[2]);
3171   ymothervertex[8]  = ymothervertex[4];
3172   xmothervertex[9]  = xmothervertex[8];
3173   ymothervertex[9]  = ymothervertex[2];
3174   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3175   ymothervertex[10] = ymothervertex[1];
3176   xmothervertex[11] = xmothervertex[10];
3177   ymothervertex[11] = ymothervertex[0];  
3178   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3179   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3180   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3181   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3182   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3183                                                                           ssdmountingblockmothershape,
3184                                                                                   fSSDAir);
3185   /////////////////////////////////////////////////////////////
3186   // Placing the Volumes into Mother Volume 
3187   /////////////////////////////////////////////////////////////
3188   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3189   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3190   for(Int_t i=0; i<4; i++) 
3191         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3192                                                                         ssdmountingblockscrewmatrix[i]);
3193   /////////////////////////////////////////////////////////////
3194   // Deallocating memory
3195   /////////////////////////////////////////////////////////////
3196   delete mountingblockrot;
3197   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3198   delete ssdmountingblockglobalrot; 
3199   delete ssdmountingblockglobaltrans; 
3200   /////////////////////////////////////////////////////////////
3201   return ssdmountingblockmother;
3202 }
3203 ///////////////////////////////////////////////////////////////////////////////
3204  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3205   /////////////////////////////////////////////////////////////
3206   // Method generating the Mounting Block Clip 
3207   /////////////////////////////////////////////////////////////  
3208   const Int_t kmothervertexnumber = 10;
3209   Double_t xmothervertex[kmothervertexnumber];
3210   Double_t ymothervertex[kmothervertexnumber];
3211   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3212                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3213   xmothervertex[1] = xmothervertex[0];
3214   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3215                                    - fgkMountingBlockClibScrewRadius);
3216   xmothervertex[3] = xmothervertex[2]; 
3217   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3218   xmothervertex[5] = xmothervertex[4]; 
3219   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3220   xmothervertex[7] = xmothervertex[6]; 
3221   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3222   xmothervertex[9] = xmothervertex[8]; 
3223   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3224                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3225   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3226   ymothervertex[2] = ymothervertex[1];
3227   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3228                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3229                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3230   ymothervertex[4] = ymothervertex[3];
3231   ymothervertex[5] = ymothervertex[2];
3232   ymothervertex[6] = ymothervertex[5];
3233   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3234   ymothervertex[8] = ymothervertex[7];
3235   ymothervertex[9] = ymothervertex[0];
3236
3237   ///////////////////////////////////////////////////////////////////////
3238   // TGeoXTru Volume definition for Mounting Block Clip Part
3239   ///////////////////////////////////////////////////////////////////////
3240   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3241   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3242   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3243   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3244   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3245                                                                           ssdmountingblockclipshape,fSSDAir);
3246   ssdmountingblockclip->SetLineColor(4);
3247   ///////////////////////////////////////////////////////////////////////
3248   // TGeoXTru Volume definition for Clip 
3249   ///////////////////////////////////////////////////////////////////////
3250   const Int_t kclipvertexnumber = 6;
3251   Double_t xclipvertex[kclipvertexnumber];
3252   Double_t yclipvertex[kclipvertexnumber];
3253   xclipvertex[0] = xmothervertex[0];
3254   xclipvertex[1] = xclipvertex[0];
3255   xclipvertex[2] = xmothervertex[6];
3256   xclipvertex[3] = xclipvertex[2];
3257   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3258   xclipvertex[5] = xclipvertex[4];
3259   yclipvertex[0] = ymothervertex[0];
3260   yclipvertex[1] = ymothervertex[1];
3261   yclipvertex[2] = yclipvertex[1];
3262   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3263   yclipvertex[4] = yclipvertex[3];
3264   yclipvertex[5] = yclipvertex[0];
3265   TGeoXtru* clipshape = new TGeoXtru(2);
3266   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3267   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3268   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3269                                                          +   fgkMountingBlockClibWidth);
3270   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3271   clip->SetLineColor(18);
3272   ///////////////////////////////////////////////////////////////////////
3273   // Ladder Support Piece  
3274   ///////////////////////////////////////////////////////////////////////
3275   const Int_t ksupportvertexnumber = 4;
3276   Double_t xsupportvertex[ksupportvertexnumber];
3277   Double_t ysupportvertex[ksupportvertexnumber];
3278   xsupportvertex[0] = xclipvertex[5];
3279   xsupportvertex[1] = xsupportvertex[0];
3280   xsupportvertex[2] = xmothervertex[9];
3281   xsupportvertex[3] = xsupportvertex[2];
3282   ysupportvertex[0] = yclipvertex[0];
3283   ysupportvertex[1] = yclipvertex[3];
3284   ysupportvertex[2] = ysupportvertex[1];
3285   ysupportvertex[3] = ysupportvertex[0];
3286   TGeoXtru* supportshape = new TGeoXtru(2);
3287   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3288   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3289   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3290   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3291   support->SetLineColor(9);
3292   ///////////////////////////////////////////////////////////////////////
3293   // TGeoXTru Volume definition for Screw   
3294   ///////////////////////////////////////////////////////////////////////
3295   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3296                                                 0.5*fgkMountingBlockClibScrewRadius};
3297   Int_t edgesnumber[2] = {50,6};
3298   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3299                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3300   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3301   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3302   clipscrew->SetLineColor(12);
3303   TGeoRotation* screwrot = new TGeoRotation();
3304   screwrot->SetAngles(0.,90.,0.);
3305   TGeoTranslation* screwtrans = new TGeoTranslation();
3306   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3307                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3308                                                          0.5*fgkSSDMountingBlockWidth+
3309                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3310   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3311   ///////////////////////////////////////////////////////////////////////
3312   // Placing the Volumes
3313   ///////////////////////////////////////////////////////////////////////
3314   ssdmountingblockclip->AddNode(clip,1);
3315   ssdmountingblockclip->AddNode(support,1);
3316   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3317   /////////////////////////////////////////////////////////////
3318   // Deallocating memory
3319   /////////////////////////////////////////////////////////////  
3320   delete screwtrans;
3321   delete screwrot;
3322   /////////////////////////////////////////////////////////////
3323   return ssdmountingblockclip;
3324 }
3325 ///////////////////////////////////////////////////////////////////////////////
3326 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3327   /////////////////////////////////////////////////////////////
3328   // Method generating the Cooling Tube 
3329   /////////////////////////////////////////////////////////////  
3330    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3331    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3332                                                                                                 new     TGeoTube*[2];
3333    // Ladder Cooling Tubes
3334    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3335                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3336                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
3337                                                   -0.5*fgkSSDTolerance);
3338    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3339                                                                                  coolingtubeshape[0][0]->GetDz());
3340    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3342                                                   -                                       fgkSSDSensorOverlap-fgkSSDTolerance));
3343    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3344                                                                                  coolingtubeshape[1][0]->GetDz());
3345    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3346                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDTolerance));
3347    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3348                                                                                  coolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3349    // End Ladder Cooling Tubes  
3350    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3351    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3352    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3353    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3354                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3355                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3356    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3357                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3358    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3359                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3360                                                   +                     fgkendladdercoolingsupportdistance[1]
3361                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3362    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3363                                                                         endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3364    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3365                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3366                                                   -                     fgkEndLadderMountingBlockPosition[0]
3367                                                   -                     fgkendladdercoolingsupportdistance[1]           
3368                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3369    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3370                                                                         endladdercoolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3371    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3372                                                           0.50 * (fgkMountingBlockToSensorSupport
3373                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3374                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3375                                                         +                 fgkSSDSensorOverlap
3376                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3377                                                         -                 fgkendladdercoolingsupportdistance[2]
3378                                                         -                 fgkEndLadderMountingBlockPosition[1]
3379                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3380    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3381                                                                         endladdercoolingtubeshape[3][0]->GetDz()-0.5*fgkSSDTolerance);
3382    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3383                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3384    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3385                                                                         endladdercoolingtubeshape[4][0]->GetDz()-0.5*fgkSSDTolerance);
3386    // Ladder Cooling Tubes
3387    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3388    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3389                                                                                          new TGeoVolume*[2];
3390    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3391                                                                           fSSDCoolingTubePhynox);
3392    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3393                                                                           fSSDCoolingTubeWater);
3394    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3395                                                                           fSSDCoolingTubePhynox);
3396    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3397                                                                           fSSDCoolingTubeWater);
3398    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3399                                                                           fSSDCoolingTubePhynox);
3400    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3401                                                                           fSSDCoolingTubeWater);
3402    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3403         coolingtube[i][0]->SetLineColor(fColorPhynox);
3404         coolingtube[i][1]->SetLineColor(fColorWater);
3405    }
3406    // End Ladder Cooling Tubes  
3407    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3408    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3409    endladdercoolingtube[i] = new TGeoVolume*[2];
3410    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3411                                                                 endladdercoolingtubeshape[0][0],
3412                                                                 fSSDCoolingTubePhynox);
3413    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3414                                                                 endladdercoolingtubeshape[0][1],
3415                                                                 fSSDCoolingTubeWater);
3416    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3417                                                                 endladdercoolingtubeshape[1][0],
3418                                                                 fSSDCoolingTubePhynox);
3419    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3420                                                                 endladdercoolingtubeshape[1][1],
3421                                                                 fSSDCoolingTubeWater);
3422    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3423                                                                 endladdercoolingtubeshape[2][0],
3424                                                                 fSSDCoolingTubePhynox);
3425    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3426                                                                 endladdercoolingtubeshape[2][1],
3427                                                                 fSSDCoolingTubeWater);
3428    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3429                                                                 endladdercoolingtubeshape[3][0],
3430                                                                 fSSDCoolingTubePhynox);
3431    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3432                                                                 endladdercoolingtubeshape[3][1],
3433                                                                 fSSDCoolingTubeWater);
3434    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3435                                                                 endladdercoolingtubeshape[4][0],
3436                                                                 fSSDCoolingTubePhynox);
3437    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3438                                                                 endladdercoolingtubeshape[4][1],
3439                                                                 fSSDCoolingTubeWater);
3440    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3441                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3442                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3443    }
3444   
3445   /////////////////////////////////////////////////////////////
3446   // Virtual Volume containing Cooling Tubes
3447   /////////////////////////////////////////////////////////////
3448   // Ladder Cooling Tubes
3449   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3450   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3451   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3452                                                                                         coolingtubeshape[i][0]->GetRmax(),
3453                                                                                         coolingtubeshape[i][0]->GetDz());
3454   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3455   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3456                                                                           fSSDAir);
3457   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3458                                                                           fSSDAir);
3459   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3460                                                                           fSSDAir);
3461   // End Ladder Cooling Tubes
3462   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3463   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3464   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3465                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3466                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3467   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3468   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3469                                                                           endladdervirtualcoolingtubeshape[0],
3470                                                                           fSSDAir);
3471   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3472                                                                           endladdervirtualcoolingtubeshape[1],
3473                                                                           fSSDAir);
3474   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3475                                                                           endladdervirtualcoolingtubeshape[2],
3476                                                                           fSSDAir);
3477   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3478                                                                           endladdervirtualcoolingtubeshape[3],
3479                                                                           fSSDAir);
3480   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3481                                                                           endladdervirtualcoolingtubeshape[4],
3482                                                                           fSSDAir);
3483   TList* coolingtubelist = new TList();
3484   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3485         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3486         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3487     coolingtubelist->Add(virtualcoolingtube[i]);
3488   }
3489         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3490         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3491     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3492         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3493         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3494     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3495         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3496         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3497     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3498         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3499         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3500     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3501         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3502         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3503     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3504   return coolingtubelist;
3505 }
3506 ///////////////////////////////////////////////////////////////////////////////
3507 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3508   /////////////////////////////////////////////////////////////
3509   // Method generating SSD Cooling Block    
3510   /////////////////////////////////////////////////////////////
3511   const Int_t kvertexnumber = 8;
3512   ///////////////////////////////////////
3513   // Vertex Positioning for TGeoXTru
3514   ///////////////////////////////////////
3515   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3516   vertexposition[0] = new TVector3(0.0,0.0);
3517   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3518   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3519                                           vertexposition[1]->Y());
3520   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3521                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3522   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3523   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3524                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3525   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3526                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3527                                         - fgkSSDCoolingBlockHoleLength[0]
3528                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3529                                           fgkSSDCoolingBlockHeight[0]
3530                                         - fgkSSDCoolingBlockHoleRadius[1],
3531                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3532   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3533                                         - fgkSSDCoolingBlockHoleLength[0]),
3534                                           vertexposition[6]->Y());
3535   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3536                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3537   Double_t phi = 180.-alpha;
3538   Double_t psi = 180.+2.*alpha;
3539   Double_t deltapsi = psi/nedges;
3540   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3541   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3542                                                   fgkSSDCoolingBlockHoleCenter);
3543   for(Int_t i=0; i<nedges+1; i++){
3544         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3545                                                                                                radius*SinD(phi+i*deltapsi));
3546    *vertexposition[kvertexnumber+i] += (*transvector);
3547   }
3548   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3549   for(Int_t i=0; i<kvertexnumber; i++)
3550     vertexposition[kvertexnumber+nedges+1+i] = 
3551                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3552   ///////////////////////////////////////////////////////////////////////
3553   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3554   ///////////////////////////////////////////////////////////////////////
3555   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3556   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3557   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3558   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3559         xvertexpoints[i] = vertexposition[i]->X();
3560         yvertexpoints[i] = vertexposition[i]->Y();
3561   } 
3562   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3563                                                                                         yvertexpoints);
3564   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3565   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3566   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3567                                                                           ssdcoolingblockshape,
3568                                                                                   fSSDAlCoolBlockMedium);
3569   ssdcoolingblock->SetLineColor(fColorAl);
3570   /////////////////////////////////////////////////////////////
3571   // Deallocating memory
3572   /////////////////////////////////////////////////////////////
3573   delete [] vertexposition;
3574   delete [] xvertexpoints;
3575   delete [] yvertexpoints;
3576   /////////////////////////////////////////////////////////////
3577   return ssdcoolingblock;
3578 }
3579 /////////////////////////////////////////////////////////////////////////////////
3580 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3581   ///////////////////////////////////////////////////////
3582   const Int_t kssdchipcablesnumber    = 2;
3583   const Int_t kssdchipcableslaynumber = 2;
3584   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3585   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3586   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3587   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3588                                                  -  fgkSSDChipCablesHeight[0]
3589                                                  -  fgkSSDChipCablesHeight[1]);
3590   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3591   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3592   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3593                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3594                                                           - ssdchipcablesradius[0]
3595                                                           - fgkSSDChipCablesWidth[1]
3596                                                           - fgkSSDChipCablesWidth[2]);
3597   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3598                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3599                                                           +      fgkSSDChipCablesHeight[1]
3600                                                           +      fgkSSDSensorHeight);
3601   ///////////////////////////////////////////////////////
3602   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3603   ///////////////////////////////////////////////////////
3604   TVector3** vertexposition[kssdchipcableslaynumber];
3605   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3606                                                                                                   new TVector3*[4*(nedges+1)+4];
3607   Double_t ratio[4];
3608   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3609   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3610                    /  ssdchipcablesradius[0]; 
3611   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3612                    /  ssdchipcablesradius[0];
3613   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3614                    +  fgkSSDChipCablesHeight[1])
3615                    /  ssdchipcablesradius[0];
3616   Double_t phi = 180.;
3617   Double_t deltaphi = 180./nedges;
3618   Double_t angle = 0.0;
3619   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3620   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3621   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3622         xvertexpoints[i] = new Double_t[kvertexnumber];
3623         yvertexpoints[i] = new Double_t[kvertexnumber];
3624   }  
3625   TVector3* vertex = new TVector3();
3626   TVector3* transvector[kssdchipcableslaynumber];
3627   transvector[0] = new TVector3(fgkSSDChipWidth,
3628                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3629   transvector[1] = new TVector3();
3630   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3631   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3632   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3633                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3634                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3635   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3636         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3637         transvector[1]->SetY(ssdchipcablesradius[0]
3638                                  +               fgkSSDChipCablesHeight[0]
3639                                  +               fgkSSDChipCablesHeight[1]);  
3640         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3641                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3642                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3643                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3644                                                          - i*fgkSSDChipCablesHeight[0]);
3645                 vertexposition[i][2*(nedges+1)+2] = 
3646                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3647                                 +                                fgkSSDChipCablesWidth[1]
3648                                 +                                fgkSSDChipCablesWidth[2],
3649                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3650                                 +                                fgkSSDChipCablesHeight[1]));
3651         vertexposition[i][2*(nedges+1)+3] = 
3652                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3653                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3654                                 -                                fgkSSDChipCablesHeight[i]);
3655             for(Int_t j=0; j<nedges+1; j++){            
3656                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3657                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3658                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3659                         vertexposition[0][(nedges+1)*i+j+2] = 
3660                                                 new TVector3(*vertex+*transvector[i]);
3661                         vertexposition[1][(nedges+1)*i+j+2] = 
3662                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3663                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3664                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3665                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3666                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3667                                                 new TVector3(vertex->X()*ratio[2*i+1]
3668                                                         +                        transvector[i]->X(),
3669                                                                                  vertex->Y()*ratio[2*i+1]
3670                                                         +                transvector[i]->Y());
3671                 }
3672         }
3673         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3674                 for(Int_t j=0; j<kvertexnumber; j++){   
3675                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3676                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3677                 }
3678                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3679                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3680                                                                                 xvertexpoints[i],yvertexpoints[i]);
3681                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3682                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3683                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3684                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3685                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3686                                                           (kssdchipcablesnumber*k+i)%2==0?
3687                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3688                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3689         }
3690         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3691                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3692   }
3693   /////////////////////////////////////////////////////////////
3694   // Mother Volume definition 
3695   /////////////////////////////////////////////////////////////
3696   Double_t ssdchipseparation = fgkSSDSensorLength
3697                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3698                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3699                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3700   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3701   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3702                                                           +fgkSSDChipCablesWidth[1]
3703                                                           +fgkSSDChipCablesWidth[2]);
3704   Double_t dy = fgkSSDChipCablesLength[1];
3705   Double_t dz = SSDChipCablesHeigth;
3706   new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3707   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3708 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3709 //                        ssdchipcablesmotherbox,fSSDAir);
3710   /////////////////////////////////////////////////////////////
3711   // Rotation and Translation Definition for positioning 
3712   /////////////////////////////////////////////////////////////
3713   TGeoRotation* ssdchipcablesrot[5];
3714   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3715   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3716   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3717   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3718   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3719   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3720                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3721   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3722   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3723   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3724   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3725   /////////////////////////////////////////////////////////////
3726   // Deallocating memory
3727   /////////////////////////////////////////////////////////////
3728   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3729         delete [] xvertexpoints[i];
3730         delete [] yvertexpoints[i];
3731   }
3732   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3733   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3734   delete vertex; 
3735   delete ssdchipcablesrot[0];
3736   delete ssdchipcablesrot[1];
3737   delete ssdchipcablesrot[3];
3738   /////////////////////////////////////////////////////////////
3739   return ssdchipcablesmother;
3740 }
3741 ///////////////////////////////////////////////////////////////////////////////
3742 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3743   /////////////////////////////////////////////////////////////
3744   // SSD Chip Assembly
3745   /////////////////////////////////////////////////////////////
3746   TGeoVolume* ssdchipassembly = GetSSDChips();
3747   TList* ssdchipsystemlist = new TList();
3748 //  const Int_t knedges = 20;
3749   const Int_t knedges = 5;
3750   const Int_t kchipsystemnumber = 2;
3751
3752   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3753   const char* chipsytemothername[kchipsystemnumber] = 
3754                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3755   for(Int_t i=0; i<kchipsystemnumber; i++){
3756     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3757   }
3758   /////////////////////////////////////////////////////////////
3759   // SSD Chip Cables
3760   /////////////////////////////////////////////////////////////
3761   TGeoVolume* ssdchipcables[kchipsystemnumber];
3762   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3763   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3764   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3765   //////////////////
3766   for(Int_t i=0; i<kchipsystemnumber; i++){
3767                 ssdchipcables[i] = 
3768                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3769                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3770                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3771                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3772   }
3773   for(Int_t i=0; i<kchipsystemnumber; i++){
3774         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3775                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3776                 ssdchipcablesrot[i][j] = new TGeoRotation();
3777                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3778                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3779                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3780                                                   +                fgkSSDChipSeparationLength),
3781                                                                                         0.5*fgkSSDChipWidth,
3782                                                   -                                     0.5*fgkSSDChipHeight
3783                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3784                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3785                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3786                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3787         }
3788         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3789         ssdchipsystemlist->Add(chipsystemother[i]);     
3790   }
3791   /////////////////////////////////////////////////////////////
3792   // Deallocating memory
3793   /////////////////////////////////////////////////////////////
3794   for(Int_t i=0; i<kchipsystemnumber; i++){
3795         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3796                 delete ssdchipcablesrot[i][j];
3797                 delete ssdchipcablestrans[i][j];
3798         }
3799         delete [] ssdchipcablesrot[i];
3800         delete [] ssdchipcablestrans[i];
3801   }
3802   /////////////////////////////////////////////////////////////
3803   return ssdchipsystemlist;
3804 }
3805
3806 //_____________________________________________________________________________
3807 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3808   /////////////////////////////////////////////////////////////
3809   // SSD Chip Assembly Generation    
3810   /////////////////////////////////////////////////////////////
3811   const Int_t kssdchiprownumber = 2;
3812   TGeoBBox* ssdchipcompshape[2];
3813   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3814                                                                                 0.5*fgkSSDChipLength,
3815                                                                                 0.5*fgkSSDChipWidth,
3816                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3817   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3818                                                                                 0.5*fgkSSDChipLength,
3819                                                                                 0.5*fgkSSDChipWidth,
3820                                                                                 0.5*fgkSSDChipGlueHeight);
3821   TGeoVolume* ssdchipcomp[2];
3822   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3823   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3824                                                                   fSSDChipGlueMedium);
3825   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3826   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3827   TGeoTranslation* ssdchipcomptrans[2];
3828   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3829   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3830   /////////////////////////////////////////////////////////////
3831   // Virtual Volume containing SSDChip   
3832   /////////////////////////////////////////////////////////////
3833   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3834                                                                                                                  0.5*fgkSSDChipWidth,
3835                                                                                                                  0.5*fgkSSDChipHeight);
3836   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3837   /////////////////////////////////////////////////////////////
3838   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3839   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3840                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3841                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3842                                    -  0.5*fgkSSDChipWidth)};
3843   /////////////////////////////////////////////////////////////
3844   // Virtual Volume containing SSDChipAssembly   
3845   /////////////////////////////////////////////////////////////
3846   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3847   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3848   Double_t xmothervertex[kssdmothervertexnumber];
3849   Double_t ymothervertex[kssdmothervertexnumber];
3850   ///////////////////////
3851   // Setting the vertices 
3852   ///////////////////////
3853   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3854   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3855                                    - ymothervertex[0];
3856   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3857   ymothervertex[2] = ymothervertex[1];
3858   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3859   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3860   ymothervertex[4] = ymothervertex[0];
3861   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3862   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3863                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3864   ymothervertex[6] = ymothervertex[5];
3865   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3866                                    - fgkSSDChipWidth;
3867   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3868   ymothervertex[8] = ymothervertex[7];
3869   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3870   ymothervertex[9] = ymothervertex[6];
3871   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3872   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3873   //////////////////////////////////////////////////////////
3874   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3875                                                                         xmothervertex,ymothervertex);
3876   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3877   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3878 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3879 //                                                        ssdchipmothershape,fSSDAir);
3880   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3881    /////////////////////////////////////////////////////////////
3882   for(Int_t i=0; i<kssdchiprownumber; i++)
3883     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3884                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3885                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3886   return ssdchipmother;
3887 }
3888 /////////////////////////////////////////////////////////////////////////////////
3889 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3890   /////////////////////////////////////////////////////////////
3891   // Method returning a List containing pointers to Ladder Cable Volumes    
3892   /////////////////////////////////////////////////////////////
3893   const Int_t kladdercablesegmentnumber = 2;
3894   /////////////////////////////////////////
3895   // LadderSegmentBBox Volume
3896   /////////////////////////////////////////
3897   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3898   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3899                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3900
3901
3902   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3903                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3904   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3905
3906   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3907                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3908                                                                                            0.5*fgkSSDFlexWidth[0],
3909                                                                                            0.5*fgkSSDLadderCableWidth,
3910                                                                        0.5*fgkSSDFlexHeight[0]),
3911                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3912                                                                                            0.5*fgkSSDFlexWidth[0],
3913                                                                                            0.5*fgkSSDLadderCableWidth,
3914                                                                                            fgkSSDFlexHeight[0]
3915                                                                                            +0.5*fgkSSDFlexHeight[1])
3916                                                                                    };
3917   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3918   static TGeoVolume* laddercablesegmentarbassembly = 
3919                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3920
3921   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3922   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3923
3924   if (laddercablesegmentbboxshape[0] == 0) { 
3925     // Initialise static shapes and volumes 
3926   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3927                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3928                                                                            0.5*fgkSSDFlexWidth[0],
3929                                                                            0.5*fgkSSDLadderCableWidth,
3930                                                                            0.5*fgkSSDFlexHeight[i]); 
3931
3932   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3933                         laddercablesegmentbbox[i] =
3934                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3935                                                                                  laddercablesegmentbboxshape[i],
3936                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3937             fSSDKaptonLadderCableMedium));
3938                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3939                                                                                                                    fColorPolyhamide);
3940   }
3941   
3942   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3943                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3944                                                                                             laddercablesegmentbboxtrans[i]);
3945 /////////////////////////////////////////
3946 // LadderSegmentArb8 Volume
3947 /////////////////////////////////////////
3948   const Int_t kvertexnumber = 4;
3949   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3950   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3951                                                                                                   new TVector3*[kvertexnumber];
3952 //Shape Vertex Positioning
3953   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3954         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3955         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3956                                                                                                                   i*fgkSSDFlexHeight[0]);
3957         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3958                                                                                    +                         fgkSSDFlexHeight[1]
3959                                                                                    +                      i*fgkSSDFlexHeight[0]);
3960         laddercablesegmentvertexposition[i][3] = 
3961                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3962                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3963   }
3964   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3965                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3966   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3967                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3968
3969   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3970                                         GetArbShape(laddercablesegmentvertexposition[i],
3971                                                                 laddercablesegmentwidth[i],
3972                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3973                                                                 laddercablesegmentarbshapename[i]);
3974   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3975                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3976
3977   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3978                          laddercablesegmentarb[i] =
3979                                                    new TGeoVolume(laddercablesegmentarbname[i],
3980                                                                                   laddercablesegmentarbshape[i],
3981                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3982             fSSDKaptonLadderCableMedium)); 
3983                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3984                                                                                                                    fColorPolyhamide);
3985 }
3986   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3987   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3988                                                                                                  90.,90,-90.);   
3989   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3990                                                                                                   0.,90.,0.);    
3991   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3992                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3993                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3994                                                          + fgkSSDFlexWidth[0],0.,0.,
3995                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3996                                                      *(*laddercablesegmentarbrot[0])));
3997   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3998   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3999                                                                                    laddercablesegmentarbcombitrans);
4000   }  // End of static initialisations
4001 /////////////////////////////////////////
4002 // End Ladder Cable Volume
4003 // Note: this part depends explicitly on the length passed as an argument to the function
4004 /////////////////////////////////////////
4005   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4006   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4007                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4008   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4009                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4010                                                                            0.5*ssdendladdercablelength,
4011                                                                            0.5*fgkSSDLadderCableWidth,
4012                                                                            0.5*fgkSSDFlexHeight[i]);
4013   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4014                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4015   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4016   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4017                         ladderendcablesegmentbbox[i] =
4018                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4019                                                                                  ladderendcablesegmentbboxshape[i],
4020                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4021             fSSDKaptonLadderCableMedium));
4022                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4023                                                                                                                    fColorPolyhamide);
4024   }
4025   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4026   ladderendcablesegmentbboxtrans[0] = 
4027                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4028                                                                                            0.5*ssdendladdercablelength,
4029                                                                                            0.5*fgkSSDLadderCableWidth,
4030                                                                                            0.5*fgkSSDFlexHeight[0]);
4031   ladderendcablesegmentbboxtrans[1] = 
4032                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4033                                                                                            0.5*ssdendladdercablelength,
4034                                                                                            0.5*fgkSSDLadderCableWidth,
4035                                                                                            fgkSSDFlexHeight[0]
4036                                                                                            +0.5*fgkSSDFlexHeight[1]);
4037   TGeoVolume* ladderendcablesegmentbboxassembly = 
4038                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4039   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4040                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4041                                                                                             ladderendcablesegmentbboxtrans[i]);
4042 /////////////////////////////////////////
4043   TList* laddercablesegmentlist = new TList();
4044   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4045   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4046   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4047   return laddercablesegmentlist;
4048 }
4049
4050 /////////////////////////////////////////////////////////////////////////////////
4051 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4052   /////////////////////////////////////////////////////////////
4053   // Method generating Ladder Cable Volumes Assemblies    
4054   /////////////////////////////////////////////////////////////
4055   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4056   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4057   for(Int_t i=0; i<n; i++){
4058          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4059                                                         i*(fgkCarbonFiberJunctionWidth),
4060                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4061                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4062     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4063         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4064   }
4065   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4066                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4067                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4068                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4069   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4070   return laddercable;
4071 }
4072 /////////////////////////////////////////////////////////////////////////////////
4073 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4074   /////////////////////////////////////////////////////////////
4075   // Method generating Ladder Cable Volumes Assembly   
4076   /////////////////////////////////////////////////////////////
4077   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4078   char laddercabletransname[100];
4079   for(Int_t i=0; i<n; i++){ 
4080         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4081     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4082         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4083   }
4084   return laddercableassembly;
4085 }
4086 /////////////////////////////////////////////////////////////////////////////////
4087 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4088   /////////////////////////////////////////////////////////////
4089   // Method generating Ladder Cable List Assemblies  
4090   /////////////////////////////////////////////////////////////  
4091   const Int_t kladdercableassemblynumber = 2;
4092   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4093   TGeoVolume* ladderCable[kladdercableassemblynumber];
4094   char laddercableassemblyname[100];
4095   TList* laddercableassemblylist = new TList();
4096   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4097         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4098         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4099         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4100                                          new TGeoCombiTrans((n-1)
4101                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4102                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4103                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4104         laddercableassemblylist->Add(ladderCable[i]);
4105 }
4106   return laddercableassemblylist;
4107 }
4108 ///////////////////////////////////////////////////////////////////////////////
4109 void AliITSv11GeometrySSD::SetLadderSegment(){
4110   /////////////////////////////////////////////////////////////
4111   // Method Generating Ladder Segment Array
4112   /////////////////////////////////////////////////////////////
4113   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4114   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4115   if(!fCreateMaterials) CreateMaterials();
4116   if(!fTransformationMatrices) CreateTransformationMatrices();
4117   if(!fBasicObjects) CreateBasicObjects();
4118   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4119   // Placing Carbon Fiber Support       
4120         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4121                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4122                                                                                         fcarbonfibersupportmatrix[j]);  
4123                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4124                                                                                         fcarbonfibersupportmatrix[j]);
4125   }
4126   // Placing Carbon Fiber Junction
4127     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4128         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4129                                                                    fcarbonfiberjunctionmatrix[j]);
4130   // Placing Carbon Fiber Lower Support
4131         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4132                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4133                                                            fcarbonfiberlowersupportrans[j]);    
4134   // Placing SSD Sensor Support
4135     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4136         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4137                                                                      fssdsensorsupport[1][i],
4138                                                            j+1,fssdsensorsupportmatrix[j]);
4139   // Placing SSD Cooling Tube Support 
4140         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4141                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4142                                                                    fcoolingtubesupportmatrix[j]);
4143   // Placing SSD Cooling Tube  
4144         for(Int_t j=0; j<2; j++)
4145                 for(Int_t k=0; k<2; k++){
4146                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4147                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4148                 }
4149   // Placing SSD Hybrid
4150     switch(i){
4151         case 0: 
4152                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4153                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4154                 break;
4155     case 1:
4156                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4157                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4158                 break;
4159         }
4160         // Placing Cooling Block System
4161     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4162         // Placing SSD Flex
4163         for(Int_t j=0; j<fgkflexnumber; j++){
4164       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4165       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4166         }
4167    }
4168 }
4169 ///////////////////////////////////////////////////////////////////////////////
4170 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4171   /////////////////////////////////////////////////////////////
4172   // Method Generating End Ladder
4173   /////////////////////////////////////////////////////////////
4174   // End Ladder Carbon Fiber Junction 
4175   /////////////////////////////////////////////////////////////
4176   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4177   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4178   if(!fCreateMaterials) CreateMaterials();
4179   if(!fTransformationMatrices) CreateTransformationMatrices();
4180   if(!fBasicObjects) CreateBasicObjects();
4181   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4182         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4183                 fendladdersegment[i]->AddNode(j==2 ? 
4184                                                         fendladdercarbonfiberjunction[i][1] : 
4185                                                         fendladdercarbonfiberjunction[i][0],
4186                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4187   }
4188   /////////////////////////////////////////////////////////////
4189   // End Ladder Carbon Fiber Support 
4190   /////////////////////////////////////////////////////////////
4191   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4192       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4193                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4194                   fendladdercarbonfibermatrix[i][j]);   
4195           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4196                   fendladdercarbonfibermatrix[i][j]);   
4197       }
4198   /////////////////////////////////////////////////////////////
4199   // End Ladder Mounting Block
4200   /////////////////////////////////////////////////////////////
4201   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4202        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4203                                      fendladdermountingblockcombitrans[i]);
4204   /////////////////////////////////////////////////////////////
4205   // End Ladder Mounting Block Clip
4206   /////////////////////////////////////////////////////////////
4207   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4208         for(Int_t j=0; j<2; j++)
4209                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4210                                               fendladdermountingblockclipmatrix[i][j]);
4211   /////////////////////////////////////////////////////////////
4212   // End Ladder Lower Supports
4213   /////////////////////////////////////////////////////////////
4214   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4215                                 fendladderlowersupptrans[0]);
4216   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4217                                 fendladderlowersupptrans[1]);
4218   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4219                                 fendladderlowersupptrans[2]);
4220   /////////////////////////////////////////////////////////////
4221   // End Ladder Cooling Tube Support
4222   /////////////////////////////////////////////////////////////
4223   for(Int_t i=0; i<2; i++) 
4224         for(Int_t j=0; j<(i==0?4:2); j++)   
4225                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4226                                               fendladdercoolingtubesupportmatrix[i][j]);
4227   /////////////////////////////////////////////////////////////
4228   // End Ladder Cooling Tube Support
4229   /////////////////////////////////////////////////////////////
4230 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4231 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4232   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4233   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4234   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4235   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4236   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4237   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4238   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4239   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4240 }
4241 ///////////////////////////////////////////////////////////////////////////////
4242 void AliITSv11GeometrySSD::SetLadder(){
4243   /////////////////////////////////////////////////////////////
4244   // Method Generating Ladder of Layer 5 and 6
4245   /////////////////////////////////////////////////////////////  
4246   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4247                                                                                                 fgkSSDLay6SensorsNumber};
4248   /////////////////////////////////////////////////////////////////////////////                                         
4249   /// Generating Ladder Mother Volume Containing Ladder 
4250   /////////////////////////////////////////////////////////////////////////////          
4251   TGeoXtru* laddershape[fgkladdernumber];       
4252   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4253   const Int_t kmothervertexnumber = 8;  
4254   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4255   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4256   ///////////////////////
4257   // Setting the vertices 
4258   ///////////////////////
4259   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4260                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4261   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4262   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
4263   xmothervertex[0][1] = xmothervertex[0][0];
4264   ymothervertex[0][1] = 0.0;
4265   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4266                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4267   ymothervertex[0][2] = ymothervertex[0][1];
4268   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4269   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4270   xmothervertex[0][4] = -xmothervertex[0][3];
4271   ymothervertex[0][4] = ymothervertex[0][3];
4272   xmothervertex[0][5] = -xmothervertex[0][2];
4273   ymothervertex[0][5] = ymothervertex[0][2];
4274   xmothervertex[0][6] = -xmothervertex[0][1];
4275   ymothervertex[0][6] = ymothervertex[0][1];
4276   xmothervertex[0][7] = -xmothervertex[0][0];
4277   ymothervertex[0][7] = ymothervertex[0][0];
4278   for(Int_t i=0; i<kmothervertexnumber; i++){
4279         xmothervertex[1][i] = xmothervertex[0][i];
4280         ymothervertex[1][i] = ymothervertex[0][i];
4281   }
4282 ///////////////////////////////////////////////////////////////////////////
4283 // Disalignement Mother Volume corrections 25/08/08
4284 ///////////////////////////////////////////////////////////////////////////
4285   TGeoXtru* leftladdershape1[fgkladdernumber];  
4286   TGeoXtru* leftladdershape2[fgkladdernumber];  
4287   TGeoXtru* centersensorladdershape[fgkladdernumber];   
4288   TGeoXtru* rightladdershape1[fgkladdernumber]; 
4289   TGeoXtru* rightladdershape2[fgkladdernumber]; 
4290   for(Int_t i=0; i<fgkladdernumber; i++){
4291     leftladdershape1[i] = new TGeoXtru(2);
4292     leftladdershape2[i] = new TGeoXtru(2);
4293     centersensorladdershape[i] = new TGeoXtru(2);
4294     rightladdershape1[i] = new TGeoXtru(2);
4295     rightladdershape2[i] = new TGeoXtru(2);
4296   }
4297   //////////////////////////////////////
4298   // Setting the names for shapes  
4299   //////////////////////////////////////
4300   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
4301   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
4302   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
4303   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
4304   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
4305   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
4306   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
4307   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
4308   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
4309   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
4310   //////////////////////////////////////
4311   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
4312   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
4313   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
4314   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
4315   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
4316   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
4317   for(Int_t i=0; i<fgkladdernumber; i++) {
4318     for(Int_t j=0; j<kmothervertexnumber; j++){
4319       xcentersensorvertex[i][j] = xmothervertex[i][j];
4320       ycentersensorvertex[i][j] = ymothervertex[i][j];
4321       xend1laddervertex[i][j] = xmothervertex[i][j];
4322       yend1laddervertex[i][j] = ymothervertex[i][j];
4323       xend2laddervertex[i][j] = xmothervertex[i][j];
4324       yend2laddervertex[i][j] = ymothervertex[i][j];
4325     }
4326     // Add some space around sensors to accommodate misalignments
4327     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
4328     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
4329     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
4330     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
4331     
4332     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
4333     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
4334     
4335     // Center Ladder Piece
4336     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
4337                                               ycentersensorvertex[i]);
4338     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4339                                                  + 1.45*fgkSSDMountingBlockWidth);
4340     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
4341                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4342                                                  - 2.4*fgkSSDMountingBlockWidth);
4343
4344     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
4345
4346     // Cuts off first corner (neg x)
4347     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
4348     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
4349     // Cuts off last part (pos x)
4350     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
4351     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
4352
4353     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
4354                                        yend1laddervertex[i]);
4355     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4356     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4357                                          - fgkEndLadderMountingBlockPosition[0]);
4358     
4359     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
4360                                        yend2laddervertex[i]);
4361     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4362                                          - fgkEndLadderMountingBlockPosition[0]); 
4363     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4364                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4365
4366     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4367                                         yend1laddervertex[i]);
4368     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4369                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4370                                         -2.4*fgkSSDMountingBlockWidth);
4371     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4372                                         + fgkEndLadderMountingBlockPosition[1]);
4373
4374     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4375                                         yend2laddervertex[i]);
4376     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4377                                            + fgkEndLadderMountingBlockPosition[1]);
4378     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4379                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4380   }
4381   TGeoCompositeShape* laddershapecontainer[2];
4382   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4383                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4384                                                    "+Lay5CenterSensorContainer"
4385                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4386   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4387                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4388                                                    "+Lay6CenterSensorContainer"
4389                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4390   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4391   for(Int_t i=0; i<fgkladdernumber; i++){
4392     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4393     fladder[i]->SetLineColor(4);
4394   }
4395 ///////////////////////////////////////////////////////////////////////////
4396  if(!fCreateMaterials) CreateMaterials();
4397  if(!fTransformationMatrices) CreateTransformationMatrices();
4398  if(!fBasicObjects) CreateBasicObjects();
4399  SetLadderSegment(); 
4400  SetEndLadderSegment();
4401   for(Int_t i=0; i<fgkladdernumber; i++){
4402         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4403         //////////////////////////                                              
4404         /// Placing Ladder Segment
4405         //////////////////////////              
4406                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4407                                                                      fladdersegment[i==0 ? 1 : 0],
4408                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4409         //////////////////////////                                              
4410         /// Placing SSD Sensor
4411         //////////////////////////              
4412         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4413                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4414                                                         fssdsensormatrix[i][j]);
4415         }
4416         ///////////////////////////////                                         
4417         /// Placing End Ladder Segment
4418         ///////////////////////////////         
4419         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4420         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4421    }
4422 /////////////////////////////////////////////////////////////////////////////                                           
4423 /// Placing Ladder Cables
4424 /////////////////////////////////////////////////////////////////////////////           
4425   Int_t sidecablenumber[2][2];
4426   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4427   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4428   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4429   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4430   Double_t carbonfibertomoduleposition[3];
4431   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4432   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4433                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4434          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4435          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4436          -            fgkSSDSensorCenterSupportThickness[0]);
4437   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4438                                                                  +   0.5*fgkCoolingTubeSupportHeight
4439          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4440   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4441   Double_t ssdendladdercablelength[4];
4442   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4443                                                          + fgkSSDSensorLength
4444                                                          - fgkSSDModuleStiffenerPosition[1]
4445                                                          - fgkSSDStiffenerWidth 
4446                                                          - fgkSSDFlexWidth[0]
4447                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4448   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4449                                                          + fgkSSDModuleStiffenerPosition[1]
4450                                                          + fgkSSDStiffenerWidth
4451                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4452   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4453                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4454                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4455                                                          - kendladdercablecorrection;
4456   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4457                                                          + carbonfibertomoduleposition[1]
4458                                                          - fgkSSDModuleStiffenerPosition[1]
4459                                                          - fgkSSDStiffenerWidth)
4460                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4461   TList* laddercableassemblylist[4];
4462   const Int_t kendladdercablesnumber = 4;
4463   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4464         for(Int_t j=0; j<kendladdercablesnumber; j++){
4465                 laddercableassemblylist[j] = 
4466                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4467                                                                    ssdendladdercablelength[j]);
4468                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4469                                                                         j<2?1:2,fladdercablematrix[i][j]);
4470   }
4471 }
4472 ////////////////////////////////////////////////////////////////////////////////
4473 void AliITSv11GeometrySSD::SetLayer(){
4474 ////////////////////////////////////////////////////////////////////////////////
4475   // Creating Ladder of Layer 5 and Layer 6
4476   /////////////////////////////////////////////////////////////
4477   if(!fCreateMaterials) CreateMaterials();
4478   if(!fTransformationMatrices) CreateTransformationMatrices();
4479   if(!fBasicObjects) CreateBasicObjects();
4480   SetLadder(); // Generating the ladder of Layer5 and Layer6
4481   const Int_t kssdlayladdernumber[fgklayernumber] = 
4482                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4483   /////////////////////////////////////////////////////////////
4484   // Generating mother volumes for Layer5 and Layer6
4485   /////////////////////////////////////////////////////////////
4486   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4487   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4488   Int_t *ladderindex[fgklayernumber];
4489   Int_t index[fgklayernumber] = {8,9};
4490   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4491   for(Int_t i=0; i<fgklayernumber; i++) 
4492         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4493                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4494                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4495                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4496                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4497         }
4498   /////////////////////////////////////////////////////////////
4499   // Deallocating memory
4500   /////////////////////////////////////////////////////////////
4501   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
4502 }
4503 ////////////////////////////////////////////////////////////////////////////////
4504 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4505   /////////////////////////////////////////////////////////////
4506   // Insert the layer 5 in the mother volume. 
4507   /////////////////////////////////////////////////////////////
4508   if (! moth) {
4509     AliError("Can't insert layer5, mother is null!\n");
4510     return;
4511   };
4512   if(!fSSDLayer5) SetLayer();
4513   fMotherVol = moth;
4514   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4515                                                                                 + fgkLay5CenterITSPosition);
4516   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4517  }
4518 ////////////////////////////////////////////////////////////////////////////////
4519 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4520   /////////////////////////////////////////////////////////////
4521   // Insert the layer 6 in the mother volume. 
4522   /////////////////////////////////////////////////////////////
4523   if (! moth) {
4524     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4525     return;
4526   };
4527   if(!fSSDLayer6) SetLayer();
4528   fMotherVol = moth;
4529   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4530                                                                                 + fgkLay6CenterITSPosition);
4531   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4532  }
4533  ////////////////////////////////////////////////////////////////////////////////
4534  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4535   /////////////////////////////////////////////////////////////
4536   // Method generating the Arc structure of Ladder Support 
4537   /////////////////////////////////////////////////////////////
4538   const Int_t kssdlayladdernumber[fgklayernumber] = 
4539                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4540   Double_t mountingsupportedge[fgklayernumber];
4541   Double_t mountingblockratio[fgklayernumber];
4542   Double_t theta[fgklayernumber];
4543   Double_t phi[fgklayernumber];
4544   Double_t psi0[fgklayernumber];
4545   Double_t deltapsi[fgklayernumber];
4546   TVector3* mountingsupportedgevector[fgklayernumber];
4547   for(Int_t i=0; i<fgklayernumber; i++){
4548         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4549     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4550                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4551                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4552                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4553                                                           / kssdlayladdernumber[i])));
4554     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4555     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4556         mountingsupportedgevector[i] = new TVector3();
4557         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4558         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4559                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4560                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4561     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4562     deltapsi[i] = (theta[i]+phi[i])/nedges;
4563   }
4564   TVector3** vertex[fgklayernumber];
4565   TList* vertexlist[fgklayernumber];
4566   Int_t indexedge[fgklayernumber] = {0,0};
4567   for(Int_t i=0; i<fgklayernumber; i++){
4568         vertex[i] = new TVector3*[nedges+1];
4569         vertexlist[i] = new TList();
4570   } 
4571   for(Int_t i=0; i<fgklayernumber; i++){
4572         for(Int_t j=0; j<nedges+1; j++){
4573                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4574                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4575                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4576                 vertexlist[i]->Add(vertex[i][j]);
4577         }
4578         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4579   }
4580   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4581   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4582   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4583   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4584   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4585   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4586   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4587   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4588   for(Int_t i=0; i<fgklayernumber; i++){
4589     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4590     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4591     xcentervertex[i] = new Double_t[indexedge[i]+3];
4592     ycentervertex[i] = new Double_t[indexedge[i]+3];
4593         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4594         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4595         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4596         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4597         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4598                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4599                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4600                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4601                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4602                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4603                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4604                 if(j<indexedge[i]+1){
4605                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4606                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4607                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4608                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4609                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4610                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4611                 }
4612         }
4613         xsidevertex[i][1] = xsidevertex[i][0]; 
4614         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4615         xsidevertex[i][2] = xsidevertex[i][3]; 
4616         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4617         xcentervertex[i][1] = xcentervertex[i][0]; 
4618         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4619         xcentervertex[i][2] = xcentervertex[i][3]; 
4620         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4621         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4622         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4623         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4624         ycenterlowervertex[i][0] = ysidevertex[i][0];
4625         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4626         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4627   }
4628   /////////////////////////////////////////////////////////////
4629   // Building the Arc Structure of Ladder Supports 
4630   /////////////////////////////////////////////////////////////
4631   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4632   TGeoXtru* centermountingsupportshape[fgklayernumber];
4633   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4634   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4635   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4636   TGeoVolume* centermountingblocksupport[fgklayernumber];
4637   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4638   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4639   char sidemountingblockname[100];
4640   char centermountingblockname[100];
4641   char sideladdersupportpiecename[100];
4642   char centerladdersupportpiecename[100];
4643   for(Int_t i=0; i<fgklayernumber; i++){ 
4644         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4645         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4646         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4647         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4648         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4649     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4650                                                                                                 xsidevertex[i],ysidevertex[i]);
4651     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4652                                                                                                          -fgkMountingBlockSupportWidth[0]);
4653     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4654     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4655                                                                           sidemountingblocksupportshape[i],
4656                                                                                   fSSDAlCoolBlockMedium);
4657         sidemountingblocksupport[i]->SetLineColor(9);
4658         centermountingsupportshape[i] = new TGeoXtru(2);
4659     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4660                                                                                                 xcentervertex[i],ycentervertex[i]);
4661         centermountingsupportshape[i]->DefineSection(0,0.);
4662     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4663                                                                                                   -fgkMountingBlockSupportWidth[0]);
4664
4665     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4666                                                                           centermountingsupportshape[i],
4667                                                                                   fSSDAlCoolBlockMedium);
4668         centermountingblocksupport[i]->SetLineColor(9);
4669         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4670     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4671                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4672         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4673                                                                                                          -fgkMountingBlockSupportWidth[0]);
4674     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4675     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4676                                                                           sideladdersupportpieceshape[i],
4677                                                                                   fSSDCarbonFiberMedium);
4678         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4679         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4680     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4681                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4682         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4683     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4684                                                                                                   -fgkMountingBlockSupportWidth[0]);
4685     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4686                                                                           centerladdersupportpieceshape[i],
4687                                                                                   fSSDCarbonFiberMedium);
4688         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4689   }
4690   /////////////////////////////////////////////////////////////
4691   // Building the Up Structure of Ladder Supports 
4692   /////////////////////////////////////////////////////////////
4693   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4694   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4695   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4696   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4697   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4698   //////////////////////////////////////////////////////////
4699   // Setting the volume for TGeoXtru Mounting Block Piece  
4700   //////////////////////////////////////////////////////////
4701   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4702   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4703   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4704   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4705   TGeoVolume* mountingblockpieceup[fgklayernumber];
4706   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4707   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4708   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4709   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4710   char mountingblockpiecedownname[100];
4711   char mountingblockpieceupname[100];
4712   for(Int_t i=0; i<fgklayernumber; i++){
4713     ///////////////////////////
4714     // Mounting Block Down Vertex
4715     ///////////////////////////
4716         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4717     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4718         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4719         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4720                                               + fgkMountingBlockSupportDownHeight 
4721                                               - fgkSSDLadderVerticalDisalignment;
4722         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4723         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4724                                                                                 + fgkSSDMountingBlockHeight[1]
4725                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4726                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4727         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4728         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4729         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4730         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4731         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4732         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4733         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4734         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4735                                                                                 + fgkSSDMountingBlockHeight[2]
4736                                                                                 - fgkSSDMountingBlockHeight[0];
4737         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4738         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4739         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4740         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4741         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4742                                                                                                          mountingblockpiecedownyvertex[i]);
4743         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4744         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4745         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4746                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4747         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4748
4749     ///////////////////////////
4750     // Mounting Block Up Vertex
4751     ///////////////////////////
4752         mountingblockpieceupshape[i] = new TGeoXtru(2);
4753         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4754         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4755         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4756                                                                                 + fgkMountingBlockSupportUpHeight[i]
4757                                               - fgkSSDLadderVerticalDisalignment;
4758         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4759         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4760                                                                                 + fgkSSDMountingBlockHeight[1]
4761                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4762                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4763         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4764         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4765         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4766         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4767         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4768         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4769         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4770         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4771                                                                                 + fgkSSDMountingBlockHeight[2]
4772                                                                                 - fgkSSDMountingBlockHeight[0];
4773         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4774         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4775         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4776         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4777
4778         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4779                                                                                                          mountingblockpieceupyvertex[i]);
4780         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4781         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4782         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4783                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4784         mountingblockpieceup[i]->SetLineColor(fColorG10);
4785  }
4786   ///////////////////////////////////////////////////////////////////
4787   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4788   ///////////////////////////////////////////////////////////////////
4789   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4790   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4791   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4792   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4793   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4794   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4795   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4796   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4797   char mountingblocksupportrapezoidowname[100];
4798   char mountingblocksupportrapezoidupname[100];
4799   Double_t scalefactor = 3./4.;
4800   for(Int_t i=0; i<fgklayernumber; i++){
4801   ////////////////////////////////////////////
4802   // Mounting Block Support Down Trapezoid Vertex 
4803   ////////////////////////////////////////////
4804         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4805         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4806                                                                                                  - mountingsupportedge[i];
4807         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4808         mountingblocksupportrapezoidownxvertex[i][1] = 
4809                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4810         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4811                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4812                                                                                              - mountingblockpiecedownyvertex[i][0]);
4813         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4814         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4815         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4816         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4817         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4818         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4819
4820         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4821                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4822         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4823                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4824         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4825         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4826         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4827                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4828         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4829   ////////////////////////////////////////////
4830   // Mounting Block Support Up Trapezoid Vertex 
4831   ////////////////////////////////////////////
4832         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4833         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4834                                                                                                  - mountingsupportedge[i];
4835         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4836         mountingblocksupportrapezoidupxvertex[i][1] = 
4837                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4838         mountingblocksupportrapezoidupyvertex[i][1] = 
4839                                                                                                mountingblockpieceupyvertex[i][0]
4840                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4841                                                                                              - mountingblockpieceupyvertex[i][0]);
4842         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4843         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4844         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4845         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4846         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4847         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4848
4849         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4850                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4851         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4852                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4853         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4854         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4855         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4856                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4857         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4858   }
4859   ///////////////////////////////////////////////////////////////////
4860   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4861   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4862   Double_t boxoriginup[fgklayernumber][2][3];
4863   Double_t boxorigindown[fgklayernumber][2][3];
4864   char mountingblocksupportboxdownname[100];
4865   char mountingblocksupportboxupname[100];
4866   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4867   mountingblocksupportrot->SetAngles(90.,180.,-90);
4868   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4869   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4870   TGeoHMatrix* laddersupportmatrix[2];
4871   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4872   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4873   /////////////////////////////////////////////////////////////
4874   // Creating Mother Volume for Containment
4875   /////////////////////////////////////////////////////////////
4876   Double_t *xmothervertex[fgklayernumber];
4877   Double_t *ymothervertex[fgklayernumber];
4878   for(Int_t i=0; i<fgklayernumber; i++){
4879         xmothervertex[i] = new Double_t[8];
4880         ymothervertex[i] = new Double_t[8];
4881   }  
4882   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4883   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4884   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4885   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4886   char upmotheladdersupportname[100];
4887   char downmotheladdersupportname[100];
4888   for(Int_t i=0; i<fgklayernumber; i++){
4889         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4890                                                     -  mountingsupportedge[i];
4891         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4892         xmothervertex[i][1] = xmothervertex[i][0];
4893         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4894                                                         + fgkMountingBlockSupportWidth[0];
4895         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4896         ymothervertex[i][2] = ymothervertex[i][1];
4897         xmothervertex[i][3] = xmothervertex[i][2];
4898         ymothervertex[i][3] = -ymothervertex[i][0];
4899         xmothervertex[i][4] = -xmothervertex[i][0];
4900         ymothervertex[i][4] = ymothervertex[i][3];
4901         xmothervertex[i][5] = xmothervertex[i][4];
4902         ymothervertex[i][5] = -ymothervertex[i][1];
4903         xmothervertex[i][6] = -xmothervertex[i][2];
4904         ymothervertex[i][6] = ymothervertex[i][5];
4905         xmothervertex[i][7] = xmothervertex[i][6];
4906         ymothervertex[i][7] = ymothervertex[i][0];
4907
4908         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4909         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4910
4911         downmotherladdersupportshape[i] = new TGeoXtru(2);
4912         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4913         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4914         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4915                                                                    +                       fgkMountingBlockSupportDownHeight
4916                                                                    +                       fgkSSDMountingBlockHeight[1]
4917                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4918                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4919                                                        - fgkSSDLadderVerticalDisalignment);
4920         
4921 //                                                 - fgkSSDModuleVerticalDisalignment);
4922         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4923
4924         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4925                                                                           downmotherladdersupportshape[i],fSSDAir);
4926     upmotherladdersupportshape[i] = new TGeoXtru(2);
4927         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4928         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4929     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4930                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4931                                                                    +                       fgkSSDMountingBlockHeight[1]
4932                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4933                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4934                                                  - fgkSSDLadderVerticalDisalignment);
4935
4936      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4937                                                                                           upmotherladdersupportshape[i],fSSDAir);
4938   }
4939   for(Int_t i=0; i<fgklayernumber; i++){
4940         /////////////////////////
4941         // Setting the box origin
4942         /////////////////////////
4943         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4944         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4945                                                    +  0.5*fgkMountingBlockSupportDownHeight
4946                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4947         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4948                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4949   
4950         boxorigindown[i][1][0] = 0.0;
4951         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4952         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4953                                                    -      fgkMountingBlockSupportWidth[0]);
4954                                                    
4955         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4956         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4957                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4958                                - 0.5*fgkSSDLadderVerticalDisalignment;
4959         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4960                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4961   
4962         boxoriginup[i][1][0] = 0.0;
4963         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4964         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4965                                                  - fgkMountingBlockSupportWidth[0]);
4966   
4967         /////////////////////////
4968     // Setting the boxes    
4969         /////////////////////////
4970         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4971                                                                                  +  fgkSSDMountingBlockLength[0]),
4972                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4973                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4974                                                                                         boxorigindown[i][0]);
4975         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4976                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4977                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4978                                                                                  -  fgkMountingBlockSupportWidth[0]),
4979                                                                                         boxorigindown[i][1]);
4980                                                                                         
4981         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4982                                                                                  +  fgkSSDMountingBlockLength[0]),
4983                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4984                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4985                                                                                         boxoriginup[i][0]);
4986
4987         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4988                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4989                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4990                                                                      -  fgkMountingBlockSupportWidth[0]),
4991                                                                                         boxoriginup[i][1]);
4992         ///////////////////////////////////////
4993         // Adding the Volumes to Mother Volume    
4994         ///////////////////////////////////////
4995         for(Int_t j=0; j<2; j++){
4996                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4997                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4998                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4999                                                                                   mountingblocksupportboxdownshape[i][j],
5000                                                                                   fSSDCarbonFiberMedium);
5001                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
5002                                                                                   mountingblocksupportboxupshape[i][j],
5003                                                                                   fSSDCarbonFiberMedium);
5004                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
5005                 mountingblocksupportboxup[i][j]->SetLineColor(9);
5006                 for(Int_t k=0; k<2; k++){
5007                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
5008                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
5009                 }
5010         }
5011         for(Int_t k=0; k<2; k++){
5012                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
5013                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
5014                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5015                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5016                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
5017                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
5018                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
5019                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
5020                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5021                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5022                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
5023                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
5024         }
5025   }
5026   TList* laddersupportlist = new TList();
5027   laddersupportlist->Add(downmotherladdersupport[0]); 
5028   laddersupportlist->Add(upmotherladdersupport[0]); 
5029   laddersupportlist->Add(downmotherladdersupport[1]); 
5030   laddersupportlist->Add(upmotherladdersupport[1]); 
5031   /////////////////////////////////////////////////////////////
5032   // Deallocating memory
5033   /////////////////////////////////////////////////////////////
5034   for(Int_t i=0; i<fgklayernumber; i++){
5035         for(Int_t j=0; j<nedges+1; j++)
5036                 delete vertex[i][j];
5037         delete mountingsupportedgevector[i];
5038         delete [] vertex[i];
5039         delete vertexlist[i];
5040         delete [] xsidevertex[i];
5041         delete [] ysidevertex[i];
5042         delete [] xcentervertex[i];
5043         delete [] ycentervertex[i];
5044         delete [] xsidelowervertex[i];
5045         delete [] ysidelowervertex[i];
5046         delete [] xcenterlowervertex[i];
5047         delete [] ycenterlowervertex[i];
5048         delete [] xmothervertex[i];
5049         delete [] ymothervertex[i];
5050   }
5051   delete [] xsidevertex;
5052   delete [] ysidevertex;
5053   delete [] xcentervertex;
5054   delete [] ycentervertex;
5055   delete [] xsidelowervertex;
5056   delete [] ysidelowervertex;
5057   delete [] xcenterlowervertex;
5058   delete [] ycenterlowervertex;
5059   delete globalrefladdersupportrot;
5060   delete mountingblocksupportrot;
5061   /////////////////////
5062   return laddersupportlist;     
5063 }
5064  ////////////////////////////////////////////////////////////////////////////////
5065 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
5066 //////////////////////////////////////////
5067 // Method Generating Ladder Support Ring
5068 //////////////////////////////////////////
5069   if(!fCreateMaterials) CreateMaterials();
5070   if(!fTransformationMatrices) CreateTransformationMatrices();
5071   if(!fBasicObjects) CreateBasicObjects();
5072   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5073   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5074     const Int_t kssdlayladdernumber[fgklayernumber] = 
5075                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5076   Double_t mountingsupportedge[fgklayernumber];
5077   Double_t mountingblockratio[fgklayernumber];
5078   Double_t theta[fgklayernumber];
5079   Double_t phi[fgklayernumber];
5080   for(Int_t i=0; i<fgklayernumber; i++){
5081         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5082     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5083                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
5084                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5085                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5086                                                           / kssdlayladdernumber[i])));
5087     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5088                          / fgkMountingBlockSupportRadius[i]);
5089     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5090   }
5091   TGeoRotation* globalrot = new TGeoRotation();
5092   globalrot->SetAngles(0.,-90.,0.); 
5093   TGeoRotation** laddersupportrot[fgklayernumber];
5094   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5095   for(Int_t i=0; i<fgklayernumber; i++){                
5096         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5097         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5098         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5099                 laddersupportrot[i][j] = new TGeoRotation();
5100                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5101                 switch(i){
5102                         case 0: //Ladder of Layer5  
5103                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5104                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5105                                                                             laddersupportmatrix[i][j]); 
5106                         break;
5107                         case 1: //Ladder of Layer6 
5108                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5109                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5110                                                                               laddersupportmatrix[i][j]); 
5111                         break;
5112                 }
5113     }
5114   }
5115   /////////////////////////////////////////////////////////////
5116   // Creating Lower Ladder Support 
5117   /////////////////////////////////////////////////////////////
5118   TVector3** ringsupportvertex[fgklayernumber];         
5119   Double_t angle = 360./nedges;
5120   for(Int_t i=0; i<fgklayernumber; i++){
5121     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5122         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5123                                                         *                          TMath::Cos(theta[i]));
5124         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5125                                                         -                          mountingsupportedge[i],
5126                                                                                    ringsupportvertex[i][0]->Y());
5127         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5128                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5129     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5130         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5131            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5132            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5133            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5134            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5135         }
5136         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5137     for(Int_t j=0; j<nedges+1; j++){
5138                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5139                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5140                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5141         }
5142   }
5143   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5144   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5145   for(Int_t i=0; i<fgklayernumber; i++){
5146         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5147         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5148         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5149                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5150                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5151         }
5152   }
5153 ////////////////////////////////////////////////////////////////////////////////
5154 // Start Corrections 13/06/08
5155 ////////////////////////////////////////////////////////////////////////////////
5156   char lowerladderpconsupportname[100];
5157   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5158   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5159   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5160   Double_t lowerladderpconradiusmax[fgklayernumber];
5161   Double_t lowerladderpconradiusmin[fgklayernumber];
5162   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5163   lowerladdersupportrot->SetAngles(90.,180.,-90);
5164   for(Int_t i=0; i<fgklayernumber; i++){
5165         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5166                                                                 *                          TMath::Cos(theta[i]);
5167     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5168   } 
5169   for(Int_t i=0; i<fgklayernumber; i++){
5170 ///////////////////////////  Modified Version ?///////////////////
5171     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5172         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5173                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5174                                                          lowerladderpconradiusmax[i]);
5175         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5176         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5177     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5178         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5179         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5180  }
5181 ////////////////////////////////////////////////////////////////////////////////
5182 // End Corrections 13/06/08
5183 ////////////////////////////////////////////////////////////////////////////////
5184   /*char lowerladdersupportname[30];
5185   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5186   TGeoVolume* lowerladdersupport[fgklayernumber];
5187   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5188   lowerladdersupportrot->SetAngles(90.,180.,-90);
5189   for(Int_t i=0; i<fgklayernumber; i++){
5190         lowerladdersupportshape[i] = new TGeoXtru(2);
5191         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5192                                                                                           xmothervertex[i],ymothervertex[i]);
5193         lowerladdersupportshape[i]->DefineSection(0,0.);
5194     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5195         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5196     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5197                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5198         lowerladdersupport[i]->SetLineColor(fColorAl);
5199         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5200         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5201   }*/
5202   /////////////////////////////////////////////////////////////
5203   // Deallocating memory
5204   /////////////////////////////////////////////////////////////
5205   for(Int_t i=0; i<fgklayernumber; i++){
5206         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5207                 delete ringsupportvertex[i][j];
5208         delete [] ringsupportvertex[i];
5209   }
5210   for(Int_t i=0; i<fgklayernumber; i++){
5211         delete [] xmothervertex[i];
5212         delete [] ymothervertex[i];
5213   }
5214   delete [] xmothervertex;
5215   delete [] ymothervertex; 
5216   delete globalrot;
5217   for(Int_t i=0; i<fgklayernumber; i++){
5218         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5219                 delete laddersupportrot[i][j];
5220         delete [] laddersupportrot[i];
5221   }
5222  }  
5223  ////////////////////////////////////////////////////////////////////////////////
5224  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5225   /////////////////////////////////////////////////////////////
5226   // Method generating Endcap CoverPlate
5227   /////////////////////////////////////////////////////////////
5228   // Holes Definition 
5229   ///////////////////
5230   Int_t nendcapcoverplateholedges = 30;
5231   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5232   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5233                                                           0.5*fgkEndCapCoverPlateThickness};
5234   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5235                                                                                                               nendcapcoverplateholedges,holesection);
5236   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5237                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5238   endcapcoverplatesmallhole->SetLineColor(6);
5239   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5240                                                                                                               nendcapcoverplateholedges,holesection);
5241   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5242                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5243   endcapcoverplatebighole->SetLineColor(6);
5244   //////////////////////////
5245   // Screw Piece Definition 
5246   //////////////////////////
5247   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5248   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5249                                                                                                       CosD(0.5*smallscrewangle),
5250                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5251   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5252                                                                                                 endcapsmallscrewpieceshape,
5253                                                                                                 fSSDCoolingTubePhynox);
5254   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5255   ///////////////////
5256   // Box Definition 
5257   ///////////////////
5258   TGeoBBox* endcapcoverplateboxshape[4];
5259   TGeoVolume* endcapcoverplatebox[4];
5260   Double_t boxorigin[5][3];
5261   boxorigin[0][0] = 0.;
5262   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5263   boxorigin[0][2] = 0.;
5264
5265   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5266   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5267   boxorigin[1][2] = 0.;
5268
5269   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5270                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5271   boxorigin[2][1] = boxorigin[1][1];
5272   boxorigin[2][2] = 0.;
5273
5274   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5275                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5276   boxorigin[3][1] = boxorigin[1][1];
5277   boxorigin[3][2] = 0.;
5278
5279   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5280                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5281                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5282                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5283
5284   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5285                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5286                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5287                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5288                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5289
5290   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5291                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5292                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5293                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5294                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5295
5296   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5297                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5298                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5299                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5300                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5301   
5302   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5303                                                                            fSSDAlCoolBlockMedium);
5304   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5305                                                                            fSSDAlCoolBlockMedium);
5306   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5307                                                                            fSSDAlCoolBlockMedium);
5308   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5309                                                                            fSSDAlCoolBlockMedium);
5310   endcapcoverplatebox[0]->SetLineColor(6);
5311   endcapcoverplatebox[1]->SetLineColor(6);
5312   endcapcoverplatebox[2]->SetLineColor(6);
5313   endcapcoverplatebox[3]->SetLineColor(6);
5314   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5315   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5316                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5317                                                                                         0.5*fgkEndCapCoverPlateThickness,
5318                                                                                         endcapfillingboxorigin);
5319   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5320                                                                            fSSDAlCoolBlockMedium);
5321   endcapfillingbox->SetLineColor(6);
5322   ////////////////////////////
5323   // Contour shape Definition 
5324   ////////////////////////////
5325   const Int_t kcontourvertexnumber = 10;
5326   Double_t xcontourvertex[kcontourvertexnumber];
5327   Double_t ycontourvertex[kcontourvertexnumber];
5328   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5329   xcontourvertex[1] = xcontourvertex[0];
5330   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5331   xcontourvertex[3] = xcontourvertex[2];
5332   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5333   xcontourvertex[5] = xcontourvertex[4];
5334   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5335   xcontourvertex[7] = xcontourvertex[6];
5336   xcontourvertex[8] = xcontourvertex[4];
5337   xcontourvertex[9] = xcontourvertex[8];
5338   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5339                                         - (kendcapcoverplatesmallholenumber[1]-1)
5340                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5341   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5342                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5343   ycontourvertex[2] = ycontourvertex[1];
5344   ycontourvertex[3] = ycontourvertex[0];
5345   ycontourvertex[4] = ycontourvertex[3];
5346   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5347   ycontourvertex[6] = ycontourvertex[5];
5348   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5349                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5350                                         + fgkEndCapCoverPlateSmallHoleRadius;
5351   ycontourvertex[8] = ycontourvertex[7];
5352   ycontourvertex[9] = ycontourvertex[0];
5353
5354   Double_t xboxin, dxboxin, yboxin, dyboxin;
5355   Double_t xboxout, dxboxout, yboxout, dyboxout;
5356   Double_t coordmin, coordmax;
5357   coordmin = -fgkEndCapCoverPlateLength[0];
5358   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5359   xboxout = 0.5*(coordmin+coordmax);
5360   dxboxout = 0.5*(coordmax-coordmin);
5361   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5362                                         - (kendcapcoverplatesmallholenumber[1]-1)
5363                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5364   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5365                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5366   yboxout = 0.5*(coordmin+coordmax);
5367   dyboxout = 0.5*(coordmax-coordmin);
5368   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5369   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5370   xboxin = 0.5*(coordmin+coordmax);
5371   dxboxin = 0.5*(coordmax-coordmin);
5372   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5373   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5374                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5375                                         + fgkEndCapCoverPlateSmallHoleRadius;
5376   yboxin = 0.5*(coordmin+coordmax);
5377   dyboxin = 0.5*(coordmax-coordmin);
5378   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5379   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5380                                                          xboxout, yboxout, 0.);
5381   trendCapCoverPlateContourboxout->RegisterYourself();
5382   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5383   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5384                                                          xboxin, yboxin, 0.);
5385   trendCapCoverPlateContourboxin->RegisterYourself();
5386   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5387         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5388
5389   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5390                                                                            fSSDAlCoolBlockMedium);
5391   contour->SetLineColor(6);
5392   /////////////////////////////
5393   // Hole Contour Shape Definition 
5394   ////////////////////////////
5395   coordmin = xcontourvertex[0];
5396   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5397   xboxout = 0.5*(coordmin+coordmax);
5398   dxboxout = 0.5*(coordmax-coordmin);
5399   coordmin = ycontourvertex[1];
5400   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5401   yboxout = 0.5*(coordmin+coordmax);
5402   dyboxout = 0.5*(coordmax-coordmin);
5403   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5404                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5405   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5406   xboxin = 0.5*(coordmin+coordmax);
5407   dxboxin = 0.5*(coordmax-coordmin);
5408   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5409                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5410   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5411   yboxin = 0.5*(coordmin+coordmax);
5412   dyboxin = 0.5*(coordmax-coordmin);
5413   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5414   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5415                                                          xboxout, yboxout, 0.);
5416   trendCapCoverPlateContourboxout1->RegisterYourself();
5417   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5418   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5419                                                          xboxin, yboxin, 0.);
5420   trendCapCoverPlateContourboxin1->RegisterYourself();
5421   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5422         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5423
5424
5425   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5426   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5427   xboxout = 0.5*(coordmin+coordmax);
5428   dxboxout = 0.5*(coordmax-coordmin);
5429   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5430                                                    - fgkEndCapCoverPlateWidth[0]);
5431   coordmax = ycontourvertex[0];
5432   yboxout = 0.5*(coordmin+coordmax);
5433   dyboxout = 0.5*(coordmax-coordmin);
5434   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5435                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5436   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5437   xboxin = 0.5*(coordmin+coordmax);
5438   dxboxin = 0.5*(coordmax-coordmin);
5439   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5440                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5441                                                    - fgkEndCapCoverPlateWidth[0]
5442                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5443   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5444   yboxin = 0.5*(coordmin+coordmax);
5445   dyboxin = 0.5*(coordmax-coordmin);
5446   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5447   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5448                                                          xboxout, yboxout, 0.);
5449   trendCapCoverPlateContourboxout2->RegisterYourself();
5450   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5451   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5452                                                          xboxin, yboxin, 0.);
5453   trendCapCoverPlateContourboxin2->RegisterYourself();
5454   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5455         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5456   
5457 //  const Int_t kholecontourvertexnumber = 10;
5458
5459   Double_t xholecontourvertex[2][kcontourvertexnumber];
5460   Double_t yholecontourvertex[2][kcontourvertexnumber];
5461   xholecontourvertex[0][0] = xcontourvertex[0];
5462   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5463   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5464   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5465   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5466                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5467                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5468   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5469   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5470                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5471   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5472   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5473   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5474   
5475   yholecontourvertex[0][0] = ycontourvertex[1];
5476   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5477   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5478   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5479   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5480   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5481                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5482   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5483   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5484   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5485   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5486
5487   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5488   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5489   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5490   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5491   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5492                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5493                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5494   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5495   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5496                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5497   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5498   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5499   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5500   
5501   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5502                                                    - fgkEndCapCoverPlateWidth[0]);
5503   yholecontourvertex[1][1] = ycontourvertex[0];
5504   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5505   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5506   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5507   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5508                                                    - fgkEndCapCoverPlateWidth[0]
5509                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5510   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5511   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5512   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5513   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5514
5515   TGeoVolume* holecontour[2];
5516   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5517                                                                   fSSDAlCoolBlockMedium);
5518   holecontour[0]->SetLineColor(6);
5519   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5520                                                                   fSSDAlCoolBlockMedium);
5521   holecontour[1]->SetLineColor(6);
5522   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5523                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5524   TGeoTranslation*  bigholetrans[3];
5525   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5526                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5527   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5528                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5529                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5530   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5531                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5532   /////////////////////////////////
5533   // Mother Volume Xtru Definition 
5534   /////////////////////////////////
5535   const Int_t kmothervertexnumber = 12;
5536   Double_t xmothervertex[kmothervertexnumber];  
5537   Double_t ymothervertex[kmothervertexnumber];  
5538   xmothervertex[0]  = xcontourvertex[0];
5539   xmothervertex[1]  = xmothervertex[0];
5540   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5541   xmothervertex[3]  = xmothervertex[2];
5542   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5543   xmothervertex[5]  = xmothervertex[4];
5544   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5545   xmothervertex[7]  = xmothervertex[6];
5546   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5547                                         + fgkEndCapCoverPlateLength[2]; 
5548   xmothervertex[9]  = xmothervertex[8];
5549   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5550   xmothervertex[11] = xmothervertex[10];
5551   
5552   ymothervertex[0]  = ycontourvertex[0];
5553   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5554   ymothervertex[2]  = ymothervertex[1];
5555   ymothervertex[3]  = ycontourvertex[1];
5556   ymothervertex[4]  = ymothervertex[3];
5557   ymothervertex[5]  = ymothervertex[1];
5558   ymothervertex[6]  = ymothervertex[5];
5559   ymothervertex[7]  = ymothervertex[0];
5560   ymothervertex[8]  = ymothervertex[7];
5561   ymothervertex[9]  = ymothervertex[8]
5562                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5563   ymothervertex[10] = ymothervertex[9];
5564   ymothervertex[11] = ymothervertex[8];
5565   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5566   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5567   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5568   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5569   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5570   ////////////////////////////////////////
5571   // Adding Nodes
5572   ////////////////////////////////////////
5573 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5574   TGeoTranslation*** endcapcoverplatesmallholetrans;
5575   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5576   Double_t transx[4] = {0,
5577                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5578                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5579                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5580                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5581                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5582   Int_t index = 0;
5583   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5584         endcapcoverplatesmallholetrans[i] = 
5585                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5586     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5587                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5588             endcapcoverplatesmallholetrans[i][j] = 
5589                 new TGeoTranslation(transx[i],
5590                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5591             if(index!=10){ 
5592                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5593                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5594                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5595                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5596                 }
5597                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5598                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5599                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5600     }
5601   }
5602   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5603   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5604   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5605   mothercoverplate->AddNode(endcapfillingbox,1);
5606   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5607   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5608   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5609   mothercoverplate->AddNode(holecontour[0],1);
5610   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5611   mothercoverplate->AddNode(holecontour[1],1);  
5612   mothercoverplate->AddNode(contour,1);
5613   /////////////////////////////////
5614   return mothercoverplate;      
5615  }
5616  ////////////////////////////////////////////////////////////////////////////////
5617  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5618   /////////////////////////////////////////////////////////////
5619   // Getting EndCap Cooling Tube 
5620   /////////////////////////////////////////////////////////////
5621   TGeoTorus* endcapcoolingtubetorushape[5];
5622   TGeoVolume* endcapcoolingtubetorus[5];
5623   TGeoTube* endcapcoolingtubeshape[4];
5624   TGeoVolume* endcapcoolingtube[4];
5625   char endcapcoolingtubetorusname[100];
5626   char endcapcoolingtubename[100];
5627   TGeoTorus* endcapcoolingwatertubetorushape[5];
5628   TGeoVolume* endcapcoolingwatertubetorus[5];
5629   TGeoTube* endcapcoolingwatertubeshape[4];
5630   TGeoVolume* endcapcoolingwatertube[4];
5631   char endcapcoolingwatertubetorusname[100];
5632   char endcapcoolingwatertubename[100];
5633   for(Int_t i=0; i<5; i++){
5634         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5635         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5636         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5637         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5638         if(i==3){
5639                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5640                                                                                 fgkEndCapCoolingTubeRadiusMin,
5641                                                                                 fgkEndCapCoolingTubeRadiusMax,
5642                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5643                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5644                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5645                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5646     }
5647         else{
5648                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5649                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5650                                                                            fgkEndCapCoolingTubeRadiusMin,
5651                                                                            fgkEndCapCoolingTubeRadiusMax,
5652                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5653                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5654                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5655                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5656                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5657         }
5658         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5659                                                                                            endcapcoolingtubetorushape[i],
5660                                                                                            fSSDCoolingTubePhynox);
5661         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5662                                                                                                         endcapcoolingwatertubetorushape[i],
5663                                                                                                         fSSDCoolingTubeWater);
5664     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5665     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5666     if(i<4){
5667                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5668                                                                   fgkEndCapCoolingTubeRadiusMax,
5669                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5670                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5671                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5672         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5673                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5674         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5675                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5676                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5677                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5678         }
5679   }
5680   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5681   /////////////////////////////////////////
5682   // Transformation for Volume Positioning 
5683   /////////////////////////////////////////
5684   TGeoCombiTrans* coolingtubecombitrans[6];
5685   TGeoRotation* coolingtuberot[8];
5686   TGeoTranslation* coolingtubetrans[6];
5687   TGeoHMatrix* coolingtubematrix[4];
5688   TGeoCombiTrans* torustubecombitrans[4];
5689   TGeoRotation* torustuberot[7];
5690   TGeoTranslation* torustubetrans[4];
5691   TGeoHMatrix* torustubematrix[5];
5692   TGeoCombiTrans* coolingwatertubecombitrans[6];
5693   TGeoRotation* coolingwatertuberot[8];
5694   TGeoTranslation* coolingwatertubetrans[6];
5695   TGeoHMatrix* coolingwatertubematrix[4];
5696   TGeoCombiTrans* toruswatertubecombitrans[4];
5697   TGeoRotation* toruswatertuberot[7];
5698   TGeoTranslation* toruswatertubetrans[4];
5699   TGeoHMatrix* toruswatertubematrix[5];
5700   for(Int_t i=0; i<8; i++){
5701     if(i<6){
5702          coolingtubetrans[i] = new TGeoTranslation();
5703          coolingwatertubetrans[i] = new TGeoTranslation();
5704     }
5705     if(i<8){
5706          coolingtuberot[i] = new TGeoRotation();
5707          coolingwatertuberot[i] = new TGeoRotation();
5708     }
5709     if(i<4){
5710          torustubetrans[i] = new TGeoTranslation();
5711          toruswatertubetrans[i] = new TGeoTranslation();
5712     }
5713     if(i<7){
5714          torustuberot[i] = new TGeoRotation();
5715          toruswatertuberot[i] = new TGeoRotation();
5716         }
5717   }
5718   /////////////////////////////////////////
5719   // Transformation for Inox Volume Positioning 
5720   /////////////////////////////////////////
5721   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5722                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5723   coolingtuberot[0]->SetAngles(0.,90.,0.);
5724   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5725                                                                                                 *coolingtuberot[0]);
5726                                                                                                 
5727   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5728   coolingtuberot[1]->SetAngles(0.,90.,0.);
5729   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5730                                                                                                 *coolingtuberot[1]);
5731
5732   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5733                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5734                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5735                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5736                                                                           0.);
5737   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5738   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5739                                                                                                 *coolingtuberot[2]);
5740
5741   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5742                                            *                             (*coolingtubecombitrans[1]));
5743
5744   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5745                                                                          endcapcoolingtubeshape[1]->GetDz());
5746   torustuberot[0]->SetAngles(0.,90.,0.); 
5747   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5748
5749   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5750
5751   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5752                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5753   coolingtuberot[3]->SetAngles(0.,90.,0.);
5754   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5755                                                                                                 *coolingtuberot[3]);
5756   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5757   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5758   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5759   
5760   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5761                                                                         endcapcoolingtubeshape[2]->GetDz());
5762   torustuberot[1]->SetAngles(0.,90.,0.); 
5763   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5764   torustuberot[2]->SetAngles(180.,0.,0.); 
5765   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5766   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5767
5768   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5769                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5770   torustuberot[3]->SetAngles(0.,90.,0.); 
5771   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5772   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5773   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5774   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5775
5776   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5777                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5778   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5779   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5780                                                                                                 *coolingtuberot[5]);
5781   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5782   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5783   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5784   
5785   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5786                                                                         endcapcoolingtubeshape[0]->GetDz());
5787   torustuberot[5]->SetAngles(0.,90.,0.); 
5788   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5789   torustuberot[6]->SetAngles(-90.,0.,0.); 
5790   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5791   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5792   
5793   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5794                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5795   coolingtuberot[6]->SetAngles(0.,90.,0.);
5796   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5797                                                                                                 *coolingtuberot[6]);
5798   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5799   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5800   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5801     /////////////////////////////////////////
5802   // Transformation for Water Volume Positioning 
5803   /////////////////////////////////////////
5804   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5805                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5806   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5807   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5808                                                                                                      *coolingwatertuberot[0]);
5809
5810   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5811   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5812   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5813                                                                                                      *coolingwatertuberot[1]);
5814
5815   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5816                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5817                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5818                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5819                                                                               0.);
5820   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5821   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5822                                                                                                     *coolingwatertuberot[2]);
5823
5824   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5825                                            *                                 (*coolingwatertubecombitrans[1]));
5826                                            
5827   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5828                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5829   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5830   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5831                                                                                                    *toruswatertuberot[0]);
5832
5833   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5834                                                   *                                     (*toruswatertubecombitrans[0]));
5835
5836   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5837                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5838   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5839   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5840                                                                                                      *coolingwatertuberot[3]);
5841   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5842   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5843                                                         *                                 (*coolingwatertubecombitrans[3]));
5844   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5845
5846   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5847                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5848   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5849   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5850                                                                                                    *toruswatertuberot[1]);
5851   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5852   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5853                                                   *                 (*toruswatertubecombitrans[1]));
5854   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5855   
5856   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5857                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5858   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5859   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5860                                                                                                    *toruswatertuberot[3]);
5861   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5862   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5863                                                   *                                     (*toruswatertubecombitrans[2]));
5864   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5865
5866   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5867                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5868   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5869   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5870                                                                                                      *coolingwatertuberot[5]);
5871   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5872   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5873                                                         *                                 (*coolingwatertubecombitrans[4]));
5874   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5875   
5876   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5877                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5878   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5879   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5880                                                                                                    *toruswatertuberot[5]);
5881   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5882   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5883                                                   *                 (*toruswatertubecombitrans[3]));
5884   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5885   
5886   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5887                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5888   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5889   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5890                                                                                                      *coolingwatertuberot[6]);
5891   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5892   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5893                                                         *                                 (*coolingwatertubecombitrans[5]));
5894   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5895   /////////////////////////////////////////
5896   // Positioning Volumes
5897   /////////////////////////////////////////
5898   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5899   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5900   
5901   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5902   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5903
5904   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5905   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5906  
5907   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5908   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5909
5910   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5911   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5912
5913   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5914   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5915
5916   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5917   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5918
5919   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5920   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5921   
5922   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5923   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5924  
5925   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5926   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5927   /////////////////////////////////////////////////////////////
5928   // Deallocating memory
5929   /////////////////////////////////////////////////////////////
5930   for(Int_t i=0; i<8; i++){
5931     if(i<6){
5932          delete coolingtubetrans[i];
5933          delete coolingwatertubetrans[i];
5934          if(i!=0){
5935           delete coolingtubecombitrans[i];
5936           delete coolingwatertubecombitrans[i];
5937          }
5938         }
5939     if(i<8){
5940           delete coolingtuberot[i];
5941           delete coolingwatertuberot[i];
5942     }
5943     if(i<4){
5944                 delete torustubetrans[i];
5945                 delete toruswatertubetrans[i];
5946                 delete torustubecombitrans[i];
5947                 delete toruswatertubecombitrans[i];
5948         } 
5949     if(i<7){
5950          delete torustuberot[i];
5951          delete toruswatertuberot[i];
5952         }
5953   }
5954   /////////////////////////////////////////////////////////////
5955   return endcapcoolingtubemother;
5956  }
5957  ////////////////////////////////////////////////////////////////////////////////
5958  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5959   /////////////////////////////////////////////////////////////
5960   // Getting EndCap Cover Side 
5961   /////////////////////////////////////////////////////////////
5962   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5963   const Int_t kvertexnumber = 15; 
5964   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5965   xvertex[0]  = 0.0;
5966   xvertex[1]  = xvertex[0];
5967   xvertex[2]  = fgkEndCapSideCoverLength[0];
5968   xvertex[3]  = fgkEndCapSideCoverLength[1];
5969   xvertex[4]  = xvertex[3];
5970   xvertex[5]  = fgkEndCapSideCoverLength[2];
5971   xvertex[6]  = xvertex[5];
5972   xvertex[7]  = xvertex[2];
5973   xvertex[8]  = xvertex[7];
5974   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5975   xvertex[10] = xvertex[9];
5976   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5977                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5978                           * fgkEndCapSideCoverLength[4];
5979   xvertex[12] = xvertex[11];
5980   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5981                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5982                           * fgkEndCapSideCoverLength[4];
5983   xvertex[14] = xvertex[13];
5984   yvertex[0]  = 0.0;
5985   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5986   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5987   yvertex[3]  = yvertex[2];
5988   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5989   yvertex[5]  = yvertex[4];
5990   yvertex[6]  = yvertex[0];
5991   yvertex[7]  = yvertex[6];
5992   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5993   yvertex[9]  = yvertex[8];
5994   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5995   yvertex[11] = yvertex[10];
5996   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5997   yvertex[13] = yvertex[12];
5998   yvertex[14] = yvertex[6];
5999   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
6000   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
6001   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
6002   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
6003   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
6004   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
6005   endcapsidecovershapein->SetName("endcapsidecovershapein");
6006   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
6007   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
6008   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
6009
6010
6011   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
6012   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
6013                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
6014   endcapsidecover->SetLineColor(fColorPhynox);
6015   ////////////////////////////////////////////
6016   // Defininition of Mother Volume
6017   ////////////////////////////////////////////
6018   const Int_t kmothervertexnumber = 7;
6019   Double_t xmothervertex[kmothervertexnumber]; 
6020   Double_t ymothervertex[kmothervertexnumber]; 
6021   for(Int_t i=0; i<kmothervertexnumber; i++){
6022         xmothervertex[i] = xvertex[i];
6023         ymothervertex[i] = yvertex[i];
6024   }
6025   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
6026   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
6027   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
6028   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
6029   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
6030                                                                 endcapsidecovermothershape,fSSDAir);
6031   ////////////////////////////////////////////
6032   endcapsidecovermother->AddNode(endcapsidecover,1);
6033   TGeoBBox* endcapsidecoverboxshape[4];
6034   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
6035                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
6036                                                                0.5*fgkEndCapSideCoverLength[4],
6037                                                                    0.5*fgkEndCapSideCoverThickness); 
6038   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
6039                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
6040                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
6041                                                          -     fgkEndCapSideCoverLength[4]),
6042                                                                    0.5*fgkEndCapSideCoverThickness); 
6043   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
6044                                                                0.5*fgkEndCapSideCoverLength[4],
6045                                                                    0.5*fgkEndCapSideCoverThickness); 
6046   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
6047                                                                0.5*fgkEndCapSideCoverWidth[5],
6048                                                                    0.5*fgkEndCapSideCoverThickness); 
6049   TGeoVolume* endcapsidecoverbox[4];
6050   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
6051   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
6052   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
6053   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
6054   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
6055 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
6056   TGeoTranslation** endcapsidecoverboxtrans;
6057   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
6058   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
6059                                                          +                                         fgkEndCapSideCoverLength[0],
6060                                                                                                    endcapsidecoverboxshape[0]->GetDY()
6061                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
6062   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
6063                                                          +                     xvertex[11],
6064                                                                                                    endcapsidecoverboxshape[1]->GetDY()
6065                                                          +                     yvertex[12],0.);
6066   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
6067                                                          +                     xvertex[11],
6068                                                                                                    endcapsidecoverboxshape[2]->GetDY()
6069                                                          +                     yvertex[12]
6070                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
6071                                                          +                     fgkEndCapSideCoverWidth[5],0.);
6072   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
6073   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
6074   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
6075   for(Int_t i=0; i<2; i++)
6076         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
6077                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
6078                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
6079                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6080                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6081                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
6082                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
6083                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
6084         }
6085   for(Int_t i=0; i<2; i++)
6086         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
6087                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
6088                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
6089                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6090                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6091                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
6092                                                         +fgkEndCapSideCoverLength[4]),0.0);
6093                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
6094                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
6095                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
6096                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
6097         }
6098         return endcapsidecovermother;
6099  } 
6100  ////////////////////////////////////////////////////////////////////////////////
6101  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
6102  ////////////////////////////////////////////////////////////////////////////////
6103  // Method returning Interface Card A, Interface Card B, Supply Card 
6104  ////////////////////////////////////////////////////////////////////////////////
6105  /////////////////////
6106  // Supply Card
6107  /////////////////////
6108  // Electronic Board Back Al Plane
6109  const Int_t kelectboardbackvertexnumber = 8;
6110  Double_t xelectboardback[kelectboardbackvertexnumber];
6111  Double_t yelectboardback[kelectboardbackvertexnumber];
6112  xelectboardback[0] = 0.0;
6113  xelectboardback[1] = xelectboardback[0];
6114  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
6115  xelectboardback[3] = xelectboardback[2];
6116  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
6117  xelectboardback[5] = xelectboardback[4];
6118  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
6119  xelectboardback[7] = xelectboardback[6];
6120  
6121  yelectboardback[0] = 0.0;
6122  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
6123  yelectboardback[2] = yelectboardback[1];
6124  yelectboardback[3] = yelectboardback[0];
6125  yelectboardback[4] = yelectboardback[3];
6126  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
6127  yelectboardback[6] = yelectboardback[5];
6128  yelectboardback[7] = yelectboardback[4];
6129  TGeoXtru* electboardbackshape = new TGeoXtru(2);
6130  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
6131                                                                         xelectboardback,yelectboardback); 
6132  electboardbackshape->DefineSection(0,0.0);
6133  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
6134  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
6135                                                                                          electboardbackshape,fSSDSupportRingAl);
6136  electboardback->SetLineColor(fColorAl);
6137  // Electronic Board Kapton Layer
6138  const Int_t kelectlayervertexnumber = 8;
6139  Double_t xelectlayer[kelectlayervertexnumber];
6140  Double_t yelectlayer[kelectlayervertexnumber];
6141  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
6142  xelectlayer[1] = xelectlayer[0];
6143  xelectlayer[2] = fgkEndCapCardElectBoardLength;
6144  xelectlayer[3] = xelectlayer[2];
6145  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
6146      
6147  yelectlayer[0] = 0.0;
6148  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
6149  yelectlayer[2] = yelectlayer[1];
6150  yelectlayer[3] = yelectlayer[0];
6151  yelectlayer[4] = yelectlayer[3];
6152  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
6153  yelectlayer[6] = yelectlayer[5];
6154  yelectlayer[7] = yelectlayer[4];
6155  TGeoXtru* electlayershape = new TGeoXtru(2);
6156  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
6157  electlayershape->DefineSection(0,0.0);
6158  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
6159  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6160                                                                                          electlayershape,fSSDKaptonFlexMedium);
6161  electlayer->SetLineColor(fColorKapton);
6162  // JMD Connector Female
6163  const Int_t kjmdconnectorvertexnumber = 6;
6164  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6165  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6166  xjmdconnectorvertex[0] = 0.0; 
6167  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6168  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6169  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6170  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6171  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6172
6173  yjmdconnectorvertex[0] = 0.0; 
6174  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6175  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6176  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6177  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6178  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6179  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6180  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6181                                                                   yjmdconnectorvertex); 
6182  jmdconnectorshape->DefineSection(0,0.0);
6183  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6184  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6185                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6186  jmdconnector->SetLineColor(fColorG10);
6187  // Top Cable Connector
6188  const Int_t kcableconnectorvertexnumber = 8;
6189  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6190  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6191  xconnectorvertex[0] = 0.0;
6192  xconnectorvertex[1] = xconnectorvertex[0];
6193  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6194  xconnectorvertex[3] = xconnectorvertex[2];
6195  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6196                                          - fgkEndCapCardCableConnectorLength[2];
6197  xconnectorvertex[5] = xconnectorvertex[4];
6198  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6199  xconnectorvertex[7] = xconnectorvertex[6];
6200
6201  yconnectorvertex[0] = 0.0;
6202  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6203  yconnectorvertex[2] = yconnectorvertex[1];
6204  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6205  yconnectorvertex[4] = yconnectorvertex[3];
6206  yconnectorvertex[5] = yconnectorvertex[1];
6207  yconnectorvertex[6] = yconnectorvertex[5];
6208  yconnectorvertex[7] = yconnectorvertex[0];
6209  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6210  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6211                                                                     yconnectorvertex); 
6212  cableconnectorshape->DefineSection(0,0.0);
6213  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6214  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6215                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6216  cableconnector->SetLineColor(fColorG10);
6217  // Strip Connection
6218  TGeoBBox* endcapstripconnectionshape = 
6219                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6220                                                                                          0.5*fgkEndCapStripConnectionThickness,
6221                                                                                          0.5*fgkEndCapStripConnectionWidth);
6222  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6223                                                                                                         endcapstripconnectionshape,
6224                                                                                                         fSSDSupportRingAl);
6225  endcapstripconnection->SetLineColor(fColorAl);
6226  // Interface Card B
6227  const Int_t kcardBvertexnumber = 12; 
6228  Double_t xcardBvertexnumber[kcardBvertexnumber];
6229  Double_t ycardBvertexnumber[kcardBvertexnumber];
6230
6231  xcardBvertexnumber[0]  = 0.0;
6232  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6233  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6234  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6235  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6236  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6237  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6238  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6239  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6240  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6241  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6242  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6243  
6244  ycardBvertexnumber[0]  = 0.0;
6245  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6246  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6247  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6248  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6249  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6250  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6251  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6252  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6253  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6254  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6255  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6256
6257  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6258  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6259  interfacecardBshape->DefineSection(0,0.);
6260  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6261  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6262                                                                                          fSSDMountingBlockMedium);
6263  interfacecardB->SetLineColor(46);
6264  // Interface Card B Electronic Board
6265  const Int_t kelectboardcardBvertexnumber = 14; 
6266  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6267  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6268
6269  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6270  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6271  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6272  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6273  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6274  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6275  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6276  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6277  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6278  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6279  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6280  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6281  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6282  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6283
6284  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6285  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6286  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6287  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6288  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6289  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6290  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6291  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6292  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6293  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6294  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6295  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6296  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6297  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6298
6299  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6300  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6301                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6302  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6303  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6304                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6305  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6306                                                                                           fSSDSupportRingAl);
6307  electboardcardB->SetLineColor(fColorAl);
6308  // Generating Stiffener 2
6309  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6310                                                                                            0.5*fgkEndCapStiffenerThickness,
6311                                                                                            0.5*fgkEndCapStiffenerLength);
6312  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6313  endcapstiffener->SetLineColor(fColorAl);   
6314  // Generating Mother Interface Card B Container
6315  const Int_t kinterfacecardBmothervertexnumber = 10;
6316  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6317  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6318
6319  xinterfacecardBmothervertex[0] = 0.0;
6320  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6321  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6322                                                                 + fgkEndCapInterfaceCardBThickness;
6323  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6324  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6325                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6326  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6327  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6328  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6329  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6330                                                                 + fgkEndCapCardJMDConnectorLength[0];
6331  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6332
6333  yinterfacecardBmothervertex[0] = 0.0;
6334  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6335                                                                 + fgkEndCapInterfaceCardBWidth[1]
6336                                                                 + fgkEndCapInterfaceCardBWidth[2];
6337  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6338  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6339  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6340  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6341  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6342  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6343                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6344                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6345  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6346  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6347  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6348  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6349                                                                                   xinterfacecardBmothervertex,
6350                                                                                   yinterfacecardBmothervertex);
6351  interfacecardBmothershape->DefineSection(0,-1.e-15);
6352  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6353  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6354                                                                                                    interfacecardBmothershape,fSSDAir);
6355  electboardcardB->SetLineColor(fColorAl);
6356  // Positioning Volumes Mother Interface Card B Container 
6357  TGeoRotation* interfacecardBrot = new TGeoRotation();
6358  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6359  interfacecardBrot->SetAngles(90.,-90.,-90.);
6360  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6361  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6362  TGeoRotation* electboardcardBrot = new TGeoRotation();
6363  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6364  electboardcardBrot->SetAngles(90.,90.,-90.);
6365  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6366  TGeoCombiTrans* electboardcardBcombitrans = 
6367                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6368  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6369  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6370  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6371  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6372  TGeoTranslation* jmdconnectorcardBtrans[3];
6373  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6374  for(Int_t i=0; i<3; i++){
6375    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6376                                                          + fgkEndCapCardJMDConnectorLength[0], 
6377                                                            fgkEndCapCardElectBoardLayerWidth[1],
6378                                                            0.5*fgkEndCapCardJMDConnectorThickness
6379                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6380                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6381                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6382    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6383                                                                                                            *jmdconnectorcardBrot);
6384    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6385  }
6386  // Mother Supply Card Container 
6387  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6388  // Interface Card Container
6389  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6390  // Placing Volumes in Mother Supply Card Container
6391  // JMD Connector Positioning
6392  TGeoTranslation* jmdconnectortrans[2];
6393  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6394  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6395                                                                                         fgkEndCapCardElectBoardBackLength[0]
6396                                           -                                             fgkEndCapCardJMDConnectorThickness
6397                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6398  TGeoRotation* jmdconnectorot = new TGeoRotation();
6399  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6400                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6401                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6402                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6403                                                                       fgkEndCapCardJMDConnectorThickness
6404                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6405  jmdconnectorot->SetAngles(90.,180.,-90);
6406  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6407                                                                                 * jmdconnectorot);
6408  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6409  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6410  // Top Cable Connector Placing
6411  TGeoRotation* cableconnectorot[2];
6412  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6413  TGeoTranslation* cableconnectortrans[3];
6414  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6415  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6416  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6417  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6418  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6419                                                                                                                            *cableconnectorot[0]);
6420  TGeoHMatrix* cableconnectormatrix[2];
6421  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6422                                                         new TGeoHMatrix((*cableconnectorot[1])
6423                                                                                    *(*cableconnectorcombitrans));
6424  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6425                                            -                               fgkEndCapCardCableConnectorThickness,
6426                                                                                 fgkEndCapCardCableConnectorLength[0]
6427                                            +                            fgkEndCapCardCableConnectorToLayer);
6428  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6429                                            -                2.*fgkEndCapCardCableConnectorThickness
6430                                            -                            fgkEndCapCardCableConnectorDistance,
6431                                                                                 fgkEndCapCardCableConnectorLength[0]
6432                                            +                            fgkEndCapCardCableConnectorToLayer);
6433  for(Int_t i=0; i<2; i++){
6434         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6435     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6436  }
6437  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6438  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6439  electboardbackrot->SetAngles(90.,-90.,-90.);
6440  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6441                                                         +                fgkEndCapCardJMDConnectorLength[0]
6442                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6443  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6444                                                                                                                            *electboardbackrot);
6445  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6446  // Electronic Board Kapton Layer Positioning
6447  TGeoRotation* electlayerrot = new TGeoRotation();
6448  TGeoTranslation* electlayertrans[2];
6449  TGeoCombiTrans* electlayercombitrans[2];
6450  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6451  electlayerrot->SetAngles(90.,-90.,-90.);
6452  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6453                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6454  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6455                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6456                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6457  for(Int_t i=0; i<2; i++){
6458         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6459         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6460  }
6461  // Placing Volumes in Mother Interface Card Container
6462  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6463  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6464  for(Int_t i=0; i<2; i++){
6465         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6466  }
6467  /////////////////////////////////////////////////////////////
6468  // Generation of Card Interface Container
6469  /////////////////////////////////////////////////////////////
6470  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6471                                                   - fgkEndCapCardJMDConnectorLength[0]
6472                                                   - fgkEndCapInterfaceCardBThickness
6473                                                   - 9.*fgkEndCapStripConnectionThickness
6474                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6475  const Int_t kcardinterfacecontainervertexnumber = 14;
6476  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6477  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6478  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6479                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6480  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6481  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6482                                                                    + fgkEndCapStripConnectionThickness
6483                                                                    - fgkEndCapCardElectBoardLayerThickness
6484                                                                    - fgkEndCapCardCableConnectorWidth[0];
6485  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6486  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6487  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6488  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6489                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6490  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6491  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6492                                                                    + fgkEndCapInterfaceCardBThickness;
6493  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6494  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6495                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6496  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6497  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6498                                    - fgkEndCapInterfaceElectBoardCardBThickness
6499                                                                    + fgkEndCapCardJMDConnectorLength[0]
6500                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6501  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6502
6503  ycardinterfacecontainervertex[0]  = 0.;
6504  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6505                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6506                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6507  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6508  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6509                                                                    - fgkEndCapStripConnectionWidth;
6510  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6511  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6512  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6513  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6514                                                                    + fgkEndCapInterfaceCardBWidth[1]
6515                                                                    + fgkEndCapInterfaceCardBWidth[2];
6516  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6517  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6518  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6519  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6520  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6521  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6522  
6523  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6524  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6525                                                                                   xcardinterfacecontainervertex,
6526                                                                                   ycardinterfacecontainervertex);
6527  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6528                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6529  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6530                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6531  TGeoVolume** cardinterfacecontainer;
6532  cardinterfacecontainer = new TGeoVolume*[4];
6533  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6534                                                                                         interfacecardmothershape,fSSDAir); 
6535  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6536                                                                                         interfacecardmothershape,fSSDAir); 
6537  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6538                                                                                         interfacecardmothershape,fSSDAir); 
6539  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6540                                                                                         interfacecardmothershape,fSSDAir); 
6541  /////////////////////////////////
6542  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6543  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6544  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6545  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6546  /////////////////////////////////
6547  TGeoRotation* endcapstripconnectionrot[2];
6548  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6549  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6550  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6551  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6552                                                                         *                                 (*endcapstripconnectionrot[0]));
6553  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6554  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6555                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6556                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6557                                                                                         -endcapstripconnectionshape->GetDZ(),
6558                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6559  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6560  TGeoTranslation* cardinterfacetrans[9];
6561  TGeoHMatrix* cardinterfacematrix[9]; 
6562  for(Int_t i=0; i<7; i++){ 
6563         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6564                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6565                                                                                                 0.0,0.0);  
6566         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6567                                                    *                             (*endcapstripconnectionmatrix));
6568  }
6569  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6570                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6571                                                                                                 0.0,0.0);  
6572  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6573                                                 *                                 (*endcapstripconnectionmatrix));
6574  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6575                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6576                                                                                                 0.0,0.0);  
6577  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6578                                                 *                                 (*endcapstripconnectionmatrix));
6579
6580  for(Int_t i=0; i<4; i++){
6581         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6582                                                                            cardinterfacematrix[7]);                             
6583         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6584                                                                            cardinterfacematrix[8]);                             
6585  }
6586  TGeoTranslation* mothersupplycardtrans = 
6587                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6588                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6589                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6590  TGeoHMatrix* mothersupplycardmatrix[7];
6591  Int_t index[4] = {1,1,1,1};
6592  for(Int_t i=0; i<7; i++){
6593         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6594                                                         *                                 (*mothersupplycardtrans));
6595         for(Int_t j=0; j<4; j++){
6596                 switch(j){
6597                         case 0: //Layer5 EndCap Left Side  
6598                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6599                                                                                                    cardinterfacematrix[i]);                             
6600                                 if(i!=0){
6601                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6602                                                                                                            mothersupplycardmatrix[i]);                  
6603                                         index[j]++;
6604
6605                                 }
6606                         break;
6607                         case 1: //Layer5 EndCap Rigth Side  
6608                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6609                                                                                                    cardinterfacematrix[i]);                     
6610                                 if(i>0&&i<6){
6611                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6612                                                                                                            mothersupplycardmatrix[i]);                  
6613                                         index[j]++;
6614                                 }
6615                         break;
6616                         case 2: //Layer6 EndCap Left Side  
6617                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6618                                                                                                    cardinterfacematrix[i]);                             
6619                                 if(i!=6){
6620                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6621                                                                                                            mothersupplycardmatrix[i]);                  
6622                                         index[j]++;
6623                                 }
6624                         break;
6625                         case 3: //Layer6 EndCap Right Side  
6626                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6627                                                                                                    cardinterfacematrix[i]);                             
6628                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6629                                                                                                    mothersupplycardmatrix[i]);                  
6630                                 index[j]++;
6631                         break;
6632                 }
6633         }
6634  }
6635  // Positioning Interface 
6636  TGeoTranslation* motherinterfacecardtrans = 
6637                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6638                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6639                                                          -fgkEndCapCardElectBoardLayerThickness
6640                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6641  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6642                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6643  // Positioning Interface Card B 
6644  TGeoTranslation* interfacecardBmothertrans = 
6645                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6646                                                                                 + 2.*fgkEndCapStripConnectionThickness
6647                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6648                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6649                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6650  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6651                                                                                                                          interfacecardBmothertrans);
6652  // Positioning Stiffener 
6653  TGeoTranslation* endcapstiffenertrans = 
6654                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6655                                                                            +    2.0*fgkEndCapStripConnectionThickness
6656                                                                            +    fgkEndCapInterfaceCardBThickness
6657                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6658                                                                            +    stiffenertransx
6659                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6660                                                                                         endcapstiffenershape->GetDZ()
6661                                                                            -    0.5*(fgkEndCapStiffenerLength
6662                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6663  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6664  /////////////////////////////////////////////////////////////
6665  // Deallocating memory
6666  /////////////////////////////////////////////////////////////
6667  delete interfacecardBrot;
6668  delete interfacecardBtrans;
6669  delete electboardcardBtrans;
6670  delete electboardcardBrot; 
6671  delete jmdconnectorcardBrot;
6672  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6673  delete jmdconnectorot;
6674  delete jmdconnectortrans[1];
6675  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6676  delete cableconnectorcombitrans;
6677  delete electboardbacktrans;
6678  delete electboardbackrot;
6679  delete electlayerrot;
6680  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6681  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6682  delete mothersupplycardtrans;
6683  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6684  /////////////////////////////////////////////////////////////
6685  return cardinterfacecontainer;
6686  }
6687  ////////////////////////////////////////////////////////////////////////////////
6688  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6689   /////////////////////////////////////////////////////////////
6690   // Method returning EndCap Mother Volume
6691   /////////////////////////////////////////////////////////////
6692   const Int_t kendcapcoverplatesmallholenumber = 9;
6693   Double_t endcapmotherorigin[3];
6694   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6695                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6696                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6697   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6698                                           -                      fgkEndCapCoverPlateWidth[2]
6699                                           -       (kendcapcoverplatesmallholenumber-1)
6700                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6701                                           +  0.5*(fgkEndCapSideCoverLength[2]
6702                                           +               fgkEndCapCoverPlateWidth[1]
6703                                           -       fgkEndCapCoverPlateWidth[0])
6704                                           -      (fgkEndCapCoverPlateWidth[1]
6705                                           -       fgkEndCapCoverPlateWidth[0]);
6706   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6707                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6708                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6709                                                 +      fgkEndCapSideCoverWidth[1]
6710                                                 +      fgkEndCapSideCoverThickness
6711                                                 +      fgkEndCapKaptonFoilThickness);
6712   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6713                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6714                                                           +              2.0* fgkEndCapSideCoverThickness),
6715                                                                          0.5* (fgkEndCapSideCoverLength[2]
6716                                                           +                    fgkEndCapCoverPlateWidth[1]
6717                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6718                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6719                                                       +                                    fgkEndCapSideCoverWidth[1]
6720                                                           +                                       fgkEndCapSideCoverThickness
6721                                                       +                                   fgkEndCapKaptonFoilThickness),
6722                                                                                          endcapmotherorigin);
6723   TGeoVolume** endcapassembly;  
6724   endcapassembly = new TGeoVolume*[4];
6725   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6726                                                                                         endcapmothershape,fSSDAir); 
6727   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6728                                                                                         endcapmothershape,fSSDAir); 
6729   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6730                                                                                         endcapmothershape,fSSDAir); 
6731   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6732                                                                                         endcapmothershape,fSSDAir); 
6733  /////////////////////////////////
6734  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6735  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6736  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6737  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6738  /////////////////////////////////
6739   /////////////////////////////////////////////////////
6740   // Placing Endcap Cover Plate
6741   /////////////////////////////////////////////////////
6742   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6743   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6744   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6745   TGeoCombiTrans* endcapcoverplatecombitrans = 
6746                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6747                                                                                          endcapcoverplaterot);
6748   TGeoTranslation* endcapcoverplatetrans = 
6749                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6750   TGeoHMatrix* endcapcoverplatematrix = 
6751                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6752                                                                           *       (*endcapcoverplatecombitrans));
6753   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6754   /////////////////////////////////////////////////////
6755   // Placing Endcap Side Cover
6756   /////////////////////////////////////////////////////
6757   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6758   TGeoRotation* endcapsidecoverot[2];
6759   TGeoCombiTrans* endcapsidecovercombitrans[3];
6760   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6761   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6762   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6763                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6764                                                                                         - fgkEndCapCoverPlateWidth[2]
6765                                                                                     - (kendcapcoverplatesmallholenumber-1)
6766                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6767                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6768                                                                                         + fgkEndCapSideCoverLength[2],
6769                                                                                           0.5*(fgkEndCapSideCoverThickness
6770                                                                                         + fgkEndCapCoverPlateThickness)
6771                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6772                                                                                           endcapsidecoverot[0]);
6773   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6774   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6775                                                                                                         0.5*fgkEndCapCoverPlateThickness
6776                                                                                                         -fgkEndCapSideCoverWidth[1],
6777                                                                                                         endcapsidecoverot[1]);
6778   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6779                                                                                                         +fgkEndCapCoverPlateLength[3]
6780                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6781                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6782                                                                                                         0.5*fgkEndCapCoverPlateThickness
6783                                                                                                         -fgkEndCapSideCoverWidth[1],
6784                                                                                                         endcapsidecoverot[1]);
6785   TGeoHMatrix* endcapsidecovermatrix[2];
6786   for(Int_t i=0; i<2; i++){
6787    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6788                                                         *                                 (*endcapsidecovercombitrans[0]));
6789         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6790                                                                                                                 endcapsidecovermatrix[i]);
6791   }
6792   /////////////////////////////////////////////////////
6793   // Placing Endcap Cooling Tube
6794   /////////////////////////////////////////////////////
6795   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6796   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6797   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6798   TGeoCombiTrans* endcapccolingtubecombitrans 
6799                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6800                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6801                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6802                                                 - fgkEndCapCoolingTubeToCoverSide,
6803                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6804                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6805   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6806                                                                                                           endcapccolingtubecombitrans);
6807   /////////////////////////////////////////////////////
6808   // Placing Screws 
6809   /////////////////////////////////////////////////////
6810   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6811                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6812   Int_t screwcoverplatedgesnumber[2] = {20,20};
6813   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6814                                                                                 fgkEndCapCoverPlateThickness
6815                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6816   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6817                                                                                                  screwcoverplatedgesnumber,
6818                                                                                                  screwcoverplatesection);
6819   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6820                                                                                            screwcoverplateshape,
6821                                                                                            fSSDCoolingTubePhynox); 
6822   screwcoverplate->SetLineColor(12);
6823   Double_t transx[4] = {0,
6824                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6825                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6826                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6827                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6828                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6829   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6830 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6831   TGeoTranslation*** endcapcoverplatescrewtrans;
6832   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6833   Int_t index = 0;
6834   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6835         endcapcoverplatescrewtrans[i] = 
6836                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6837     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6838                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6839         if(index==1||index==9||index==28||index==36){
6840                         endcapcoverplatescrewtrans[i][j] = 
6841                                 new TGeoTranslation(transx[i],
6842                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6843                                                                         fgkEndCapSideCoverThickness);
6844                 }
6845                 else{
6846                         endcapcoverplatescrewtrans[i][j] = 
6847                                 new TGeoTranslation(transx[i],
6848                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6849                                                                         0.);
6850                 }
6851             if(index!=19) 
6852                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6853                                                                                           endcapcoverplatescrewtrans[i][j]);
6854         }
6855   }
6856   /////////////////////////////////////////////////////
6857   // Placing Cover Plate Clips 
6858   /////////////////////////////////////////////////////
6859   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6860                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6861                                                                                                          0.5*fgkEndCapSideCoverThickness);
6862   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6863                                                                                                         endcapcoverplateclipshape,
6864                                                                                                         fSSDCoolingTubePhynox);
6865   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6866                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6867                                                                                                          0.5*fgkEndCapSideCoverThickness);
6868   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6869                                                                                                         endcapcoverplatedownclipshape,
6870                                                                                                         fSSDCoolingTubePhynox);
6871   TGeoTranslation* endcapcoverplatecliptrans[4];
6872   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6873                                                            -                     fgkEndCapCoverPlateLength[0]
6874                                                            -                     fgkEndCapSideCoverThickness,
6875                                                                                                          0.0,
6876                                                                                                  0.5*(fgkEndCapSideCoverThickness
6877                                                            +                                              fgkEndCapCoverPlateThickness));
6878   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6879                                                            -                     fgkEndCapCoverPlateLength[0]
6880                                                            -                     fgkEndCapSideCoverThickness,
6881                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6882                                                            *                                     fgkEndCapSideCoverWidth[5],
6883                                                                                                  0.5*(fgkEndCapSideCoverThickness
6884                                                            +                                              fgkEndCapCoverPlateThickness));
6885   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6886                                                            -                     fgkEndCapCoverPlateLength[0]
6887                                                            +                                     fgkEndCapCoverPlateLength[1]
6888                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6889                                                            -                                     fgkEndCapCoverPlateClipLength
6890                                                            +                                 fgkEndCapSideCoverThickness,
6891                                                                                                          0.0,
6892                                                                                                  0.5*(fgkEndCapSideCoverThickness
6893                                                            +                                              fgkEndCapCoverPlateThickness));
6894   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6895                                                            -                     fgkEndCapCoverPlateLength[0]
6896                                                            +                                     fgkEndCapCoverPlateLength[1]
6897                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6898                                                            -                                     fgkEndCapCoverPlateClipLength
6899                                                            +                                 fgkEndCapSideCoverThickness,
6900                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6901                                                            *                                     fgkEndCapSideCoverWidth[5],
6902                                                                                                  0.5*(fgkEndCapSideCoverThickness
6903                                                            +                                              fgkEndCapCoverPlateThickness));
6904   endcapcoverplateclip->SetLineColor(fColorPhynox);
6905   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6906   for(Int_t i=0; i<4; i++) 
6907         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6908                                                                                                    endcapcoverplatecliptrans[i]);  
6909   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6910   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6911                                                                    -                     fgkEndCapCoverPlateLength[0]
6912                                                                    -                     fgkEndCapSideCoverThickness,
6913                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6914                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6915                                                                                                         0.5*(fgkEndCapSideCoverThickness
6916                                                                +                                         fgkEndCapCoverPlateThickness)
6917                                                                    -                     fgkEndCapSideCoverWidth[1]
6918                                                                    -                                     fgkEndCapSideCoverThickness);
6919   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6920                                                                    -                     fgkEndCapCoverPlateLength[0]
6921                                                                    -                     fgkEndCapSideCoverThickness,
6922                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6923                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6924                                                                    +                            fgkEndCapSideCoverLength[2]
6925                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6926                                                                                                         0.5*(fgkEndCapSideCoverThickness
6927                                                                +                                         fgkEndCapCoverPlateThickness)
6928                                                                    -                     fgkEndCapSideCoverWidth[1]
6929                                                                    -                                     fgkEndCapSideCoverThickness);
6930   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6931                                                                    -                     fgkEndCapCoverPlateLength[0]
6932                                                                    +                     fgkEndCapSideCoverThickness
6933                                                                    +                     fgkEndCapCoverPlateLength[1]
6934                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6935                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6936                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6937                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6938                                                                                                         0.5*(fgkEndCapSideCoverThickness
6939                                                                +                                         fgkEndCapCoverPlateThickness)
6940                                                                    -                     fgkEndCapSideCoverWidth[1]
6941                                                                    -                                     fgkEndCapSideCoverThickness);
6942   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6943                                                                    -                     fgkEndCapCoverPlateLength[0]
6944                                                                    +                     fgkEndCapSideCoverThickness
6945                                                                    +                     fgkEndCapCoverPlateLength[1]
6946                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6947                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6948                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6949                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6950                                                                    +                                 fgkEndCapSideCoverLength[2]
6951                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6952                                                                                                         0.5*(fgkEndCapSideCoverThickness
6953                                                                +                                         fgkEndCapCoverPlateThickness)
6954                                                                    -                     fgkEndCapSideCoverWidth[1]
6955                                                                    -                                     fgkEndCapSideCoverThickness);
6956   for(Int_t i=0; i<4; i++)
6957         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6958                                                                                                    endcapcoverplatedowncliptrans[i]);
6959   /////////////////////////////////////////////////////
6960   // Placing Kapton Foil
6961   /////////////////////////////////////////////////////
6962   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6963                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6964                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6965   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6966                                                                                                 endcapkaptonfoilshape,
6967                                                                                                 fSSDKaptonFlexMedium);
6968   endcapkaptonfoil->SetLineColor(8);
6969   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6970                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6971                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6972                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6973                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6974                                                                              -                     fgkEndCapSideCoverWidth[1]
6975                                                                                  -                     fgkEndCapSideCoverThickness);
6976   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6977   /////////////////////////////////////////////////////////////
6978   // Placing Electronic Tubes
6979   /////////////////////////////////////////////////////////////
6980   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6981                                                                              - fgkEndCapInterfaceCardBThickness
6982                                                                              - 9.*fgkEndCapStripConnectionThickness
6983                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6984                                                                                fgkEndCapKaptonFoilWidth
6985                                                                              - fgkEndCapInterfaceCardBThickness
6986                                                                              - 9.*fgkEndCapStripConnectionThickness
6987                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6988                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6989   TGeoVolume* endcapeffectivecables[2];
6990   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6991                                                                                          fgkEndCapEffectiveCableRadiusMax,
6992                                                                                          endcapeffectivecableswidth[0],
6993                                                                                          10,"EndCapEffectiveCables1"); 
6994   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6995                                                                                          fgkEndCapEffectiveCableRadiusMax,
6996                                                                                          endcapeffectivecableswidth[1],
6997                                                                                          25,"EndCapEffectiveCables2"); 
6998   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6999   TGeoTranslation* endcapeffectivecablestrans[2];
7000   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
7001                                           -                                                        0.5*endcapeffectivecableswidth[0]
7002                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
7003                                           -                                                               fgkEndCapCoverPlateWidth[2]
7004                                           -                                             (kendcapcoverplatesmallholenumber-1)
7005                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7006                                           +                                             fgkEndCapSideCoverLength[2],
7007                                           -                     0.5*fgkEndCapCoverPlateThickness
7008                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
7009                                           -                                              fgkEndCapInterfaceCardBWidth[0]
7010                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
7011   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
7012                                           -                                                        0.5*endcapeffectivecableswidth[1]
7013                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
7014                                           -                                                               fgkEndCapCoverPlateWidth[2]
7015                                           -                                             (kendcapcoverplatesmallholenumber-1)
7016                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7017                                           +                                         fgkEndCapSideCoverLength[2],
7018                                           -                     0.5*fgkEndCapCoverPlateThickness
7019                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
7020                                           -                                              fgkEndCapInterfaceCardBWidth[0])
7021                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
7022   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
7023   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
7024   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
7025                                                                                                                    *endcapeffectivecablesrot);
7026   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
7027                                                                                                                    *endcapeffectivecablesrot);
7028 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
7029 //                                                                                                        endcapeffectivecablescombitrans[0]);
7030   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
7031                                                                                                           endcapeffectivecablescombitrans[1]);
7032   /////////////////////////////////////////////////////////////
7033   // Placing End Cap Cards
7034   /////////////////////////////////////////////////////////////
7035   TGeoVolume** endcapcards = GetEndCapCards();
7036   TGeoRotation* endcapcardsrot[2];
7037   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
7038   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
7039   TGeoTranslation* endcapcardstrans[2]; 
7040   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
7041                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
7042   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
7043   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
7044   TGeoHMatrix* endcapcardsmatrix[2];
7045   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
7046   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
7047                                                   - fgkEndCapCardJMDConnectorLength[0]
7048                                                   - fgkEndCapInterfaceCardBThickness
7049                                                   - 9.*fgkEndCapStripConnectionThickness
7050                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
7051   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
7052                                           -                                             fgkEndCapCoverPlateLength[0]
7053                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
7054                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
7055                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
7056                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
7057                                           -                                                               fgkEndCapInterfaceCardBThickness
7058                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
7059                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
7060                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
7061                                           -                                                               fgkEndCapCoverPlateWidth[2]
7062                                           -                                             (kendcapcoverplatesmallholenumber-1)
7063                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7064                                           +                     fgkEndCapKaptonFoilWidth,
7065                                                                                           0.5*fgkEndCapCoverPlateThickness
7066                                           -                                                     fgkEndCapSideCoverWidth[1]);
7067   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
7068   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
7069    /////////////////////////////////////////////////////////////
7070   // Deallocating memory
7071   /////////////////////////////////////////////////////////////
7072   delete endcapcoverplaterot;
7073   delete endcapcoverplatecombitrans;
7074   delete endcapcoverplatetrans;
7075   for(Int_t i=0; i<3; i++){
7076    delete endcapsidecovercombitrans[i];
7077    if(i<2) delete endcapsidecoverot[i]; 
7078   }
7079   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
7080   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
7081   delete endcapcardsmatrix[0];
7082   return endcapassembly;
7083  } 
7084  ////////////////////////////////////////////////////////////////////////////////
7085  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
7086                                                                                                                         Double_t radiusmax, 
7087                                                                                                                         Double_t width, 
7088                                                                                                                         Int_t ncables,
7089                                                                                                                         const char* volname){
7090   /////////////////////////////////////////////////////////////
7091   // Generating EndCap High Voltage Tubes 
7092   /////////////////////////////////////////////////////////////
7093   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
7094   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
7095
7096   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
7097   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
7098                                                                                                    effectiveouteradius,0.5*width);
7099   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
7100                                                                                                 effectiveinnertubeshape,
7101                                                                                                 fSSDStiffenerConnectorMedium);
7102   effectiveinnertube->SetLineColor(41);
7103   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
7104                                                                                                 effectiveoutertubeshape,
7105                                                                                                 fSSDKaptonChipCableMedium);
7106   effectiveoutertube->SetLineColor(39);
7107   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
7108   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
7109   effectivemothertube->AddNode(effectiveinnertube,1);
7110   effectivemothertube->AddNode(effectiveoutertube,1);
7111   return effectivemothertube;
7112  } 
7113  ////////////////////////////////////////////////////////////////////////////////
7114  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
7115   /////////////////////////////////////////////////////////////
7116   // Generating EndCap Support Layer 5 and Layer 6 
7117   /////////////////////////////////////////////////////////////
7118   const Int_t knedges = 5;
7119   ///////////////////////////////////////////////
7120   // Setting the vertices for TGeoXtru Up Volume
7121   ///////////////////////////////////////////////
7122   const Int_t klayernumber = 2;
7123   Double_t xupvertex[klayernumber][knedges+3];
7124   Double_t yupvertex[klayernumber][knedges+3];
7125   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
7126   Double_t middledgeangle[klayernumber] = {0.0,0.0};
7127   Double_t middlepsi[klayernumber] = {0.0,0.0};
7128   for(Int_t i=0; i<klayernumber; i++){
7129         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
7130         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
7131         xupvertex[i][2] = -xupvertex[i][1];
7132         xupvertex[i][3] = -xupvertex[i][0];
7133
7134         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
7135         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
7136         yupvertex[i][2] =  yupvertex[i][1];
7137         yupvertex[i][3] =  yupvertex[i][0];
7138         
7139     middledgeangle[i] = upedgeangle[i]/knedges;
7140     middlepsi[i] = 90.0-0.5*upedgeangle[i];
7141     for(Int_t j=1; j<knedges; j++){
7142                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
7143                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
7144         }
7145   }
7146   ////////////////////////////////////
7147   // Generating Up TGeoXtru
7148   ////////////////////////////////////
7149   TGeoXtru* upendcapsupportshape[klayernumber];
7150   TGeoVolume* upendcapsupport[klayernumber]; 
7151   char upendcapsupportname[100]; 
7152   for(Int_t i=0; i<klayernumber; i++){
7153    upendcapsupportshape[i] = new TGeoXtru(2);
7154    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
7155    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
7156    upendcapsupportshape[i]->DefineSection(0,0.);
7157    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7158    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7159                                                                         fSSDSupportRingAl);
7160    upendcapsupport[i]->SetLineColor(5);
7161   }
7162   ///////////////////////////////////////////////
7163   // Setting the vertices for TGeoXtru Down Volume
7164   ///////////////////////////////////////////////
7165   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7166   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7167   for(Int_t i=0; i<klayernumber; i++){
7168         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7169         xdownvertex[i][1] =  xupvertex[i][0];
7170         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7171         ydownvertex[i][1] =  yupvertex[i][0];
7172         for(Int_t j=0; j<knedges; j++){
7173                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7174                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7175         } 
7176         for(Int_t j=0; j<knedges; j++){
7177                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7178                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7179                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7180                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7181         }
7182   }
7183   ////////////////////////////////////
7184   // Generating Down TGeoXtru
7185   ////////////////////////////////////  
7186   TGeoXtru* downendcapsupportshape[klayernumber];
7187   TGeoVolume* downendcapsupport[klayernumber]; 
7188   char downendcapsupportname[100]; 
7189   for(Int_t i=0; i<klayernumber; i++){
7190         downendcapsupportshape[i] = new TGeoXtru(2);
7191     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7192         downendcapsupportshape[i] = new TGeoXtru(2);
7193         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7194     if(i==0){
7195                 downendcapsupportshape[i]->DefineSection(0,0.);
7196                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7197     }
7198         else{
7199                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7200                                                                  -                 fgkEndCapSupportLowWidth[i]);
7201                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7202         }
7203     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7204                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7205         downendcapsupport[i]->SetLineColor(5);
7206   }
7207   ///////////////////////////////////////////////
7208   // Setting TGeoPgon Volume
7209   ///////////////////////////////////////////////
7210   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7211                                                                                                    fgkSSDLay6LadderNumber};
7212   TGeoPgon* endcapsupportmothershape[klayernumber];
7213   TGeoVolume** endcapsupportmother;
7214   endcapsupportmother = new TGeoVolume*[klayernumber];
7215   char endcapsupportmothername[100];
7216   for(Int_t i=0; i<klayernumber; i++){
7217         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7218     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7219         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7220     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7221                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7222     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7223                                                                                         fSSDAir);       
7224   }
7225   ////////////////////////////////////
7226   TGeoRotation** endcapsupportrot[klayernumber];
7227   for(Int_t i=0; i<2; i++){
7228         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7229         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7230            endcapsupportrot[i][j] = new TGeoRotation();
7231            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7232        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7233        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7234         }
7235   }
7236   return endcapsupportmother;
7237  } 
7238  ////////////////////////////////////////////////////////////////////////////////
7239  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7240   /////////////////////////////////////////////////////////////
7241   // Setting End Cap Support Layer 5 and 6. 
7242   /////////////////////////////////////////////////////////////
7243   const Int_t kendcapcoverplatesmallholenumber = 9;
7244   const Int_t klayernumber = 2;
7245   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7246                                                                                                    fgkSSDLay6LadderNumber};
7247   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7248                                                                                 360.0/kssdlayladdernumber[1]};
7249   TGeoVolume** endcapsupport = EndCapSupport();
7250   TGeoVolume** endcapassembly = GetEndCapAssembly();
7251   TGeoPgon* endcapsupportshape[klayernumber];
7252   Double_t* radiusmin[klayernumber];
7253   Double_t* radiusmax[klayernumber];
7254   for(Int_t i=0; i<klayernumber; i++){
7255     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7256         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7257         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7258   }  
7259   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7260   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7261                                                                           endcapassemblyshape->GetDY(),
7262                                                                           endcapassemblyshape->GetDZ()};
7263   ///////////////////////////////////////////////
7264   // Setting TGeoPgon Volume for Mother Container
7265   ///////////////////////////////////////////////
7266   TGeoPgon* endcapsupportsystemshape[klayernumber];
7267   char endcapsupportsystemothername[100];
7268   for(Int_t i=0; i<klayernumber; i++){
7269         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7270     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7271         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7272                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7273                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7274                                                                                            +2.*endcapassemblycenter[2])
7275                                                                                            /CosD(0.5*upedgeangle[i]));  
7276     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7277                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7278                                                                                              - fgkEndCapCoverPlateWidth[0]),
7279                                                                                            *radiusmin[i],
7280                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7281                                                                                            +2.*endcapassemblycenter[2])
7282                                                                                            /CosD(0.5*upedgeangle[i]));
7283   }
7284   fgkEndCapSupportSystem = new TGeoVolume*[4];
7285   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7286                                                                           endcapsupportsystemshape[0],fSSDAir); 
7287   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7288                                                                           endcapsupportsystemshape[0],fSSDAir); 
7289   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7290                                                                           endcapsupportsystemshape[1],fSSDAir); 
7291   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7292                                                                           endcapsupportsystemshape[1],fSSDAir); 
7293   ///////////////////////////////////////////////
7294   TGeoTranslation* endcapassemblytrans[klayernumber];
7295   for(Int_t i=0; i<klayernumber; i++)
7296         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7297                                                                            -  fgkEndCapSideCoverThickness
7298                                                                            +  endcapassemblycenter[0],
7299                                                                            -  0.5*fgkEndCapCoverPlateThickness
7300                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7301                                                                            +  2.0*endcapassemblycenter[2]
7302                                                                            +  0.5*fgkEndCapSupportLength[i]
7303                                                                            /  TanD(0.5*upedgeangle[i]),
7304                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7305                                                                            -  fgkEndCapCoverPlateWidth[2]
7306                                                                            - (kendcapcoverplatesmallholenumber-1)
7307                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7308   TGeoRotation** endcapassemblyrot[klayernumber];
7309   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7310   for(Int_t i=0; i<klayernumber; i++){
7311    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7312    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7313    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7314    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7315    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7316    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7317    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7318    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7319         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7320         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7321    }
7322   }
7323   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7324                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7325   for(Int_t i=0; i<2*klayernumber; i++){
7326         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7327                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7328                                                                                                                                            endcapassemblymatrix[1][j+2]);
7329         }
7330         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7331   }
7332    /////////////////////////////////////////////////////////////
7333   // Deallocating memory
7334   /////////////////////////////////////////////////////////////
7335   for(Int_t i=0; i<klayernumber; i++){
7336         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7337                 delete endcapassemblyrot[i][j];
7338         }
7339         delete [] endcapassemblyrot[i];
7340         delete endcapassemblymatrix[i][0];
7341         delete endcapassemblymatrix[i][1];
7342   }
7343   /////////////////////////////////////////////////////////////
7344   }
7345   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7346   /////////////////////////////////////////////////////////////
7347   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7348   /////////////////////////////////////////////////////////////
7349   if (! moth) {
7350     AliError("Can't insert end cap support of layer5, mother is null!\n");
7351     return;
7352   };
7353   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7354   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7355   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7356                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7357                                                                            +            fgkEndCapSupportCenterLay5Position
7358                                                                            -            fgkEndCapSideCoverLength[2]);
7359   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7360                                                                                                 fgkEndCapSideCoverLength[2]
7361                                                                            -        fgkEndCapSupportCenterLay5Position
7362                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7363   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7364   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7365   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7366         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7367   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7368   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7369    /////////////////////////////////////////////////////////////
7370   // Deallocating memory
7371   /////////////////////////////////////////////////////////////
7372   delete endcapsupportsystemrot;
7373   delete endcapsupportsystemITSCentertrans[1];
7374  }
7375   /////////////////////////////////////////////////////////////
7376   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7377   /////////////////////////////////////////////////////////////
7378   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7379   /////////////////////////////////////////////////////////////
7380   if (! moth) {
7381     AliError("Can't insert end cap support of layer6, mother is null!\n");
7382     return;
7383   };
7384   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7385   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7386   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7387                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7388                                                                            +            fgkEndCapSupportCenterLay6Position
7389                                                                            -            fgkEndCapSideCoverLength[2]);
7390   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7391                                                                                                 fgkEndCapSideCoverLength[2]
7392                                                                            -        fgkEndCapSupportCenterLay6Position
7393                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7394   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7395   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7396   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7397         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7398   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7399   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7400    /////////////////////////////////////////////////////////////
7401   // Deallocating memory
7402   /////////////////////////////////////////////////////////////
7403   delete endcapsupportsystemrot;
7404   delete endcapsupportsystemITSCentertrans[1];
7405  }
7406  ////////////////////////////////////////////////////////////////////////////////
7407  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7408   /////////////////////////////////////////////////////////////
7409   // Setting Ladder Support of Layer 5. 
7410   /////////////////////////////////////////////////////////////
7411   if (! moth) {
7412     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7413     return;
7414   };
7415   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7416   fMotherVol = moth;
7417   TGeoTranslation* centerITSRingSupportLay5trans[2];
7418   for(Int_t i=0; i<2; i++){
7419         centerITSRingSupportLay5trans[i] = 
7420                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7421     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7422   }
7423  }
7424  ////////////////////////////////////////////////////////////////////////////////
7425  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7426   /////////////////////////////////////////////////////////////
7427   // Setting Ladder Support of Layer 6. 
7428   /////////////////////////////////////////////////////////////
7429   if (! moth) {
7430     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7431     return;
7432   };
7433   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7434   fMotherVol = moth;
7435   TGeoTranslation* centerITSRingSupportLay6trans[2];
7436   for(Int_t i=0; i<2; i++){
7437         centerITSRingSupportLay6trans[i] = 
7438                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7439     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7440   }
7441  }
7442  ////////////////////////////////////////////////////////////////////////////////
7443  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7444   /////////////////////////////////////////////////////////////
7445   // Setting Ladder Support of Layer 6. 
7446   /////////////////////////////////////////////////////////////
7447   if (! moth) {
7448     AliError("Can't insert SSD Cone, mother is null!\n");
7449     return;
7450   };
7451   if(!fSSDCone) SetSSDCone();
7452   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7453                                                                 +                                         fgkSSDCentralAL3SupportLength);
7454     moth->AddNode(fSSDCone,1,ssdconetrans);
7455 }
7456  ////////////////////////////////////////////////////////////////////////////////
7457  void AliITSv11GeometrySSD::SetSSDCone(){
7458   /////////////////////////////////////////////////////////////
7459   // Method generating SSDCone 
7460   /////////////////////////////////////////////////////////////
7461   if(!fCreateMaterials) CreateMaterials();
7462   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7463   Double_t ssdpconesectionradiusmax[16];
7464   Double_t ssdpconesectionradiusmin[16];
7465   Double_t ssdpconezsection[16];
7466   TGeoPcon* ssdpconelittleholeshape[8];
7467   TGeoVolume* ssdpconelittlehole[8];
7468   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7469   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7470   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7471                                                       / SinD(fgkSSDPConeAngle)
7472                                                           + ssdpconesectionradiusmin[0];
7473   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7474                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7475                                                           / SinD(fgkSSDPConeAngle);
7476   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7477   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7478                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7479   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7480   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7481                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7482   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7483   ssdpconelittlehole[0]->SetLineColor(4);
7484   /////////////////////////////////////////////////////////////
7485   ssdpconezsection[2] = ssdpconezsection[1];  
7486   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7487   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7488   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7489                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7490                                                           / SinD(fgkSSDPConeAngle);
7491   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7492                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7493   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7494                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7495   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7496                                                                    * TMath::RadToDeg();
7497   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7498                                                                                                           60.-ssdpconelittleholeangle,2);    
7499   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7500                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7501   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7502   ssdpconelittlehole[1]->SetLineColor(4);
7503   TGeoRotation* ssdconelittleholerot[6];
7504   for(Int_t i=0; i<6; i++){
7505         ssdconelittleholerot[i] = new TGeoRotation();
7506     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7507   }
7508   /////////////////////////////////////////////////////////////
7509   ssdpconezsection[4] = ssdpconezsection[3];  
7510   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7511   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7512   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7513                                                           * CosD(fgkSSDPConeAngle)
7514                                                           / SinD(fgkSSDPConeAngle);
7515   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7516   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7517                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7518   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7519   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7520                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7521   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7522   ssdpconelittlehole[2]->SetLineColor(4);
7523   ///////////////////////////////////////////////////
7524   ssdpconezsection[6] = ssdpconezsection[5];  
7525   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7526   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7527   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7528                                                           -ssdpconezsection[0]
7529                                                           * CosD(fgkSSDPConeAngle)
7530                                                           / SinD(fgkSSDPConeAngle);
7531   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7532   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7533                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7534   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7535                                                                    * TMath::RadToDeg();
7536   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7537                                                                                                           45.-ssdpconemiddleholeangle,2);    
7538   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7539                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7540   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7541   ssdpconelittlehole[3]->SetLineColor(4);
7542   TGeoRotation* ssdconemiddleholerot[8];
7543   for(Int_t i=0; i<8; i++){
7544         ssdconemiddleholerot[i] = new TGeoRotation();
7545     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7546   }
7547   /////////////////////////////////////////////////////////////
7548   ssdpconezsection[8] = ssdpconezsection[7];  
7549   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7550   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7551   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7552                                                           * CosD(fgkSSDPConeAngle)
7553                                                           / SinD(fgkSSDPConeAngle);
7554   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7555   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7556                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7557   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7558   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7559                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7560   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7561   ssdpconelittlehole[4]->SetLineColor(4);
7562   /////////////////////////////////////////////////////////////
7563   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7564   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7565                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7566                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7567                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7568                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7569   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7570   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7571                                                                                  * TMath::RadToDeg();
7572   ssdpconezsection[10] = ssdpconezsection[9];
7573   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7574   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7575   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7576                                                           * CosD(fgkSSDPConeAngle)
7577                                                           / SinD(fgkSSDPConeAngle);
7578   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7579   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7580                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7581   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7582                                                                                         ssdpconetrapezoidsectionangle,2);    
7583   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7584                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7585   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7586   ssdpconelittlehole[5]->SetLineColor(4);
7587   TGeoRotation* ssdconeupradiusrot[8];
7588   for(Int_t i=0; i<8; i++){
7589         ssdconeupradiusrot[i] = new TGeoRotation();
7590     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7591   }
7592   /////////////////////////////////////////////////////////////
7593   ssdpconezsection[12] = ssdpconezsection[11];
7594   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7595   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7596   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7597   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7598   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7599   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7600   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7601                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7602   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7603   ssdpconelittlehole[6]->SetLineColor(4);
7604   /////////////////////////////////////////////////////////////
7605   ssdpconezsection[14] = 0.0;
7606   ssdpconezsection[15] = ssdpconezsection[0];
7607   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7608   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7609   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7610   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7611   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7612   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7613                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7614   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7615   ssdpconelittlehole[7]->SetLineColor(4);
7616   /////////////////////////////////////////////////////////////
7617   TGeoTube* ssdtubeconeshape[2];
7618   TGeoVolume* ssdtubecone[2];
7619   TGeoTranslation* ssdtubeconetrans[2];
7620   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7621                                                                            fgkSSDPConeExternalRadius,
7622                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7623   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7624                                                                            0.5*ssdpconezsection[0]); 
7625   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7626   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7627   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7628                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7629                                           + ssdpconezsection[13]);
7630   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7631   ssdtubecone[0]->SetLineColor(4);
7632   ssdtubecone[1]->SetLineColor(4);
7633   /////////////////////////////////////////////////////////////
7634   // Mother Volume Container
7635   /////////////////////////////////////////////////////////////
7636   Double_t ssdconemotherradiusmin[8];
7637   Double_t ssdconemotherradiusmax[8];
7638   Double_t ssdconemothersection[8]; 
7639   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7640   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7641   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7642   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7643   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7644   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7645   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7646   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7647   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7648   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7649   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7650   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7651   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7652   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7653   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7654   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7655   ssdconemothersection[0] = 0.0;
7656   ssdconemothersection[1] = ssdpconezsection[0];
7657   ssdconemothersection[2] = ssdpconezsection[0];
7658   ssdconemothersection[3] = ssdpconezsection[11];
7659   ssdconemothersection[4] = ssdpconezsection[11];
7660   ssdconemothersection[5] = ssdpconezsection[13];
7661   ssdconemothersection[6] = ssdpconezsection[13];
7662   ssdconemothersection[7] = fgkSSDPConeLength;
7663   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7664   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7665                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7666   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7667   /////////////////////////////////////////////////////////////
7668   //Placing the Volumes into Mother 
7669   /////////////////////////////////////////////////////////////
7670   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7671   for(Int_t i=0; i<6; i++){
7672         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7673   }
7674   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7675   for(Int_t i=0; i<8; i++){
7676     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7677   }
7678   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7679   for(Int_t i=0; i<8; i++){
7680     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7681   }
7682   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7683   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7684   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7685   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7686   /////////////////////////////////////////////////////////////
7687   // ITS General Support
7688   /////////////////////////////////////////////////////////////
7689   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7690                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7691   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7692   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7693                                                                              - fgkSSDCentralAL3SupportLength);
7694   ssdcentralsupport->SetLineColor(4);
7695   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7696   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7697                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7698   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7699   TGeoTranslation* ssdcentralal3supportrans[3]; 
7700   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7701   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7702                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7703   ssdcentralal3support->SetLineColor(4);
7704   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7705   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7706   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7707   Double_t ssdpconcentralradiusmin[2];
7708   Double_t ssdpconcentralradiusmax[2];
7709   Double_t ssdpconcentralsection[2];
7710   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7711   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7712   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7713   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7714   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7715   ssdpconcentralsection[1] = 0.;
7716   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7717                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7718   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7719   ssdpconcentralal3->SetLineColor(4);
7720   fSSDCone->AddNode(ssdpconcentralal3,1);
7721   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7722   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7723   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7724                                                                 -2.*fgkSSDCentralAL3SupportLength);
7725   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7726                                                                                                                      *ssdcentralal3supportrot);
7727   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7728   TGeoRotation* ssdconemotherot = new TGeoRotation();
7729   ssdconemotherot->SetAngles(90.,180.,-90.);
7730   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7731                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7732   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7733   fSSDCone->AddNode(ssdconemother,1);
7734   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7735   /////////////////////////////////////////////////////////////
7736   // Deallocating memory
7737   /////////////////////////////////////////////////////////////
7738   delete ssdcentralal3supportrot;
7739   delete ssdcentralal3supportrans[2];
7740   delete ssdconemotherot;
7741   delete ssdconemothertrans;
7742   /////////////////////////////////////////////////////////////
7743  }
7744  ////////////////////////////////////////////////////////////////////////////////
7745  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7746   /////////////////////////////////////////////////////////////
7747   // Setting SSD Cables
7748   /////////////////////////////////////////////////////////////
7749   if (! moth) {
7750     AliError("Can't insert SSD Cables, mother is null!\n");
7751     return;
7752   };
7753   TGeoVolume* ssdcables = SetSSDCables();
7754   moth->AddNode(ssdcables,1);
7755 }
7756  ////////////////////////////////////////////////////////////////////////////////
7757  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7758   /////////////////////////////////////////////////////////////
7759   // Method generating SSDCables
7760   /////////////////////////////////////////////////////////////
7761   // SSD Layer 5 Cables
7762   //////////////////////////////////////////////////////////////////////////////////////////////////
7763   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7764   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7765   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7766   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7767   //////////////////////////////////////////////////////////////////////////////////////////////////
7768   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7769   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7770                                                                             -  fgkSSDLowerPConeRadius)
7771                                                                             * TanD(fgkSSDPConeAngle);
7772   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7773                                                                               + fgkEndCapSupportCenterLay5Position
7774                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7775   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7776                                                                            - ssdcableslay5startconedistance; 
7777   ssdcablelay5rightsidelength *= ssdcablesfactor;
7778   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7779   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7780                                                                                                 ssdcableslay5rightsideradiusmax,
7781                                                                                                 0.5*ssdcablelay5rightsidelength); 
7782   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7783                                                                                                          ssdcablelay5rightubeshape,
7784                                                                                                          fSSDCopper);
7785   ssdcablelay5righttube->SetLineColor(9);
7786   TGeoTranslation* ssdcablelay5rightrans = 
7787                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7788                                                                                  +              fgkEndCapSupportCenterLay5Position
7789                                                                                  +      0.5*ssdcablelay5rightsidelength);
7790   ////////////////////////////////////
7791   //  Double_t cablescapacity[20];
7792   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7793   ////////////////////////////////////
7794   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7795   ////////////////////////////////////
7796   // TGeoPCone Volumes
7797   ///////////////////////////////////
7798   TGeoPcon* ssdcableslay5pconshape[3];
7799   TGeoVolume* ssdcableslay5pcon[3]; 
7800   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7801   Double_t ssdcableslay5pconzsection[6];
7802   Double_t ssdcableslay5pconrmin[6];
7803   Double_t ssdcableslay5pconrmax[6];
7804   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7805   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7806   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7807   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7808   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7809                                                            + fgkEndCapSupportCenterLay5Position
7810                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7811   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7812                                                            + fgkSSDCentralAL3SupportLength
7813                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7814                                                            * TanD(fgkSSDPConeAngle);      
7815   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7816                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7817   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7818                                                            ssdcableslay5pconshape[0],fSSDCopper);
7819   ssdcableslay5pcon[0]->SetLineColor(9);
7820   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7821 ////////////////////////////////////
7822 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7823 ////////////////////////////////////
7824   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7825   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7826                                                            + fgkSSDCentralAL3SupportLength
7827                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7828                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7829   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7830                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7831                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7832   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7833                                                                                    ssdcableangle,2);   
7834   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7835   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7836   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7837                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7838   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7839   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7840   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7841                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7842   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7843   ssdcableslay5pcon[1]->SetLineColor(9);
7844   ////////////////////////////////////
7845   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7846                                                                                    ssdcableangle,2);   
7847   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7848   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7849   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7850   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7851   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7852   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7853                                                            * TanD(fgkSSDPConeAngle)
7854                                                            + 0.5*fgkSSDCentralSupportLength
7855                                                            + fgkSSDCentralAL3SupportLength;
7856   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7857   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7858                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7859   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7860   ssdcableslay5pcon[2]->SetLineColor(9);
7861 ////////////////////////////////////
7862   TGeoRotation* ssdcableslay5pconrot[4];        
7863   for(Int_t i=0; i<4; i++){
7864    ssdcableslay5pconrot[i] = new TGeoRotation();
7865    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7866    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7867    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7868   }
7869   ////////////////////////////////////
7870   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7871   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7872   ////////////////////////////////////
7873   // Positioning Left SSD Cables Part
7874   ////////////////////////////////////
7875   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7876                                                                                                         - 0.5*ssdcablelay5rightsidelength
7877                                                                                                         - fgkEndCapSupportCenterLay5Position
7878                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7879   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7880   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7881   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7882   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7883   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7884   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7885         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7886         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7887     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7888   }
7889   ////////////////////////////////////
7890   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7891   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7892   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7893   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7894   /////////////////////////////////////////////////////////////
7895   // Water Tubes Layer 5
7896   /////////////////////////
7897   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7898                                                                                      ssdcableslay5rightsideradiusmax
7899                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7900                                                                                      0.5*ssdcablelay5rightsidelength); 
7901   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7902                                                                                                          ssdcablelay5rightubewatershape,
7903                                                                                                          fSSDCoolingTubeWater);
7904   ssdcablelay5rightwatertube->SetLineColor(7);
7905   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7906   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7907   ////////////////////////////////////
7908   // TGeoPCone Water Volumes Layer 
7909   ///////////////////////////////////
7910   TGeoPcon* ssdcableslay5pconwatershape[3];
7911   TGeoVolume* ssdcableslay5pconwater[3]; 
7912   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7913   Double_t ssdcableslay5pconwaterzsection[6];
7914   Double_t ssdcableslay5pcwateronrmin[6];
7915   Double_t ssdcableslay5pconwaterrmax[6];
7916   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7917   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7918                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7919   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7920   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7921                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7922   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7923   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7924   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7925                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7926   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7927                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7928   ssdcableslay5pconwater[0]->SetLineColor(7);
7929   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7930   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7931 ////////////////////////////////////
7932   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7933   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7934   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7935                                                                                                 ssdcableangle,2);   
7936   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7937   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7938                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7939   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7940   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7941                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7942   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7943                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7944   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7945                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7946   ssdcableslay5pconwater[1]->SetLineColor(7);
7947 ////////////////////////////////////
7948   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7949                                                                                                 ssdcableangle,2);   
7950   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7951   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7952                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7953   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7954   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7955                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7956   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7957   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7958   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7959                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7960   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7961                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7962   ssdcableslay5pconwater[2]->SetLineColor(7);
7963 ////////////////////////////////////
7964   TGeoRotation* ssdcableslay5pconwaterot[4];    
7965   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7966   for(Int_t i=0; i<4; i++){
7967    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7968    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7969    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7970         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7971         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7972         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7973         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7974         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7975   }
7976   /////////////////////////
7977   // SSD Layer 6 Cables
7978   /////////////////////////
7979   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7980   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7981   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7982   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7983                                                                                                 ssdcableslay6rightsideradiusmax,
7984                                                                                                 0.5*ssdcablelay6rightsidelength); 
7985   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7986                                                                                                          ssdcablelay6rightubeshape,
7987                                                                                                          fSSDCopper);
7988   ssdcablelay6righttube->SetLineColor(9);
7989   TGeoTranslation* ssdcablelay6rightrans = 
7990                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7991                                                                                  +              fgkEndCapSupportCenterLay6Position
7992                                                                                  +      0.5*ssdcablelay6rightsidelength);
7993   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7994                                                                                                         - 0.5*ssdcablelay6rightsidelength
7995                                                                                                         - fgkEndCapSupportCenterLay6Position
7996                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7997   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7998   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7999   ////////////////////////////////////
8000   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
8001   ////////////////////////////////////
8002   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
8003                                                                                    ssdcableangle,2);   
8004   TGeoVolume* ssdcableslay6pcon;
8005   Double_t ssdcableslay6pconrmin[2];
8006   Double_t ssdcableslay6pconrmax[2];
8007   Double_t ssdcableslay6pconzsection[2];
8008   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
8009   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
8010   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
8011   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
8012   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8013                                                            + fgkEndCapSupportCenterLay6Position
8014                                                            + ssdcablelay6rightsidelength;
8015   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
8016   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
8017                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
8018   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
8019                                                            ssdcableslay6pconshape,fSSDCopper);
8020   ssdcableslay6pcon->SetLineColor(9);
8021   for(Int_t i=0; i<4; i++){
8022    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
8023    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8024   }
8025   ////////////////////////////////////
8026   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
8027   /////////////////////////
8028   // Water Tubes Layer 6
8029   /////////////////////////
8030   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
8031                                                                                                                   ssdcableslay6rightsideradiusmax
8032                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
8033                                                                                                                   0.5*ssdcablelay6rightsidelength); 
8034   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
8035                                                                                                          ssdcablelay6righwatertubeshape,
8036                                                                                                          fSSDCoolingTubeWater);
8037   ssdcablelay6rightwatertube->SetLineColor(7);
8038   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
8039   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
8040   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
8041                                                                                    ssdcableangle,2);   
8042   TGeoVolume* ssdcableslay6waterpcon;
8043   Double_t ssdcableslay6waterpconrmin[2];
8044   Double_t ssdcableslay6waterpconrmax[2];
8045   Double_t ssdcableslay6waterpconzsection[2];
8046   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
8047   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
8048                                                             + fgkSSDCablesLay5RightSideWaterHeight;
8049   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
8050   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
8051   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8052                                                            + fgkEndCapSupportCenterLay6Position
8053                                                            + ssdcablelay6rightsidelength;
8054   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8055   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
8056                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
8057   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
8058                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
8059   ssdcableslay6waterpcon->SetLineColor(7);
8060   TGeoRotation* ssdcableslay6pconwaterot[4];    
8061   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
8062   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
8063   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
8064   for(Int_t i=0; i<4; i++){
8065    ssdcableslay6pconwaterot[i] = new TGeoRotation();
8066    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
8067    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
8068                                                                                  * (*ssdcableslay6pconwaterot[i]));   
8069    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
8070    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
8071   }
8072   ////////////////////////////////////////
8073   // From ITS Ring to Patch Panel3-RB26
8074   ////////////////////////////////////////
8075   Double_t ssdcablepatchpanel3BB26radiusmin[2];
8076   Double_t ssdcablepatchpanel3BB26radiusmax[2];
8077   Double_t ssdcablepatchpanel3RB26zsection[2];
8078   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
8079   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
8080                                                                           + fgkSSDCablesLay5RightSideHeight
8081                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8082   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
8083   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
8084                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8085                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8086   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
8087                                                                                  + fgkSSDCentralAL3SupportLength
8088                                                                                  + fgkSSDPConeZLength[0];
8089   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
8090   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
8091                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8092                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8093   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
8094                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
8095   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
8096                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
8097   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
8098   TGeoRotation* ssdcablepatchpanel3B26rot[3];
8099   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
8100   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
8101   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
8102                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8103   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
8104   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
8105                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8106   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
8107   ////////////////////////////////////
8108   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
8109   ////////////////////////////////////////
8110   //  ITS Ring Cables RB26 Part
8111   ////////////////////////////////////////
8112   Double_t ssdcableitsring3BB26pconzsection[2];
8113   Double_t ssdcableitsring3BB26pconrmin[2];
8114   Double_t ssdcableitsring3BB26pconrmax[2];
8115   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
8116                                                                           + fgkSSDCentralAL3SupportLength
8117                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
8118   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
8119   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8120   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
8121                                                                   + fgkSSDCablesLay5RightSideHeight
8122                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8123   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
8124   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
8125   TGeoPcon* ssdcableitsring3BB26pconshape[4];
8126   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8127                                                                    -              0.5*ssdcableangle,ssdcableangle
8128                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
8129                                                                    -                             fgkSSDCableAngle),2);
8130   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8131                                                                    -              0.5*ssdcableangle,ssdcableangle
8132                                                                    +                      3.0*fgkSSDCableAngle
8133                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8134   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
8135                                                                    -              0.5*ssdcableangle,ssdcableangle
8136                                                                    -                      fgkSSDCableAngle
8137                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
8138   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8139                                                                    -              0.5*ssdcableangle,ssdcableangle
8140                                                                    +                      3.0*fgkSSDCableAngle
8141                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8142   for(Int_t i=0;i<4;i++)
8143         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
8144                                                          ssdcableitsring3BB26pconrmin[j],
8145                                                          ssdcableitsring3BB26pconrmax[j]); 
8146   TGeoVolume* ssdcableitsring3BB26pcon[4];
8147   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
8148                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
8149   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
8150                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
8151   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
8152                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
8153   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
8154                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
8155   for(Int_t i=0;i<4;i++){
8156         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
8157         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
8158 }
8159   ////////////////////////////////////
8160   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8161   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8162   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8163   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8164   ////////////////////////////////////////
8165   // From ITS Ring to Patch Panel2-RB24
8166   ////////////////////////////////////////
8167   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8168   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8169   Double_t ssdcablepatchpanel3RB24zsection[2];
8170   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8171   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8172   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8173   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8174                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8175                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8176                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8177   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8178                                                                          -  fgkSSDCentralAL3SupportLength
8179                                                                          -  fgkSSDPConeZLength[0];
8180   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8181   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8182                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8183                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8184   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8185                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8186   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8187                                                                                                 ssdcablepatchpanel3RB24pconshape,
8188                                                                                                 fSSDCopper);
8189   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8190   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8191   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8192   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
8193   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8194                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8195   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
8196   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8197                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8198   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8199   ////////////////////////////////////
8200   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8201   ////////////////////////////////////////
8202   //  ITS Ring Cables RB24 Part
8203   ////////////////////////////////////////
8204   Double_t ssdcableitsring3BB24pconzsection[2];
8205   Double_t ssdcableitsring3BB24pconrmin[2];
8206   Double_t ssdcableitsring3BB24pconrmax[2];
8207   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8208   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8209   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8210   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8211                                                                   + fgkSSDCablesLay5RightSideHeight
8212                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8213   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8214   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8215   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8216   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8217                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8218                                                                    -                             fgkSSDCableAngle),2);
8219   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8220                                                                      ssdcableangle-fgkSSDCableAngle
8221                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8222   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8223                                                                    -                      fgkSSDCableAngle
8224                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8225   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8226                                                                                                   ssdcableangle-fgkSSDCableAngle
8227                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8228   for(Int_t i=0;i<4;i++)
8229         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8230                                                          ssdcableitsring3BB24pconrmin[j],
8231                                                          ssdcableitsring3BB24pconrmax[j]); 
8232   TGeoVolume* ssdcableitsring3BB24pcon[4];
8233   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8234                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8235   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8236                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8237   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8238                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8239   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8240                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8241   for(Int_t i=0;i<4;i++){
8242         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8243         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8244 }
8245   ////////////////////////////////////
8246   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8247   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8248   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8249   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8250   ////////////////////////////////////
8251   // Volumes for Material Budget 
8252   ////////////////////////////////////
8253   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8254                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8255                                                                                                          ssdcableslay6rightsideradiusmax
8256                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8257                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8258   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8259                                                                                                          ssdcablelay6materialbudgetubeshape,
8260                                                                                                          fSSDCopper);
8261   ssdcablelay6materialbudgetube->SetLineColor(9);
8262   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8263   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8264
8265   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8266                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8267   TGeoVolume* ssdcablelay6materialbudgetpcon;
8268   Double_t ssdcablelay6materialbudgetpconrmin[2];
8269   Double_t ssdcablelay6materialbudgetpconrmax[2];
8270   Double_t ssdcablelay6materialbudgetpconzsection[2];
8271   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8272                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8273   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8274                                                                                 + fgkSSDCableMaterialBudgetHeight;
8275   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8276   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8277   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8278                                                                                         + fgkEndCapSupportCenterLay6Position
8279                                                                                         + ssdcablelay6rightsidelength;
8280   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8281   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8282                                                   ssdcablelay6materialbudgetpconzsection[i],
8283                                                   ssdcablelay6materialbudgetpconrmin[i],
8284                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8285   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8286                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8287   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8288   for(Int_t i=0; i<4; i++){
8289    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8290    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8291   }
8292 ////////////////////////////////////
8293  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8294   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8295   Double_t ssdcablesvolume = 0.0;
8296   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8297   std::cout << ssdcablesvolume << std::endl;*/
8298   return ssdcablesmother;
8299  }
8300  ////////////////////////////////////////////////////////////////////////////////
8301 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8302                                             Double_t height, const char* shapename, Int_t isign) const{
8303   /////////////////////////////////////////////////////////////
8304   // Method generating an Arb shape 
8305   /////////////////////////////////////////////////////////////
8306   const Int_t kvertexnumber = 8;
8307   const Int_t ktransvectnumber = 2;
8308   TVector3 vertex[kvertexnumber];
8309   TVector3 transvector[2];
8310   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
8311   /////////////////////////////////////////////////////////////
8312   //Setting the vertices for TGeoArb8
8313   /////////////////////////////////////////////////////////////
8314   vertex[0] = *vertexpos[0];
8315   vertex[1] = *vertexpos[1];
8316   vertex[2] = vertex[1]; 
8317   vertex[3] = vertex[0]; 
8318   vertex[4] = *vertexpos[2];
8319   vertex[5] = *vertexpos[3];
8320   vertex[6] = vertex[5];
8321   vertex[7] = vertex[4];
8322
8323   // NB: order of points is clockwise
8324   if (isign < 0) {
8325     vertex[2] -= transvector[0];
8326     vertex[3] -= transvector[0];
8327     vertex[6] -= transvector[1];
8328     vertex[7] -= transvector[1];
8329   }
8330   else {
8331     vertex[0] += transvector[0];
8332     vertex[1] += transvector[0];
8333     vertex[4] += transvector[1];
8334     vertex[5] += transvector[1];
8335   }
8336
8337   /////////////////////////////////////////////////////////////
8338   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8339   for(Int_t i = 0; i<kvertexnumber;i++) {
8340     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
8341   }
8342
8343   return arbshape;
8344
8345 ///////////////////////////////////////////////////////////////////////////////
8346 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8347                                                                 Double_t rmax, Int_t nedges, Double_t height){
8348   /////////////////////////////////////////////////////////////
8349   // Method generating Arc shape 
8350   /////////////////////////////////////////////////////////////
8351         const Int_t kvertexnumber = 2*nedges+2;
8352         TGeoXtru* arcshape = new TGeoXtru(2);   
8353         TVector3** vertexposition[2];
8354         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8355         Double_t angle = 0.;
8356     for(Int_t i=0; i<nedges+1; i++){ 
8357                 angle = 90.+0.5*phi-i*(phi/nedges);
8358                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8359                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8360         }
8361         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8362         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8363         for(Int_t i=0; i<kvertexnumber; i++){ 
8364                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8365                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8366                 }
8367                 else if(i>=1&&i<nedges+2)
8368                 {
8369                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8370                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8371                 }
8372         else
8373                 {
8374                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8375                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8376                 }
8377     }
8378   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8379   arcshape->DefineSection(0,-0.5*height);
8380   arcshape->DefineSection(1,0.5*height);
8381   /////////////////////////////////////////////////////////////
8382   // Deallocating memory
8383   /////////////////////////////////////////////////////////////
8384   for(Int_t i=0; i<2; i++){
8385         for(Int_t j=0; j<nedges+1; j++)
8386                 delete vertexposition[i][j];
8387         delete [] vertexposition[i];
8388   }
8389   delete [] xvertexpoints;
8390   delete [] yvertexpoints;
8391   /////////////////////////////////////////////////////////////
8392         return arcshape;
8393 }
8394 ////////////////////////////////////////////////////////////////////////////////
8395 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8396   ///////////////////////////////////////////////////////////////////////
8397   // Method Generating the Screw Shape  
8398   // radius[0]: outer radius
8399   // radius[1]: inner radius
8400   // edgesnumber[0]: outer number of edges
8401   // edgesnumber[1]: inner number of edges
8402   // section[0]: lower section position
8403   // section[1]: higher section position
8404   ///////////////////////////////////////////////////////////////////////
8405   Double_t outradius = radius[0];
8406   Double_t inradius = radius[1];
8407   Int_t outvertexnumber = edgesnumber[0];
8408   Int_t invertexnumber = edgesnumber[1];
8409   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8410   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8411   for(Int_t i=0; i<outvertexnumber; i++){
8412         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8413         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8414   }
8415   for(Int_t i=0; i<invertexnumber; i++){
8416         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8417         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8418   }
8419   TGeoXtru* screwshapeout = new TGeoXtru(2);
8420   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8421   screwshapeout->DefineSection(0,section[0]);
8422   screwshapeout->DefineSection(1,section[1]);
8423   TGeoXtru* screwshapein = new TGeoXtru(2);
8424   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8425   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8426   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8427   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8428   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8429   
8430   delete [] xscrewvertex;
8431   delete [] yscrewvertex;
8432   return screwshape;
8433 }
8434 ////////////////////////////////////////////////////////////////////////////////
8435 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8436   ///////////////////////////////////////////////////////////////////////
8437   // Method Generating the Hole Shape  
8438   // radius of the Hole
8439   // nedges: number of edges to approximate the circle
8440   ///////////////////////////////////////////////////////////////////////
8441   Double_t* xholevertex = new Double_t[nedges];
8442   Double_t* yholevertex = new Double_t[nedges];
8443   Double_t z  = 0.5*(section[0]+section[1]);
8444   Double_t dz = 0.5*(section[1]-section[0]);
8445   TGeoTranslation *tr = 0;
8446   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8447      tr = new TGeoTranslation(0.,0.,z);
8448      tr->RegisterYourself();
8449   }   
8450   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8451   for(Int_t i=0; i<nedges; i++){
8452         xholevertex[i] = radius*CosD(i*360./nedges);
8453         yholevertex[i] = radius*SinD(i*360./nedges);
8454   }
8455   TGeoXtru* holeshapeout = new TGeoXtru(2);
8456   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8457   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8458   holeshapeout->DefineSection(1,section[1]+0.01);
8459   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8460   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8461   
8462   delete [] xholevertex;
8463   delete [] yholevertex;
8464   return holeshape;
8465 }
8466 ////////////////////////////////////////////////////////////////////////////////
8467 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8468   /////////////////////////////////////////////////////////////
8469   // Given an axis specified by param, it gives the reflection of the point
8470   // respect to the axis
8471   /////////////////////////////////////////////////////////////
8472   TVector3* n = new TVector3(param[0],param[1],param[2]);
8473   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8474   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8475   /////////////////////////////////////////////////////////////
8476   // Deallocating memory
8477   /////////////////////////////////////////////////////////////
8478   delete n;
8479   /////////////////////////////////////////////////////////////
8480   return reflectedvector;
8481 }
8482 ////////////////////////////////////////////////////////////////////////////////
8483 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8484                                                        Double_t dx,
8485                                                        Double_t dy,
8486                                                        Double_t dz) const{
8487   /////////////////////////////////////////////////////////////
8488   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8489   /////////////////////////////////////////////////////////////
8490   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8491   const Double_t *vect = hmatrix->GetTranslation();
8492   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8493   hmatrix->SetTranslation(newvect);
8494   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8495   delete hmatrix;
8496   return matrix;
8497 }
8498 ////////////////////////////////////////////////////////////////////////////////
8499 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8500   /////////////////////////////////////////////////////////////
8501   // Method returning the Medium type 
8502   /////////////////////////////////////////////////////////////
8503   char ch[100];
8504   sprintf(ch, "ITS_%s",mediumName);
8505   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8506   if (! medium)
8507     AliError(Form("medium %s not found !\n", mediumName));
8508   return medium;
8509 }
8510 ////////////////////////////////////////////////////////////////////////////////
8511 void AliITSv11GeometrySSD::CreateMaterials(){
8512 ///////////////////////////////////
8513 // This part has to be modified
8514 ///////////////////////////////////
8515   ///////////////////////////////////
8516   // Silicon for Sensor
8517   /////////////////////////////////// 
8518   fSSDSensorMedium = GetMedium("SI$");
8519   ///////////////////////////////////
8520   // Silicon Mixture for Sensor
8521   /////////////////////////////////// 
8522   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8523   fSSDChipGlueMedium = GetMedium("EPOXY$");
8524   ///////////////////////////////////
8525   // Stiffener Components Materials
8526   /////////////////////////////////// 
8527   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8528   ///////////////////////////  
8529   // Stiffener Connectors 
8530   ///////////////////////////  
8531   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8532   ////////////////////////////////  
8533   // Stiffener 0603-1812 Capacitor
8534   ////////////////////////////////  
8535   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8536   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8537   ///////////////////////////  
8538   // Stiffener Hybrid Wire 
8539   ///////////////////////////  
8540   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8541   ///////////////////////////  
8542   // Al for Cooling Block
8543   ///////////////////////////  
8544   fSSDAlCoolBlockMedium = GetMedium("AL$");
8545   //////////////////////////////////////////////////////  
8546   // Kapton and Al for Chip Cable Flex and Ladder Cables
8547   //////////////////////////////////////////////////////  
8548   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8549   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8550   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8551   fSSDAlTraceFlexMedium = GetMedium("AL$");
8552   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8553   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8554   /////////////////////////////////////////////////////////////////  
8555   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8556   //////////////////////////////////////////////////////////////////  
8557   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8558   /////////////////////////////////////////////////////////////////  
8559   // G10 for Detector Leg, TubeHolder
8560   //////////////////////////////////////////////////////////////////  
8561   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8562   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8563   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8564   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8565   /////////////////////////////////////////////////////////////////  
8566   // Water and Phynox for Cooling Tube
8567   //////////////////////////////////////////////////////////////////  
8568   fSSDCoolingTubeWater = GetMedium("WATER$");
8569   fSSDCoolingTubePhynox = GetMedium("INOX$");
8570   /////////////////////////////////////////////////////////////////////
8571   // Material for Support Rings
8572   /////////////////////////////////////////////////////////////////////
8573   fSSDSupportRingAl = GetMedium("AL$");
8574   fSSDRohaCellCone = GetMedium("ROHACELL$");
8575   /////////////////////////////////////////////////////////////////////
8576   fSSDAir = GetMedium("SDD AIR$");
8577   fSSDCopper = GetMedium("COPPER$");
8578   fCreateMaterials = kTRUE;
8579 }
8580 /////////////////////////////////////////////////////////////////////