]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
removed overlaps on SSD cables (M. Sitta)
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoTube.h"
33 #include "TGeoBBox.h"
34 #include "TGeoXtru.h"
35 #include "TGeoTorus.h"
36 #include "TGeoPgon.h"
37 #include "TGeoPcon.h"
38 #include "TRotation.h"
39 #include "AliITSv11GeometrySSD.h"
40 /////////////////////////////////////////////////////////////////////////////////
41 // Names of the Sensitive Volumes of Layer 5 and Layer 6
42 /////////////////////////////////////////////////////////////////////////////////
43 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
44 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
45 /////////////////////////////////////////////////////////////////////////////////
46 //Parameters for SSD Geometry
47 /////////////////////////////////////////////////////////////////////////////////
48 // Variable for Vertical Disalignement of Modules
49 /////////////////////////////////////////////////////////////////////////////////
50 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
51 /////////////////////////////////////////////////////////////////////////////////
52 // Layer5 (lengths are in mm and angles in degrees)
53 /////////////////////////////////////////////////////////////////////////////////
54 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
55 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
56 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
57 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
58 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
59 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
60 /////////////////////////////////////////////////////////////////////////////////
61 // Layer6 (lengths are in mm and angles in degrees)
62 /////////////////////////////////////////////////////////////////////////////////
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
64 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
65 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
66 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
67 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
68 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
69 /////////////////////////////////////////////////////////////////////////////////
70 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
71 /////////////////////////////////////////////////////////////////////////////////
72 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
73 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
74 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
75 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
76 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
77 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
78 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
80 /////////////////////////////////////////////////////////////////////////////////
81 // Stiffener (lengths are in mm and angles in degrees)
82 /////////////////////////////////////////////////////////////////////////////////
83 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
84 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
85 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
86 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
87 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
88 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
89 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
94 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
97                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
98 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
101 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
102                                                                                                           0.25*fgkSSDStiffenerHeight;
103 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
105 /////////////////////////////////////////////////////////////////////////////////
106 // Cooling Block (lengths are in mm and angles in degrees)
107 /////////////////////////////////////////////////////////////////////////////////
108 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
109 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
111                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
112 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
113                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
115                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
117                                                                                                                                          1.500*fgkmm;
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
119                                                                                                                                          0.300*fgkmm;
120 /////////////////////////////////////////////////////////////////////////////////
121 // SSD Sensor (lengths are in mm and angles in degrees)
122 /////////////////////////////////////////////////////////////////////////////////
123 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
124                                                                                                                  "SSDSensorSensitiveVol";
125 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
126 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
127 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
128 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
129                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
130 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
132 /////////////////////////////////////////////////////////////////////////////////
133 // Flex (lengths are in mm and angles in degrees)
134 /////////////////////////////////////////////////////////////////////////////////
135 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
136 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
137                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
138                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
139                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
140                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
141                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
143                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
144 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
145                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
146 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
147 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
149 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
150                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
151 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
152                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
153 /////////////////////////////////////////////////////////////////////////////////
154 // SSD Ladder Cable (lengths are in mm and angles in degrees)
155 /////////////////////////////////////////////////////////////////////////////////
156 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
157 /////////////////////////////////////////////////////////////////////////////////
158 // SSD Module (lengths are in mm and angles in degrees)
159 /////////////////////////////////////////////////////////////////////////////////
160 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
161                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
162 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
163                                                                                                                                         45.600*fgkmm;
164 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
165                                                                                                                                          5.075*fgkmm;
166 /////////////////////////////////////////////////////////////////////////////////
167 // Sensor Support (lengths are in mm and angles in degrees)
168 /////////////////////////////////////////////////////////////////////////////////
169 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
170                                                                                                                                          5.800*fgkmm;
171 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
172                                                                                                                                          2.000*fgkmm;
173 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
174                                                                                                      { 4.620*fgkmm, 5.180*fgkmm};
175 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
176                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
177 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
178                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
179                                                             +  fgkSSDSensorSideSupportThickness[0])
180                                                                 -  fgkSSDSensorSideSupportLength;
181 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
182                                                                                                                                     5.250*fgkmm;
183 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
184                                                                                                                                         1.680*fgkmm;
185 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
186                                                                   = {fgkSSDSensorSideSupportHeight[0]
187                                                                   +  fgkSSDSensorSideSupportThickness[0],
188                                                                          fgkSSDSensorSideSupportHeight[1]
189                                                                   +  fgkSSDSensorSideSupportThickness[1]};
190 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
191                                                                   =  {fgkSSDSensorSideSupportThickness[0],
192                                                                           fgkSSDSensorSideSupportThickness[1]};
193 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
194                                                                                                                                    19.000*fgkmm;
195 /////////////////////////////////////////////////////////////////////////////////
196 // Chip Cables (lengths are in mm and angles in degrees)
197 /////////////////////////////////////////////////////////////////////////////////
198 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
199                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
200 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
201                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
202                                                                   -  (fgkSSDSensorSideSupportHeight[1]
203                                                                   -   fgkSSDSensorSideSupportHeight[0])
204                                                                   -   fgkSSDCoolingBlockHoleCenter
205                                                                   -   fgkSSDStiffenerHeight
206                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
207                                                                           fgkSSDModuleCoolingBlockToSensor
208                                                                   -   fgkSSDCoolingBlockHoleCenter
209                                                                   -       fgkSSDStiffenerHeight
210                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
211 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
212                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
213 /////////////////////////////////////////////////////////////////////////////////
214 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
215 /////////////////////////////////////////////////////////////////////////////////
216 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
217                                                                                                                                         3.820*fgkmm;
218 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
219 //                                                                                                                                         3.780;
220 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
221                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
222 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
223                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
224 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
225                                                                                                                                 { 30.00, 90.00};
226 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
227                                                                                                                                          1.78*fgkmm;
228 /////////////////////////////////////////////////////////////////////////////////
229 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
230 /////////////////////////////////////////////////////////////////////////////////
231 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
232                                                                    = fgkSSDModuleSensorSupportDistance
233                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
234 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
235 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
236                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
237 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
238                                                                                                                                         1.630*fgkmm;
239 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
240 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
241                                                                         = fgkCarbonFiberTriangleLength
242                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
243                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
244                                                                         * TMath::DegToRad());
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
246                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
247                                                                         - fgkCarbonFiberSupportWidth)
248                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
249                                                                         - fgkCarbonFiberSupportWidth;
250 /////////////////////////////////////////////////////////////////////////////////
251 // Carbon Fiber Lower Support Parameters (lengths are in mm)
252 /////////////////////////////////////////////////////////////////////////////////
253 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
254                                                                                                                                           =  0.950*fgkmm;
255 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
256                                                                                                                                           =  1.600*fgkmm;
257 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
258                                                                                                                                           =  0.830*fgkmm;
259 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
260                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
261 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
262                                                                         = fgkCarbonFiberJunctionWidth
263                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
264                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
266                                                                         = {fgkCarbonFiberLowerSupportWidth
267                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
268                                                                            fgkCarbonFiberLowerSupportWidth
269                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
270                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
271 /////////////////////////////////////////////////////////////////////////////////
272 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
273 /////////////////////////////////////////////////////////////////////////////////
274 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
275                                                            {0.5 * (fgkSSDLay5LadderLength
276                                                                         -  fgkSSDLay5SensorsNumber
277                                                                         *  fgkCarbonFiberJunctionWidth
278                                                                         -  fgkCarbonFiberLowerSupportWidth),
279                                                                 0.5 * (fgkSSDLay5LadderLength
280                                                                         -  fgkSSDLay5SensorsNumber
281                                                                         *  fgkCarbonFiberJunctionWidth
282                                                                         +  fgkCarbonFiberLowerSupportWidth)};
283 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
284                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
285                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
286 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
287                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
288                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
289 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
290                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
291 /////////////////////////////////////////////////////////////////////////////////
292 // Cooling Tube Support (lengths are in mm and angles in degrees)
293 /////////////////////////////////////////////////////////////////////////////////
294 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
295 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
296                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
297 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
298 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
299 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
300 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
301                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
302 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
303                                                                                                                                           11.70*fgkmm;
304 /////////////////////////////////////////////////////////////////////////////////
305 // Cooling Tube (lengths are in mm and angles in degrees)
306 /////////////////////////////////////////////////////////////////////////////////
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
308 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
310                                                                                                         fgkCarbonFiberJunctionWidth;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
312                                                                          fgkSSDModuleSensorSupportDistance
313                                                                   +      fgkSSDCoolingBlockLength;
314 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
315 /////////////////////////////////////////////////////////////////////////////////
316 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
317 /////////////////////////////////////////////////////////////////////////////////
318 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
319                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
320 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
321                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
322 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
323                                                                                                                                           20.0*fgkmm;
324 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
325                                                                                                                                                     40.0;
326 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
327                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
328 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
329                                                                                                                                           2.5*fgkmm;
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
331                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
333                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
335                                                                                                                                           1.0*fgkmm;
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
337                                                                                                                                           6.0*fgkmm;
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
339                                                                                                                                           4.0*fgkmm;
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
341                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
342 /////////////////////////////////////////////////////////////////////////////////
343 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
344 /////////////////////////////////////////////////////////////////////////////////
345 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
346 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
347 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
349 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
350 /////////////////////////////////////////////////////////////////////////////////
351 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
352 /////////////////////////////////////////////////////////////////////////////////
353 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
354 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
355 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
356                                                                                                   -  fgkSSDMountingBlockHeight[1]
357                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
358                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
359                                                                                                   +  fgkSSDModuleVerticalDisalignment
360                                                                                                   -      fgkMountingBlockSupportDownHeight,
361                                                                                                          fgkSSDLay6RadiusMin
362                                                                                                   -  fgkSSDMountingBlockHeight[1]
363                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
364                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
365                                                                                                   +  fgkSSDModuleVerticalDisalignment
366                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
368                                                                                                     -  fgkSSDMountingBlockHeight[1]
369                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
370                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
371                                                                                                         +  fgkSSDModuleVerticalDisalignment
372                                                                                                         -  fgkMountingBlockSupportRadius[0],
373                                                                                                            fgkSSDLay6RadiusMax
374                                                                                                     -  fgkSSDMountingBlockHeight[1]
375                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
376                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
377                                                                                                         +  fgkSSDModuleVerticalDisalignment
378                                                                                                         -  fgkMountingBlockSupportRadius[1]};
379 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
380 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
381 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
382 /////////////////////////////////////////////////////////////////////////////////
383 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
384 /////////////////////////////////////////////////////////////////////////////////
385 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
386 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
387 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
388 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
389                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
390 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
391                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
392 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
393                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
397 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
399 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
400 /////////////////////////////////////////////////////////////////////////////////
401 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
402 /////////////////////////////////////////////////////////////////////////////////
403 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
404 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
405 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
406 /////////////////////////////////////////////////////////////////////////////////
407 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
408 /////////////////////////////////////////////////////////////////////////////////
409 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
410                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
411 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
412 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
413 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
414                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
415 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
416                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
418 /////////////////////////////////////////////////////////////////////////////////
419 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
420 /////////////////////////////////////////////////////////////////////////////////
421 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
422                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
423 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
424                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
425                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
426 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
427 /////////////////////////////////////////////////////////////////////////////////
428 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
429 /////////////////////////////////////////////////////////////////////////////////
430 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
431                                                                                                            {62.0*fgkmm,21.87*fgkmm};
432 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
433                                                                                                             {47.0*fgkmm,0.35*fgkmm};
434 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
435                                                                                                                                           1.0*fgkmm;
436 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
437 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
438                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
439 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
440                                                                                                                                          0.15*fgkmm;
441 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
442                                                                                                                                          19.0*fgkmm;
443 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
444                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
446                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
448                                                                                                                                           2.1*fgkmm;
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
450                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
452                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
454                                                                                                                                            19*fgkmm; 
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
456                                                                                                                                           1.0*fgkmm;
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
458                                                                                                                                           3.6*fgkmm;
459 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
460                                                                                                                                          61.0*fgkmm; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
462                                                                                                                                          5.97*fgkmm; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
464 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
465                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
466                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
467 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
468                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
469 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
470                                                                                                                                           1.0*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
472                                                                                                                                    = 0.15*fgkmm; 
473 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
474                                                                                                                                          20.0*fgkmm;
475 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
476 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
477 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
478 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
479 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
480 /////////////////////////////////////////////////////////////////////////////////
481 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
482 /////////////////////////////////////////////////////////////////////////////////
483 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
484 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
485 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
486 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
487 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
488 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
489 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
490 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
492 /////////////////////////////////////////////////////////////////////////////////
493 // SSD Cone Parameters (lengths are in mm and angles in degrees)
494 /////////////////////////////////////////////////////////////////////////////////
495 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
496 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
497 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
498 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
500 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
501 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
502 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
503 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
508 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
514 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
516 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
517 /////////////////////////////////////////////////////////////////////////////////
518 // SSD Cables Parameters (lengths are in mm and angles in degrees)
519 /////////////////////////////////////////////////////////////////////////////////
520 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
522 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
523 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
524 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
525 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
526 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
527 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
528 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
529 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
531 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
532 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
533 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
534 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
535 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
536 /////////////////////////////////////////////////////////////////////////////////
537 ClassImp(AliITSv11GeometrySSD)
538 /////////////////////////////////////////////////////////////////////////////////
539 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
540   AliITSv11Geometry(),
541   fSSDChipMedium(),
542   fSSDChipGlueMedium(),
543   fSSDStiffenerMedium(),
544   fSSDStiffenerConnectorMedium(),
545   fSSDStiffener0603CapacitorMedium(),
546   fSSDStiffener1812CapacitorMedium(),
547   fSSDStiffenerHybridWireMedium(),
548   fSSDKaptonFlexMedium(),
549   fSSDAlTraceFlexMedium(),
550   fSSDAlTraceLadderCableMedium(),
551   fSSDKaptonLadderCableMedium(),
552   fSSDKaptonChipCableMedium(),
553   fSSDAlTraceChipCableMedium(),
554   fSSDAlCoolBlockMedium(),
555   fSSDSensorMedium(),
556   fSSDSensorSupportMedium(),
557   fSSDCarbonFiberMedium(),
558   fSSDTubeHolderMedium(),
559   fSSDCoolingTubeWater(),
560   fSSDCoolingTubePhynox(),
561   fSSDSupportRingAl(),
562   fSSDMountingBlockMedium(),
563   fSSDRohaCellCone(),
564   fSSDAir(),
565   fSSDCopper(),
566   fCreateMaterials(kFALSE),
567   fTransformationMatrices(kFALSE),
568   fBasicObjects(kFALSE),
569   fcarbonfiberjunction(),
570   fcoolingtubesupport(),
571   fhybridmatrix(),
572   fssdcoolingblocksystem(),
573   fcoolingblocksystematrix(),
574   fssdstiffenerflex(),
575   fssdendflex(),
576   fendladdercoolingtubesupportmatrix(),
577   fendladdermountingblock(),
578   fendladdermountingblockclip(),
579   fSSDSensor5(),
580   fSSDSensor6(),
581   fSSDLayer5(), 
582   fSSDLayer6(),
583   fMotherVol(),
584   fLay5LadderSupportRing(),
585   fLay6LadderSupportRing(),
586   fgkEndCapSupportSystem(),
587   fSSDCone(),
588   fColorCarbonFiber(4),
589   fColorRyton(5),
590   fColorPhynox(14),
591   fColorSilicon(3),
592   fColorAl(38),
593   fColorKapton(6),
594   fColorPolyhamide(5),
595   fColorStiffener(9),
596   fColorEpoxy(30),
597   fColorWater(7),
598   fColorG10(41)
599 {
600   ////////////////////////
601   // Standard constructor
602   ////////////////////////
603 }
604 /////////////////////////////////////////////////////////////////////////////////
605 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
606   AliITSv11Geometry(s.GetDebug()),
607   fSSDChipMedium(s.fSSDChipMedium),
608   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
609   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
610   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
611   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
612   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
613   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
614   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
615   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
616   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
617   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
618   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
619   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
620   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
621   fSSDSensorMedium(s.fSSDSensorMedium),
622   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
623   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
624   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
625   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
626   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
627   fSSDSupportRingAl(s.fSSDSupportRingAl),
628   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
629   fSSDRohaCellCone(s.fSSDRohaCellCone),
630   fSSDAir(s.fSSDAir),
631   fSSDCopper(s.fSSDCopper),
632   fCreateMaterials(s.fCreateMaterials),
633   fTransformationMatrices(s.fTransformationMatrices),
634   fBasicObjects(s.fBasicObjects),
635   fcarbonfiberjunction(s.fcarbonfiberjunction),
636   fcoolingtubesupport(s.fcoolingtubesupport),
637   fhybridmatrix(s.fhybridmatrix),
638   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
639   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
640   fssdstiffenerflex(s.fssdstiffenerflex),
641   fssdendflex(s.fssdendflex),
642   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
643   fendladdermountingblock(s.fendladdermountingblock),
644   fendladdermountingblockclip(s.fendladdermountingblockclip),
645   fSSDSensor5(s.fSSDSensor5),
646   fSSDSensor6(s.fSSDSensor6),
647   fSSDLayer5(s.fSSDLayer5),     
648   fSSDLayer6(s.fSSDLayer6),
649   fMotherVol(s.fMotherVol),
650   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
651   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
652   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
653   fSSDCone(s.fSSDCone),
654   fColorCarbonFiber(s.fColorCarbonFiber),
655   fColorRyton(s.fColorRyton),
656   fColorPhynox(s.fColorPhynox),
657   fColorSilicon(s.fColorSilicon),
658   fColorAl(s.fColorAl),
659   fColorKapton(s.fColorKapton),
660   fColorPolyhamide(s.fColorPolyhamide),
661   fColorStiffener(s.fColorStiffener),
662   fColorEpoxy(s.fColorEpoxy),
663   fColorWater(s.fColorWater),
664   fColorG10(s.fColorG10)
665 {
666   ////////////////////////
667   // Copy Constructor
668   ////////////////////////
669 }
670 /////////////////////////////////////////////////////////////////////////////////
671 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
672 operator=(const AliITSv11GeometrySSD &s){
673   ////////////////////////
674   // Assignment operator
675   ////////////////////////
676   this->~AliITSv11GeometrySSD();
677   new(this) AliITSv11GeometrySSD(s); 
678   return *this;
679 /*      
680   if(&s == this) return *this;
681   fMotherVol = s.fMotherVol;
682   return *this;
683  */
684 }
685 ///////////////////////////////////////////////////////////////////////////////
686 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
687   ///////////////////////////////////////////////////////////////////////  
688   // Method generating the trasformation matrix for the whole SSD Geometry   
689   ///////////////////////////////////////////////////////////////////////  
690   // Setting some variables for Carbon Fiber Supportmatrix creation
691   //////////////////////////////////////////////////////////////////////
692   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
693                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
694   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
695                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
696                                                                  +      fgkCarbonFiberSupportWidth);
697   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
698                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
699   TGeoRotation* carbonfiberot[3];
700   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
701   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
702   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
703   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
704   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
705                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
706                                                   -  fgkCarbonFiberTriangleLength
707                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
708   ///////////////////////////////////////////
709   //Setting Local Translations and Rotations: 
710   ///////////////////////////////////////////
711   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
712   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
713                                                                          0.5*carbonfibersupportheight,NULL);    
714   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
715                                                                          2.*symmetryplaneposition+transvector[1],
716                                                                          transvector[2], carbonfiberot[2]);
717   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
718   /////////////////////////////////////////////////////////////
719   // Carbon Fiber Support Transformations
720   /////////////////////////////////////////////////////////////
721   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
722   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
723                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
724                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
725                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
726   }             
727   /////////////////////////////////////////////////////////////
728   // Carbon Fiber Junction Transformation
729   /////////////////////////////////////////////////////////////
730   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
731   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
732   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
733   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
734   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
735         localcarbonfiberjunctionmatrix[i] = 
736                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
737         localcarbonfiberjunctionrot[i] = 
738                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
739         localcarbonfiberjunctiontrans[i] = 
740                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
741   }
742   ///////////////////////
743   // Setting Translations
744   ///////////////////////
745   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
746   localcarbonfiberjunctiontrans[1][0] = 
747                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
748   localcarbonfiberjunctiontrans[2][0] = 
749                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
750                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
751                                  fgkCarbonFiberTriangleLength
752                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
753   localcarbonfiberjunctiontrans[0][1] = 
754                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
755   localcarbonfiberjunctiontrans[1][1] = 
756                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
757   localcarbonfiberjunctiontrans[2][1] = 
758                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
759   ////////////////////
760   // Setting Rotations
761   ////////////////////
762   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
763                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
764                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
765   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
766         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
767   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
768   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
769   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
770   ////////////////////////////////////////
771   // Setting Carbon Fiber Junction matrix 
772   ////////////////////////////////////////
773   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
774                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
775                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
776                         localcarbonfiberjunctionmatrix[i][j] = 
777                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
778                                                            *localcarbonfiberjunctionrot[i][j]);
779                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
780          }
781   }
782   /////////////////////////////////////////////////////////////
783   // Carbon Fiber Lower Support Transformations
784   /////////////////////////////////////////////////////////////
785   TGeoTranslation* localcarbonfiberlowersupportrans[2];
786   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
787                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
788                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
789                                                                          0.0);
790   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
791                                                                          fgkCarbonFiberJunctionWidth
792                                                                 -    fgkCarbonFiberLowerSupportWidth
793                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
794                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
795                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
796    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
797    fcarbonfiberlowersupportrans[0] = 
798                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
799    fcarbonfiberlowersupportrans[1] = 
800                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
801   /////////////////////////////////////////////////////////////
802   // SSD Sensor Support Transformations
803   /////////////////////////////////////////////////////////////
804   const Int_t kssdsensorsupportmatrixnumber = 3;
805   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
806   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
807   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
808   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
809         localssdsensorsupportmatrix[i] = 
810                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
811         localssdsensorsupportrot[i] = 
812                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
813         localssdsensorsupportrans[i] = 
814                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
815   }
816   ///////////////////////
817   // Setting Translations
818   ///////////////////////
819   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
820                                                                           0.5*fgkSSDSensorSideSupportWidth,
821                                                                           0.0);
822   localssdsensorsupportrans[1][0] = 
823                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
824   localssdsensorsupportrans[2][0] = 
825                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
826   localssdsensorsupportrans[0][1] = 
827                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
828                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
829                                                                                 0.0);
830   localssdsensorsupportrans[1][1] = 
831                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
832                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
833                                                                     -   fgkSSDModuleSensorSupportDistance,
834                                                                                 0.0);
835   localssdsensorsupportrans[2][1] = 
836                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
837                                                                         -    fgkSSDSensorCenterSupportPosition,
838                                                                                  0.5*fgkSSDSensorCenterSupportWidth
839                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
840                                                                                  fgkSSDSensorCenterSupportThickness[0]);
841   localssdsensorsupportrans[0][2] = 
842                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
843                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
844                                                                                  fgkCarbonFiberJunctionWidth
845                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
846                                                                         +    fgkSSDSensorCenterSupportLength
847                                                                         -    fgkSSDSensorCenterSupportThickness[0])
848                                                                         -    fgkSSDSensorCenterSupportPosition,
849                                                                              0.0);
850   localssdsensorsupportrans[1][2] = 
851                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
852   localssdsensorsupportrans[2][2] = 
853                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
854   ////////////////////
855   // Setting Rotations
856   ////////////////////
857   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
858                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
859                         localssdsensorsupportrot[i][j] = new TGeoRotation();
860   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
861         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
862         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
863   }
864   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
865   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
866   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
867   ////////////////////////////////////////
868   // SSD Sensor Support matrix 
869   ////////////////////////////////////////
870   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
871                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
872                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
873                         localssdsensorsupportmatrix[i][j] = 
874                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
875                                                            *localssdsensorsupportrot[i][j]);
876                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
877          }
878   }
879   /////////////////////////////////////////////////////////////
880   // SSD Cooling Tube Support Transformations
881   /////////////////////////////////////////////////////////////
882   const Int_t kcoolingtubesupportmatrixnumber = 2;
883   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
884   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
885   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
886   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
887                                                                                                         /fgkCoolingTubeSupportRmax);
888   localcoolingtubesupportrans[0] = 
889                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
890                                                 +  2.*(fgkCoolingTubeSupportLength
891                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
892                                                 +  fgkCarbonFiberTriangleLength
893                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
894   localcoolingtubesupportrans[1] = 
895                         new TGeoTranslation(fgkCarbonFiberJunctionLength
896                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
897                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
898                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
899                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
900                     -  0.5*(fgkCarbonFiberLowerSupportWidth
901                                         +          fgkSSDSensorCenterSupportLength
902                     -      fgkSSDSensorCenterSupportThickness[0])
903                                         +  0.5*fgkSSDSensorLength,
904                                         -  0.5*fgkCoolingTubeSupportHeight);  
905   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
906   localcoolingtubesupportrot[i] = new TGeoRotation();
907   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
908   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
909   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
910         localcoolingtubesupportmatrix[i] = 
911                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
912                                                    *localcoolingtubesupportrot[i]);
913   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
914   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
915                                                                 (*localcoolingtubesupportmatrix[0]));
916   /////////////////////////////////////////////////////////////
917   // End Ladder SSD Cooling Tube Support Transformations
918   /////////////////////////////////////////////////////////////
919   TGeoTranslation** localendladdercooltubetrans[2];
920   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
921   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
922   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
923   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
924                                                                                         -          (fgkCoolingTubeSupportLength
925                                                                                         -               fgkCoolingTubeSupportRmax),
926                                                                                                         fgkEndLadderMountingBlockPosition[0]
927                                                                                         -               fgkendladdercoolingsupportdistance[0]
928                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
929                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
930   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
931                                                                                         -          (fgkCoolingTubeSupportLength
932                                                                                         -               fgkCoolingTubeSupportRmax),
933                                                                                                         fgkEndLadderMountingBlockPosition[0]
934                                                                                         +               fgkendladdercoolingsupportdistance[1]
935                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
936                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
937   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
938                                                                                         -       fgkCoolingTubeSupportRmax)
939                                                                                         +               fgkCarbonFiberTriangleLength
940                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
941                                                                                                 0.0,
942                                                                                                 0.0);
943   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
944                                                                                                         fgkendladdercoolingsupportdistance[0]
945                                                                                         +               fgkendladdercoolingsupportdistance[1],
946                                                                                                         0.0);
947   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
948   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
949                                                                                         +               fgkCarbonFiberJunctionLength
950                                                                                         -               fgkCoolingTubeSupportLength,
951                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
952                                                                                         -       0.5*fgkCoolingTubeSupportWidth
953                                                                                                    -fgkendladdercoolingsupportdistance[2],
954                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
955   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
956                                                                                         +               fgkCoolingTubeSupportLength
957                                                                                         -               fgkCoolingTubeSupportRmax
958                                                                                         -               fgkCarbonFiberJunctionLength,
959                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
960                                                                                         -       0.5*fgkCoolingTubeSupportWidth
961                                                                                         -               fgkendladdercoolingsupportdistance[2],
962                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
963   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
964   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
965   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
966   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
967   (*localcoolingtubesupportrot[1]));
968   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
969   (*localcoolingtubesupportrot[1]));
970   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
971   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
972   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
973   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
974   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
975
976   fendladdercoolingtubesupportmatrix[1][0] =    
977                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
978                                                                                    *(*localcoolingtubesupportrot[1]));
979   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
980   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
981   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
982   /////////////////////////////////////////////////////////////
983   // SSD Cooling Tube Transformations
984   /////////////////////////////////////////////////////////////
985   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
986   localcoolingtuberot->SetAngles(0.,90.,0.);
987   TGeoTranslation** localcoolingtubetrans[4];
988   TVector3** localcoolingtubevect[4];
989   for(Int_t i=0; i<4; i++){
990         localcoolingtubevect[i] = new TVector3*[2];
991         localcoolingtubetrans[i] = new TGeoTranslation*[2];
992         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
993   }
994   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
995                                                   -fgkCarbonFiberTriangleLength),
996                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
997                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
998                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
999                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1000                                                   +      fgkSSDSensorCenterSupportLength
1001                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1002                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1003                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1004                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1005                                                   -  0.5*fgkCoolingTubeSupportWidth,
1006                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1007   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1008                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1009                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1010                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1011                                                   +  fgkCoolingTubeSupportWidth,
1012                                                   localcoolingtubevect[0][0]->Z());     
1013   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1014                                                          +                               fgkCarbonFiberTriangleLength,
1015                                                                                          localcoolingtubevect[0][0]->Y(),
1016                                                                                          localcoolingtubevect[0][0]->Z());
1017   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1018                                                          +                               fgkCarbonFiberTriangleLength,
1019                                                                                          localcoolingtubevect[0][1]->Y(),
1020                                                                                          localcoolingtubevect[0][1]->Z());
1021   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1022                                                   -     fgkCarbonFiberTriangleLength),
1023                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1024                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1025                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1026                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1027                                                   +      fgkSSDSensorCenterSupportLength
1028                                                   -      fgkSSDSensorCenterSupportThickness[0])
1029                                                   +  fgkSSDModuleStiffenerPosition[1]
1030                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1031                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1032   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1033                                                          +                               fgkCarbonFiberTriangleLength,
1034                                                                                          localcoolingtubevect[2][0]->Y(),
1035                                                                                          localcoolingtubevect[2][0]->Z());      
1036   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1037                                                   -     fgkCarbonFiberTriangleLength),
1038                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1039                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1040                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1041                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1042                                                   +      fgkSSDSensorCenterSupportLength
1043                                                   -      fgkSSDSensorCenterSupportThickness[0])
1044                                                   +      fgkSSDSensorLength
1045                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1046                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1047   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1048                                                   + fgkCarbonFiberTriangleLength,
1049                                                         localcoolingtubevect[3][0]->Y(),
1050                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1051   for(Int_t i=0; i<4; i++) 
1052         for(Int_t j=0; j<2; j++){
1053                 localcoolingtubetrans[i][j] = 
1054                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1055                                                                 localcoolingtubevect[i][j]->Y(),
1056                                                                 localcoolingtubevect[i][j]->Z());
1057                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1058                                                           *                                     (*localcoolingtuberot));
1059         }
1060   /////////////////////////////////////////////////////////////
1061   // SSD End Ladder Cooling Tube Transformations
1062   /////////////////////////////////////////////////////////////
1063   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1064   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1065   TGeoTranslation** localendlladdercoolingtubetrans[2];
1066   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1067   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1068   for(Int_t i=0; i<2; i++)      
1069         for(Int_t j=0; j<(i==0?6:4); j++)       
1070                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1071   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1072                                                                         -        fgkCoolingTubeSupportRmax)
1073                                                                         +        fgkCarbonFiberJunctionLength,
1074                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1075                                                                         -    fgkendladdercoolingsupportdistance[0]),
1076                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1077   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1078                                                                         -        fgkCoolingTubeSupportRmax)
1079                                                                         -        fgkCarbonFiberJunctionLength
1080                                                                         +    fgkCarbonFiberTriangleLength,
1081                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1082                                                                         -    fgkendladdercoolingsupportdistance[0]),
1083                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1084   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1085                                                                         -   fgkCoolingTubeSupportRmax)
1086                                                                         +       fgkCarbonFiberJunctionLength,
1087                                                                            fgkEndLadderMountingBlockPosition[0]
1088                                                                         -   fgkendladdercoolingsupportdistance[0]
1089                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1090                                                   +                             fgkendladdercoolingsupportdistance[1]
1091                                                   +                             fgkCoolingTubeSupportWidth),
1092                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1093   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1094                                                                         -        fgkCoolingTubeSupportRmax)
1095                                                                         -        fgkCarbonFiberJunctionLength
1096                                                                         +    fgkCarbonFiberTriangleLength,
1097                                                                            fgkEndLadderMountingBlockPosition[0]
1098                                                                         -   fgkendladdercoolingsupportdistance[0]
1099                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1100                                                   +                             fgkendladdercoolingsupportdistance[1]
1101                                                   +                             fgkCoolingTubeSupportWidth),
1102                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1103   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1104                                                                         -   fgkCoolingTubeSupportRmax)
1105                                                                         +       fgkCarbonFiberJunctionLength,
1106                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1107                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1108                                                   -                     fgkEndLadderMountingBlockPosition[0]
1109                                                   -                     fgkendladdercoolingsupportdistance[1]           
1110                                                   -                     fgkCoolingTubeSupportWidth),
1111                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1112   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1113                                                                         -        fgkCoolingTubeSupportRmax)
1114                                                                         -        fgkCarbonFiberJunctionLength
1115                                                                         +    fgkCarbonFiberTriangleLength,
1116                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1117                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1118                                                   -                     fgkEndLadderMountingBlockPosition[0]
1119                                                   -                     fgkendladdercoolingsupportdistance[1]           
1120                                                   -                     fgkCoolingTubeSupportWidth),
1121                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1122   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1123                                                                         -   fgkCoolingTubeSupportRmax)
1124                                                                         +       fgkCarbonFiberJunctionLength,
1125                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1126                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1127                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1128                                                         +                 fgkSSDSensorOverlap
1129                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1130                                                         -                 fgkendladdercoolingsupportdistance[2]
1131                                                         -                 fgkEndLadderMountingBlockPosition[1]
1132                                                         -                 fgkCoolingTubeSupportWidth)
1133                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1134                                                         -                 fgkendladdercoolingsupportdistance[2]
1135                                                         -                 fgkCoolingTubeSupportWidth,
1136                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1137   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1138                                                   -      fgkCoolingTubeSupportRmax)
1139                                                   -      fgkCarbonFiberJunctionLength
1140                                                   +    fgkCarbonFiberTriangleLength,
1141                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1142                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1143                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1144                                                         +                 fgkSSDSensorOverlap
1145                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1146                                                         -                 fgkendladdercoolingsupportdistance[2]
1147                                                         -                 fgkEndLadderMountingBlockPosition[1]
1148                                                         -                 fgkCoolingTubeSupportWidth)
1149                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1150                                                         -                 fgkendladdercoolingsupportdistance[2]
1151                                                         -                 fgkCoolingTubeSupportWidth,
1152                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1153   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1154                                                                         -   fgkCoolingTubeSupportRmax)
1155                                                                         +       fgkCarbonFiberJunctionLength,
1156                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1157                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1158                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1159   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1160                                                                         -        fgkCoolingTubeSupportRmax)
1161                                                                         -        fgkCarbonFiberJunctionLength
1162                                                                         +    fgkCarbonFiberTriangleLength,
1163                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1164                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1165                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1166   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1167   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1168   for(Int_t i=0; i<2; i++)
1169         for(Int_t j=0; j<(i==0?6:4); j++){
1170                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1171                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1172         }
1173   /////////////////////////////////////////////////////////////
1174   // SSD Hybrid Components Transformations
1175   /////////////////////////////////////////////////////////////
1176   const Int_t khybridmatrixnumber = 3;
1177   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1178   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1179                                             0.5*fgkSSDStiffenerWidth,
1180                                             0.5*fgkSSDStiffenerHeight);
1181   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1182                                             fgkSSDModuleStiffenerPosition[1],0.0);
1183
1184   localhybridtrans[2] = new TGeoTranslation(
1185                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1186                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1187                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1188                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1189                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1190                       -       fgkSSDSensorCenterSupportThickness[0]),
1191                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1192                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight)); 
1193   fhybridmatrix = new TGeoHMatrix();
1194   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1195   /////////////////////////////////////////////////////////////
1196   // SSD Cooling Block Transformations
1197   /////////////////////////////////////////////////////////////
1198   const Int_t kcoolingblockmatrixnumber = 4;    
1199   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1200   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1201                             -  fgkCoolingTubeSupportRmin),0.0,
1202                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1203   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1204                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1205                                0.0,fgkSSDStiffenerHeight);
1206   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1207   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1208   fcoolingblocksystematrix = new TGeoHMatrix();
1209   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1210       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1211   /////////////////////////////////////////////////////////////
1212   // SSD Stiffener Flex Transformations
1213   /////////////////////////////////////////////////////////////
1214   const Int_t klocalflexmatrixnumber = 4;
1215   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1216   for(Int_t i=0; i<fgkflexnumber; i++)    
1217       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1218   for(Int_t i=0; i<fgkflexnumber; i++)
1219       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1220             localflexmatrix[i][j] = new TGeoCombiTrans();
1221   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1222                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1223                                                                   -    fgkSSDStiffenerWidth;
1224   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1225                                         +0.5*fgkSSDStiffenerLength,
1226                                          0.5*fgkSSDStiffenerWidth,
1227                                         -0.5*fgkSSDStiffenerHeight
1228                                         -0.5*fgkSSDFlexHeight[0]);
1229   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1230                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1231                                         -0.5*fgkSSDStiffenerWidth,
1232                                         -0.5*fgkSSDStiffenerHeight
1233                                         -0.5*fgkSSDFlexHeight[0]);
1234   TGeoRotation* localflexrot = new TGeoRotation();
1235   localflexrot->SetAngles(180.,0.,0.);    
1236   localflexmatrix[1][0]->SetRotation(localflexrot);
1237   for(Int_t i=0; i<fgkflexnumber; i++)
1238       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1239             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1240   for(Int_t i=0; i<fgkflexnumber; i++){
1241       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1242       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1243             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1244   }
1245   /////////////////////////////////////////////////////////////
1246   // SSD End Flex Transformations
1247   /////////////////////////////////////////////////////////////
1248   TGeoRotation* localendflexrot = new TGeoRotation();
1249   localendflexrot->SetAngles(0.0,90.0,0.0);
1250   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1251   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1252                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1253   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1254                             * TMath::DegToRad()*ssdflexradiusmax
1255                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1256                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
1257   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1258                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1259                             +      fgkSSDFlexLength[2];
1260   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1261                               0.5*fgkSSDFlexWidth[0],
1262                               2.*fgkSSDStiffenerHeight
1263                             + 0.5*fgkSSDFlexHeight[0]);      
1264   localendflexmatrix->SetRotation(localendflexrot);
1265   for(Int_t i=0; i<fgkflexnumber; i++) 
1266       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1267   /////////////////////////////////////////////////////////////
1268   // End Ladder Carbon Fiber Junction
1269   /////////////////////////////////////////////////////////////
1270   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1271   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1272   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1273   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1274       localendladdercarbonfiberjunctionmatrix[i] 
1275             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1276       localendladdercarbonfiberjunctionrot[i] 
1277             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1278       localendladdercarbonfiberjunctiontrans[i] 
1279             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1280       fendladdercarbonfiberjunctionmatrix[i]
1281             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1282   }
1283   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1284       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1285             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1286             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1287       }
1288   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1289       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1290           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1291   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1292       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1293                               0.0,0.0);
1294       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1295                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1296                 *                     SinD(fgkCarbonFiberTriangleAngle),
1297                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1298   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1299   }
1300   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1301   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1302   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1303   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1304       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1305       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1306       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1307       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1308             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1309       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1310             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1311                                *localendladdercarbonfiberjunctionglobalrot[i]);
1312   }
1313   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1314       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1315             localendladdercarbonfiberjunctionmatrix[i][j] = 
1316                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1317                                      *localendladdercarbonfiberjunctionrot[i][j]);
1318            fendladdercarbonfiberjunctionmatrix[i][j] =
1319             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1320             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1321       }  
1322   /////////////////////////////////////////////////////////////
1323   // End Ladder Carbon Fiber Support
1324   /////////////////////////////////////////////////////////////
1325   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1326   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1327       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1328       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1329             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1330       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1331   }
1332   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1333       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1334             fendladdercarbonfibermatrix[i][j] = 
1335             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1336             *(*fcarbonfibersupportmatrix[j]));
1337   /////////////////////////////////////////////////////////////
1338   // End Ladder SSD Mounting Block
1339   /////////////////////////////////////////////////////////////
1340   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1341       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1342   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1343       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1344                                 +        fgkSSDMountingBlockLength[1])
1345                                 +  0.5*fgkCarbonFiberTriangleLength,
1346                                 fgkEndLadderMountingBlockPosition[i],
1347                                 -  fgkSSDMountingBlockHeight[1]
1348                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1349   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1350   endladdermountingblockrot->SetAngles(0.,90.,0.);
1351   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1352         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1353   /////////////////////////////////////////////////////////////
1354   // End Ladder SSD Mounting Block Clip Matrix 
1355   /////////////////////////////////////////////////////////////
1356   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1357         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1358   
1359   TGeoRotation* localendladdercliprot = new TGeoRotation();
1360   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1361   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1362                                                                                   -     fgkSSDMountingBlockLength[1])
1363                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1364   localendladdercliprot->SetAngles(90.,180.,-90.);
1365   TGeoCombiTrans* localendladderclipcombitrans = 
1366                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1367   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1368         for(Int_t j=0; j<2; j++){
1369                 fendladdermountingblockclipmatrix[i][j] = 
1370                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1371                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1372         }
1373   /////////////////////////////////////////////////////////////
1374   // End Ladder Carbon Fiber Lower Support
1375   /////////////////////////////////////////////////////////////
1376   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1377       fendladderlowersupptrans[i] = 
1378             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1379                         +  0.5*fgkSSDMountingBlockWidth),
1380                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1381   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1382                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1383                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1384                                                                          0.0);
1385   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1386  /////////////////////////////////////////////////////////////
1387   // Matrix for positioning Ladder into mother volume
1388   /////////////////////////////////////////////////////////////
1389   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1390   for(Int_t i=0; i<fgkladdernumber; i++) 
1391         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1392   TGeoRotation* localladdermotherrot = new TGeoRotation();
1393   localladdermotherrot->SetAngles(0.,90.,0.);  
1394   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1395   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1396   for(Int_t i=0; i<fgkladdernumber; i++){
1397         localladdermothertrans[i] = new TGeoTranslation(0.,
1398                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1399                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1400                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1401                                                           * fgkCarbonFiberJunctionWidth,0.);
1402         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1403                                                                                                                 *localladdermotherrot);
1404         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1405         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1406   }
1407   /////////////////////////////////////////////////////////////
1408   // Ladder Cables Matrices
1409   /////////////////////////////////////////////////////////////
1410   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1411                                              + fgkSSDFlexHeight[1];  
1412   Double_t ssdladdercabletransx[3];
1413   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1414                                                   *   SinD(2.*fgkSSDFlexAngle)
1415                                                   *       CosD(2.*fgkSSDFlexAngle);
1416   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1417                                                   -     ssdladdercabletransx[0]
1418                                                   /     SinD(2.*fgkSSDFlexAngle))
1419                                                   *     CosD(fgkSSDFlexAngle);                                          
1420   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1421                                                   *       TMath::DegToRad()*ssdflexradiusmax
1422                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1423                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1424                                                   -       fgkSSDLadderCableWidth)
1425                                                   *       CosD(2.*fgkSSDFlexAngle);
1426   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1427                                                   *     TanD(2.*fgkSSDFlexAngle),
1428                                                         ssdladdercabletransx[1]
1429                                                   *     TanD(fgkSSDFlexAngle),
1430                                                         ssdladdercabletransx[2]
1431                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1432   TGeoRotation* localladdercablerot[3]; 
1433   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1434   localladdercablerot[0]->SetAngles(90.,0.,0.);
1435   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1436   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1437                                                  *                        (*localladdercablerot[0]));
1438   ////////////////////////////////////////////
1439   // LocalLadderCableCombiTransMatrix
1440   ////////////////////////////////////////////
1441   const Int_t klocalladdersidecablesnumber = 2;
1442   const Int_t klocalladdercombitransnumber = 5;
1443   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1444   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1445          localladdercablecombitransmatrix[i] = 
1446                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1447   ///////////////////////////////////////////
1448   // Left Side Ladder Cables Transformations
1449   ///////////////////////////////////////////
1450   localladdercablecombitransmatrix[0][0]  =
1451                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1452                                                 0.,0.,NULL);
1453   localladdercablecombitransmatrix[0][1] = 
1454         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1455                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1456                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1457                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1458                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1459                                            + fgkSSDSensorCenterSupportLength
1460                                            - fgkSSDSensorCenterSupportThickness[0]),
1461                                            - (fgkSSDModuleCoolingBlockToSensor
1462                                            + 0.5*fgkCoolingTubeSupportHeight
1463                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1464                                            - fgkSSDChipHeight),NULL);
1465   localladdercablecombitransmatrix[0][2] = 
1466                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1467                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1468   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1469                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1470                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1471                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1472                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1473                                                                                                 new TGeoRotation("",180.,0.,0.));
1474   localladdercablecombitransmatrix[0][4] = 
1475                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1476                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1477                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1478                                                           0.,
1479                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1480                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1481                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1482                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1483   ///////////////////////////////////////////
1484   // Rigth Side Ladder Cables Transformations
1485   ///////////////////////////////////////////
1486   TGeoCombiTrans* localladdercablessdmodulematrix = 
1487         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1488                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1489                                                                          fgkSSDStiffenerWidth,
1490                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1491   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1492    localladdercablecombitransmatrix[1][i] = 
1493                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1494                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1495   ///////////////////////////////////////////
1496   // Setting LadderCableHMatrix
1497   ///////////////////////////////////////////
1498   Int_t beamaxistrans[2][3];
1499   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1500   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1501   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1502   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1503   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1504   beamaxistrans[1][2] = beamaxistrans[1][0];
1505   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1506   TGeoRotation* laddercablerot = new TGeoRotation();
1507   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1508   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1509   Double_t* laddercabletransvector;     
1510   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1511         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1512         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1513   }
1514   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1515         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1516                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1517                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1518                         localladdercablehmatrix[i][j]->MultiplyLeft(
1519                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1520         }
1521                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1522                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1523                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1524                                                                          laddercabletransvector[1]
1525                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1526                                         *                                fgkCarbonFiberJunctionWidth,
1527                                                                          laddercabletransvector[2]);
1528                 laddercablecombitrans->SetRotation(*laddercablerot);
1529                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1530                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1531         }
1532     fladdercablematrix[i][2] = 
1533                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1534                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1535         fladdercablematrix[i][3] = 
1536                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1537                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1538   }
1539   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1540         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1541                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1542   ///////////////////////////////////////////
1543   // Setting Ladder HMatrix
1544   ///////////////////////////////////////////
1545   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1546                                                                                                 fgkSSDLay6SensorsNumber};
1547   for(Int_t i=0; i<fgkladdernumber; i++){
1548         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1549         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1550                 fladdermatrix[i][j] = new TGeoHMatrix();
1551                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1552                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1553                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1554         }
1555   }
1556   ///////////////////////////////////////////
1557   // Setting SSD Sensor Matrix 
1558   ///////////////////////////////////////////
1559   TGeoCombiTrans* localssdsensorcombitrans[2];
1560   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1561   localssdsensorrot->SetAngles(0.,90.,0.);      
1562   TGeoTranslation* localssdsensortrans[2];
1563   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1564   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1565                                           -             (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1566                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1567                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1568                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1569                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1570                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1571                                           -             fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment
1572                                           +    (fgkSSDSensorSideSupportHeight[1]
1573                                           -             fgkSSDSensorSideSupportHeight[0]));
1574   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1575                                           -        (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1576                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1577                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1578                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1579                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1580                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1581                                                         -fgkSSDModuleCoolingBlockToSensor-0.5*fgkSSDModuleVerticalDisalignment);
1582   for(Int_t i=0; i<2; i++) 
1583         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1584                                                                                                          *localssdsensorrot);   
1585     for(Int_t i=0; i<fgkladdernumber; i++){
1586         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1587         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1588                 switch(i){
1589                         case 0: //Ladder of Layer5  
1590                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1591                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1592                                                                                                 *localssdsensorcombitrans[1])));
1593                         break;
1594                         case 1: //Ladder of Layer6 
1595                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1596                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1597                                                                                                 *localssdsensorcombitrans[0])));
1598                 break;
1599                 }
1600           }
1601   }     
1602   //////////////////////////
1603   // Setting SSD End Ladder  
1604   //////////////////////////
1605   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1606   for(Int_t i=0; i<2; i++){
1607         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1608         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1609         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1610         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1611         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1612         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1613         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1614         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1615    }
1616   /////////////////////////////////////////////////////
1617   // Setting the CombiTransformation to pass ITS center 
1618   /////////////////////////////////////////////////////
1619   Double_t itscentertransz[fgklayernumber];
1620   itscentertransz[0] = fgkSSDLay5LadderLength
1621                                          - fgkLay5CenterITSPosition;
1622   itscentertransz[1] = fgkSSDLay6LadderLength
1623                                          - fgkLay6CenterITSPosition;
1624   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1625                                                    + 0.5*fgkCoolingTubeSupportHeight;
1626   TGeoRotation* itscenterrot[3];
1627   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1628   itscenterrot[0]->SetAngles(90.,180.,-90.);
1629   itscenterrot[1]->SetAngles(0.,90.,0.);
1630   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1631   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1632   for(Int_t i=0; i<fgklayernumber; i++) 
1633         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1634                                                          itssensortransy,
1635                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1636                                                    - itscentertransz[i],itscenterrot[2]);
1637   TGeoRotation** locallayerrot[fgklayernumber];
1638   TGeoTranslation** locallayertrans[fgklayernumber];    
1639   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1640   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1641   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1642                                          - fgkLay5CenterITSPosition);
1643   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1644                                          - fgkLay6CenterITSPosition);
1645   const Int_t kssdlayladdernumber[fgklayernumber] = 
1646                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1647   for(Int_t i=0; i<fgklayernumber; i++){
1648     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1649     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1650         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1651         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1652   }
1653   Double_t layerladderangleposition[fgklayernumber] = 
1654                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1655   Double_t layerradius = 0.;
1656   for(Int_t i=0; i<fgklayernumber; i++){        
1657         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1658                 switch(i){
1659                         case 0: //Ladder of Layer5  
1660                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1661                         break;
1662                         case 1: //Ladder of Layer6 
1663                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1664                 break;
1665                 }
1666                 locallayerrot[i][j] = new TGeoRotation();
1667                 locallayertrans[i][j] = new TGeoTranslation();
1668                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1669                 locallayertrans[i][j]->SetTranslation(layerradius 
1670                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1671                                                             layerradius 
1672                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1673                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1674                                                                          *locallayerrot[i][j]);
1675                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1676                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1677                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1678         }
1679   }
1680   /////////////////////////////////////////////////////////////
1681   // Deallocating memory
1682   /////////////////////////////////////////////////////////////
1683   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1684         delete carbonfiberot[i];
1685         delete localcarbonfibersupportmatrix[i];
1686   }
1687   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1688      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1689        delete localcarbonfiberjunctionmatrix[i][j];
1690            delete localcarbonfiberjunctionrot[i][j];
1691            delete localcarbonfiberjunctiontrans[i][j];
1692            }
1693        delete [] localcarbonfiberjunctionmatrix[i];
1694        delete [] localcarbonfiberjunctionrot[i];
1695        delete [] localcarbonfiberjunctiontrans[i];
1696   }
1697   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1698            delete localcarbonfiberlowersupportrans[i];
1699   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1700      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1701        delete localssdsensorsupportmatrix[i][j];
1702            delete localssdsensorsupportrot[i][j];
1703            delete localssdsensorsupportrans[i][j];
1704            }
1705        delete [] localssdsensorsupportmatrix[i];
1706        delete [] localssdsensorsupportrot[i];
1707        delete [] localssdsensorsupportrans[i];
1708   }
1709   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1710         delete localcoolingtubesupportmatrix[i];
1711         delete localcoolingtubesupportrot[i];
1712         delete localcoolingtubesupportrans[i];
1713   }
1714   for(Int_t i=0; i<4; i++){
1715         for(Int_t j=0; j<2; j++){
1716                 delete localcoolingtubevect[i][j];
1717                 delete localcoolingtubetrans[i][j];
1718         }
1719         delete [] localcoolingtubevect[i];
1720         delete [] localcoolingtubetrans[i];
1721   }
1722  delete endladdermountingblockrot;
1723  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1724  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1725  for(Int_t i=0; i<fgkflexnumber; i++){
1726       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1727             delete localflexmatrix[i][j];
1728       delete [] localflexmatrix[i];
1729  }
1730  delete localendlladdercoolingtuberot;
1731  for(Int_t i=0; i<2; i++){
1732         for(Int_t j=0; j<(i==0?6:4); j++)
1733                 delete localendlladdercoolingtubetrans[i][j];
1734         delete [] localendlladdercoolingtubetrans[i];
1735   }
1736
1737  delete localflexrot;
1738  delete localendflexrot;
1739  delete localendflexmatrix;
1740  for(Int_t i=0; i<fgkladdernumber; i++){ 
1741         delete localladdermothertrans[i];
1742         delete localladdermothercombitrans[i];
1743   }
1744  delete localladdermotherrot;
1745  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1746       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1747             delete localendladdercarbonfiberjunctionmatrix[i][j];
1748             delete localendladdercarbonfiberjunctionrot[i][j];
1749             delete localendladdercarbonfiberjunctiontrans[i][j];
1750       }
1751       delete [] localendladdercarbonfiberjunctionmatrix[i];
1752       delete [] localendladdercarbonfiberjunctionrot[i];
1753       delete [] localendladdercarbonfiberjunctiontrans[i];
1754       delete localendladdercarbonfiberjunctionglobalrot[i];
1755       delete localendladdercarbonfiberjunctionglobaltrans[i];
1756       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1757  }
1758   for(Int_t i=0; i<2; i++){
1759         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1760         delete [] localendladdercooltubetrans[i];
1761   }
1762   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1763       delete localendladdercarbonfibertrans[i];
1764   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1765   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1766         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1767                 delete localladdercablecombitransmatrix[i][j];
1768                 delete []localladdercablecombitransmatrix[i];
1769   }
1770   delete localendladdercliprot;
1771   delete localendladdercliptrans;
1772   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1773         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1774                 delete localladdercablehmatrix[i][j];
1775         delete []localladdercablehmatrix[i];
1776   }
1777   delete laddercablerot;
1778   delete laddercabletrans;
1779   delete laddercablecombitrans;
1780   delete localladdercablessdmodulematrix;
1781   delete localssdsensorrot;     
1782   for(Int_t i=0; i<2; i++){
1783         delete localssdsensortrans[i];
1784         delete localssdsensorcombitrans[i];
1785   }
1786   for(Int_t i=0; i<fgklayernumber; i++){
1787         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1788                 delete locallayerrot[i][j];
1789                 delete locallayertrans[i][j];
1790                 delete locallayercombitrans[i][j];
1791     }
1792         delete [] locallayerrot[i];
1793         delete [] locallayertrans[i];
1794         delete [] locallayercombitrans[i];
1795         delete localbeamaxistrans[i];
1796   }
1797   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1798   for(Int_t i=0; i<fgkladdernumber; i++){
1799         for(Int_t j=0; j<fgkladdernumber; j++)
1800                 delete ladderglobalmatrix[i][j];
1801         delete [] ladderglobalmatrix[i];
1802   }
1803   /////////////////////////////////////////////////////////////
1804   fTransformationMatrices = kTRUE;      
1805 }
1806 ///////////////////////////////////////////////////////////////////////////////
1807 void AliITSv11GeometrySSD::CreateBasicObjects(){
1808   /////////////////////////////////////////////////////////////  
1809   // Method generating the Objects of SSD Geometry    
1810   /////////////////////////////////////////////////////////////
1811   // SSD Sensor
1812   ///////////////////////////////////
1813   SetSSDSensor();
1814   /////////////////////////////////////////////////////////////  
1815   // Carbon Fiber Support    
1816   /////////////////////////////////////////////////////////////  
1817   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1818   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1819       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1820   /////////////////////////////////////////////////////////////
1821   // Carbon Fiber Junction 
1822   /////////////////////////////////////////////////////////////
1823   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth);
1824   /////////////////////////////////////////////////////////////
1825   // Carbon Fiber Lower Support
1826   /////////////////////////////////////////////////////////////
1827   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1828   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1829         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1830   /////////////////////////////
1831   // SSD Sensor Support
1832   /////////////////////////////
1833   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1834                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1835   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1836                                                                          fgkSSDSensorSideSupportThickness[1]};
1837   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1838         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1839                                                                                            fgkSSDSensorSideSupportHeight[i],
1840                                                                                            fgkSSDSensorSideSupportWidth,
1841                                                                                            sidesupporthickness);  
1842         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1843                                                                                            fgkSSDSensorCenterSupportHeight[i],
1844                                                                                            fgkSSDSensorCenterSupportWidth,
1845                                                                                            sidesupporthickness);
1846   }
1847   /////////////////////////////////////////////////////////////
1848   // SSD Cooling Tube Support
1849   /////////////////////////////////////////////////////////////
1850   Int_t edgesnumber = 16;
1851   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1852   /////////////////////////////////////////////////////////////
1853   // SSD Hybrid
1854   /////////////////////////////////////////////////////////////
1855   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1856   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1857         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1858   /////////////////////////////////////////////////////////////
1859   // SSD Cooling Block System
1860   /////////////////////////////////////////////////////////////
1861   fssdcoolingblocksystem = GetCoolingBlockSystem();
1862    /////////////////////////////////////////////////////////////
1863   // SSD Cooling Tube
1864   /////////////////////////////////////////////////////////////
1865   TList* coolingtubelist = GetCoolingTubeList();        
1866   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1867         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1868   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1869         fendladdercoolingtube[i] = 
1870                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1871   /////////////////////////////////////////////////////////////
1872   // SSD Flex  
1873   /////////////////////////////////////////////////////////////
1874   fssdstiffenerflex = GetSSDStiffenerFlex();
1875   fssdendflex = GetSSDEndFlex();
1876   ///////////////////////////////////
1877   // End Ladder Carbon Fiber Junction
1878   ///////////////////////////////////
1879   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1880                                                    fendladdercarbonfiberjunction[i] = 
1881                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1882   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1883     fendladdercarbonfiberjunction[i][0] = 
1884                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]);
1885     fendladdercarbonfiberjunction[i][1] = 
1886                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]);
1887   }
1888   ///////////////////////////////////
1889   // End Ladder Mounting Block
1890   ///////////////////////////////////
1891   fendladdermountingblock = GetSSDMountingBlock();
1892   ///////////////////////////////////
1893   // End Ladder Mounting Block
1894   ///////////////////////////////////
1895   fendladdermountingblockclip = GetMountingBlockClip();
1896   ///////////////////////////////////
1897   // Ladder Support 
1898   ///////////////////////////////////
1899   TList* laddersupportlist = GetMountingBlockSupport(20);
1900   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1901   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1902   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1903   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1904   /////////////////////////////////////////////////////////////
1905   // Deallocating memory
1906   /////////////////////////////////////////////////////////////
1907   delete carbonfibersupportlist;
1908   delete carbonfiberlowersupportlist;
1909   delete ssdhybridcomponentslist;
1910   delete laddersupportlist;
1911   /////////////////////////////////////////////////////////////
1912   fBasicObjects = kTRUE;
1913 }
1914 /////////////////////////////////////////////////////////////////////////////////
1915 void AliITSv11GeometrySSD::SetSSDSensor(){
1916   ////////////////////////////////////////////////////////////////
1917   // Method generating SSD Sensors: it sets the private variables
1918   // fSSDSensor5, fSSDSensor6  
1919   ////////////////////////////////////////////////////////////////
1920   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1921   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1922   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1923                                                 0.5*ssdsensitivewidth,
1924                                                 0.5*fgkSSDSensorHeight,
1925                                                 0.5*ssdsensitivelength);
1926   TGeoVolume* ssdsensorsensitiveLay5 = 
1927         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1928   TGeoVolume* ssdsensorsensitiveLay6 = 
1929         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1930   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1931   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1932   TGeoBBox* ssdsensorinsensitiveshape[2];
1933   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1934                                                 0.5*fgkSSDSensorInsensitiveWidth,
1935                                                 0.5*fgkSSDSensorHeight,
1936                                                 0.5*fgkSSDSensorLength);
1937   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1938                                                 0.5*ssdsensitivewidth,
1939                                                 0.5*fgkSSDSensorHeight,
1940                                                 0.5*fgkSSDSensorInsensitiveWidth);
1941   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1942                                              "SSDSensorInsensitive2"};
1943   TGeoVolume* ssdsensorinsensitive[2];
1944   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1945       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1946                      fSSDSensorMedium);
1947       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1948   }
1949   /////////////////////////////////////////////////////////////
1950   // Virtual Volume containing SSD Sensor  
1951   /////////////////////////////////////////////////////////////
1952   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1953                                                                                              0.5*fgkSSDSensorWidth,
1954                                                                                              0.5*fgkSSDSensorHeight,
1955                                                                                              0.5*fgkSSDSensorLength);
1956   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1957                                                                                  fSSDAir);      
1958   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1959                                                                                  fSSDAir);      
1960   /////////////////////////////////////////////////////////////
1961   for(Int_t i=0; i<4; i++){ 
1962             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1963             ssdsensorinsensitive[1],i<2?1:2,
1964                         new TGeoTranslation(
1965                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1966       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1967                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1968       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1969             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1970             ssdsensorinsensitive[1],i<2?1:2,
1971                         new TGeoTranslation(
1972                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1973       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1974                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1975       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1976   }
1977     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1978     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1979 }
1980 ///////////////////////////////////////////////////////////////////////////////
1981 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1982   /////////////////////////////////////////////////////////////  
1983   // Method generating the Carbon Fiber Support   
1984   /////////////////////////////////////////////////////////////  
1985   const Int_t kvertexnumber = 4;
1986   const Int_t kshapesnumber = 2;
1987   TVector3** vertexposition[kshapesnumber];
1988   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1989   Double_t carbonfibersupportxaxisEdgeproj = 
1990                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1991         *       TMath::DegToRad());
1992   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1993                                  /                         fgkCarbonFiberSupportXAxisLength);
1994   /////////////////////
1995   //Vertex Positioning
1996   ////////////////////
1997   vertexposition[0][0] = new TVector3();
1998   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1999                                                                           fgkCarbonFiberSupportYAxisLength);
2000   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2001                                                                           carbonfibersupportxaxisEdgeproj
2002                                            *                      TMath::Tan(theta));
2003   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2004                                            -                      carbonfibersupportxaxisEdgeproj,
2005                                                                           fgkCarbonFiberSupportYAxisLength
2006                                            -                      vertexposition[0][2]->Y());
2007   ////////////////////////////////////////////////////
2008   //Setting the parameters for Isometry Transformation
2009   ////////////////////////////////////////////////////
2010   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2011                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2012                                                                  +      fgkCarbonFiberSupportWidth);
2013   Double_t* param = new Double_t[4]; 
2014   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2015   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2016                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2017                                                           (GetReflection(vertexposition[0][j],param))->Y());
2018   char* carbonfibersupportshapename[kshapesnumber] = 
2019                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2020   char* carbonfibersupportname[kshapesnumber] = 
2021                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2022   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2023   TGeoVolume* carbonfibersupport[kshapesnumber];
2024   TList* carbonfibersupportlist = new TList();
2025   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2026   Double_t carbonfibersupportheight = 
2027           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2028           *TMath::DegToRad());
2029   for(Int_t i = 0; i< kshapesnumber; i++){
2030    carbonfibersupportshape[i] = 
2031                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2032                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2033    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2034                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2035    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2036    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2037    }
2038   /////////////////////////////////////////////////////////////
2039   // Deallocating memory
2040   /////////////////////////////////////////////////////////////
2041   for(Int_t i=0; i< kshapesnumber; i++){
2042      for(Int_t j=0; j< kvertexnumber; j++)
2043            delete vertexposition[i][j];
2044        delete [] vertexposition[i];
2045   }
2046   delete [] param;
2047   /////////////////////////////////////////////////////////////
2048    return carbonfibersupportlist;
2049 }
2050 /////////////////////////////////////////////////////////////////////////////////
2051 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2052   /////////////////////////////////////////////////////////////
2053   // Method generating SSD Carbon Fiber Junction
2054   /////////////////////////////////////////////////////////////
2055   const Int_t kvertexnumber = 6;
2056   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2057   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2058                                                           *  TMath::DegToRad()),-1.,0.};
2059   TVector3* vertex[kvertexnumber];
2060   vertex[0] = new TVector3();
2061   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2062                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2063                         *                         TMath::DegToRad()),
2064                                                   fgkCarbonFiberJunctionEdge[0]
2065                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2066                         *                         TMath::DegToRad()));
2067   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2068                                                    fgkCarbonFiberJunctionEdge[1]);
2069   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2070   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2071   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2072   Double_t xvertexpoints[6], yvertexpoints[6];
2073   for(Int_t i=0; i<kvertexnumber; i++) 
2074           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2075   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2076   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2077   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2078   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2079                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2080   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2081   /////////////////////////////////////////////////////////////
2082   // Deallocating memory
2083   /////////////////////////////////////////////////////////////
2084   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2085   ///////////////////////////////////////////////////////////// 
2086   return carbonfiberjunction;
2087 }
2088 ////////////////////////////////////////////////////////////////////////////////
2089 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2090   /////////////////////////////////////////////////////////////
2091   // Method generating the Carbon Fiber Lower Support   
2092   /////////////////////////////////////////////////////////////  
2093   const Int_t kvertexnumber = 4;
2094   const Int_t kshapesnumber = 2;
2095   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2096                                                                 fgkCarbonFiberLowerSupportWidth};
2097   TVector3** vertexposition[kshapesnumber];
2098   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2099                                                  new TVector3*[kvertexnumber];
2100   //First Shape Vertex Positioning
2101   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2102   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2103                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2104   vertexposition[0][2] = new TVector3();
2105   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2106   //Second Shape Vertex Positioning
2107   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2108                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2109                                  /                              fgkCarbonFiberTriangleLength);
2110   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2111                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2112                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2113   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2114                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2115                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2116   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2117   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2118                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2119   char* carbonfiberlowersupportshapename[kshapesnumber] = 
2120                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2121   char* carbonfiberlowersupportname[kshapesnumber] = 
2122                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2123   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2124   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2125   TList* carbonfiberlowersupportlist = new TList();
2126   for(Int_t i = 0; i< kshapesnumber; i++){ 
2127         carbonfiberlowersupportshape[i] = 
2128                                                                 GetArbShape(vertexposition[i],width,
2129                                                                                         fgkCarbonFiberLowerSupportHeight,
2130                                                                                         carbonfiberlowersupportshapename[i]);
2131     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2132                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2133         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2134     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2135   }
2136   /////////////////////////////////////////////////////////////
2137   // Deallocating memory
2138   /////////////////////////////////////////////////////////////
2139   for(Int_t i=0; i< kshapesnumber; i++){
2140      for(Int_t j=0; j< kvertexnumber; j++)
2141            delete vertexposition[i][j];
2142        delete [] vertexposition[i];
2143   }
2144   /////////////////////////////////////////////////////////////
2145   return carbonfiberlowersupportlist;
2146 }
2147 ///////////////////////////////////////////////////////////////////////////////
2148 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2149                                                                  Double_t width, Double_t* thickness)const{
2150   /////////////////////////////////////////////////////////////
2151   // Method generating the Sensor Support   
2152   /////////////////////////////////////////////////////////////  
2153         const Int_t kvertexnumber = 6;
2154         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2155     TVector3* vertexposition[kvertexnumber];
2156         vertexposition[0] = new TVector3();     
2157         vertexposition[1] = new TVector3(0.0,length);   
2158         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2159         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2160         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2161         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2162         Double_t xvertexpoints[6], yvertexpoints[6];
2163         for(Int_t i=0; i<kvertexnumber; i++) 
2164                 xvertexpoints[i] = vertexposition[i]->X(), 
2165                 yvertexpoints[i] = vertexposition[i]->Y();
2166     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2167     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2168     ssdsensorsupportshape->DefineSection(1,0.5*width);
2169     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2170                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2171   /////////////////////////////////////////////////////////////
2172   // Deallocating memory
2173   /////////////////////////////////////////////////////////////
2174         for (Int_t i=0; i<kvertexnumber; i++)
2175                 delete vertexposition[i];
2176   /////////////////////////////////////////////////////////////
2177     return ssdsensorsupport;
2178 }
2179 ////////////////////////////////////////////////////////////////////////////////
2180 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2181   /////////////////////////////////////////////////////////////
2182   // Method generating the Cooling Tube Support
2183   /////////////////////////////////////////////////////////////
2184   if(nedges%2!=0) nedges--;     
2185   const Int_t kvertexnumber = nedges+5;
2186   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2187                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2188   Double_t angle = 90.+phi;
2189   Double_t psi = 90.-phi;
2190   ///////////////////////////////////////
2191   // Vertex Positioning for TGeoXTru
2192   ///////////////////////////////////////
2193   TVector3** vertexposition = new TVector3*[kvertexnumber];
2194   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2195                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2196   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2197                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2198   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2199                                                                    fgkCoolingTubeSupportRmax);
2200   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2201                                                                    fgkCoolingTubeSupportRmax);
2202   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2203                                                                     vertexposition[1]->Y());
2204   for(Int_t i=0; i<nedges; i++)
2205         vertexposition[i+5] = 
2206                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2207                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2208   ///////////////////////////////////////////////////////////////////////
2209   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2210   ///////////////////////////////////////////////////////////////////////
2211   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2212   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2213   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2214   for(Int_t i=0; i<kvertexnumber; i++){
2215         xvertexpoints[i] = vertexposition[i]->X();
2216         yvertexpoints[i] = vertexposition[i]->Y();
2217   } 
2218   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2219                                                                                         yvertexpoints);
2220   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2221   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2222   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2223                                                                           coolingtubesupportarcshape,
2224                                                                                   fSSDTubeHolderMedium);
2225   coolingtubesupportarc->SetLineColor(fColorG10);
2226   //////////////////////////////////////////////////////////////////////////
2227   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2228   //////////////////////////////////////////////////////////////////////////
2229   TGeoTubeSeg* coolingtubesupportsegshape = 
2230                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2231                                                                                         fgkCoolingTubeSupportRmax,
2232                                                                                         0.5*fgkCoolingTubeSupportWidth,
2233                                                                                         phi,360-phi);
2234   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2235                                                                                         coolingtubesupportsegshape,
2236                                                                                         fSSDTubeHolderMedium);
2237   coolingtubesupportseg->SetLineColor(fColorG10);
2238   //////////////////////////////////////////////////////////////////////////
2239   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2240   //////////////////////////////////////////////////////////////////////////
2241   Double_t* boxorigin = new Double_t[3];
2242   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2243   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2244   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2245                                                                                  0.5*fgkCoolingTubeSupportHeight,
2246                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2247   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2248                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2249   coolingtubesupportbox->SetLineColor(fColorG10);
2250   //////////////////////////////////////////////////////////////////////////
2251   // Cooling Tube for Cooling Tube Support 
2252   //////////////////////////////////////////////////////////////////////////
2253   TGeoXtru* coolingtubearcshape[2];
2254   coolingtubearcshape[0] = new TGeoXtru(2);     
2255   Double_t* xvert = new Double_t[nedges+2];
2256   Double_t* yvert = new Double_t[nedges+2];
2257   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2258   ////////////////////////////////////////
2259   // Positioning the vertices for TGeoXTru
2260   ////////////////////////////////////////
2261   xvert[0] = 0., yvert[0] = 0.;
2262   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2263   for(Int_t i=0; i< nedges; i++)
2264                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2265                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2266   ////////////////////////////////////////
2267   // Defining TGeoXTru PolyGone
2268   ////////////////////////////////////////
2269   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2270   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2271   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2272   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2273                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2274   TGeoVolume* coolingtubearc[2];
2275   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2276                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2277   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2278                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2279   coolingtubearc[0]->SetLineColor(fColorWater);
2280   coolingtubearc[1]->SetLineColor(fColorPhynox);
2281   ////////////////////////////////////////////
2282   // Defining TGeoTubeSeg Part of Cooling Tube
2283   ////////////////////////////////////////////
2284   TGeoTubeSeg* coolingtubesegshape[2];
2285   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2286                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2287   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2288                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2289   TGeoVolume* coolingtubeseg[2];
2290   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2291                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2292   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2293                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2294   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2295   coolingtubeseg[1]->SetLineColor(fColorWater);
2296   /////////////////////////////////////////////////////////////
2297   // Virtual Volume containing Cooling Tube Support  
2298   /////////////////////////////////////////////////////////////
2299   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2300   const Int_t kvirtualvertexnumber = 8;
2301   TVector3* virtualvertex[kvirtualvertexnumber];
2302    ////////////////////////////////////////
2303   // Positioning the vertices for TGeoXTru
2304   ////////////////////////////////////////
2305   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2306   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2307   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2308   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2309   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2310   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2311   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2312   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2313   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2314   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2315         xmothervertex[i] = virtualvertex[i]->X(),
2316         ymothervertex[i] = virtualvertex[i]->Y();
2317   ////////////////////////////////////////
2318   // Defining TGeoXTru PolyGone
2319   ////////////////////////////////////////
2320   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2321                                                                                                                                          ymothervertex);
2322   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2323   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2324   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2325                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2326   ////////////////////////////////////////
2327   // Positioning Volumes in Virtual Volume
2328   ////////////////////////////////////////
2329   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2330   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2331   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2332   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2333   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2334   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2335   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2336   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2337   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2338   /////////////////////////////////////////////////////////////
2339   // Deallocating memory
2340   /////////////////////////////////////////////////////////////
2341   delete [] vertexposition;
2342   delete xvertexpoints;
2343   delete yvertexpoints;
2344   delete xvert;
2345   delete yvert;
2346   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2347         delete virtualvertex[i];
2348   /////////////////////////////////////////////////////////////
2349         return virtualcoolingtubesupport;
2350 }
2351 /////////////////////////////////////////////////////////////////////////////////
2352 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2353   /////////////////////////////////////////////////////////////
2354   // Method generating List containing SSD Hybrid Components   
2355   /////////////////////////////////////////////////////////////
2356   TList* ssdhybridlist = new TList();
2357   const Int_t kssdstiffenernumber = 2;
2358   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2359                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2360                                                                   -    fgkSSDStiffenerWidth;
2361   Double_t ssdchipcablesradius[kssdstiffenernumber];
2362   for(Int_t i=0; i<kssdstiffenernumber; i++)
2363           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2364                                -  fgkSSDChipCablesHeight[0]
2365                                -  fgkSSDChipCablesHeight[1]);
2366   /////////////////////////////////////////////////////////////
2367   // Mother Volumes Containers 
2368   /////////////////////////////////////////////////////////////
2369   const Int_t kmothernumber = 2;
2370   const Int_t kmothervertexnumber = 12;
2371   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2372   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2373   ///////////////////////
2374   // Setting the vertices 
2375   ///////////////////////
2376   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2377   xmothervertex[0][1]  = xmothervertex[0][0]; 
2378   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2379   xmothervertex[0][3]  = xmothervertex[0][2];
2380   xmothervertex[0][4]  = xmothervertex[0][0];
2381   xmothervertex[0][5]  = xmothervertex[0][4];
2382   xmothervertex[0][6]  = -xmothervertex[0][0];
2383   xmothervertex[0][7]  = xmothervertex[0][6];
2384   xmothervertex[0][8]  = -xmothervertex[0][2];
2385   xmothervertex[0][9]  = xmothervertex[0][8];
2386   xmothervertex[0][10] = xmothervertex[0][7];
2387   xmothervertex[0][11] = xmothervertex[0][10];
2388   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2389   for(Int_t i = 0; i<kmothernumber; i++){
2390       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2391                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2392       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2393       ymothervertex[i][2]  = ymothervertex[i][1];
2394       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2395       ymothervertex[i][4]  = ymothervertex[i][3];
2396       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2397       ymothervertex[i][6]  = ymothervertex[i][5];
2398       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2399       ymothervertex[i][8]  = ymothervertex[i][7];
2400       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2401       ymothervertex[i][10] = ymothervertex[i][9];
2402       ymothervertex[i][11] = ymothervertex[i][0];
2403   }
2404   TGeoXtru* ssdhybridmothershape[kmothernumber];
2405   TGeoVolume* ssdhybridmother[kmothernumber];
2406   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2407   for(Int_t i=0; i<kmothernumber; i++){
2408       ssdhybridmothershape[i] = new TGeoXtru(2);
2409       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2410                                           ymothervertex[i]);
2411       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2412                                                -fgkSSDChipCablesHeight[i+2]);
2413       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2414       ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2415                                           fSSDAir);
2416    }   
2417   /////////////////////////////////////////////////////////////
2418   // SSD Stiffener   
2419   /////////////////////////////////////////////////////////////
2420   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2421                                              0.5*fgkSSDStiffenerLength,
2422                                              0.5*fgkSSDStiffenerWidth,
2423                                              0.5*fgkSSDStiffenerHeight);
2424   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2425                                             fSSDStiffenerMedium);  
2426   ssdstiffener->SetLineColor(fColorStiffener); 
2427   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2428   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2429       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2430   /////////////////////////////////////////////////////////////
2431   // SSD Chip System    
2432   /////////////////////////////////////////////////////////////
2433   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2434   Double_t ssdchipseparation = fgkSSDSensorLength
2435                              - 2.*fgkSSDModuleStiffenerPosition[1]
2436                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2437                              - 0.5*fgkSSDChipWidth);
2438   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2439                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2440   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2441                                       - 0.5*ssdchipsystemlength,
2442                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2443                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2444 ////////////////////////////
2445 // Capacitor 0603-2200 nF
2446 ///////////////////////////
2447   const Int_t knapacitor0603number = 5;
2448   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2449                                                                                          0.5*fgkSSDCapacitor0603Length,
2450                                                                                          0.5*fgkSSDCapacitor0603Width,
2451                                                                                          0.5*fgkSSDCapacitor0603Height);
2452   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2453                                              fSSDStiffener0603CapacitorMedium); 
2454   capacitor0603->SetLineColor(fColorAl);
2455   for(Int_t i=0; i<kmothernumber; i++){
2456       for(Int_t j=0; j<kssdstiffenernumber; j++){
2457             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2458             for(Int_t k=1; k<knapacitor0603number+1; k++){
2459                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2460                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2461                                              j*ssdstiffenerseparation
2462                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2463                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2464                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2465             }
2466       } 
2467       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2468       ssdhybridlist->Add(ssdhybridmother[i]);
2469   }    
2470 /////////////////////////////////////////////////////////////
2471 // Mother Volume Containing Capacitor Part 
2472 /////////////////////////////////////////////////////////////
2473   const Int_t kcapacitormothernumber = 8;
2474   Double_t xcapacitorvertex[kcapacitormothernumber];
2475   Double_t ycapacitorvertex[kcapacitormothernumber];  
2476   ///////////////////////
2477   // Setting the vertices 
2478   ///////////////////////
2479   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2480   xcapacitorvertex[1] = xcapacitorvertex[0];   
2481   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2482   xcapacitorvertex[3] = xcapacitorvertex[2];   
2483   xcapacitorvertex[4] = xcapacitorvertex[0];   
2484   xcapacitorvertex[5] = xcapacitorvertex[0];   
2485   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2486   xcapacitorvertex[7] = xcapacitorvertex[6];   
2487   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2488   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2489   ycapacitorvertex[2] = ycapacitorvertex[1];   
2490   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2491   ycapacitorvertex[4] = ycapacitorvertex[3];   
2492   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2493   ycapacitorvertex[6] = ycapacitorvertex[5];   
2494   ycapacitorvertex[7] = ycapacitorvertex[0];   
2495   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2496   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2497                                               ycapacitorvertex);
2498   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2499   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2500   TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2501                                           fSSDAir);
2502 ////////////////////////////
2503 // Connector 
2504 ///////////////////////////
2505   const Int_t kssdconnectornumber = 2;
2506   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2507   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2508   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2509                                    +  fgkSSDConnectorAlHeight};  
2510   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2511   TGeoVolume* ssdconnector[kssdconnectornumber];
2512   for(Int_t i=0; i<kssdconnectornumber; i++){
2513       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2514                                           0.5*fgkSSDConnectorWidth,
2515                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2516                            +              i*fgkSSDConnectorNiHeight),
2517                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2518       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2519                                        i==0 ? fSSDAlTraceFlexMedium 
2520                                             : fSSDStiffenerConnectorMedium);      
2521       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2522   }
2523   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2524   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2525                        +  fgkSSDConnectorPosition[0]
2526                        -  fgkSSDConnectorSeparation
2527                        -  1.5*fgkSSDConnectorLength,
2528                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2529                        -  fgkSSDConnectorPosition[1]
2530                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2531   ssdconnectortrans[1] = new TGeoTranslation(
2532                        -  ssdstiffenershape->GetDX()
2533                        +  fgkSSDConnectorPosition[0]
2534                        -  0.5*fgkSSDConnectorLength,
2535                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2536                        -  fgkSSDConnectorPosition[1]
2537                        -  ssdconnectorshape[0]->GetDY(),0.0);
2538   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2539                        -  fgkSSDConnectorPosition[0]
2540                        +  fgkSSDConnectorSeparation
2541                        +  1.5*fgkSSDConnectorLength,
2542                           -(ssdstiffenershape->GetDY()
2543                        -  fgkSSDConnectorPosition[1]
2544                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2545   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2546                        -  fgkSSDConnectorPosition[0]
2547                        +  0.5*fgkSSDConnectorLength,
2548                           -(ssdstiffenershape->GetDY()
2549                        -  fgkSSDConnectorPosition[1]
2550                        -  ssdconnectorshape[0]->GetDY()),0.0);
2551   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2552       for(Int_t j=0; j<kssdconnectornumber; j++)
2553             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2554 ////////////////////////////
2555 // Capacitor 1812-330 nF
2556 /////////////////////////// 
2557   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2558   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2559                                                                                          0.5*fgkSSDCapacitor1812Length,
2560                                                                                          0.5*fgkSSDCapacitor1812Width,
2561                                                                                          0.5*fgkSSDCapacitor1812Height,
2562             ssdcapacitor1812origin);
2563   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2564                                              fSSDStiffener1812CapacitorMedium); 
2565   capacitor1812->SetLineColor(fColorAl);
2566   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2567                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2568                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2569   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2570 ////////////////////////////
2571 //Hybrid Wire
2572 ////////////////////////////
2573   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2574                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2575                                  - fgkSSDConnectorSeparation;
2576   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2577                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2578   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2579                                          + TMath::Power(wirey,2));
2580   Double_t wireangle = TMath::ATan(wirex/wirey);
2581   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2582                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2583   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2584                                              fSSDStiffenerHybridWireMedium); 
2585   hybridwire->SetLineColor(fColorPhynox);
2586   TGeoCombiTrans* hybridwirecombitrans[2];
2587   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2588                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2589                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2590                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2591                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2592                                    ssdstiffenershape->GetDZ()
2593                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2594                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2595   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2596                             0.0,
2597                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2598                             0.0,        
2599                             new TGeoRotation("HybridWireRot2",
2600                           - wireangle*TMath::RadToDeg(),0.,0.));
2601   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2602   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2603   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2604   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2605   ssdhybridlist->Add(ssdhybridcapacitormother);
2606   /////////////////////////////////////////////////////////////
2607   // Deallocating memory
2608   /////////////////////////////////////////////////////////////
2609   delete hybridwirecombitrans[0];
2610   delete hybridwirecombitrans[1];
2611   delete ssdchipsystemlist;
2612   return ssdhybridlist;
2613   /////////////////////////////////////////////////////////////
2614 }
2615 ///////////////////////////////////////////////////////////////////////////////
2616 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2617   /////////////////////////////////////////////////////////////
2618   // SSD Cooling Block System
2619   /////////////////////////////////////////////////////////////
2620   // SSD Cooling Block and Cooling Tube Transformations
2621   /////////////////////////////////////////////////////////////
2622   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2623   localcoolingblockrot->SetAngles(0.,90.,0.);
2624   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2625   TVector3* coolingblocktransvector;
2626   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2627                                                                 + fgkSSDCoolingBlockLength,
2628                                                                   fgkSSDSensorLength
2629                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2630                                                                 - fgkSSDCoolingBlockWidth);
2631   const Int_t kcoolingblocktransnumber = 2;
2632   const Int_t kcoolingblocknumber = 4;
2633   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2634   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2635   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2636   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2637   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2638   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2639                                         0.5*fgkSSDCoolingBlockWidth,
2640                                         fgkSSDCoolingBlockHoleCenter);
2641   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2642   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2643   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2644     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2645       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2646                                              j*coolingblocktransvector->Y(),
2647                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2648                                                     + fgkCoolingTubeRmax));
2649       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2650       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2651     }
2652   }
2653   /////////////////////////////////////////////////////////////
2654   // Virtual Volume containing CoolingBlock System   
2655   /////////////////////////////////////////////////////////////
2656   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2657   const Int_t kmothervertexnumber = 16;  
2658   Double_t xmothervertex[kmothervertexnumber];
2659   Double_t ymothervertex[kmothervertexnumber];
2660   ///////////////////////
2661   // Setting the vertices 
2662   ///////////////////////fgkCoolingTubeSupportRmax
2663   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2664   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2665                                    + fgkSSDCoolingBlockWidth;
2666   xmothervertex[2] = coolingblocktransvector->X()
2667                                    + fgkSSDCoolingBlockLength
2668                                    + 4*coolingtubedistance;
2669   ymothervertex[2] = ymothervertex[1];
2670   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2671   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2672   ymothervertex[4] = ymothervertex[0];
2673   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2674   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2675   ymothervertex[6] = ymothervertex[5]; 
2676   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2677                                    - fgkSSDCoolingBlockWidth; 
2678   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2679   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2680                                    - coolingtubedistance;
2681   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2682   ymothervertex[10] = ymothervertex[9];
2683   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2684   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2685   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2686   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2687   ymothervertex[14] = ymothervertex[13];
2688   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2689   //////////////////////////////////////////////////////////
2690   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2691                                                                         xmothervertex,ymothervertex);
2692   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2693                                                                                            + fgkCoolingTubeRmax));
2694   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2695                                                                                            + fgkCoolingTubeRmax));
2696   TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2697                                                           coolingsystemothershape,fSSDAir);
2698   /////////////////////////////////////////////////////////////
2699   // SSD Cooling Tube Part 
2700   /////////////////////////////////////////////////////////////
2701   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2702   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2703                                                                                  0.5*fgkSSDCoolingBlockWidth); 
2704   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2705                                                                          0.5*fgkSSDCoolingBlockWidth);
2706   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2707   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2708                                                                         fSSDCoolingTubePhynox);
2709   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2710                                                                         fSSDCoolingTubeWater);
2711   coolingtube[0]->SetLineColor(fColorPhynox);
2712   coolingtube[1]->SetLineColor(fColorWater);
2713   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2714   /////////////////////////////////////////////////////////////
2715   // Adding Cooling block to mother volume
2716   /////////////////////////////////////////////////////////////
2717    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2718         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2719         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2720         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2721   }
2722   /////////////////////////////////////////////////////////////
2723   // Deallocating memory
2724   /////////////////////////////////////////////////////////////
2725         delete coolingblocktransvector;
2726         delete localcoolingblockrot;
2727         delete localcoolingtubetrans;
2728         delete localcoolingtuberot;
2729   /////////////////////////////////////////////////////////////
2730   // Checking overlaps  
2731   /////////////////////////////////////////////////////////////
2732         //coolingsystemother->CheckOverlaps(0.01);
2733   /////////////////////////////////////////////////////////////
2734         return coolingsystemother;
2735 }
2736 /////////////////////////////////////////////////////////////////////////////////
2737 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2738   /////////////////////////////////////////////////////////////
2739   // SSD Flex
2740   /////////////////////////////////////////////////////////////
2741   const Int_t kssdflexlayernumber = 2;
2742   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2743   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2744   const Int_t kmothervertexnumber = 17; 
2745   Double_t xmothervertex[kmothervertexnumber];
2746   Double_t ymothervertex[kmothervertexnumber];
2747   /////////////////////////////////////////////
2748   // Auxiliary variables for vertex positioning
2749   /////////////////////////////////////////////
2750   const Int_t kssdflexboxnumber = 5;
2751   Double_t ssdflexboxlength[kssdflexboxnumber];
2752   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2753                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2754                                           *     fgkSSDChipSeparationLength
2755                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2756                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2757   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2758   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2759                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2760   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2761   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2762                                           -     ssdflexboxlength[1];
2763   Double_t ssdflexboxwidth[kssdflexboxnumber];
2764   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2765   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2766   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2767   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2768   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2769   ///////////////////////
2770   // Setting the vertices 
2771   ///////////////////////
2772   xmothervertex[0]  = 0.0;
2773   xmothervertex[1]  = xmothervertex[0];
2774   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2775   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2776                                         + ssdflexboxlength[4];
2777   xmothervertex[4]  = xmothervertex[3];
2778   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2779   xmothervertex[6]  = xmothervertex[5];
2780   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2781   xmothervertex[8]  = xmothervertex[7];
2782   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2783   xmothervertex[10] = xmothervertex[9]; 
2784   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2785   xmothervertex[12] = xmothervertex[11];
2786   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2787   xmothervertex[14] = xmothervertex[13];
2788   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2789   xmothervertex[16] = xmothervertex[15];
2790   ymothervertex[0]  = 0.0;
2791   ymothervertex[1]  = fgkSSDFlexWidth[1];
2792   ymothervertex[2]  = fgkSSDFlexWidth[0];
2793   ymothervertex[3]  = ymothervertex[2];
2794   ymothervertex[4]  = ymothervertex[0];
2795   ymothervertex[5]  = ymothervertex[4];
2796   ymothervertex[6]  = ssdflexboxwidth[2];
2797   ymothervertex[7]  = ymothervertex[6];
2798   ymothervertex[8]  = ymothervertex[0];
2799   ymothervertex[9]  = ymothervertex[8];
2800   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2801   ymothervertex[11] = ymothervertex[10];
2802   ymothervertex[12] = ymothervertex[0];
2803   ymothervertex[13] = ymothervertex[12];
2804   ymothervertex[14] = ymothervertex[7];
2805   ymothervertex[15] = ymothervertex[14];
2806   ymothervertex[16] = ymothervertex[0];
2807   /////////////////////////////////////////////////////////////
2808   // First Mother Volume containing SSDFlex
2809   /////////////////////////////////////////////////////////////
2810   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2811   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2812                                                                     ymothervertex);
2813   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2814   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2815   TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2816                                                                                          fSSDAir);
2817   /////////////////////////////////////////////////////////////
2818   // SSDFlex Layer Shapes
2819   /////////////////////////////////////////////////////////////
2820   for(Int_t i=0; i<kssdflexlayernumber; i++){
2821         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2822                                                                    ymothervertex);
2823     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2824         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2825   }
2826   /////////////////////////////////////
2827   // Setting Layers into Mother Volume
2828   /////////////////////////////////////
2829   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2830   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2831                                                                                                  fSSDKaptonFlexMedium};
2832   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2833                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2834   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2835   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2836   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2837         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2838                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2839                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2840         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2841     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2842                                          +                                         fgkSSDFlexHeight[1])); 
2843     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2844   }
2845   //ssdflexmother->CheckOverlaps(0.01);
2846   return ssdflexmother;
2847 }
2848 /////////////////////////////////////////////////////////////////////////////////
2849 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2850   /////////////////////////////////////////////////////////////
2851   // Method generating SSD End Flex   
2852   /////////////////////////////////////////
2853   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2854                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2855   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2856                                                 * TMath::DegToRad()*ssdflexradiusmax
2857                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2858                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2859   const Int_t knedges = 20;  
2860   const Int_t karcnumber = 2;
2861   TVector3* vertexposition[karcnumber*(knedges+1)];
2862   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2863   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2864   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2865   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2866                                                                                  - 90.0*TMath::DegToRad()};
2867   TVector3* referencetrans[karcnumber];
2868   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2869                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2870                                                                    radius[0]);
2871   referencetrans[1] = new TVector3(referencetrans[0]->X()
2872                                         +              fgkSSDFlexLength[2],
2873      -              fgkSSDStiffenerHeight);
2874 for(Int_t i=0; i<karcnumber; i++){
2875         for(Int_t j=0; j<knedges+1; j++){
2876                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2877                                                                                                radius[i]*SinD(angle[i]));
2878                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2879         }       
2880   }
2881   ///////////////////////
2882   // Setting the vertices 
2883   ///////////////////////
2884   const Int_t kendflexlayernumber = 4;
2885   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2886   TVector3** vertex[kendflexlayernumber];
2887   for(Int_t i=0; i<kendflexlayernumber; i++) 
2888                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2889   TVector3* transvector[kendflexlayernumber+1];
2890   TVector3* deltatransvector = new TVector3();  
2891   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2892   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2893                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2894   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2895         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2896                                         *                 CosD(fgkSSDFlexAngle),
2897                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2898                                         *         SinD(fgkSSDFlexAngle),0.0);   
2899         *transvector[i] = *transvector[i-1]+*deltatransvector;
2900   }
2901   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2902   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2903   for(Int_t i=0; i<karcnumber; i++){
2904         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2905                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2906                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2907                                               /radius[i];
2908         }
2909   }
2910   for(Int_t i=0; i<kendflexlayernumber; i++){
2911         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2912         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2913         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2914                 if(j<(knedges+1)){
2915                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2916                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2917                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2918                         *vertex[i][j+2] += *referencetrans[0];
2919                         vertex[i][4*(knedges+1)-j+1] = 
2920                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2921                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2922                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2923                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2924                 }
2925                 else{
2926                 
2927                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2928                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2929                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2930                         *vertex[i][j+2] += *referencetrans[1];
2931                         vertex[i][4*(knedges+1)-j+1] = 
2932                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2933                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2934                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2935                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2936            }
2937         }
2938   }
2939   /////////////////////////////////////////////////////////////
2940   // First Mother Volume containing SSDEndFlex
2941   /////////////////////////////////////////////////////////////
2942   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2943   Double_t xmothervertex[kendflexvertexnumber];
2944   Double_t ymothervertex[kendflexvertexnumber];
2945   xmothervertex[0] = vertex[0][0]->X(); 
2946   ymothervertex[0] = vertex[0][0]->Y();
2947   for(Int_t i=1; i<kendflexvertexnumber; i++){
2948         if(i<2*(knedges+1)+2){
2949                 xmothervertex[i] = vertex[3][i]->X();
2950                 ymothervertex[i] = vertex[3][i]->Y();
2951         }
2952         else{
2953                 xmothervertex[i] = vertex[0][i]->X();
2954                 ymothervertex[i] = vertex[0][i]->Y();
2955         }
2956   }
2957   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2958                                                                            xmothervertex,ymothervertex);
2959   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2960   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2961   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2962                                                                  ssdendflexmothershape,fSSDAir);        
2963   //////////////////////////////////////
2964   // End Flex TGeoXtru Layer Definition 
2965   //////////////////////////////////////
2966   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2967   TGeoVolume* ssdendflex[kendflexlayernumber];
2968   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2969   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2970   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2971   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2972   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2973                                                                                                         fSSDKaptonFlexMedium};
2974   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2975                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2976   for(Int_t i=0; i<kendflexlayernumber; i++){
2977         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2978                 xvertex[i][j] = vertex[i][j]->X();
2979                 yvertex[i][j] = vertex[i][j]->Y();
2980         }
2981   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2982   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2983   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2984   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2985                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2986   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2987   ssdendflexmother->AddNode(ssdendflex[i],1);
2988   }
2989   /////////////////////////////////////////////////////////////
2990   // Deallocating memory
2991   /////////////////////////////////////////////////////////////
2992   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2993   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2994   for(Int_t i=0; i<kendflexlayernumber; i++){
2995         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2996         delete [] vertex[i];
2997   }
2998   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2999   delete deltatransvector;
3000   /////////////////////////////////////////////////////////////
3001   //ssdendflexmother->CheckOverlaps(0.01);
3002   return ssdendflexmother;
3003 }
3004 ///////////////////////////////////////////////////////////////////////////////
3005 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3006   /////////////////////////////////////////////////////////////
3007   // Method generating the Mounting Block
3008   /////////////////////////////////////////////////////////////  
3009   const Int_t kvertexnumber = 8;
3010   Double_t xvertex[kvertexnumber];
3011   Double_t yvertex[kvertexnumber];
3012   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3013   xvertex[1] = xvertex[0];
3014   xvertex[2] = -xvertex[0];
3015   xvertex[3] = xvertex[2];
3016   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3017                          -                                 fgkSSDMountingBlockLength[2]);
3018   xvertex[5] = xvertex[4];
3019   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3020                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3021                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3022   xvertex[7] = xvertex[6];
3023   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3024                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3025                          -  fgkSSDModuleVerticalDisalignment;
3026   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3027   yvertex[2] = yvertex[1]; 
3028   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3029   yvertex[4] = yvertex[3];
3030   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3031                          - fgkSSDMountingBlockHeight[0];
3032   yvertex[6] = yvertex[5];
3033   yvertex[7] = yvertex[0];
3034   ///////////////////////////////////////////////////////////////////////
3035   // TGeoXTru Volume definition for Mounting Block Part
3036   ///////////////////////////////////////////////////////////////////////
3037   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3038   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3039   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3040   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3041   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3042                                                                           ssdmountingblockshape,
3043                                                                                   fSSDMountingBlockMedium);
3044   ssdmountingblock->SetLineColor(fColorG10);
3045   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3046   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3047   TGeoRotation* mountingblockrot = new TGeoRotation();
3048   mountingblockrot->SetAngles(90.,180.,-90.);
3049   mountingblockcombitrans->SetRotation(*mountingblockrot);
3050   /////////////////////////////////////////////////////////////
3051   // Generating the Mounting Block Screw Vertices 
3052   /////////////////////////////////////////////////////////////  
3053   const Int_t kscrewvertexnumber = 15;
3054   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3055                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3056                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3057                                  * TMath::RadToDeg();
3058   Double_t phi0 = 90.+alpha;
3059   Double_t phi = 270.-2*alpha;
3060   Double_t deltaphi = phi/kscrewvertexnumber;   
3061   TVector3* screwvertex[kscrewvertexnumber+1];
3062   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3063         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3064                                    *CosD(phi0+i*deltaphi),
3065                                    fgkSSDMountingBlockScrewHoleRadius[0]
3066                                    *SinD(phi0+i*deltaphi));
3067   Double_t xscrewvertex[kscrewvertexnumber+6];
3068   Double_t yscrewvertex[kscrewvertexnumber+6];
3069   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3070   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3071                                   -               fgkSSDMountingBlockScrewHoleEdge);
3072   xscrewvertex[1] = xscrewvertex[0];
3073   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3074   xscrewvertex[2] = screwvertex[0]->X();
3075   yscrewvertex[2] = yscrewvertex[1];
3076   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3077         xscrewvertex[i+3] = screwvertex[i]->X();        
3078         yscrewvertex[i+3] = screwvertex[i]->Y();        
3079   } 
3080   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3081   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3082   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3083   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3084   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3085   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3086   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3087   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3088                                                         +                                  fgkSSDMountingBlockHeight[2]);
3089   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3090                                                                                 ssdmountingblockscrewshape,
3091                                                                                             fSSDMountingBlockMedium);
3092   ssdmountingblockscrew->SetLineColor(fColorG10);
3093   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3094   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3095   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3096                                                                         -                                yscrewvertex[1],
3097                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3098                                                                         -                                fgkSSDMountingBlockHeight[2]
3099                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3100                                                                         +                                fgkSSDMountingBlockHeight[2]
3101                                                                         -                                yvertex[0]));
3102   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3103                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3104                                                                                                                  yscrewvertex[1]
3105                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3106                                                                                                          +fgkSSDMountingBlockHeight[2]
3107                                                                                                          -yvertex[0]));
3108   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3109                                                                                                           yscrewvertex[1],
3110                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3111                                                                         +                                 fgkSSDMountingBlockHeight[2]
3112                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3113                                                                         +                                 fgkSSDMountingBlockHeight[2]
3114                                                                         -                                 yvertex[0]));
3115   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3116                                                                                                          yscrewvertex[1],
3117                                                                         -                                yscrewvertex[1]
3118                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3119                                                                         +                                fgkSSDMountingBlockHeight[2]
3120                                                                         -                                yvertex[0]));
3121   TGeoRotation* ssdmountingblockscrewrot[4];
3122   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3123         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3124     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3125     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3126   for(Int_t i=1; i<4; i++) 
3127         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3128   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3129   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3130   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3131   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3132                                                          +                                xvertex[0],yscrewvertex[1]
3133                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3134                                                          +                                fgkSSDMountingBlockHeight[2]
3135                                                          -                                yvertex[0]),0.);      
3136   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3137   for(Int_t i=0; i<4; i++){
3138         ssdmountingblockscrewmatrix[i] = 
3139                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3140         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3141   }
3142   ///////////////////////////////////////////////////////////////////////
3143   // TGeoXtru for Mother Volume 
3144   ///////////////////////////////////////////////////////////////////////
3145   const Int_t kvertexmothernumber = 12;
3146   Double_t xmothervertex[kvertexmothernumber];
3147   Double_t ymothervertex[kvertexmothernumber];
3148   for(Int_t i=0; i<6; i++){
3149         xmothervertex[i] = xvertex[i];
3150         ymothervertex[i] = yvertex[i];
3151   } 
3152   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3153   ymothervertex[6]  = ymothervertex[5];
3154   xmothervertex[7]  = xmothervertex[6];
3155   ymothervertex[7]  = ymothervertex[4];
3156   xmothervertex[8]  = xmothervertex[7]
3157                                         + 0.5*(fgkSSDMountingBlockLength[1]
3158                                         -          fgkSSDMountingBlockLength[2]);
3159   ymothervertex[8]  = ymothervertex[4];
3160   xmothervertex[9]  = xmothervertex[8];
3161   ymothervertex[9]  = ymothervertex[2];
3162   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3163   ymothervertex[10] = ymothervertex[1];
3164   xmothervertex[11] = xmothervertex[10];
3165   ymothervertex[11] = ymothervertex[0];  
3166   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3167   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3168   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3169   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3170   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3171                                                                           ssdmountingblockmothershape,
3172                                                                                   fSSDAir);
3173   /////////////////////////////////////////////////////////////
3174   // Placing the Volumes into Mother Volume 
3175   /////////////////////////////////////////////////////////////
3176   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3177   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3178   for(Int_t i=0; i<4; i++) 
3179         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3180                                                                         ssdmountingblockscrewmatrix[i]);
3181   /////////////////////////////////////////////////////////////
3182   // Deallocating memory
3183   /////////////////////////////////////////////////////////////
3184   delete mountingblockrot;
3185   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3186   delete ssdmountingblockglobalrot; 
3187   delete ssdmountingblockglobaltrans; 
3188   /////////////////////////////////////////////////////////////
3189   return ssdmountingblockmother;
3190 }
3191 ///////////////////////////////////////////////////////////////////////////////
3192  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3193   /////////////////////////////////////////////////////////////
3194   // Method generating the Mounting Block Clip 
3195   /////////////////////////////////////////////////////////////  
3196   const Int_t kmothervertexnumber = 10;
3197   Double_t xmothervertex[kmothervertexnumber];
3198   Double_t ymothervertex[kmothervertexnumber];
3199   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3200                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3201   xmothervertex[1] = xmothervertex[0];
3202   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3203                                    - fgkMountingBlockClibScrewRadius);
3204   xmothervertex[3] = xmothervertex[2]; 
3205   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3206   xmothervertex[5] = xmothervertex[4]; 
3207   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3208   xmothervertex[7] = xmothervertex[6]; 
3209   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3210   xmothervertex[9] = xmothervertex[8]; 
3211   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3212                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0]
3213                                    - fgkSSDModuleVerticalDisalignment;
3214   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3215   ymothervertex[2] = ymothervertex[1];
3216   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3217                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3218                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3219   ymothervertex[4] = ymothervertex[3];
3220   ymothervertex[5] = ymothervertex[2];
3221   ymothervertex[6] = ymothervertex[5];
3222   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3223   ymothervertex[8] = ymothervertex[7];
3224   ymothervertex[9] = ymothervertex[0];
3225   ///////////////////////////////////////////////////////////////////////
3226   // TGeoXTru Volume definition for Mounting Block Clip Part
3227   ///////////////////////////////////////////////////////////////////////
3228   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3229   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3230   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3231   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3232   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3233                                                                           ssdmountingblockclipshape,fSSDAir);
3234   ssdmountingblockclip->SetLineColor(4);
3235   ///////////////////////////////////////////////////////////////////////
3236   // TGeoXTru Volume definition for Clip 
3237   ///////////////////////////////////////////////////////////////////////
3238   const Int_t kclipvertexnumber = 6;
3239   Double_t xclipvertex[kclipvertexnumber];
3240   Double_t yclipvertex[kclipvertexnumber];
3241   xclipvertex[0] = xmothervertex[0];
3242   xclipvertex[1] = xclipvertex[0];
3243   xclipvertex[2] = xmothervertex[6];
3244   xclipvertex[3] = xclipvertex[2];
3245   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3246   xclipvertex[5] = xclipvertex[4];
3247   yclipvertex[0] = ymothervertex[0];
3248   yclipvertex[1] = ymothervertex[1];
3249   yclipvertex[2] = yclipvertex[1];
3250   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3251   yclipvertex[4] = yclipvertex[3];
3252   yclipvertex[5] = yclipvertex[0];
3253   TGeoXtru* clipshape = new TGeoXtru(2);
3254   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3255   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3256   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3257                                                          +   fgkMountingBlockClibWidth);
3258   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3259   clip->SetLineColor(18);
3260   ///////////////////////////////////////////////////////////////////////
3261   // Ladder Support Piece  
3262   ///////////////////////////////////////////////////////////////////////
3263   const Int_t ksupportvertexnumber = 4;
3264   Double_t xsupportvertex[ksupportvertexnumber];
3265   Double_t ysupportvertex[ksupportvertexnumber];
3266   xsupportvertex[0] = xclipvertex[5];
3267   xsupportvertex[1] = xsupportvertex[0];
3268   xsupportvertex[2] = xmothervertex[9];
3269   xsupportvertex[3] = xsupportvertex[2];
3270   ysupportvertex[0] = yclipvertex[0];
3271   ysupportvertex[1] = yclipvertex[3];
3272   ysupportvertex[2] = ysupportvertex[1];
3273   ysupportvertex[3] = ysupportvertex[0];
3274   TGeoXtru* supportshape = new TGeoXtru(2);
3275   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3276   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3277   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3278   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3279   support->SetLineColor(9);
3280   ///////////////////////////////////////////////////////////////////////
3281   // TGeoXTru Volume definition for Screw   
3282   ///////////////////////////////////////////////////////////////////////
3283   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3284                                                 0.5*fgkMountingBlockClibScrewRadius};
3285   Int_t edgesnumber[2] = {50,6};
3286   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3287                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3288   TGeoXtru* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3289   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3290   clipscrew->SetLineColor(12);
3291   TGeoRotation* screwrot = new TGeoRotation();
3292   screwrot->SetAngles(0.,90.,0.);
3293   TGeoTranslation* screwtrans = new TGeoTranslation();
3294   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3295                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3296                                                          0.5*fgkSSDMountingBlockWidth+
3297                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3298   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3299   ///////////////////////////////////////////////////////////////////////
3300   // Placing the Volumes
3301   ///////////////////////////////////////////////////////////////////////
3302   ssdmountingblockclip->AddNode(clip,1);
3303   ssdmountingblockclip->AddNode(support,1);
3304   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3305   /////////////////////////////////////////////////////////////
3306   // Deallocating memory
3307   /////////////////////////////////////////////////////////////  
3308   delete screwtrans;
3309   delete screwrot;
3310   /////////////////////////////////////////////////////////////
3311   return ssdmountingblockclip;
3312 }
3313 ///////////////////////////////////////////////////////////////////////////////
3314 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3315   /////////////////////////////////////////////////////////////
3316   // Method generating the Cooling Tube 
3317   /////////////////////////////////////////////////////////////  
3318    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3319    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3320                                                                                                 new     TGeoTube*[2];
3321    // Ladder Cooling Tubes
3322    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3323                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3324                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth));
3325    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3326                                                                                  coolingtubeshape[0][0]->GetDz());
3327    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3328                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3329                                                   -                                       fgkSSDSensorOverlap));
3330    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3331                                                                                  coolingtubeshape[1][0]->GetDz());
3332    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3333                                                                                  0.5*fgkSSDModuleStiffenerPosition[1]);
3334    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3335                                                                                  coolingtubeshape[2][0]->GetDz());
3336    // End Ladder Cooling Tubes  
3337    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3338    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3339         endladdercoolingtubeshape[i] = new      TGeoTube*[2];
3340    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3342                                                   -                     fgkendladdercoolingsupportdistance[0]));
3343    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3344                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3345    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3346                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3347                                                   +                     fgkendladdercoolingsupportdistance[1]
3348                                                   -                     fgkCoolingTubeSupportWidth));
3349    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3350                                                                         endladdercoolingtubeshape[1][0]->GetDz());
3351    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3352                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3353                                                   -                     fgkEndLadderMountingBlockPosition[0]
3354                                                   -                     fgkendladdercoolingsupportdistance[1]           
3355                                                   -                     fgkCoolingTubeSupportWidth));
3356    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3357                                                                         endladdercoolingtubeshape[2][0]->GetDz());
3358    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3359                                                           0.50 * (fgkMountingBlockToSensorSupport
3360                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3361                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3362                                                         +                 fgkSSDSensorOverlap
3363                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3364                                                         -                 fgkendladdercoolingsupportdistance[2]
3365                                                         -                 fgkEndLadderMountingBlockPosition[1]
3366                                                         -                 fgkCoolingTubeSupportWidth));
3367    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3368                                                                         endladdercoolingtubeshape[3][0]->GetDz());
3369    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3370                                                           0.50 * fgkendladdercoolingsupportdistance[2]);
3371    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3372                                                                         endladdercoolingtubeshape[4][0]->GetDz());
3373    // Ladder Cooling Tubes
3374    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3375    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3376                                                                                          new TGeoVolume*[2];
3377    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3378                                                                           fSSDCoolingTubePhynox);
3379    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3380                                                                           fSSDCoolingTubeWater);
3381    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3382                                                                           fSSDCoolingTubePhynox);
3383    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3384                                                                           fSSDCoolingTubeWater);
3385    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3386                                                                           fSSDCoolingTubePhynox);
3387    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3388                                                                           fSSDCoolingTubeWater);
3389    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3390         coolingtube[i][0]->SetLineColor(fColorPhynox);
3391         coolingtube[i][1]->SetLineColor(fColorWater);
3392    }
3393    // End Ladder Cooling Tubes  
3394    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3395    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3396    endladdercoolingtube[i] = new TGeoVolume*[2];
3397    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3398                                                                 endladdercoolingtubeshape[0][0],
3399                                                                 fSSDCoolingTubePhynox);
3400    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3401                                                                 endladdercoolingtubeshape[0][1],
3402                                                                 fSSDCoolingTubeWater);
3403    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3404                                                                 endladdercoolingtubeshape[1][0],
3405                                                                 fSSDCoolingTubePhynox);
3406    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3407                                                                 endladdercoolingtubeshape[1][1],
3408                                                                 fSSDCoolingTubeWater);
3409    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3410                                                                 endladdercoolingtubeshape[2][0],
3411                                                                 fSSDCoolingTubePhynox);
3412    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3413                                                                 endladdercoolingtubeshape[2][1],
3414                                                                 fSSDCoolingTubeWater);
3415    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3416                                                                 endladdercoolingtubeshape[3][0],
3417                                                                 fSSDCoolingTubePhynox);
3418    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3419                                                                 endladdercoolingtubeshape[3][1],
3420                                                                 fSSDCoolingTubeWater);
3421    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3422                                                                 endladdercoolingtubeshape[4][0],
3423                                                                 fSSDCoolingTubePhynox);
3424    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3425                                                                 endladdercoolingtubeshape[4][1],
3426                                                                 fSSDCoolingTubeWater);
3427    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3428         endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3429         endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3430    }
3431   /////////////////////////////////////////////////////////////
3432   // Virtual Volume containing Cooling Tubes
3433   /////////////////////////////////////////////////////////////
3434   // Ladder Cooling Tubes
3435   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3436   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3437   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3438                                                                                         coolingtubeshape[i][0]->GetRmax(),
3439                                                                                         coolingtubeshape[i][0]->GetDz());
3440   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3441   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3442                                                                           fSSDAir);
3443   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3444                                                                           fSSDAir);
3445   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3446                                                                           fSSDAir);
3447   // End Ladder Cooling Tubes
3448   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3449   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3450   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3451                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3452                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3453   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3454   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3455                                                                           endladdervirtualcoolingtubeshape[0],
3456                                                                           fSSDAir);
3457   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3458                                                                           endladdervirtualcoolingtubeshape[1],
3459                                                                           fSSDAir);
3460   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3461                                                                           endladdervirtualcoolingtubeshape[2],
3462                                                                           fSSDAir);
3463   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3464                                                                           endladdervirtualcoolingtubeshape[3],
3465                                                                           fSSDAir);
3466   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3467                                                                           endladdervirtualcoolingtubeshape[4],
3468                                                                           fSSDAir);
3469   TList* coolingtubelist = new TList();
3470   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3471         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3472         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3473     coolingtubelist->Add(virtualcoolingtube[i]);
3474   }
3475         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3476         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3477     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3478         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3479         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3480     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3481         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3482         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3483     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3484         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3485         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3486     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3487         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3488         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3489     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3490   return coolingtubelist;
3491 }
3492 ///////////////////////////////////////////////////////////////////////////////
3493 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3494   /////////////////////////////////////////////////////////////
3495   // Method generating SSD Cooling Block    
3496   /////////////////////////////////////////////////////////////
3497   const Int_t kvertexnumber = 8;
3498   ///////////////////////////////////////
3499   // Vertex Positioning for TGeoXTru
3500   ///////////////////////////////////////
3501   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3502   vertexposition[0] = new TVector3(0.0,0.0);
3503   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3504   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3505                                           vertexposition[1]->Y());
3506   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3507                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3508   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3509   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3510                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3511   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3512                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3513                                         - fgkSSDCoolingBlockHoleLength[0]
3514                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3515                                           fgkSSDCoolingBlockHeight[0]
3516                                         - fgkSSDCoolingBlockHoleRadius[1],
3517                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3518   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3519                                         - fgkSSDCoolingBlockHoleLength[0]),
3520                                           vertexposition[6]->Y());
3521   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3522                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3523   Double_t phi = 180.-alpha;
3524   Double_t psi = 180.+2.*alpha;
3525   Double_t deltapsi = psi/nedges;
3526   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3527   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3528                                                   fgkSSDCoolingBlockHoleCenter);
3529   for(Int_t i=0; i<nedges+1; i++){
3530         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3531                                                                                                radius*SinD(phi+i*deltapsi));
3532    *vertexposition[kvertexnumber+i] += (*transvector);
3533   }
3534   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3535   for(Int_t i=0; i<kvertexnumber; i++)
3536     vertexposition[kvertexnumber+nedges+1+i] = 
3537                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3538   ///////////////////////////////////////////////////////////////////////
3539   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3540   ///////////////////////////////////////////////////////////////////////
3541   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3542   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3543   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3544   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3545         xvertexpoints[i] = vertexposition[i]->X();
3546         yvertexpoints[i] = vertexposition[i]->Y();
3547   } 
3548   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3549                                                                                         yvertexpoints);
3550   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3551   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3552   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3553                                                                           ssdcoolingblockshape,
3554                                                                                   fSSDAlCoolBlockMedium);
3555   ssdcoolingblock->SetLineColor(fColorAl);
3556   /////////////////////////////////////////////////////////////
3557   // Deallocating memory
3558   /////////////////////////////////////////////////////////////
3559   delete [] vertexposition;
3560   delete xvertexpoints;
3561   delete yvertexpoints;
3562   /////////////////////////////////////////////////////////////
3563   return ssdcoolingblock;
3564 }
3565 /////////////////////////////////////////////////////////////////////////////////
3566 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3567   ///////////////////////////////////////////////////////
3568   const Int_t kssdchipcablesnumber    = 2;
3569   const Int_t kssdchipcableslaynumber = 2;
3570   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3571   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3572   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3573   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3574                                                  -  fgkSSDChipCablesHeight[0]
3575                                                  -  fgkSSDChipCablesHeight[1]);
3576   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3577   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3578   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3579                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3580                                                           - ssdchipcablesradius[0]
3581                                                           - fgkSSDChipCablesWidth[1]
3582                                                           - fgkSSDChipCablesWidth[2]);
3583   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3584                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3585                                                           +      fgkSSDChipCablesHeight[1]
3586                                                           +      fgkSSDSensorHeight);
3587   ///////////////////////////////////////////////////////
3588   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3589   ///////////////////////////////////////////////////////
3590   TVector3** vertexposition[kssdchipcableslaynumber];
3591   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3592                                                                                                   new TVector3*[4*(nedges+1)+4];
3593   Double_t ratio[4];
3594   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3595   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3596                    /  ssdchipcablesradius[0]; 
3597   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3598                    /  ssdchipcablesradius[0];
3599   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3600                    +  fgkSSDChipCablesHeight[1])
3601                    /  ssdchipcablesradius[0];
3602   Double_t phi = 180.;
3603   Double_t deltaphi = 180./nedges;
3604   Double_t angle = 0.0;
3605   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3606   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3607   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3608         xvertexpoints[i] = new Double_t[kvertexnumber];
3609         yvertexpoints[i] = new Double_t[kvertexnumber];
3610   }  
3611   TVector3* vertex = new TVector3();
3612   TVector3* transvector[kssdchipcableslaynumber];
3613   transvector[0] = new TVector3(fgkSSDChipWidth,
3614                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3615   transvector[1] = new TVector3();
3616   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3617   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3618   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3619                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3620                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3621   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3622         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3623         transvector[1]->SetY(ssdchipcablesradius[0]
3624                                  +               fgkSSDChipCablesHeight[0]
3625                                  +               fgkSSDChipCablesHeight[1]);  
3626         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3627                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3628                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3629                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3630                                                          - i*fgkSSDChipCablesHeight[0]);
3631                 vertexposition[i][2*(nedges+1)+2] = 
3632                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3633                                 +                                fgkSSDChipCablesWidth[1]
3634                                 +                                fgkSSDChipCablesWidth[2],
3635                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3636                                 +                                fgkSSDChipCablesHeight[1]));
3637         vertexposition[i][2*(nedges+1)+3] = 
3638                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3639                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3640                                 -                                fgkSSDChipCablesHeight[i]);
3641             for(Int_t j=0; j<nedges+1; j++){            
3642                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3643                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3644                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3645                         vertexposition[0][(nedges+1)*i+j+2] = 
3646                                                 new TVector3(*vertex+*transvector[i]);
3647                         vertexposition[1][(nedges+1)*i+j+2] = 
3648                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3649                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3650                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3651                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3652                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3653                                                 new TVector3(vertex->X()*ratio[2*i+1]
3654                                                         +                        transvector[i]->X(),
3655                                                                                  vertex->Y()*ratio[2*i+1]
3656                                                         +                transvector[i]->Y());
3657                 }
3658         }
3659         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3660                 for(Int_t j=0; j<kvertexnumber; j++){   
3661                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3662                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3663                 }
3664                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3665                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3666                                                                                 xvertexpoints[i],yvertexpoints[i]);
3667                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3668                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3669                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3670                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3671                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3672                                                           (kssdchipcablesnumber*k+i)%2==0?
3673                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3674                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3675         }
3676         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3677                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3678   }
3679   /////////////////////////////////////////////////////////////
3680   // Mother Volume definition 
3681   /////////////////////////////////////////////////////////////
3682   Double_t ssdchipseparation = fgkSSDSensorLength
3683                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3684                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3685                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3686   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3687   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3688                                                           +fgkSSDChipCablesWidth[1]
3689                                                           +fgkSSDChipCablesWidth[2]);
3690   Double_t dy = fgkSSDChipCablesLength[1];
3691   Double_t dz = SSDChipCablesHeigth;
3692   TGeoBBox* ssdchipcablesmotherbox = new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3693   TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3694                           ssdchipcablesmotherbox,fSSDAir);
3695   /////////////////////////////////////////////////////////////
3696   // Rotation and Translation Definition for positioning 
3697   /////////////////////////////////////////////////////////////
3698   TGeoRotation* ssdchipcablesrot[5];
3699   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3700   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3701   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3702   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3703   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3704   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3705                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3706   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3707   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3708   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3709   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3710   /////////////////////////////////////////////////////////////
3711   // Deallocating memory
3712   /////////////////////////////////////////////////////////////
3713   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3714         delete [] xvertexpoints[i];
3715         delete [] yvertexpoints[i];
3716   }
3717   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3718   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3719   delete vertex; 
3720   delete ssdchipcablesrot[0];
3721   delete ssdchipcablesrot[1];
3722   delete ssdchipcablesrot[3];
3723   /////////////////////////////////////////////////////////////
3724   return ssdchipcablesmother;
3725 }
3726 ///////////////////////////////////////////////////////////////////////////////
3727 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3728   /////////////////////////////////////////////////////////////
3729   // SSD Chip Assembly
3730   /////////////////////////////////////////////////////////////
3731   TGeoVolume* ssdchipassembly = GetSSDChips();
3732   TList* ssdchipsystemlist = new TList();
3733 //  const Int_t knedges = 20;
3734   const Int_t knedges = 5;
3735   const Int_t kchipsystemnumber = 2;
3736   /////////////////////////////////////////////////////////////
3737   // Mother Volume containing SSDChipSystem
3738   /////////////////////////////////////////////////////////////
3739   TGeoXtru* chipsystemothershape[kchipsystemnumber];
3740   for(Int_t i=0; i<kchipsystemnumber; i++) chipsystemothershape[i] = new TGeoXtru(2);
3741   const Int_t kmothervertexnumber = 12;  
3742   Double_t xmothervertex[kchipsystemnumber][kmothervertexnumber];
3743   Double_t ymothervertex[kchipsystemnumber][kmothervertexnumber];
3744   Double_t ssdchipcablesradius[kchipsystemnumber];
3745   Double_t ssdchipseparation = fgkSSDSensorLength
3746                              - 2.*fgkSSDModuleStiffenerPosition[1]
3747                              - 2.*(fgkSSDStiffenerWidth
3748                              - fgkSSDStiffenerToChipDist-0.5*fgkSSDChipWidth);
3749   for(Int_t i=0; i<kchipsystemnumber; i++)
3750         ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
3751                                                    -  fgkSSDChipCablesHeight[0]
3752                                                    -  fgkSSDChipCablesHeight[1]);
3753   ///////////////////////
3754   // Setting the vertices 
3755   ///////////////////////
3756   xmothervertex[0][0]  = -0.5*fgkSSDChipCablesLength[1];  
3757   xmothervertex[0][1]  = xmothervertex[0][0];  
3758   xmothervertex[0][2]  = (fgkSSDChipNumber-1)*(fgkSSDChipLength
3759                                            + fgkSSDChipSeparationLength)+0.5*fgkSSDChipCablesLength[1];  
3760   xmothervertex[0][3]  = xmothervertex[0][2];  
3761   xmothervertex[0][4]  = 0.5*fgkSSDChipCablesLength[1];  
3762   xmothervertex[0][5]  = xmothervertex[0][4];  
3763   xmothervertex[0][6]  = xmothervertex[0][2]-0.5*fgkSSDChipCablesLength[1];  
3764   xmothervertex[0][7]  = xmothervertex[0][6]; 
3765   xmothervertex[0][8]  = 0.0;  
3766   xmothervertex[0][9]  = xmothervertex[0][8];  
3767   xmothervertex[0][10] = xmothervertex[0][4];  
3768   xmothervertex[0][11] = xmothervertex[0][10];  
3769   for(Int_t i=0; i<kmothervertexnumber; i++) 
3770         xmothervertex[1][i] = xmothervertex[0][i]; 
3771   for(Int_t i=0; i<kchipsystemnumber; i++){
3772         ymothervertex[i][0]  = -0.5*fgkSSDChipWidth-ssdchipcablesradius[i]
3773                                                  - fgkSSDChipCablesWidth[1]-fgkSSDChipCablesWidth[2];
3774         ymothervertex[i][1]  = ssdchipseparation-ymothervertex[i][0];
3775         ymothervertex[i][2]  = ymothervertex[i][1];
3776         ymothervertex[i][3]  = ymothervertex[i][0];
3777         ymothervertex[i][4]  = ymothervertex[i][0];
3778         ymothervertex[i][5]  = 0.5*fgkSSDChipWidth;
3779         ymothervertex[i][6]  = ymothervertex[i][5];
3780         ymothervertex[i][7]  = ssdchipseparation-0.5*fgkSSDChipWidth;
3781         ymothervertex[i][8]  = ymothervertex[i][7];
3782         ymothervertex[i][9]  = ymothervertex[i][5];
3783         ymothervertex[i][10] = ymothervertex[i][5];
3784         ymothervertex[i][11] = ymothervertex[i][4];
3785   }
3786   //////////////////////////////////////////////////////////
3787   TGeoVolume* chipsystemother[kchipsystemnumber];
3788   const char* chipsytemothername[kchipsystemnumber] = 
3789                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3790   for(Int_t i=0; i<kchipsystemnumber; i++){
3791     chipsystemothershape[i]->DefinePolygon(kmothervertexnumber,
3792                                                                         xmothervertex[i],ymothervertex[i]);
3793     chipsystemothershape[i]->DefineSection(0,-fgkSSDChipCablesHeight[i+2]
3794                                                                                   -0.5*fgkSSDChipHeight);
3795     chipsystemothershape[i]->DefineSection(1,0.5*fgkSSDChipHeight);
3796     chipsystemother[i] = new TGeoVolume(chipsytemothername[i],
3797                                                           chipsystemothershape[i],fSSDAir);
3798   }
3799   /////////////////////////////////////////////////////////////
3800   // SSD Chip Cables
3801   /////////////////////////////////////////////////////////////
3802   TGeoVolume* ssdchipcables[kchipsystemnumber];
3803   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3804   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3805   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3806   //////////////////
3807   for(Int_t i=0; i<kchipsystemnumber; i++){
3808                 ssdchipcables[i] = 
3809                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3810                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3811                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3812                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3813   }
3814   for(Int_t i=0; i<kchipsystemnumber; i++){
3815         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3816                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3817                 ssdchipcablesrot[i][j] = new TGeoRotation();
3818                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3819                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3820                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3821                                                   +                fgkSSDChipSeparationLength),
3822                                                                                         0.5*fgkSSDChipWidth,
3823                                                   -                                     0.5*fgkSSDChipHeight
3824                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3825                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3826                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3827                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3828         }
3829         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3830         ssdchipsystemlist->Add(chipsystemother[i]);     
3831   }
3832   /////////////////////////////////////////////////////////////
3833   // Deallocating memory
3834   /////////////////////////////////////////////////////////////
3835   for(Int_t i=0; i<kchipsystemnumber; i++){
3836         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3837                 delete ssdchipcablesrot[i][j];
3838                 delete ssdchipcablestrans[i][j];
3839         }
3840         delete ssdchipcablesrot[i];
3841         delete ssdchipcablestrans[i];
3842   }
3843   /////////////////////////////////////////////////////////////
3844   return ssdchipsystemlist;
3845 }
3846 ///////////////////////////////////////////////////////////////////////////////
3847 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3848   /////////////////////////////////////////////////////////////
3849   // SSD Chip Assembly Generation    
3850   /////////////////////////////////////////////////////////////
3851   const Int_t kssdchiprownumber = 2;
3852   TGeoBBox* ssdchipcompshape[2];
3853   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3854                                                                                 0.5*fgkSSDChipLength,
3855                                                                                 0.5*fgkSSDChipWidth,
3856                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3857   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3858                                                                                 0.5*fgkSSDChipLength,
3859                                                                                 0.5*fgkSSDChipWidth,
3860                                                                                 0.5*fgkSSDChipGlueHeight);
3861   TGeoVolume* ssdchipcomp[2];
3862   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3863   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3864                                                                   fSSDChipGlueMedium);
3865   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3866   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3867   TGeoTranslation* ssdchipcomptrans[2];
3868   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3869   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3870   /////////////////////////////////////////////////////////////
3871   // Virtual Volume containing SSDChip   
3872   /////////////////////////////////////////////////////////////
3873   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3874                                                                                                                  0.5*fgkSSDChipWidth,
3875                                                                                                                  0.5*fgkSSDChipHeight);
3876   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3877   /////////////////////////////////////////////////////////////
3878   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3879   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3880                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3881                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3882                                    -  0.5*fgkSSDChipWidth)};
3883   /////////////////////////////////////////////////////////////
3884   // Virtual Volume containing SSDChipAssembly   
3885   /////////////////////////////////////////////////////////////
3886   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3887   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3888   Double_t xmothervertex[kssdmothervertexnumber];
3889   Double_t ymothervertex[kssdmothervertexnumber];
3890   ///////////////////////
3891   // Setting the vertices 
3892   ///////////////////////
3893   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3894   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3895                                    - ymothervertex[0];
3896   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3897   ymothervertex[2] = ymothervertex[1];
3898   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3899   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3900   ymothervertex[4] = ymothervertex[0];
3901   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3902   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3903                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3904   ymothervertex[6] = ymothervertex[5];
3905   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3906                                    - fgkSSDChipWidth;
3907   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3908   ymothervertex[8] = ymothervertex[7];
3909   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3910   ymothervertex[9] = ymothervertex[6];
3911   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3912   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3913   //////////////////////////////////////////////////////////
3914   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3915                                                                         xmothervertex,ymothervertex);
3916   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3917   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3918   TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3919                                                           ssdchipmothershape,fSSDAir);
3920    /////////////////////////////////////////////////////////////
3921   for(Int_t i=0; i<kssdchiprownumber; i++)
3922     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3923                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3924                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3925   return ssdchipmother;
3926 }
3927 /////////////////////////////////////////////////////////////////////////////////
3928 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3929   /////////////////////////////////////////////////////////////
3930   // Method returning a List containing pointers to Ladder Cable Volumes    
3931   /////////////////////////////////////////////////////////////
3932   const Int_t kladdercablesegmentnumber = 2;
3933   /////////////////////////////////////////
3934   // LadderSegmentBBox Volume
3935   /////////////////////////////////////////
3936   TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber];
3937   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3938                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3939   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3940                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3941                                                                            0.5*fgkSSDFlexWidth[0],
3942                                                                            0.5*fgkSSDLadderCableWidth,
3943                                                                            0.5*fgkSSDFlexHeight[i]); 
3944   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3945                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3946   TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3947   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3948                         laddercablesegmentbbox[i] =
3949                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3950                                                                                  laddercablesegmentbboxshape[i],
3951                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3952             fSSDKaptonLadderCableMedium));
3953                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3954                                                                                                                    fColorPolyhamide);
3955   }
3956   TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber];                                                                                
3957   laddercablesegmentbboxtrans[0] = 
3958                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3959                                                                                            0.5*fgkSSDFlexWidth[0],
3960                                                                                            0.5*fgkSSDLadderCableWidth,
3961                                                                                            0.5*fgkSSDFlexHeight[0]);
3962   laddercablesegmentbboxtrans[1] = 
3963                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3964                                                                                            0.5*fgkSSDFlexWidth[0],
3965                                                                                            0.5*fgkSSDLadderCableWidth,
3966                                                                                            fgkSSDFlexHeight[0]
3967                                                                                            +0.5*fgkSSDFlexHeight[1]);
3968   TGeoVolume* laddercablesegmentbboxassembly = 
3969                                                    new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly"); 
3970   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3971                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3972                                                                                             laddercablesegmentbboxtrans[i]);
3973 /////////////////////////////////////////
3974 // LadderSegmentArb8 Volume
3975 /////////////////////////////////////////
3976   const Int_t kvertexnumber = 4;
3977   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3978   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3979                                                                                                   new TVector3*[kvertexnumber];
3980 //Shape Vertex Positioning
3981   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3982         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3983         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3984                                                                                                                   i*fgkSSDFlexHeight[0]);
3985         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3986                                                                                    +                         fgkSSDFlexHeight[1]
3987                                                                                    +                      i*fgkSSDFlexHeight[0]);
3988         laddercablesegmentvertexposition[i][3] = 
3989                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3990                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3991   }
3992   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3993                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3994   char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3995                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3996   TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3997   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3998                                         GetArbShape(laddercablesegmentvertexposition[i],
3999                                                                 laddercablesegmentwidth[i],
4000                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
4001                                                                 laddercablesegmentarbshapename[i]);
4002   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
4003                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
4004   TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
4005   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
4006                          laddercablesegmentarb[i] =
4007                                                    new TGeoVolume(laddercablesegmentarbname[i],
4008                                                                                   laddercablesegmentarbshape[i],
4009                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
4010             fSSDKaptonLadderCableMedium)); 
4011                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
4012                                                                                                                    fColorPolyhamide);
4013 }
4014   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
4015   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
4016                                                                                                  90.,90,-90.);   
4017   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
4018                                                                                                   0.,90.,0.);    
4019   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
4020                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
4021                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
4022                                                          + fgkSSDFlexWidth[0],0.,0.,
4023                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
4024                                                      *(*laddercablesegmentarbrot[0])));
4025   TGeoVolume* laddercablesegmentarbassembly = 
4026                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
4027   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
4028   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
4029                                                                                    laddercablesegmentarbcombitrans);
4030 /////////////////////////////////////////
4031 // End Ladder Cable Volume
4032 /////////////////////////////////////////
4033   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4034   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4035                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4036   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4037                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4038                                                                            0.5*ssdendladdercablelength,
4039                                                                            0.5*fgkSSDLadderCableWidth,
4040                                                                            0.5*fgkSSDFlexHeight[i]);
4041   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4042                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4043   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4044   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4045                         ladderendcablesegmentbbox[i] =
4046                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4047                                                                                  ladderendcablesegmentbboxshape[i],
4048                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4049             fSSDKaptonLadderCableMedium));
4050                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4051                                                                                                                    fColorPolyhamide);
4052   }
4053   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4054   ladderendcablesegmentbboxtrans[0] = 
4055                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4056                                                                                            0.5*ssdendladdercablelength,
4057                                                                                            0.5*fgkSSDLadderCableWidth,
4058                                                                                            0.5*fgkSSDFlexHeight[0]);
4059   ladderendcablesegmentbboxtrans[1] = 
4060                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4061                                                                                            0.5*ssdendladdercablelength,
4062                                                                                            0.5*fgkSSDLadderCableWidth,
4063                                                                                            fgkSSDFlexHeight[0]
4064                                                                                            +0.5*fgkSSDFlexHeight[1]);
4065   TGeoVolume* ladderendcablesegmentbboxassembly = 
4066                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4067   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4068                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4069                                                                                             ladderendcablesegmentbboxtrans[i]);
4070 /////////////////////////////////////////
4071   TList* laddercablesegmentlist = new TList();
4072   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4073   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4074   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4075   return laddercablesegmentlist;
4076   }
4077 /////////////////////////////////////////////////////////////////////////////////
4078 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4079   /////////////////////////////////////////////////////////////
4080   // Method generating Ladder Cable Volumes Assemblies    
4081   /////////////////////////////////////////////////////////////
4082   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4083   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4084   for(Int_t i=0; i<n; i++){
4085          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4086                                                         i*(fgkCarbonFiberJunctionWidth),
4087                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4088                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4089     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4090         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4091   }
4092   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4093                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4094                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4095                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4096   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4097   return laddercable;
4098 }
4099 /////////////////////////////////////////////////////////////////////////////////
4100 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4101   /////////////////////////////////////////////////////////////
4102   // Method generating Ladder Cable Volumes Assembly   
4103   /////////////////////////////////////////////////////////////
4104   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4105   char laddercabletransname[30];
4106   for(Int_t i=0; i<n; i++){ 
4107         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4108     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4109         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4110   }
4111   return laddercableassembly;
4112 }
4113 /////////////////////////////////////////////////////////////////////////////////
4114 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4115   /////////////////////////////////////////////////////////////
4116   // Method generating Ladder Cable List Assemblies  
4117   /////////////////////////////////////////////////////////////  
4118   const Int_t kladdercableassemblynumber = 2;
4119   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4120   TGeoVolume* ladderCable[kladdercableassemblynumber];
4121   char laddercableassemblyname[30];
4122   TList* laddercableassemblylist = new TList();
4123   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4124         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4125         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4126         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4127                                          new TGeoCombiTrans((n-1)
4128                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4129                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4130                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4131         laddercableassemblylist->Add(ladderCable[i]);
4132 }
4133   return laddercableassemblylist;
4134 }
4135 ///////////////////////////////////////////////////////////////////////////////
4136 void AliITSv11GeometrySSD::SetLadderSegment(){
4137   /////////////////////////////////////////////////////////////
4138   // Method Generating Ladder Segment Array
4139   /////////////////////////////////////////////////////////////
4140   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4141   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4142   if(!fCreateMaterials) CreateMaterials();
4143   if(!fTransformationMatrices) CreateTransformationMatrices();
4144   if(!fBasicObjects) CreateBasicObjects();
4145   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4146   // Placing Carbon Fiber Support       
4147         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4148                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4149                                                                                         fcarbonfibersupportmatrix[j]);  
4150                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4151                                                                                         fcarbonfibersupportmatrix[j]);
4152   }
4153   // Placing Carbon Fiber Junction
4154     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4155         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4156                                                                    fcarbonfiberjunctionmatrix[j]);
4157   // Placing Carbon Fiber Lower Support
4158         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4159                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4160                                                            fcarbonfiberlowersupportrans[j]);    
4161   // Placing SSD Sensor Support
4162     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4163         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4164                                                                      fssdsensorsupport[1][i],
4165                                                            j+1,fssdsensorsupportmatrix[j]);
4166   // Placing SSD Cooling Tube Support 
4167         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4168                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4169                                                                    fcoolingtubesupportmatrix[j]);
4170   // Placing SSD Cooling Tube  
4171         for(Int_t j=0; j<2; j++)
4172                 for(Int_t k=0; k<2; k++){
4173                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4174                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4175                 }
4176   // Placing SSD Hybrid
4177     switch(i){
4178         case 0: 
4179                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4180                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4181                 break;
4182     case 1:
4183                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4184                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4185                 break;
4186         }
4187         // Placing Cooling Block System
4188     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4189         // Placing SSD Flex
4190         for(Int_t j=0; j<fgkflexnumber; j++){
4191       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4192       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4193         }
4194    }
4195 }
4196 ///////////////////////////////////////////////////////////////////////////////
4197 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4198   /////////////////////////////////////////////////////////////
4199   // Method Generating End Ladder
4200   /////////////////////////////////////////////////////////////
4201   // End Ladder Carbon Fiber Junction 
4202   /////////////////////////////////////////////////////////////
4203   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4204   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4205   if(!fCreateMaterials) CreateMaterials();
4206   if(!fTransformationMatrices) CreateTransformationMatrices();
4207   if(!fBasicObjects) CreateBasicObjects();
4208   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4209         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4210                 fendladdersegment[i]->AddNode(j==2 ? 
4211                                                         fendladdercarbonfiberjunction[i][1] : 
4212                                                         fendladdercarbonfiberjunction[i][0],
4213                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4214   }
4215   /////////////////////////////////////////////////////////////
4216   // End Ladder Carbon Fiber Support 
4217   /////////////////////////////////////////////////////////////
4218   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4219       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4220                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4221                   fendladdercarbonfibermatrix[i][j]);   
4222           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4223                   fendladdercarbonfibermatrix[i][j]);   
4224       }
4225   /////////////////////////////////////////////////////////////
4226   // End Ladder Mounting Block
4227   /////////////////////////////////////////////////////////////
4228   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4229        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4230                                      fendladdermountingblockcombitrans[i]);
4231   /////////////////////////////////////////////////////////////
4232   // End Ladder Mounting Block Clip
4233   /////////////////////////////////////////////////////////////
4234   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4235         for(Int_t j=0; j<2; j++)
4236                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4237                                               fendladdermountingblockclipmatrix[i][j]);
4238   /////////////////////////////////////////////////////////////
4239   // End Ladder Lower Supports
4240   /////////////////////////////////////////////////////////////
4241   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4242                                 fendladderlowersupptrans[0]);
4243   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4244                                 fendladderlowersupptrans[1]);
4245   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4246                                 fendladderlowersupptrans[2]);
4247   /////////////////////////////////////////////////////////////
4248   // End Ladder Cooling Tube Support
4249   /////////////////////////////////////////////////////////////
4250   for(Int_t i=0; i<2; i++) 
4251         for(Int_t j=0; j<(i==0?4:2); j++)   
4252                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4253                                               fendladdercoolingtubesupportmatrix[i][j]);
4254   /////////////////////////////////////////////////////////////
4255   // End Ladder Cooling Tube Support
4256   /////////////////////////////////////////////////////////////
4257   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                    
4258   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                    
4259   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4260   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4261   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4262   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4263   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4264   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4265   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4266   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                                                                    
4267 }
4268 ///////////////////////////////////////////////////////////////////////////////
4269 void AliITSv11GeometrySSD::SetLadder(){
4270   /////////////////////////////////////////////////////////////
4271   // Method Generating Ladder of Layer 5 and 6
4272   /////////////////////////////////////////////////////////////  
4273   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4274                                                                                                 fgkSSDLay6SensorsNumber};
4275   /////////////////////////////////////////////////////////////////////////////                                         
4276   /// Generating Ladder Mother Volume Containing Ladder 
4277   /////////////////////////////////////////////////////////////////////////////          
4278   TGeoXtru* laddershape[fgkladdernumber];       
4279   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4280   const Int_t kmothervertexnumber = 8;  
4281   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4282   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4283   ///////////////////////
4284   // Setting the vertices 
4285   ///////////////////////
4286   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4287                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4288   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4289   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
4290                                           -  fgkSSDModuleVerticalDisalignment;
4291   xmothervertex[0][1] = xmothervertex[0][0];
4292   ymothervertex[0][1] = 0.0;
4293   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4294                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4295   ymothervertex[0][2] = ymothervertex[0][1];
4296   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4297   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4298   xmothervertex[0][4] = -xmothervertex[0][3];
4299   ymothervertex[0][4] = ymothervertex[0][3];
4300   xmothervertex[0][5] = -xmothervertex[0][2];
4301   ymothervertex[0][5] = ymothervertex[0][2];
4302   xmothervertex[0][6] = -xmothervertex[0][1];
4303   ymothervertex[0][6] = ymothervertex[0][1];
4304   xmothervertex[0][7] = -xmothervertex[0][0];
4305   ymothervertex[0][7] = ymothervertex[0][0];
4306   for(Int_t i=0; i<kmothervertexnumber; i++){
4307         xmothervertex[1][i] = xmothervertex[0][i];
4308         ymothervertex[1][i] = ymothervertex[0][i];
4309   }
4310   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4311   for(Int_t i=0; i<fgkladdernumber; i++){
4312         laddershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
4313                                                                     ymothervertex[i]);
4314     laddershape[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4315     laddershape[i]->DefineSection(1,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4316                                                                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4317     fladder[i] = new TGeoVolume(laddername[i],laddershape[i],fSSDAir);
4318         fladder[i]->SetLineColor(4);
4319  }
4320 ///////////////////////////////////////////////////////////////////////////
4321  if(!fCreateMaterials) CreateMaterials();
4322  if(!fTransformationMatrices) CreateTransformationMatrices();
4323  if(!fBasicObjects) CreateBasicObjects();
4324  SetLadderSegment(); 
4325  SetEndLadderSegment();
4326   for(Int_t i=0; i<fgkladdernumber; i++){
4327         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4328         //////////////////////////                                              
4329         /// Placing Ladder Segment
4330         //////////////////////////              
4331                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4332                                                                      fladdersegment[i==0 ? 1 : 0],
4333                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4334         //////////////////////////                                              
4335         /// Placing SSD Sensor
4336         //////////////////////////              
4337                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4338                                                         fssdsensormatrix[i][j]);
4339         }
4340         ///////////////////////////////                                         
4341         /// Placing End Ladder Segment
4342         ///////////////////////////////         
4343     fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4344         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4345    }
4346 /////////////////////////////////////////////////////////////////////////////                                           
4347 /// Placing Ladder Cables
4348 /////////////////////////////////////////////////////////////////////////////           
4349   Int_t sidecablenumber[2][2];
4350   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4351   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4352   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4353   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4354   Double_t carbonfibertomoduleposition[3];
4355   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4356   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4357                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4358          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4359          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4360          -            fgkSSDSensorCenterSupportThickness[0]);
4361   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4362                                                                  +   0.5*fgkCoolingTubeSupportHeight
4363          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4364   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4365   Double_t ssdendladdercablelength[4];
4366   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4367                                                          + fgkSSDSensorLength
4368                                                          - fgkSSDModuleStiffenerPosition[1]
4369                                                          - fgkSSDStiffenerWidth 
4370                                                          - fgkSSDFlexWidth[0]
4371                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4372   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4373                                                          + fgkSSDModuleStiffenerPosition[1]
4374                                                          + fgkSSDStiffenerWidth
4375                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4376   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4377                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4378                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4379                                                          - kendladdercablecorrection;
4380   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4381                                                          + carbonfibertomoduleposition[1]
4382                                                          - fgkSSDModuleStiffenerPosition[1]
4383                                                          - fgkSSDStiffenerWidth)
4384                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4385   TList* laddercableassemblylist[4];
4386   const Int_t kendladdercablesnumber = 4;
4387   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4388         for(Int_t j=0; j<kendladdercablesnumber; j++){
4389                 laddercableassemblylist[j] = 
4390                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4391                                                                    ssdendladdercablelength[j]);
4392             fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4393                                                                         j<2?1:2,fladdercablematrix[i][j]);
4394   }
4395 }
4396 ////////////////////////////////////////////////////////////////////////////////
4397 void AliITSv11GeometrySSD::SetLayer(){
4398 ////////////////////////////////////////////////////////////////////////////////
4399   // Creating Ladder of Layer 5 and Layer 6
4400   /////////////////////////////////////////////////////////////
4401   if(!fCreateMaterials) CreateMaterials();
4402   if(!fTransformationMatrices) CreateTransformationMatrices();
4403   if(!fBasicObjects) CreateBasicObjects();
4404   SetLadder(); // Generating the ladder of Layer5 and Layer6
4405   const Int_t kssdlayladdernumber[fgklayernumber] = 
4406                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4407   /////////////////////////////////////////////////////////////
4408   // Generating mother volumes for Layer5 and Layer6
4409   /////////////////////////////////////////////////////////////
4410   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4411   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4412   Int_t *ladderindex[fgklayernumber];
4413   Int_t index[fgklayernumber] = {8,9};
4414   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4415   for(Int_t i=0; i<fgklayernumber; i++) 
4416         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4417                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4418                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4419                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4420                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4421         }
4422   /////////////////////////////////////////////////////////////
4423   // Deallocating memory
4424   /////////////////////////////////////////////////////////////
4425   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4426 }
4427 ////////////////////////////////////////////////////////////////////////////////
4428 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4429   /////////////////////////////////////////////////////////////
4430   // Insert the layer 5 in the mother volume. 
4431   /////////////////////////////////////////////////////////////
4432   if (! moth) {
4433     printf("Error::AliITSv11GeometrySSD: Can't insert layer5, mother is null!\n");
4434     return;
4435   };
4436   if(!fSSDLayer5) SetLayer();
4437   fMotherVol = moth;
4438   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4439                                                                                 + fgkLay5CenterITSPosition);
4440   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4441  }
4442 ////////////////////////////////////////////////////////////////////////////////
4443 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4444   /////////////////////////////////////////////////////////////
4445   // Insert the layer 6 in the mother volume. 
4446   /////////////////////////////////////////////////////////////
4447   if (! moth) {
4448     printf("Error::AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4449     return;
4450   };
4451   if(!fSSDLayer6) SetLayer();
4452   fMotherVol = moth;
4453   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4454                                                                                 + fgkLay6CenterITSPosition);
4455   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4456  }
4457  ////////////////////////////////////////////////////////////////////////////////
4458  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4459   /////////////////////////////////////////////////////////////
4460   // Method generating the Arc structure of Ladder Support 
4461   /////////////////////////////////////////////////////////////
4462   const Int_t kssdlayladdernumber[fgklayernumber] = 
4463                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4464   Double_t mountingsupportedge[fgklayernumber];
4465   Double_t mountingblockratio[fgklayernumber];
4466   Double_t theta[fgklayernumber];
4467   Double_t phi[fgklayernumber];
4468   Double_t psi0[fgklayernumber];
4469   Double_t deltapsi[fgklayernumber];
4470   TVector3* mountingsupportedgevector[fgklayernumber];
4471   for(Int_t i=0; i<fgklayernumber; i++){
4472         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4473     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4474                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4475                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4476                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4477                                                           / kssdlayladdernumber[i])));
4478     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4479     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4480         mountingsupportedgevector[i] = new TVector3();
4481     mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4482         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(1.
4483                                                                  -TMath::Power(mountingsupportedgevector[i]->X()
4484                                                                  /                         fgkMountingBlockSupportRadius[i],2)));
4485     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4486     deltapsi[i] = (theta[i]+phi[i])/nedges;
4487   }
4488   TVector3** vertex[fgklayernumber];
4489   TList* vertexlist[fgklayernumber];
4490   Int_t indexedge[fgklayernumber] = {0,0};
4491   for(Int_t i=0; i<fgklayernumber; i++){
4492         vertex[i] = new TVector3*[nedges+1];
4493         vertexlist[i] = new TList();
4494   } 
4495   for(Int_t i=0; i<fgklayernumber; i++){
4496         for(Int_t j=0; j<nedges+1; j++){
4497                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4498                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4499                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4500                 vertexlist[i]->Add(vertex[i][j]);
4501         }
4502         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4503   }
4504   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4505   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4506   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4507   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4508   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4509   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4510   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4511   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4512   for(Int_t i=0; i<fgklayernumber; i++){
4513     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4514     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4515     xcentervertex[i] = new Double_t[indexedge[i]+3];
4516     ycentervertex[i] = new Double_t[indexedge[i]+3];
4517         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4518         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4519         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4520         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4521         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4522                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4523                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4524                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4525                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4526                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4527                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4528                 if(j<indexedge[i]+1){
4529                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4530                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4531                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4532                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4533                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4534                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4535                 }
4536         }
4537         xsidevertex[i][1] = xsidevertex[i][0]; 
4538         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4539         xsidevertex[i][2] = xsidevertex[i][3]; 
4540         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4541         xcentervertex[i][1] = xcentervertex[i][0]; 
4542         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4543         xcentervertex[i][2] = xcentervertex[i][3]; 
4544         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4545         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4546         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4547         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4548         ycenterlowervertex[i][0] = ysidevertex[i][0];
4549         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4550         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4551   }
4552   /////////////////////////////////////////////////////////////
4553   // Building the Arc Structure of Ladder Supports 
4554   /////////////////////////////////////////////////////////////
4555   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4556   TGeoXtru* centermountingsupportshape[fgklayernumber];
4557   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4558   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4559   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4560   TGeoVolume* centermountingblocksupport[fgklayernumber];
4561   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4562   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4563   char sidemountingblockname[40];
4564   char centermountingblockname[40];
4565   char sideladdersupportpiecename[40];
4566   char centerladdersupportpiecename[40];
4567   for(Int_t i=0; i<fgklayernumber; i++){ 
4568         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4569         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4570         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4571         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4572         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4573     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4574                                                                                                 xsidevertex[i],ysidevertex[i]);
4575     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4576                                                                                                          -fgkMountingBlockSupportWidth[0]);
4577     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4578     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4579                                                                           sidemountingblocksupportshape[i],
4580                                                                                   fSSDAlCoolBlockMedium);
4581         sidemountingblocksupport[i]->SetLineColor(9);
4582         centermountingsupportshape[i] = new TGeoXtru(2);
4583     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4584                                                                                                 xcentervertex[i],ycentervertex[i]);
4585         centermountingsupportshape[i]->DefineSection(0,0.);
4586     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4587                                                                                                   -fgkMountingBlockSupportWidth[0]);
4588     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4589                                                                           centermountingsupportshape[i],
4590                                                                                   fSSDAlCoolBlockMedium);
4591         centermountingblocksupport[i]->SetLineColor(9);
4592         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4593     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4594                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4595         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4596                                                                                                          -fgkMountingBlockSupportWidth[0]);
4597     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4598     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4599                                                                           sideladdersupportpieceshape[i],
4600                                                                                   fSSDCarbonFiberMedium);
4601         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4602         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4603     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4604                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4605         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4606     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4607                                                                                                   -fgkMountingBlockSupportWidth[0]);
4608     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4609                                                                           centerladdersupportpieceshape[i],
4610                                                                                   fSSDCarbonFiberMedium);
4611         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4612   }
4613   /////////////////////////////////////////////////////////////
4614   // Building the Up Structure of Ladder Supports 
4615   /////////////////////////////////////////////////////////////
4616   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4617   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4618   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4619   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4620   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4621   //////////////////////////////////////////////////////////
4622   // Setting the volume for TGeoXtru Mounting Block Piece  
4623   //////////////////////////////////////////////////////////
4624   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4625   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4626   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4627   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4628   TGeoVolume* mountingblockpieceup[fgklayernumber];
4629   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4630   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4631   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4632   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4633   char mountingblockpiecedownname[34];
4634   char mountingblockpieceupname[34];
4635   for(Int_t i=0; i<fgklayernumber; i++){
4636     ///////////////////////////
4637     // Mounting Block Down Vertex
4638     ///////////////////////////
4639         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4640     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4641         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4642         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4643                                                                                 + fgkMountingBlockSupportDownHeight;
4644         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4645         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4646                                                                                 + fgkSSDMountingBlockHeight[1]
4647                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4648                                                                                 - fgkSSDModuleCoolingBlockToSensor
4649                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4650         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4651         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4652         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4653         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4654         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4655         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4656         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4657         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4658                                                                                 + fgkSSDMountingBlockHeight[2]
4659                                                                                 - fgkSSDMountingBlockHeight[0];
4660         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4661         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4662         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4663         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4664         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4665                                                                                                          mountingblockpiecedownyvertex[i]);
4666         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4667         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4668         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4669                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4670         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4671     ///////////////////////////
4672     // Mounting Block Up Vertex
4673     ///////////////////////////
4674         mountingblockpieceupshape[i] = new TGeoXtru(2);
4675         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4676         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4677         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4678                                                                                 + fgkMountingBlockSupportUpHeight[i];
4679         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4680         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4681                                                                                 + fgkSSDMountingBlockHeight[1]
4682                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4683                                                                                 - fgkSSDModuleCoolingBlockToSensor
4684                                                                                 - 2.*fgkSSDModuleVerticalDisalignment;
4685         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4686         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4687         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4688         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4689         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4690         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4691         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4692         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4693                                                                                 + fgkSSDMountingBlockHeight[2]
4694                                                                                 - fgkSSDMountingBlockHeight[0];
4695         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4696         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4697         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4698         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4699         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4700                                                                                                          mountingblockpieceupyvertex[i]);
4701         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4702         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4703         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4704                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4705         mountingblockpieceup[i]->SetLineColor(fColorG10);
4706  }
4707   ///////////////////////////////////////////////////////////////////
4708   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4709   ///////////////////////////////////////////////////////////////////
4710   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4711   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4712   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4713   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4714   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4715   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4716   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4717   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4718   char mountingblocksupportrapezoidowname[40];
4719   char mountingblocksupportrapezoidupname[40];
4720   Double_t scalefactor = 3./4.;
4721   for(Int_t i=0; i<fgklayernumber; i++){
4722   ////////////////////////////////////////////
4723   // Mounting Block Support Down Trapezoid Vertex 
4724   ////////////////////////////////////////////
4725         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4726         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4727                                                                                                  - mountingsupportedge[i];
4728         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4729         mountingblocksupportrapezoidownxvertex[i][1] = 
4730                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4731         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4732                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4733                                                                                              - mountingblockpiecedownyvertex[i][0]);
4734         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4735         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4736         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4737         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4738         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4739         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4740         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4741                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4742         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4743                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4744         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4745         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4746         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4747                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4748         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4749   ////////////////////////////////////////////
4750   // Mounting Block Support Up Trapezoid Vertex 
4751   ////////////////////////////////////////////
4752         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4753         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4754                                                                                                  - mountingsupportedge[i];
4755         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4756         mountingblocksupportrapezoidupxvertex[i][1] = 
4757                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4758         mountingblocksupportrapezoidupyvertex[i][1] = 
4759                                                                                                mountingblockpieceupyvertex[i][0]
4760                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4761                                                                                              - mountingblockpieceupyvertex[i][0]);
4762         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4763         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4764         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4765         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4766         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4767         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4768         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4769                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4770         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4771                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4772         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4773         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4774         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4775                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4776         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4777   }
4778   ///////////////////////////////////////////////////////////////////
4779   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4780   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4781   Double_t boxoriginup[fgklayernumber][2][3];
4782   Double_t boxorigindown[fgklayernumber][2][3];
4783   char mountingblocksupportboxdownname[34];
4784   char mountingblocksupportboxupname[34];
4785   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4786   mountingblocksupportrot->SetAngles(90.,180.,-90);
4787   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4788   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4789   TGeoHMatrix* laddersupportmatrix[2];
4790   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4791   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4792   /////////////////////////////////////////////////////////////
4793   // Creating Mother Volume for Containment
4794   /////////////////////////////////////////////////////////////
4795   Double_t *xmothervertex[fgklayernumber];
4796   Double_t *ymothervertex[fgklayernumber];
4797   for(Int_t i=0; i<fgklayernumber; i++){
4798         xmothervertex[i] = new Double_t[8];
4799         ymothervertex[i] = new Double_t[8];
4800   }  
4801   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4802   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4803   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4804   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4805   char upmotheladdersupportname[30];
4806   char downmotheladdersupportname[30];
4807   for(Int_t i=0; i<fgklayernumber; i++){
4808         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4809                                                     -  mountingsupportedge[i];
4810         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4811         xmothervertex[i][1] = xmothervertex[i][0];
4812         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4813                                                         + fgkMountingBlockSupportWidth[0];
4814         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4815         ymothervertex[i][2] = ymothervertex[i][1];
4816         xmothervertex[i][3] = xmothervertex[i][2];
4817         ymothervertex[i][3] = -ymothervertex[i][0];
4818         xmothervertex[i][4] = -xmothervertex[i][0];
4819         ymothervertex[i][4] = ymothervertex[i][3];
4820         xmothervertex[i][5] = xmothervertex[i][4];
4821         ymothervertex[i][5] = -ymothervertex[i][1];
4822         xmothervertex[i][6] = -xmothervertex[i][2];
4823         ymothervertex[i][6] = ymothervertex[i][5];
4824         xmothervertex[i][7] = xmothervertex[i][6];
4825         ymothervertex[i][7] = ymothervertex[i][0];
4826         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4827         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4828     downmotherladdersupportshape[i] = new TGeoXtru(2);
4829         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4830         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4831     downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4832                                                                    +                       fgkMountingBlockSupportDownHeight
4833                                                                    +                       fgkSSDMountingBlockHeight[1]
4834                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4835                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4836                                                                    -                       2.*fgkSSDModuleVerticalDisalignment);
4837     downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4838                                                                           downmotherladdersupportshape[i],fSSDAir);
4839     upmotherladdersupportshape[i] = new TGeoXtru(2);
4840         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4841         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4842     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4843                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4844                                                                    +                       fgkSSDMountingBlockHeight[1]
4845                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4846                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4847                                                                    -               2.*fgkSSDModuleVerticalDisalignment);
4848     upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4849                                                                                           upmotherladdersupportshape[i],fSSDAir);
4850   }
4851   for(Int_t i=0; i<fgklayernumber; i++){
4852         /////////////////////////
4853         // Setting the box origin
4854         /////////////////////////
4855         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4856         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4857                                                    +  0.5*fgkMountingBlockSupportDownHeight;
4858         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4859                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4860   
4861         boxorigindown[i][1][0] = 0.0;
4862         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4863         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4864                                                    -      fgkMountingBlockSupportWidth[0]);
4865                                                    
4866         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4867         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4868                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4869         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4870                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4871   
4872         boxoriginup[i][1][0] = 0.0;
4873         boxoriginup[i][1][1] = fgkMountingBlockSupportRadius[i]
4874                                                  + 0.5*fgkMountingBlockSupportUpHeight[i];
4875         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4876                                                  - fgkMountingBlockSupportWidth[0]);
4877   
4878         /////////////////////////
4879     // Setting the boxes    
4880         /////////////////////////
4881         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4882                                                                                  +  fgkSSDMountingBlockLength[0]),
4883                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4884                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4885                                                                                         boxorigindown[i][0]);
4886     mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4887                                                                                         0.5*fgkMountingBlockSupportDownHeight,
4888                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4889                                                                                  -  fgkMountingBlockSupportWidth[0]),
4890                                                                                         boxorigindown[i][1]);
4891                                                                                         
4892         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4893                                                                                  +  fgkSSDMountingBlockLength[0]),
4894                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4895                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4896                                                                                         boxoriginup[i][0]);
4897                                                                                         
4898         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4899                                                                                         0.5*fgkMountingBlockSupportUpHeight[i],
4900                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4901                                                                      -  fgkMountingBlockSupportWidth[0]),
4902                                                                                         boxoriginup[i][1]);
4903         ///////////////////////////////////////
4904     // Adding the Volumes to Mother Volume    
4905         ///////////////////////////////////////
4906         for(Int_t j=0; j<2; j++){
4907                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4908                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4909                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4910                                                                                   mountingblocksupportboxdownshape[i][j],
4911                                                                                   fSSDCarbonFiberMedium);
4912                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4913                                                                                   mountingblocksupportboxupshape[i][j],
4914                                                                                   fSSDCarbonFiberMedium);
4915                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4916                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4917                 for(Int_t k=0; k<2; k++){
4918                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4919                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4920                 }
4921         }
4922         for(Int_t k=0; k<2; k++){
4923                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4924                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4925                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4926                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4927             downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4928                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4929                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4930                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4931                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4932                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4933                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4934                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4935         }
4936   }
4937   TList* laddersupportlist = new TList();
4938   laddersupportlist->Add(downmotherladdersupport[0]); 
4939   laddersupportlist->Add(upmotherladdersupport[0]); 
4940   laddersupportlist->Add(downmotherladdersupport[1]); 
4941   laddersupportlist->Add(upmotherladdersupport[1]); 
4942   /////////////////////////////////////////////////////////////
4943   // Deallocating memory
4944   /////////////////////////////////////////////////////////////
4945   for(Int_t i=0; i<fgklayernumber; i++){
4946         for(Int_t j=0; j<nedges+1; j++)
4947                 delete vertex[i][j];
4948         delete mountingsupportedgevector[i];
4949         delete [] vertex[i];
4950         delete vertexlist[i];
4951         delete [] xsidevertex[i];
4952         delete [] ysidevertex[i];
4953         delete [] xcentervertex[i];
4954         delete [] ycentervertex[i];
4955         delete [] xsidelowervertex[i];
4956         delete [] ysidelowervertex[i];
4957         delete [] xcenterlowervertex[i];
4958         delete [] ycenterlowervertex[i];
4959   }
4960   delete xsidevertex;
4961   delete ysidevertex;
4962   delete xcentervertex;
4963   delete ycentervertex;
4964   delete xsidelowervertex;
4965   delete ysidelowervertex;
4966   delete xcenterlowervertex;
4967   delete ycenterlowervertex;
4968   delete globalrefladdersupportrot;
4969   delete mountingblocksupportrot;
4970   /////////////////////
4971   return laddersupportlist;     
4972 }
4973  ////////////////////////////////////////////////////////////////////////////////
4974 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4975 //////////////////////////////////////////
4976 // Method Generating Ladder Support Ring
4977 //////////////////////////////////////////
4978   if(!fCreateMaterials) CreateMaterials();
4979   if(!fTransformationMatrices) CreateTransformationMatrices();
4980   if(!fBasicObjects) CreateBasicObjects();
4981   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4982   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4983     const Int_t kssdlayladdernumber[fgklayernumber] = 
4984                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4985   Double_t mountingsupportedge[fgklayernumber];
4986   Double_t mountingblockratio[fgklayernumber];
4987   Double_t theta[fgklayernumber];
4988   Double_t phi[fgklayernumber];
4989   for(Int_t i=0; i<fgklayernumber; i++){
4990         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4991     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4992                                                           *(TMath::Sqrt(4.0-TMath::Power(mountingblockratio[i],2))
4993                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4994                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4995                                                           / kssdlayladdernumber[i])));
4996     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4997                          / fgkMountingBlockSupportRadius[i]);
4998     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4999   }
5000   TGeoRotation* globalrot = new TGeoRotation();
5001   globalrot->SetAngles(0.,-90.,0.); 
5002   TGeoRotation** laddersupportrot[fgklayernumber];
5003   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5004   for(Int_t i=0; i<fgklayernumber; i++){                
5005         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5006         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5007         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5008                 laddersupportrot[i][j] = new TGeoRotation();
5009                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5010                 switch(i){
5011                         case 0: //Ladder of Layer5  
5012                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5013                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5014                                                                             laddersupportmatrix[i][j]); 
5015                         break;
5016                         case 1: //Ladder of Layer6 
5017                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5018                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5019                                                                               laddersupportmatrix[i][j]); 
5020                         break;
5021                 }
5022     }
5023   }
5024   /////////////////////////////////////////////////////////////
5025   // Creating Lower Ladder Support 
5026   /////////////////////////////////////////////////////////////
5027   TVector3** ringsupportvertex[fgklayernumber];         
5028   Double_t angle = 360./nedges;
5029   for(Int_t i=0; i<fgklayernumber; i++){
5030     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5031         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5032                                                         *                          TMath::Cos(theta[i]));
5033         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5034                                                         -                          mountingsupportedge[i],
5035                                                                                    ringsupportvertex[i][0]->Y());
5036         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5037                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5038     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5039         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5040            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5041            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5042            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5043            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5044         }
5045         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5046     for(Int_t j=0; j<nedges+1; j++){
5047                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5048                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5049                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5050         }
5051   }
5052   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5053   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5054   for(Int_t i=0; i<fgklayernumber; i++){
5055         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5056         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5057         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5058                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5059                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5060         }
5061   }
5062 ////////////////////////////////////////////////////////////////////////////////
5063 // Start Corrections 13/06/08
5064 ////////////////////////////////////////////////////////////////////////////////
5065   char lowerladderpconsupportname[30];
5066   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5067   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5068   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5069   Double_t lowerladderpconradiusmax[fgklayernumber];
5070   Double_t lowerladderpconradiusmin[fgklayernumber];
5071   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5072   lowerladdersupportrot->SetAngles(90.,180.,-90);
5073   for(Int_t i=0; i<fgklayernumber; i++){
5074         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5075                                                                 *                          TMath::Cos(theta[i]);
5076     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5077   } 
5078   for(Int_t i=0; i<fgklayernumber; i++){
5079 ///////////////////////////  Modified Version ?///////////////////
5080     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5081         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5082                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5083                                                          lowerladderpconradiusmax[i]);
5084         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5085         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5086     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5087         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5088         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5089  }
5090 ////////////////////////////////////////////////////////////////////////////////
5091 // End Corrections 13/06/08
5092 ////////////////////////////////////////////////////////////////////////////////
5093   /*char lowerladdersupportname[30];
5094   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5095   TGeoVolume* lowerladdersupport[fgklayernumber];
5096   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5097   lowerladdersupportrot->SetAngles(90.,180.,-90);
5098   for(Int_t i=0; i<fgklayernumber; i++){
5099         lowerladdersupportshape[i] = new TGeoXtru(2);
5100         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5101                                                                                           xmothervertex[i],ymothervertex[i]);
5102         lowerladdersupportshape[i]->DefineSection(0,0.);
5103     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5104         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5105     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5106                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5107         lowerladdersupport[i]->SetLineColor(fColorAl);
5108         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5109         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5110   }*/
5111   /////////////////////////////////////////////////////////////
5112   // Deallocating memory
5113   /////////////////////////////////////////////////////////////
5114   for(Int_t i=0; i<fgklayernumber; i++){
5115         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5116                 delete ringsupportvertex[i][j];
5117         delete [] ringsupportvertex[i];
5118   }
5119   for(Int_t i=0; i<fgklayernumber; i++){
5120         delete [] xmothervertex[i];
5121         delete [] ymothervertex[i];
5122   }
5123   delete xmothervertex;
5124   delete ymothervertex; 
5125   delete globalrot;
5126   for(Int_t i=0; i<fgklayernumber; i++){
5127         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5128                 delete laddersupportrot[i][j];
5129         delete [] laddersupportrot[i];
5130   }
5131  }  
5132  ////////////////////////////////////////////////////////////////////////////////
5133  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5134   /////////////////////////////////////////////////////////////
5135   // Method generating Endcap CoverPlate
5136   /////////////////////////////////////////////////////////////
5137   // Holes Definition 
5138   ///////////////////
5139   Int_t nendcapcoverplateholedges = 30;
5140   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5141   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5142                                                           0.5*fgkEndCapCoverPlateThickness};
5143   TGeoXtru* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5144                                                                                                               nendcapcoverplateholedges,holesection);
5145   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5146                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5147   endcapcoverplatesmallhole->SetLineColor(6);
5148   TGeoXtru* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5149                                                                                                               nendcapcoverplateholedges,holesection);
5150   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5151                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5152   endcapcoverplatebighole->SetLineColor(6);
5153   //////////////////////////
5154   // Screw Piece Definition 
5155   //////////////////////////
5156   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5157   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5158                                                                                                       CosD(0.5*smallscrewangle),
5159                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5160   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5161                                                                                                 endcapsmallscrewpieceshape,
5162                                                                                                 fSSDCoolingTubePhynox);
5163   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5164   ///////////////////
5165   // Box Definition 
5166   ///////////////////
5167   TGeoBBox* endcapcoverplateboxshape[4];
5168   TGeoVolume* endcapcoverplatebox[4];
5169   Double_t boxorigin[5][3];
5170   boxorigin[0][0] = 0.;
5171   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5172   boxorigin[0][2] = 0.;
5173
5174   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5175   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5176   boxorigin[1][2] = 0.;
5177
5178   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5179                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5180   boxorigin[2][1] = boxorigin[1][1];
5181   boxorigin[2][2] = 0.;
5182
5183   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5184                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5185   boxorigin[3][1] = boxorigin[1][1];
5186   boxorigin[3][2] = 0.;
5187
5188   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5189                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5190                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5191                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5192
5193   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5194                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5195                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5196                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5197                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5198
5199   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5200                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5201                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5202                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5203                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5204
5205   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5206                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5207                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5208                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5209                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5210   
5211   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5212                                                                            fSSDAlCoolBlockMedium);
5213   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5214                                                                            fSSDAlCoolBlockMedium);
5215   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5216                                                                            fSSDAlCoolBlockMedium);
5217   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5218                                                                            fSSDAlCoolBlockMedium);
5219   endcapcoverplatebox[0]->SetLineColor(6);
5220   endcapcoverplatebox[1]->SetLineColor(6);
5221   endcapcoverplatebox[2]->SetLineColor(6);
5222   endcapcoverplatebox[3]->SetLineColor(6);
5223   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5224   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5225                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5226                                                                                         0.5*fgkEndCapCoverPlateThickness,
5227                                                                                         endcapfillingboxorigin);
5228   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5229                                                                            fSSDAlCoolBlockMedium);
5230   endcapfillingbox->SetLineColor(6);
5231   ////////////////////////////
5232   // Contour Xtru Definition 
5233   ////////////////////////////
5234   const Int_t kcontourvertexnumber = 10;
5235   Double_t xcontourvertex[kcontourvertexnumber];
5236   Double_t ycontourvertex[kcontourvertexnumber];
5237   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5238   xcontourvertex[1] = xcontourvertex[0];
5239   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5240   xcontourvertex[3] = xcontourvertex[2];
5241   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5242   xcontourvertex[5] = xcontourvertex[4];
5243   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5244   xcontourvertex[7] = xcontourvertex[6];
5245   xcontourvertex[8] = xcontourvertex[4];
5246   xcontourvertex[9] = xcontourvertex[8];
5247   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5248                                         - (kendcapcoverplatesmallholenumber[1]-1)
5249                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5250   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5251                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5252   ycontourvertex[2] = ycontourvertex[1];
5253   ycontourvertex[3] = ycontourvertex[0];
5254   ycontourvertex[4] = ycontourvertex[3];
5255   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5256   ycontourvertex[6] = ycontourvertex[5];
5257   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5258                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5259                                         + fgkEndCapCoverPlateSmallHoleRadius;
5260   ycontourvertex[8] = ycontourvertex[7];
5261   ycontourvertex[9] = ycontourvertex[0];
5262   TGeoXtru* contourshape = new TGeoXtru(2);
5263   contourshape->DefinePolygon(kcontourvertexnumber,xcontourvertex,ycontourvertex);  
5264   contourshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5265   contourshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5266   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5267                                                                            fSSDAlCoolBlockMedium);
5268   contour->SetLineColor(6);
5269   /////////////////////////////
5270   // Hole Contour Xtru Definition 
5271   ////////////////////////////
5272   const Int_t kholecontourvertexnumber = 10;
5273   Double_t xholecontourvertex[2][kcontourvertexnumber];
5274   Double_t yholecontourvertex[2][kcontourvertexnumber];
5275   xholecontourvertex[0][0] = xcontourvertex[0];
5276   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5277   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5278   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5279   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5280                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5281                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5282   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5283   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5284                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5285   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5286   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5287   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5288   
5289   yholecontourvertex[0][0] = ycontourvertex[1];
5290   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5291   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5292   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5293   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5294   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5295                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5296   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5297   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5298   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5299   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5300
5301   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5302   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5303   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5304   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5305   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5306                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5307                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5308   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5309   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5310                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5311   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5312   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5313   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5314   
5315   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5316                                                    - fgkEndCapCoverPlateWidth[0]);
5317   yholecontourvertex[1][1] = ycontourvertex[0];
5318   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5319   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5320   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5321   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5322                                                    - fgkEndCapCoverPlateWidth[0]
5323                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5324   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5325   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5326   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5327   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5328
5329   TGeoXtru* holecontourshape[2];
5330   holecontourshape[0] = new TGeoXtru(2);
5331   holecontourshape[0]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[0],
5332                                                                   yholecontourvertex[0]);  
5333   holecontourshape[0]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5334   holecontourshape[0]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5335
5336   holecontourshape[1] = new TGeoXtru(2);
5337   holecontourshape[1]->DefinePolygon(kholecontourvertexnumber,xholecontourvertex[1],
5338                                                                   yholecontourvertex[1]);  
5339   holecontourshape[1]->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5340   holecontourshape[1]->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5341
5342   TGeoVolume* holecontour[2];
5343   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",holecontourshape[0],
5344                                                                   fSSDAlCoolBlockMedium);
5345   holecontour[0]->SetLineColor(6);
5346   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",holecontourshape[1],
5347                                                                   fSSDAlCoolBlockMedium);
5348   holecontour[1]->SetLineColor(6);
5349   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5350                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5351   TGeoTranslation*  bigholetrans[3];
5352   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5353                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5354   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5355                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5356                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5357   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5358                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5359   /////////////////////////////////
5360   // Mother Volume Xtru Definition 
5361   /////////////////////////////////
5362   const Int_t kmothervertexnumber = 12;
5363   Double_t xmothervertex[kmothervertexnumber];  
5364   Double_t ymothervertex[kmothervertexnumber];  
5365   xmothervertex[0]  = xcontourvertex[0];
5366   xmothervertex[1]  = xmothervertex[0];
5367   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5368   xmothervertex[3]  = xmothervertex[2];
5369   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5370   xmothervertex[5]  = xmothervertex[4];
5371   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5372   xmothervertex[7]  = xmothervertex[6];
5373   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5374                                         + fgkEndCapCoverPlateLength[2]; 
5375   xmothervertex[9]  = xmothervertex[8];
5376   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5377   xmothervertex[11] = xmothervertex[10];
5378   
5379   ymothervertex[0]  = ycontourvertex[0];
5380   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5381   ymothervertex[2]  = ymothervertex[1];
5382   ymothervertex[3]  = ycontourvertex[1];
5383   ymothervertex[4]  = ymothervertex[3];
5384   ymothervertex[5]  = ymothervertex[1];
5385   ymothervertex[6]  = ymothervertex[5];
5386   ymothervertex[7]  = ymothervertex[0];
5387   ymothervertex[8]  = ymothervertex[7];
5388   ymothervertex[9]  = ymothervertex[8]
5389                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5390   ymothervertex[10] = ymothervertex[9];
5391   ymothervertex[11] = ymothervertex[8];
5392   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5393   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5394   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5395   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5396   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5397   ////////////////////////////////////////
5398   // Adding Nodes
5399   ////////////////////////////////////////
5400 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5401   TGeoTranslation*** endcapcoverplatesmallholetrans;
5402   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5403   Double_t transx[4] = {0,
5404                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5405                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5406                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5407                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5408                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5409   Int_t index = 0;
5410   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5411         endcapcoverplatesmallholetrans[i] = 
5412                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5413     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5414                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5415             endcapcoverplatesmallholetrans[i][j] = 
5416                 new TGeoTranslation(transx[i],
5417                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5418             if(index!=10){ 
5419                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5420                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5421                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5422                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5423                 }
5424                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5425                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5426                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5427     }
5428   }
5429   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5430   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5431   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5432   mothercoverplate->AddNode(endcapfillingbox,1);
5433   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5434   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5435   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5436   mothercoverplate->AddNode(holecontour[0],1);
5437   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5438   mothercoverplate->AddNode(holecontour[1],1);  
5439   mothercoverplate->AddNode(contour,1);
5440   /////////////////////////////////
5441   return mothercoverplate;      
5442  }
5443  ////////////////////////////////////////////////////////////////////////////////
5444  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5445   /////////////////////////////////////////////////////////////
5446   // Getting EndCap Cooling Tube 
5447   /////////////////////////////////////////////////////////////
5448   TGeoTorus* endcapcoolingtubetorushape[5];
5449   TGeoVolume* endcapcoolingtubetorus[5];
5450   TGeoTube* endcapcoolingtubeshape[4];
5451   TGeoVolume* endcapcoolingtube[4];
5452   char endcapcoolingtubetorusname[30];
5453   char endcapcoolingtubename[30];
5454   TGeoTorus* endcapcoolingwatertubetorushape[5];
5455   TGeoVolume* endcapcoolingwatertubetorus[5];
5456   TGeoTube* endcapcoolingwatertubeshape[4];
5457   TGeoVolume* endcapcoolingwatertube[4];
5458   char endcapcoolingwatertubetorusname[30];
5459   char endcapcoolingwatertubename[30];
5460   for(Int_t i=0; i<5; i++){
5461         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5462         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5463         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5464         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5465         if(i==3){
5466                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5467                                                                                 fgkEndCapCoolingTubeRadiusMin,
5468                                                                                 fgkEndCapCoolingTubeRadiusMax,
5469                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5470                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5471                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5472                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5473     }
5474         else{
5475                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5476                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5477                                                                            fgkEndCapCoolingTubeRadiusMin,
5478                                                                            fgkEndCapCoolingTubeRadiusMax,
5479                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5480                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5481                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5482                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5483                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5484         }
5485         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5486                                                                                            endcapcoolingtubetorushape[i],
5487                                                                                            fSSDCoolingTubePhynox);
5488         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5489                                                                                                         endcapcoolingwatertubetorushape[i],
5490                                                                                                         fSSDCoolingTubeWater);
5491     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5492     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5493     if(i<4){
5494                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5495                                                                   fgkEndCapCoolingTubeRadiusMax,
5496                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5497                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5498                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5499         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5500                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5501         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5502                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5503                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5504                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5505         }
5506   }
5507   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5508   /////////////////////////////////////////
5509   // Transformation for Volume Positioning 
5510   /////////////////////////////////////////
5511   TGeoCombiTrans* coolingtubecombitrans[6];
5512   TGeoRotation* coolingtuberot[8];
5513   TGeoTranslation* coolingtubetrans[6];
5514   TGeoHMatrix* coolingtubematrix[4];
5515   TGeoCombiTrans* torustubecombitrans[4];
5516   TGeoRotation* torustuberot[7];
5517   TGeoTranslation* torustubetrans[4];
5518   TGeoHMatrix* torustubematrix[5];
5519   TGeoCombiTrans* coolingwatertubecombitrans[6];
5520   TGeoRotation* coolingwatertuberot[8];
5521   TGeoTranslation* coolingwatertubetrans[6];
5522   TGeoHMatrix* coolingwatertubematrix[4];
5523   TGeoCombiTrans* toruswatertubecombitrans[4];
5524   TGeoRotation* toruswatertuberot[7];
5525   TGeoTranslation* toruswatertubetrans[4];
5526   TGeoHMatrix* toruswatertubematrix[5];
5527   for(Int_t i=0; i<8; i++){
5528     if(i<6){
5529          coolingtubetrans[i] = new TGeoTranslation();
5530          coolingwatertubetrans[i] = new TGeoTranslation();
5531     }
5532     if(i<8){
5533          coolingtuberot[i] = new TGeoRotation();
5534          coolingwatertuberot[i] = new TGeoRotation();
5535     }
5536     if(i<4){
5537          torustubetrans[i] = new TGeoTranslation();
5538          toruswatertubetrans[i] = new TGeoTranslation();
5539     }
5540     if(i<7){
5541          torustuberot[i] = new TGeoRotation();
5542          toruswatertuberot[i] = new TGeoRotation();
5543         }
5544   }
5545   /////////////////////////////////////////
5546   // Transformation for Inox Volume Positioning 
5547   /////////////////////////////////////////
5548   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5549                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5550   coolingtuberot[0]->SetAngles(0.,90.,0.);
5551   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5552                                                                                                 *coolingtuberot[0]);
5553                                                                                                 
5554   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5555   coolingtuberot[1]->SetAngles(0.,90.,0.);
5556   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5557                                                                                                 *coolingtuberot[1]);
5558
5559   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5560                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5561                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5562                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5563                                                                           0.);
5564   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5565   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5566                                                                                                 *coolingtuberot[2]);
5567
5568   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5569                                            *                             (*coolingtubecombitrans[1]));
5570
5571   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5572                                                                          endcapcoolingtubeshape[1]->GetDz());
5573   torustuberot[0]->SetAngles(0.,90.,0.); 
5574   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5575
5576   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5577
5578   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5579                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5580   coolingtuberot[3]->SetAngles(0.,90.,0.);
5581   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5582                                                                                                 *coolingtuberot[3]);
5583   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5584   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5585   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5586   
5587   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5588                                                                         endcapcoolingtubeshape[2]->GetDz());
5589   torustuberot[1]->SetAngles(0.,90.,0.); 
5590   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5591   torustuberot[2]->SetAngles(180.,0.,0.); 
5592   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5593   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5594
5595   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5596                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5597   torustuberot[3]->SetAngles(0.,90.,0.); 
5598   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5599   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5600   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5601   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5602
5603   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5604                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5605   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5606   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5607                                                                                                 *coolingtuberot[5]);
5608   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5609   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5610   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5611   
5612   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5613                                                                         endcapcoolingtubeshape[0]->GetDz());
5614   torustuberot[5]->SetAngles(0.,90.,0.); 
5615   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5616   torustuberot[6]->SetAngles(-90.,0.,0.); 
5617   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5618   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5619   
5620   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5621                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5622   coolingtuberot[6]->SetAngles(0.,90.,0.);
5623   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5624                                                                                                 *coolingtuberot[6]);
5625   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5626   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5627   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5628     /////////////////////////////////////////
5629   // Transformation for Water Volume Positioning 
5630   /////////////////////////////////////////
5631   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5632                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5633   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5634   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5635                                                                                                      *coolingwatertuberot[0]);
5636
5637   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5638   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5639   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5640                                                                                                      *coolingwatertuberot[1]);
5641
5642   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5643                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5644                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5645                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5646                                                                               0.);
5647   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5648   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5649                                                                                                     *coolingwatertuberot[2]);
5650
5651   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5652                                            *                                 (*coolingwatertubecombitrans[1]));
5653                                            
5654   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5655                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5656   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5657   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5658                                                                                                    *toruswatertuberot[0]);
5659
5660   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5661                                                   *                                     (*toruswatertubecombitrans[0]));
5662
5663   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5664                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5665   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5666   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5667                                                                                                      *coolingwatertuberot[3]);
5668   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5669   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5670                                                         *                                 (*coolingwatertubecombitrans[3]));
5671   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5672
5673   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5674                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5675   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5676   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5677                                                                                                    *toruswatertuberot[1]);
5678   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5679   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5680                                                   *                 (*toruswatertubecombitrans[1]));
5681   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5682   
5683   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5684                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5685   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5686   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5687                                                                                                    *toruswatertuberot[3]);
5688   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5689   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5690                                                   *                                     (*toruswatertubecombitrans[2]));
5691   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5692
5693   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5694                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5695   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5696   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5697                                                                                                      *coolingwatertuberot[5]);
5698   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5699   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5700                                                         *                                 (*coolingwatertubecombitrans[4]));
5701   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5702   
5703   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5704                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5705   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5706   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5707                                                                                                    *toruswatertuberot[5]);
5708   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5709   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5710                                                   *                 (*toruswatertubecombitrans[3]));
5711   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5712   
5713   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5714                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5715   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5716   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5717                                                                                                      *coolingwatertuberot[6]);
5718   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5719   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5720                                                         *                                 (*coolingwatertubecombitrans[5]));
5721   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5722   /////////////////////////////////////////
5723   // Positioning Volumes
5724   /////////////////////////////////////////
5725   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5726   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5727   
5728   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5729   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5730
5731   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5732   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5733  
5734   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5735   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5736
5737   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5738   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5739
5740   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5741   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5742
5743   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5744   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5745
5746   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5747   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5748   
5749   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5750   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5751  
5752   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5753   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5754   /////////////////////////////////////////////////////////////
5755   // Deallocating memory
5756   /////////////////////////////////////////////////////////////
5757   for(Int_t i=0; i<8; i++){
5758     if(i<6){
5759          delete coolingtubetrans[i];
5760          delete coolingwatertubetrans[i];
5761          if(i!=0){
5762           delete coolingtubecombitrans[i];
5763           delete coolingwatertubecombitrans[i];
5764          }
5765         }
5766     if(i<8){
5767           delete coolingtuberot[i];
5768           delete coolingwatertuberot[i];
5769     }
5770     if(i<4){
5771                 delete torustubetrans[i];
5772                 delete toruswatertubetrans[i];
5773                 delete torustubecombitrans[i];
5774                 delete toruswatertubecombitrans[i];
5775         } 
5776     if(i<7){
5777          delete torustuberot[i];
5778          delete toruswatertuberot[i];
5779         }
5780   }
5781   /////////////////////////////////////////////////////////////
5782   return endcapcoolingtubemother;
5783  }
5784  ////////////////////////////////////////////////////////////////////////////////
5785  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5786   /////////////////////////////////////////////////////////////
5787   // Getting EndCap Cover Side 
5788   /////////////////////////////////////////////////////////////
5789   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5790   const Int_t kvertexnumber = 15; 
5791   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5792   xvertex[0]  = 0.0;
5793   xvertex[1]  = xvertex[0];
5794   xvertex[2]  = fgkEndCapSideCoverLength[0];
5795   xvertex[3]  = fgkEndCapSideCoverLength[1];
5796   xvertex[4]  = xvertex[3];
5797   xvertex[5]  = fgkEndCapSideCoverLength[2];
5798   xvertex[6]  = xvertex[5];
5799   xvertex[7]  = xvertex[2];
5800   xvertex[8]  = xvertex[7];
5801   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5802   xvertex[10] = xvertex[9];
5803   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5804                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5805                           * fgkEndCapSideCoverLength[4];
5806   xvertex[12] = xvertex[11];
5807   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5808                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5809                           * fgkEndCapSideCoverLength[4];
5810   xvertex[14] = xvertex[13];
5811   yvertex[0]  = 0.0;
5812   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5813   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5814   yvertex[3]  = yvertex[2];
5815   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5816   yvertex[5]  = yvertex[4];
5817   yvertex[6]  = yvertex[0];
5818   yvertex[7]  = yvertex[6];
5819   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5820   yvertex[9]  = yvertex[8];
5821   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5822   yvertex[11] = yvertex[10];
5823   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5824   yvertex[13] = yvertex[12];
5825   yvertex[14] = yvertex[6];
5826   TGeoXtru* endcapsidecovershape = new TGeoXtru(2);
5827   endcapsidecovershape->DefinePolygon(kvertexnumber,xvertex,yvertex); 
5828   endcapsidecovershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5829   endcapsidecovershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5830   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5831                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5832   endcapsidecover->SetLineColor(fColorPhynox);
5833   ////////////////////////////////////////////
5834   // Defininition of Mother Volume
5835   ////////////////////////////////////////////
5836   const Int_t kmothervertexnumber = 7;
5837   Double_t xmothervertex[kmothervertexnumber]; 
5838   Double_t ymothervertex[kmothervertexnumber]; 
5839   for(Int_t i=0; i<kmothervertexnumber; i++){
5840         xmothervertex[i] = xvertex[i];
5841         ymothervertex[i] = yvertex[i];
5842   }
5843   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5844   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5845   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5846   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5847   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5848                                                                 endcapsidecovermothershape,fSSDAir);
5849   ////////////////////////////////////////////
5850   endcapsidecovermother->AddNode(endcapsidecover,1);
5851   TGeoBBox* endcapsidecoverboxshape[4];
5852   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5853                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5854                                                                0.5*fgkEndCapSideCoverLength[4],
5855                                                                    0.5*fgkEndCapSideCoverThickness); 
5856   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5857                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5858                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5859                                                          -     fgkEndCapSideCoverLength[4]),
5860                                                                    0.5*fgkEndCapSideCoverThickness); 
5861   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5862                                                                0.5*fgkEndCapSideCoverLength[4],
5863                                                                    0.5*fgkEndCapSideCoverThickness); 
5864   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5865                                                                0.5*fgkEndCapSideCoverWidth[5],
5866                                                                    0.5*fgkEndCapSideCoverThickness); 
5867   TGeoVolume* endcapsidecoverbox[4];
5868   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5869   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5870   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5871   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5872   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5873 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5874   TGeoTranslation** endcapsidecoverboxtrans;
5875   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5876   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5877                                                          +                                         fgkEndCapSideCoverLength[0],
5878                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5879                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5880   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5881                                                          +                     xvertex[11],
5882                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5883                                                          +                     yvertex[12],0.);
5884   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5885                                                          +                     xvertex[11],
5886                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5887                                                          +                     yvertex[12]
5888                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5889                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5890   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5891   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5892   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5893   for(Int_t i=0; i<2; i++)
5894         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5895                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5896                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5897                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5898                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5899                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5900                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5901                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5902         }
5903   for(Int_t i=0; i<2; i++)
5904         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5905                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5906                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5907                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5908                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5909                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5910                                                         +fgkEndCapSideCoverLength[4]),0.0);
5911                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5912                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5913                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5914                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5915         }
5916         return endcapsidecovermother;
5917  } 
5918  ////////////////////////////////////////////////////////////////////////////////
5919  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5920  ////////////////////////////////////////////////////////////////////////////////
5921  // Method returning Interface Card A, Interface Card B, Supply Card 
5922  ////////////////////////////////////////////////////////////////////////////////
5923  /////////////////////
5924  // Supply Card
5925  /////////////////////
5926  // Electronic Board Back Al Plane
5927  const Int_t kelectboardbackvertexnumber = 8;
5928  Double_t xelectboardback[kelectboardbackvertexnumber];
5929  Double_t yelectboardback[kelectboardbackvertexnumber];
5930  xelectboardback[0] = 0.0;
5931  xelectboardback[1] = xelectboardback[0];
5932  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5933  xelectboardback[3] = xelectboardback[2];
5934  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5935  xelectboardback[5] = xelectboardback[4];
5936  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5937  xelectboardback[7] = xelectboardback[6];
5938  
5939  yelectboardback[0] = 0.0;
5940  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5941  yelectboardback[2] = yelectboardback[1];
5942  yelectboardback[3] = yelectboardback[0];
5943  yelectboardback[4] = yelectboardback[3];
5944  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5945  yelectboardback[6] = yelectboardback[5];
5946  yelectboardback[7] = yelectboardback[4];
5947  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5948  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5949                                                                         xelectboardback,yelectboardback); 
5950  electboardbackshape->DefineSection(0,0.0);
5951  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5952  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5953                                                                                          electboardbackshape,fSSDSupportRingAl);
5954  electboardback->SetLineColor(fColorAl);
5955  // Electronic Board Kapton Layer
5956  const Int_t kelectlayervertexnumber = 8;
5957  Double_t xelectlayer[kelectlayervertexnumber];
5958  Double_t yelectlayer[kelectlayervertexnumber];
5959  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5960  xelectlayer[1] = xelectlayer[0];
5961  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5962  xelectlayer[3] = xelectlayer[2];
5963  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5964      
5965  yelectlayer[0] = 0.0;
5966  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5967  yelectlayer[2] = yelectlayer[1];
5968  yelectlayer[3] = yelectlayer[0];
5969  yelectlayer[4] = yelectlayer[3];
5970  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5971  yelectlayer[6] = yelectlayer[5];
5972  yelectlayer[7] = yelectlayer[4];
5973  TGeoXtru* electlayershape = new TGeoXtru(2);
5974  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5975  electlayershape->DefineSection(0,0.0);
5976  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5977  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5978                                                                                          electlayershape,fSSDKaptonFlexMedium);
5979  electlayer->SetLineColor(fColorKapton);
5980  // JMD Connector Female
5981  const Int_t kjmdconnectorvertexnumber = 6;
5982  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5983  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5984  xjmdconnectorvertex[0] = 0.0; 
5985  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5986  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5987  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5988  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5989  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5990
5991  yjmdconnectorvertex[0] = 0.0; 
5992  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5993  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5994  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5995  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5996  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5997  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5998  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5999                                                                   yjmdconnectorvertex); 
6000  jmdconnectorshape->DefineSection(0,0.0);
6001  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6002  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6003                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6004  jmdconnector->SetLineColor(fColorG10);
6005  // Top Cable Connector
6006  const Int_t kcableconnectorvertexnumber = 8;
6007  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6008  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6009  xconnectorvertex[0] = 0.0;
6010  xconnectorvertex[1] = xconnectorvertex[0];
6011  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6012  xconnectorvertex[3] = xconnectorvertex[2];
6013  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6014                                          - fgkEndCapCardCableConnectorLength[2];
6015  xconnectorvertex[5] = xconnectorvertex[4];
6016  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6017  xconnectorvertex[7] = xconnectorvertex[6];
6018
6019  yconnectorvertex[0] = 0.0;
6020  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6021  yconnectorvertex[2] = yconnectorvertex[1];
6022  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6023  yconnectorvertex[4] = yconnectorvertex[3];
6024  yconnectorvertex[5] = yconnectorvertex[1];
6025  yconnectorvertex[6] = yconnectorvertex[5];
6026  yconnectorvertex[7] = yconnectorvertex[0];
6027  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6028  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6029                                                                     yconnectorvertex); 
6030  cableconnectorshape->DefineSection(0,0.0);
6031  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6032  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6033                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6034  cableconnector->SetLineColor(fColorG10);
6035  // Strip Connection
6036  TGeoBBox* endcapstripconnectionshape = 
6037                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6038                                                                                          0.5*fgkEndCapStripConnectionThickness,
6039                                                                                          0.5*fgkEndCapStripConnectionWidth);
6040  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6041                                                                                                         endcapstripconnectionshape,
6042                                                                                                         fSSDSupportRingAl);
6043  endcapstripconnection->SetLineColor(fColorAl);
6044  // Interface Card B
6045  const Int_t kcardBvertexnumber = 12; 
6046  Double_t xcardBvertexnumber[kcardBvertexnumber];
6047  Double_t ycardBvertexnumber[kcardBvertexnumber];
6048
6049  xcardBvertexnumber[0]  = 0.0;
6050  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6051  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6052  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6053  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6054  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6055  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6056  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6057  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6058  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6059  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6060  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6061  
6062  ycardBvertexnumber[0]  = 0.0;
6063  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6064  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6065  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6066  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6067  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6068  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6069  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6070  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6071  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6072  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6073  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6074
6075  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6076  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6077  interfacecardBshape->DefineSection(0,0.);
6078  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6079  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6080                                                                                          fSSDMountingBlockMedium);
6081  interfacecardB->SetLineColor(46);
6082  // Interface Card B Electronic Board
6083  const Int_t kelectboardcardBvertexnumber = 14; 
6084  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6085  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6086
6087  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6088  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6089  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6090  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6091  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6092  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6093  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6094  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6095  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6096  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6097  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6098  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6099  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6100  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6101
6102  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6103  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6104  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6105  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6106  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6107  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6108  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6109  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6110  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6111  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6112  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6113  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6114  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6115  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6116
6117  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6118  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6119                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6120  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6121  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6122                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6123  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6124                                                                                           fSSDSupportRingAl);
6125  electboardcardB->SetLineColor(fColorAl);
6126  // Generating Stiffener 2
6127  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6128                                                                                            0.5*fgkEndCapStiffenerThickness,
6129                                                                                            0.5*fgkEndCapStiffenerLength);
6130  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6131  endcapstiffener->SetLineColor(fColorAl);   
6132  // Generating Mother Interface Card B Container
6133  const Int_t kinterfacecardBmothervertexnumber = 10;
6134  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6135  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6136
6137  xinterfacecardBmothervertex[0] = 0.0;
6138  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6139  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6140                                                                 + fgkEndCapInterfaceCardBThickness;
6141  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6142  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6143                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6144  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6145  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6146  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6147  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6148                                                                 + fgkEndCapCardJMDConnectorLength[0];
6149  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6150
6151  yinterfacecardBmothervertex[0] = 0.0;
6152  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6153                                                                 + fgkEndCapInterfaceCardBWidth[1]
6154                                                                 + fgkEndCapInterfaceCardBWidth[2];
6155  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6156  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6157  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6158  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6159  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6160  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6161                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6162                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6163  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6164  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6165  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6166  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6167                                                                                   xinterfacecardBmothervertex,
6168                                                                                   yinterfacecardBmothervertex);
6169  interfacecardBmothershape->DefineSection(0,-1.e-15);
6170  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6171  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6172                                                                                                    interfacecardBmothershape,fSSDAir);
6173  electboardcardB->SetLineColor(fColorAl);
6174  // Positioning Volumes Mother Interface Card B Container 
6175  TGeoRotation* interfacecardBrot = new TGeoRotation();
6176  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6177  interfacecardBrot->SetAngles(90.,-90.,-90.);
6178  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6179  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6180  TGeoRotation* electboardcardBrot = new TGeoRotation();
6181  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6182  electboardcardBrot->SetAngles(90.,90.,-90.);
6183  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6184  TGeoCombiTrans* electboardcardBcombitrans = 
6185                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6186  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6187  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6188  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6189  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6190  TGeoTranslation* jmdconnectorcardBtrans[3];
6191  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6192  for(Int_t i=0; i<3; i++){
6193    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6194                                                          + fgkEndCapCardJMDConnectorLength[0], 
6195                                                            fgkEndCapCardElectBoardLayerWidth[1],
6196                                                            0.5*fgkEndCapCardJMDConnectorThickness
6197                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6198                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6199                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6200    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6201                                                                                                            *jmdconnectorcardBrot);
6202    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6203  }
6204  // Mother Supply Card Container 
6205  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6206  // Interface Card Container
6207  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6208  // Placing Volumes in Mother Supply Card Container
6209  // JMD Connector Positioning
6210  TGeoTranslation* jmdconnectortrans[2];
6211  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6212  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6213                                                                                         fgkEndCapCardElectBoardBackLength[0]
6214                                           -                                             fgkEndCapCardJMDConnectorThickness
6215                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6216  TGeoRotation* jmdconnectorot = new TGeoRotation();
6217  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6218                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6219                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6220                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6221                                                                       fgkEndCapCardJMDConnectorThickness
6222                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6223  jmdconnectorot->SetAngles(90.,180.,-90);
6224  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6225                                                                                 * jmdconnectorot);
6226  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6227  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6228  // Top Cable Connector Placing
6229  TGeoRotation* cableconnectorot[2];
6230  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6231  TGeoTranslation* cableconnectortrans[3];
6232  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6233  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6234  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6235  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6236  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6237                                                                                                                            *cableconnectorot[0]);
6238  TGeoHMatrix* cableconnectormatrix[2];
6239  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6240                                                         new TGeoHMatrix((*cableconnectorot[1])
6241                                                                                    *(*cableconnectorcombitrans));
6242  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6243                                            -                               fgkEndCapCardCableConnectorThickness,
6244                                                                                 fgkEndCapCardCableConnectorLength[0]
6245                                            +                            fgkEndCapCardCableConnectorToLayer);
6246  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6247                                            -                2.*fgkEndCapCardCableConnectorThickness
6248                                            -                            fgkEndCapCardCableConnectorDistance,
6249                                                                                 fgkEndCapCardCableConnectorLength[0]
6250                                            +                            fgkEndCapCardCableConnectorToLayer);
6251  for(Int_t i=0; i<2; i++){
6252         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6253     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6254  }
6255  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6256  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6257  electboardbackrot->SetAngles(90.,-90.,-90.);
6258  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6259                                                         +                fgkEndCapCardJMDConnectorLength[0]
6260                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6261  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6262                                                                                                                            *electboardbackrot);
6263  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6264  // Electronic Board Kapton Layer Positioning
6265  TGeoRotation* electlayerrot = new TGeoRotation();
6266  TGeoTranslation* electlayertrans[2];
6267  TGeoCombiTrans* electlayercombitrans[2];
6268  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6269  electlayerrot->SetAngles(90.,-90.,-90.);
6270  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6271                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6272  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6273                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6274                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6275  for(Int_t i=0; i<2; i++){
6276         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6277         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6278  }
6279  // Placing Volumes in Mother Interface Card Container
6280  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6281  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6282  for(Int_t i=0; i<2; i++){
6283         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6284  }
6285  /////////////////////////////////////////////////////////////
6286  // Generation of Card Interface Container
6287  /////////////////////////////////////////////////////////////
6288  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6289                                                   - fgkEndCapCardJMDConnectorLength[0]
6290                                                   - fgkEndCapInterfaceCardBThickness
6291                                                   - 9.*fgkEndCapStripConnectionThickness
6292                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6293  const Int_t kcardinterfacecontainervertexnumber = 14;
6294  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6295  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6296  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6297                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6298  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6299  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6300                                                                    + fgkEndCapStripConnectionThickness
6301                                                                    - fgkEndCapCardElectBoardLayerThickness
6302                                                                    - fgkEndCapCardCableConnectorWidth[0];
6303  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6304  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6305  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6306  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6307                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6308  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6309  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6310                                                                    + fgkEndCapInterfaceCardBThickness;
6311  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6312  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6313                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6314  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6315  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6316                                    - fgkEndCapInterfaceElectBoardCardBThickness
6317                                                                    + fgkEndCapCardJMDConnectorLength[0]
6318                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6319  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6320
6321  ycardinterfacecontainervertex[0]  = 0.;
6322  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6323                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6324                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6325  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6326  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6327                                                                    - fgkEndCapStripConnectionWidth;
6328  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6329  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6330  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6331  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6332                                                                    + fgkEndCapInterfaceCardBWidth[1]
6333                                                                    + fgkEndCapInterfaceCardBWidth[2];
6334  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6335  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6336  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6337  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6338  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6339  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6340  
6341  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6342  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6343                                                                                   xcardinterfacecontainervertex,
6344                                                                                   ycardinterfacecontainervertex);
6345  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6346                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6347  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6348                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6349  TGeoVolume** cardinterfacecontainer;
6350  cardinterfacecontainer = new TGeoVolume*[4];
6351  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6352                                                                                         interfacecardmothershape,fSSDAir); 
6353  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6354                                                                                         interfacecardmothershape,fSSDAir); 
6355  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6356                                                                                         interfacecardmothershape,fSSDAir); 
6357  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6358                                                                                         interfacecardmothershape,fSSDAir); 
6359  /////////////////////////////////
6360  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6361  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6362  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6363  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6364  /////////////////////////////////
6365  TGeoRotation* endcapstripconnectionrot[2];
6366  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6367  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6368  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6369  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6370                                                                         *                                 (*endcapstripconnectionrot[0]));
6371  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6372  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6373                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6374                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6375                                                                                         -endcapstripconnectionshape->GetDZ(),
6376                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6377  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6378  TGeoTranslation* cardinterfacetrans[9];
6379  TGeoHMatrix* cardinterfacematrix[9]; 
6380  for(Int_t i=0; i<7; i++){ 
6381         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6382                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6383                                                                                                 0.0,0.0);  
6384         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6385                                                    *                             (*endcapstripconnectionmatrix));
6386  }
6387  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6388                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6389                                                                                                 0.0,0.0);  
6390  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6391                                                 *                                 (*endcapstripconnectionmatrix));
6392  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6393                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6394                                                                                                 0.0,0.0);  
6395  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6396                                                 *                                 (*endcapstripconnectionmatrix));
6397
6398  for(Int_t i=0; i<4; i++){
6399         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6400                                                                            cardinterfacematrix[7]);                             
6401         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6402                                                                            cardinterfacematrix[8]);                             
6403  }
6404  TGeoTranslation* mothersupplycardtrans = 
6405                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6406                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6407                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6408  TGeoHMatrix* mothersupplycardmatrix[7];
6409  Int_t index[4] = {1,1,1,1};
6410  for(Int_t i=0; i<7; i++){
6411         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6412                                                         *                                 (*mothersupplycardtrans));
6413         for(Int_t j=0; j<4; j++){
6414                 switch(j){
6415                         case 0: //Layer5 EndCap Left Side  
6416                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6417                                                                                                    cardinterfacematrix[i]);                             
6418                                 if(i!=0){
6419                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6420                                                                                                            mothersupplycardmatrix[i]);                  
6421                                         index[j]++;
6422
6423                                 }
6424                         break;
6425                         case 1: //Layer5 EndCap Rigth Side  
6426                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6427                                                                                                    cardinterfacematrix[i]);                     
6428                                 if(i>0&&i<6){
6429                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6430                                                                                                            mothersupplycardmatrix[i]);                  
6431                                         index[j]++;
6432                                 }
6433                         break;
6434                         case 2: //Layer6 EndCap Left Side  
6435                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6436                                                                                                    cardinterfacematrix[i]);                             
6437                                 if(i!=6){
6438                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6439                                                                                                            mothersupplycardmatrix[i]);                  
6440                                         index[j]++;
6441                                 }
6442                         break;
6443                         case 3: //Layer6 EndCap Right Side  
6444                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6445                                                                                                    cardinterfacematrix[i]);                             
6446                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6447                                                                                                    mothersupplycardmatrix[i]);                  
6448                                 index[j]++;
6449                         break;
6450                 }
6451         }
6452  }
6453  // Positioning Interface 
6454  TGeoTranslation* motherinterfacecardtrans = 
6455                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6456                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6457                                                          -fgkEndCapCardElectBoardLayerThickness
6458                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6459  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6460                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6461  // Positioning Interface Card B 
6462  TGeoTranslation* interfacecardBmothertrans = 
6463                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6464                                                                                 + 2.*fgkEndCapStripConnectionThickness
6465                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6466                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6467                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6468  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6469                                                                                                                          interfacecardBmothertrans);
6470  // Positioning Stiffener 
6471  TGeoTranslation* endcapstiffenertrans = 
6472                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6473                                                                            +    2.0*fgkEndCapStripConnectionThickness
6474                                                                            +    fgkEndCapInterfaceCardBThickness
6475                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6476                                                                            +    stiffenertransx
6477                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6478                                                                                         endcapstiffenershape->GetDZ()
6479                                                                            -    0.5*(fgkEndCapStiffenerLength
6480                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6481  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6482  /////////////////////////////////////////////////////////////
6483  // Deallocating memory
6484  /////////////////////////////////////////////////////////////
6485  delete interfacecardBrot;
6486  delete interfacecardBtrans;
6487  delete electboardcardBtrans;
6488  delete electboardcardBrot; 
6489  delete jmdconnectorcardBrot;
6490  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6491  delete jmdconnectorot;
6492  delete jmdconnectortrans[1];
6493  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6494  delete cableconnectorcombitrans;
6495  delete electboardbacktrans;
6496  delete electboardbackrot;
6497  delete electlayerrot;
6498  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6499  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6500  delete mothersupplycardtrans;
6501  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6502  /////////////////////////////////////////////////////////////
6503  return cardinterfacecontainer;
6504  }
6505  ////////////////////////////////////////////////////////////////////////////////
6506  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6507   /////////////////////////////////////////////////////////////
6508   // Method returning EndCap Mother Volume
6509   /////////////////////////////////////////////////////////////
6510   const Int_t kendcapcoverplatesmallholenumber = 9;
6511   Double_t endcapmotherorigin[3];
6512   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6513                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6514                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6515   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6516                                           -                      fgkEndCapCoverPlateWidth[2]
6517                                           -       (kendcapcoverplatesmallholenumber-1)
6518                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6519                                           +  0.5*(fgkEndCapSideCoverLength[2]
6520                                           +               fgkEndCapCoverPlateWidth[1]
6521                                           -       fgkEndCapCoverPlateWidth[0])
6522                                           -      (fgkEndCapCoverPlateWidth[1]
6523                                           -       fgkEndCapCoverPlateWidth[0]);
6524   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6525                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6526                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6527                                                 +      fgkEndCapSideCoverWidth[1]
6528                                                 +      fgkEndCapSideCoverThickness
6529                                                 +      fgkEndCapKaptonFoilThickness);
6530   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6531                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6532                                                           +              2.0* fgkEndCapSideCoverThickness),
6533                                                                          0.5* (fgkEndCapSideCoverLength[2]
6534                                                           +                    fgkEndCapCoverPlateWidth[1]
6535                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6536                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6537                                                       +                                    fgkEndCapSideCoverWidth[1]
6538                                                           +                                       fgkEndCapSideCoverThickness
6539                                                       +                                   fgkEndCapKaptonFoilThickness),
6540                                                                                          endcapmotherorigin);
6541   TGeoVolume** endcapassembly;  
6542   endcapassembly = new TGeoVolume*[4];
6543   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6544                                                                                         endcapmothershape,fSSDAir); 
6545   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6546                                                                                         endcapmothershape,fSSDAir); 
6547   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6548                                                                                         endcapmothershape,fSSDAir); 
6549   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6550                                                                                         endcapmothershape,fSSDAir); 
6551  /////////////////////////////////
6552  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6553  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6554  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6555  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6556  /////////////////////////////////
6557   /////////////////////////////////////////////////////
6558   // Placing Endcap Cover Plate
6559   /////////////////////////////////////////////////////
6560   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6561   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6562   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6563   TGeoCombiTrans* endcapcoverplatecombitrans = 
6564                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6565                                                                                          endcapcoverplaterot);
6566   TGeoTranslation* endcapcoverplatetrans = 
6567                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6568   TGeoHMatrix* endcapcoverplatematrix = 
6569                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6570                                                                           *       (*endcapcoverplatecombitrans));
6571   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6572   /////////////////////////////////////////////////////
6573   // Placing Endcap Side Cover
6574   /////////////////////////////////////////////////////
6575   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6576   TGeoRotation* endcapsidecoverot[2];
6577   TGeoCombiTrans* endcapsidecovercombitrans[3];
6578   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6579   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6580   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6581                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6582                                                                                         - fgkEndCapCoverPlateWidth[2]
6583                                                                                     - (kendcapcoverplatesmallholenumber-1)
6584                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6585                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6586                                                                                         + fgkEndCapSideCoverLength[2],
6587                                                                                           0.5*(fgkEndCapSideCoverThickness
6588                                                                                         + fgkEndCapCoverPlateThickness)
6589                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6590                                                                                           endcapsidecoverot[0]);
6591   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6592   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6593                                                                                                         0.5*fgkEndCapCoverPlateThickness
6594                                                                                                         -fgkEndCapSideCoverWidth[1],
6595                                                                                                         endcapsidecoverot[1]);
6596   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6597                                                                                                         +fgkEndCapCoverPlateLength[3]
6598                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6599                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6600                                                                                                         0.5*fgkEndCapCoverPlateThickness
6601                                                                                                         -fgkEndCapSideCoverWidth[1],
6602                                                                                                         endcapsidecoverot[1]);
6603   TGeoHMatrix* endcapsidecovermatrix[2];
6604   for(Int_t i=0; i<2; i++){
6605    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6606                                                         *                                 (*endcapsidecovercombitrans[0]));
6607         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6608                                                                                                                 endcapsidecovermatrix[i]);
6609   }
6610   /////////////////////////////////////////////////////
6611   // Placing Endcap Cooling Tube
6612   /////////////////////////////////////////////////////
6613   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6614   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6615   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6616   TGeoCombiTrans* endcapccolingtubecombitrans 
6617                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6618                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6619                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6620                                                 - fgkEndCapCoolingTubeToCoverSide,
6621                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6622                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6623   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6624                                                                                                           endcapccolingtubecombitrans);
6625   /////////////////////////////////////////////////////
6626   // Placing Screws 
6627   /////////////////////////////////////////////////////
6628   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6629                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6630   Int_t screwcoverplatedgesnumber[2] = {20,20};
6631   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6632                                                                                 fgkEndCapCoverPlateThickness
6633                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6634   TGeoXtru* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6635                                                                                                  screwcoverplatedgesnumber,
6636                                                                                                  screwcoverplatesection);
6637   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6638                                                                                            screwcoverplateshape,
6639                                                                                            fSSDCoolingTubePhynox); 
6640   screwcoverplate->SetLineColor(12);
6641   Double_t transx[4] = {0,
6642                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6643                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6644                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6645                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6646                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6647   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6648 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6649   TGeoTranslation*** endcapcoverplatescrewtrans;
6650   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6651   Int_t index = 0;
6652   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6653         endcapcoverplatescrewtrans[i] = 
6654                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6655     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6656                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6657         if(index==1||index==9||index==28||index==36){
6658                         endcapcoverplatescrewtrans[i][j] = 
6659                                 new TGeoTranslation(transx[i],
6660                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6661                                                                         fgkEndCapSideCoverThickness);
6662                 }
6663                 else{
6664                         endcapcoverplatescrewtrans[i][j] = 
6665                                 new TGeoTranslation(transx[i],
6666                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6667                                                                         0.);
6668                 }
6669             if(index!=19) 
6670                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6671                                                                                           endcapcoverplatescrewtrans[i][j]);
6672         }
6673   }
6674   /////////////////////////////////////////////////////
6675   // Placing Cover Plate Clips 
6676   /////////////////////////////////////////////////////
6677   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6678                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6679                                                                                                          0.5*fgkEndCapSideCoverThickness);
6680   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6681                                                                                                         endcapcoverplateclipshape,
6682                                                                                                         fSSDCoolingTubePhynox);
6683   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6684                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6685                                                                                                          0.5*fgkEndCapSideCoverThickness);
6686   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6687                                                                                                         endcapcoverplatedownclipshape,
6688                                                                                                         fSSDCoolingTubePhynox);
6689   TGeoTranslation* endcapcoverplatecliptrans[4];
6690   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6691                                                            -                     fgkEndCapCoverPlateLength[0]
6692                                                            -                     fgkEndCapSideCoverThickness,
6693                                                                                                          0.0,
6694                                                                                                  0.5*(fgkEndCapSideCoverThickness
6695                                                            +                                              fgkEndCapCoverPlateThickness));
6696   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6697                                                            -                     fgkEndCapCoverPlateLength[0]
6698                                                            -                     fgkEndCapSideCoverThickness,
6699                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6700                                                            *                                     fgkEndCapSideCoverWidth[5],
6701                                                                                                  0.5*(fgkEndCapSideCoverThickness
6702                                                            +                                              fgkEndCapCoverPlateThickness));
6703   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6704                                                            -                     fgkEndCapCoverPlateLength[0]
6705                                                            +                                     fgkEndCapCoverPlateLength[1]
6706                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6707                                                            -                                     fgkEndCapCoverPlateClipLength
6708                                                            +                                 fgkEndCapSideCoverThickness,
6709                                                                                                          0.0,
6710                                                                                                  0.5*(fgkEndCapSideCoverThickness
6711                                                            +                                              fgkEndCapCoverPlateThickness));
6712   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6713                                                            -                     fgkEndCapCoverPlateLength[0]
6714                                                            +                                     fgkEndCapCoverPlateLength[1]
6715                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6716                                                            -                                     fgkEndCapCoverPlateClipLength
6717                                                            +                                 fgkEndCapSideCoverThickness,
6718                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6719                                                            *                                     fgkEndCapSideCoverWidth[5],
6720                                                                                                  0.5*(fgkEndCapSideCoverThickness
6721                                                            +                                              fgkEndCapCoverPlateThickness));
6722   endcapcoverplateclip->SetLineColor(fColorPhynox);
6723   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6724   for(Int_t i=0; i<4; i++) 
6725         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6726                                                                                                    endcapcoverplatecliptrans[i]);  
6727   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6728   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6729                                                                    -                     fgkEndCapCoverPlateLength[0]
6730                                                                    -                     fgkEndCapSideCoverThickness,
6731                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6732                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6733                                                                                                         0.5*(fgkEndCapSideCoverThickness
6734                                                                +                                         fgkEndCapCoverPlateThickness)
6735                                                                    -                     fgkEndCapSideCoverWidth[1]
6736                                                                    -                                     fgkEndCapSideCoverThickness);
6737   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6738                                                                    -                     fgkEndCapCoverPlateLength[0]
6739                                                                    -                     fgkEndCapSideCoverThickness,
6740                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6741                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6742                                                                    +                            fgkEndCapSideCoverLength[2]
6743                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6744                                                                                                         0.5*(fgkEndCapSideCoverThickness
6745                                                                +                                         fgkEndCapCoverPlateThickness)
6746                                                                    -                     fgkEndCapSideCoverWidth[1]
6747                                                                    -                                     fgkEndCapSideCoverThickness);
6748   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6749                                                                    -                     fgkEndCapCoverPlateLength[0]
6750                                                                    +                     fgkEndCapSideCoverThickness
6751                                                                    +                     fgkEndCapCoverPlateLength[1]
6752                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6753                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6754                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6755                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6756                                                                                                         0.5*(fgkEndCapSideCoverThickness
6757                                                                +                                         fgkEndCapCoverPlateThickness)
6758                                                                    -                     fgkEndCapSideCoverWidth[1]
6759                                                                    -                                     fgkEndCapSideCoverThickness);
6760   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6761                                                                    -                     fgkEndCapCoverPlateLength[0]
6762                                                                    +                     fgkEndCapSideCoverThickness
6763                                                                    +                     fgkEndCapCoverPlateLength[1]
6764                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6765                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6766                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6767                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6768                                                                    +                                 fgkEndCapSideCoverLength[2]
6769                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6770                                                                                                         0.5*(fgkEndCapSideCoverThickness
6771                                                                +                                         fgkEndCapCoverPlateThickness)
6772                                                                    -                     fgkEndCapSideCoverWidth[1]
6773                                                                    -                                     fgkEndCapSideCoverThickness);
6774   for(Int_t i=0; i<4; i++)
6775         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6776                                                                                                    endcapcoverplatedowncliptrans[i]);
6777   /////////////////////////////////////////////////////
6778   // Placing Kapton Foil
6779   /////////////////////////////////////////////////////
6780   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6781                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6782                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6783   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6784                                                                                                 endcapkaptonfoilshape,
6785                                                                                                 fSSDKaptonFlexMedium);
6786   endcapkaptonfoil->SetLineColor(8);
6787   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6788                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6789                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6790                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6791                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6792                                                                              -                     fgkEndCapSideCoverWidth[1]
6793                                                                                  -                     fgkEndCapSideCoverThickness);
6794   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6795   /////////////////////////////////////////////////////////////
6796   // Placing Electronic Tubes
6797   /////////////////////////////////////////////////////////////
6798   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6799                                                                              - fgkEndCapInterfaceCardBThickness
6800                                                                              - 9.*fgkEndCapStripConnectionThickness
6801                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6802                                                                                fgkEndCapKaptonFoilWidth
6803                                                                              - fgkEndCapInterfaceCardBThickness
6804                                                                              - 9.*fgkEndCapStripConnectionThickness
6805                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6806                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6807   TGeoVolume* endcapeffectivecables[2];
6808   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6809                                                                                          fgkEndCapEffectiveCableRadiusMax,
6810                                                                                          endcapeffectivecableswidth[0],
6811                                                                                          10,"EndCapEffectiveCables1"); 
6812   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6813                                                                                          fgkEndCapEffectiveCableRadiusMax,
6814                                                                                          endcapeffectivecableswidth[1],
6815                                                                                          25,"EndCapEffectiveCables2"); 
6816   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6817   TGeoTranslation* endcapeffectivecablestrans[2];
6818   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6819                                           -                                                        0.5*endcapeffectivecableswidth[0]
6820                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6821                                           -                                                               fgkEndCapCoverPlateWidth[2]
6822                                           -                                             (kendcapcoverplatesmallholenumber-1)
6823                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6824                                           +                                             fgkEndCapSideCoverLength[2],
6825                                           -                     0.5*fgkEndCapCoverPlateThickness
6826                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6827                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6828                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6829   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6830                                           -                                                        0.5*endcapeffectivecableswidth[1]
6831                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6832                                           -                                                               fgkEndCapCoverPlateWidth[2]
6833                                           -                                             (kendcapcoverplatesmallholenumber-1)
6834                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6835                                           +                                         fgkEndCapSideCoverLength[2],
6836                                           -                     0.5*fgkEndCapCoverPlateThickness
6837                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6838                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6839                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6840   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6841   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6842   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6843                                                                                                                    *endcapeffectivecablesrot);
6844   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6845                                                                                                                    *endcapeffectivecablesrot);
6846 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6847 //                                                                                                        endcapeffectivecablescombitrans[0]);
6848   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6849                                                                                                           endcapeffectivecablescombitrans[1]);
6850   /////////////////////////////////////////////////////////////
6851   // Placing End Cap Cards
6852   /////////////////////////////////////////////////////////////
6853   TGeoVolume** endcapcards = GetEndCapCards();
6854   TGeoRotation* endcapcardsrot[2];
6855   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6856   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6857   TGeoTranslation* endcapcardstrans[2]; 
6858   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6859                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6860   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6861   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6862   TGeoHMatrix* endcapcardsmatrix[2];
6863   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6864   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6865                                                   - fgkEndCapCardJMDConnectorLength[0]
6866                                                   - fgkEndCapInterfaceCardBThickness
6867                                                   - 9.*fgkEndCapStripConnectionThickness
6868                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6869   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6870                                           -                                             fgkEndCapCoverPlateLength[0]
6871                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6872                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6873                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6874                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6875                                           -                                                               fgkEndCapInterfaceCardBThickness
6876                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6877                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6878                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6879                                           -                                                               fgkEndCapCoverPlateWidth[2]
6880                                           -                                             (kendcapcoverplatesmallholenumber-1)
6881                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6882                                           +                     fgkEndCapKaptonFoilWidth,
6883                                                                                           0.5*fgkEndCapCoverPlateThickness
6884                                           -                                                     fgkEndCapSideCoverWidth[1]);
6885   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6886   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6887    /////////////////////////////////////////////////////////////
6888   // Deallocating memory
6889   /////////////////////////////////////////////////////////////
6890   delete endcapcoverplaterot;
6891   delete endcapcoverplatecombitrans;
6892   delete endcapcoverplatetrans;
6893   for(Int_t i=0; i<3; i++){
6894    delete endcapsidecovercombitrans[i];
6895    if(i<2) delete endcapsidecoverot[i]; 
6896   }
6897   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6898   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6899   delete endcapcardsmatrix[0];
6900   return endcapassembly;
6901  } 
6902  ////////////////////////////////////////////////////////////////////////////////
6903  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6904                                                                                                                         Double_t radiusmax, 
6905                                                                                                                         Double_t width, 
6906                                                                                                                         Int_t ncables,
6907                                                                                                                         char* volname){
6908   /////////////////////////////////////////////////////////////
6909   // Generating EndCap High Voltage Tubes 
6910   /////////////////////////////////////////////////////////////
6911   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6912   Double_t effectiveouteradius = TMath::Sqrt(TMath::Power(effectiveinneradius,2.)
6913                                                            +             TMath::Power(radiusmax,2.)
6914                                -             TMath::Power(radiusmin,2.));
6915   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6916   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6917                                                                                                    effectiveouteradius,0.5*width);
6918   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6919                                                                                                 effectiveinnertubeshape,
6920                                                                                                 fSSDStiffenerConnectorMedium);
6921   effectiveinnertube->SetLineColor(41);
6922   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6923                                                                                                 effectiveoutertubeshape,
6924                                                                                                 fSSDKaptonChipCableMedium);
6925   effectiveoutertube->SetLineColor(39);
6926   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6927   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6928   effectivemothertube->AddNode(effectiveinnertube,1);
6929   effectivemothertube->AddNode(effectiveoutertube,1);
6930   return effectivemothertube;
6931  } 
6932  ////////////////////////////////////////////////////////////////////////////////
6933  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6934   /////////////////////////////////////////////////////////////
6935   // Generating EndCap Support Layer 5 and Layer 6 
6936   /////////////////////////////////////////////////////////////
6937   const Int_t knedges = 5;
6938   ///////////////////////////////////////////////
6939   // Setting the vertices for TGeoXtru Up Volume
6940   ///////////////////////////////////////////////
6941   const Int_t klayernumber = 2;
6942   Double_t xupvertex[klayernumber][knedges+3];
6943   Double_t yupvertex[klayernumber][knedges+3];
6944   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6945   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6946   Double_t middlepsi[klayernumber] = {0.0,0.0};
6947   for(Int_t i=0; i<klayernumber; i++){
6948         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6949         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6950         xupvertex[i][2] = -xupvertex[i][1];
6951         xupvertex[i][3] = -xupvertex[i][0];
6952
6953         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6954         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6955         yupvertex[i][2] =  yupvertex[i][1];
6956         yupvertex[i][3] =  yupvertex[i][0];
6957         
6958     middledgeangle[i] = upedgeangle[i]/knedges;
6959     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6960     for(Int_t j=1; j<knedges; j++){
6961                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6962                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6963         }
6964   }
6965   ////////////////////////////////////
6966   // Generating Up TGeoXtru
6967   ////////////////////////////////////
6968   TGeoXtru* upendcapsupportshape[klayernumber];
6969   TGeoVolume* upendcapsupport[klayernumber]; 
6970   char upendcapsupportname[30]; 
6971   for(Int_t i=0; i<klayernumber; i++){
6972    upendcapsupportshape[i] = new TGeoXtru(2);
6973    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
6974    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6975    upendcapsupportshape[i]->DefineSection(0,0.);
6976    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6977    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6978                                                                         fSSDSupportRingAl);
6979    upendcapsupport[i]->SetLineColor(5);
6980   }
6981   ///////////////////////////////////////////////
6982   // Setting the vertices for TGeoXtru Down Volume
6983   ///////////////////////////////////////////////
6984   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6985   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6986   for(Int_t i=0; i<klayernumber; i++){
6987         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6988         xdownvertex[i][1] =  xupvertex[i][0];
6989         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6990         ydownvertex[i][1] =  yupvertex[i][0];
6991         for(Int_t j=0; j<knedges; j++){
6992                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6993                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6994         } 
6995         for(Int_t j=0; j<knedges; j++){
6996                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6997                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6998                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6999                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7000         }
7001   }
7002   ////////////////////////////////////
7003   // Generating Down TGeoXtru
7004   ////////////////////////////////////  
7005   TGeoXtru* downendcapsupportshape[klayernumber];
7006   TGeoVolume* downendcapsupport[klayernumber]; 
7007   char downendcapsupportname[30]; 
7008   for(Int_t i=0; i<klayernumber; i++){
7009         downendcapsupportshape[i] = new TGeoXtru(2);
7010     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7011         downendcapsupportshape[i] = new TGeoXtru(2);
7012         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7013     if(i==0){
7014                 downendcapsupportshape[i]->DefineSection(0,0.);
7015                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7016     }
7017         else{
7018                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7019                                                                  -                 fgkEndCapSupportLowWidth[i]);
7020                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7021         }
7022     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7023                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7024         downendcapsupport[i]->SetLineColor(5);
7025   }
7026   ///////////////////////////////////////////////
7027   // Setting TGeoPgon Volume
7028   ///////////////////////////////////////////////
7029   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7030                                                                                                    fgkSSDLay6LadderNumber};
7031   TGeoPgon* endcapsupportmothershape[klayernumber];
7032   TGeoVolume** endcapsupportmother;
7033   endcapsupportmother = new TGeoVolume*[klayernumber];
7034   char endcapsupportmothername[30];
7035   for(Int_t i=0; i<klayernumber; i++){
7036         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7037     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7038         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7039     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7040                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7041     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7042                                                                                         fSSDAir);       
7043   }
7044   ////////////////////////////////////
7045   TGeoRotation** endcapsupportrot[klayernumber];
7046   for(Int_t i=0; i<2; i++){
7047         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7048         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7049            endcapsupportrot[i][j] = new TGeoRotation();
7050            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7051        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7052        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7053         }
7054   }
7055   return endcapsupportmother;
7056  } 
7057  ////////////////////////////////////////////////////////////////////////////////
7058  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7059   /////////////////////////////////////////////////////////////
7060   // Setting End Cap Support Layer 5 and 6. 
7061   /////////////////////////////////////////////////////////////
7062   const Int_t kendcapcoverplatesmallholenumber = 9;
7063   const Int_t klayernumber = 2;
7064   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7065                                                                                                    fgkSSDLay6LadderNumber};
7066   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7067                                                                                 360.0/kssdlayladdernumber[1]};
7068   TGeoVolume** endcapsupport = EndCapSupport();
7069   TGeoVolume** endcapassembly = GetEndCapAssembly();
7070   TGeoPgon* endcapsupportshape[klayernumber];
7071   Double_t* radiusmin[klayernumber];
7072   Double_t* radiusmax[klayernumber];
7073   for(Int_t i=0; i<klayernumber; i++){
7074     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7075         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7076         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7077   }  
7078   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7079   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7080                                                                           endcapassemblyshape->GetDY(),
7081                                                                           endcapassemblyshape->GetDZ()};
7082   ///////////////////////////////////////////////
7083   // Setting TGeoPgon Volume for Mother Container
7084   ///////////////////////////////////////////////
7085   TGeoPgon* endcapsupportsystemshape[klayernumber];
7086   char endcapsupportsystemothername[30];
7087   for(Int_t i=0; i<klayernumber; i++){
7088         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7089     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7090         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7091                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7092                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7093                                                                                            +2.*endcapassemblycenter[2])
7094                                                                                            /CosD(0.5*upedgeangle[i]));  
7095     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7096                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7097                                                                                              - fgkEndCapCoverPlateWidth[0]),
7098                                                                                            *radiusmin[i],
7099                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7100                                                                                            +2.*endcapassemblycenter[2])
7101                                                                                            /CosD(0.5*upedgeangle[i]));
7102   }
7103   fgkEndCapSupportSystem = new TGeoVolume*[4];
7104   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7105                                                                           endcapsupportsystemshape[0],fSSDAir); 
7106   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7107                                                                           endcapsupportsystemshape[0],fSSDAir); 
7108   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7109                                                                           endcapsupportsystemshape[1],fSSDAir); 
7110   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7111                                                                           endcapsupportsystemshape[1],fSSDAir); 
7112   ///////////////////////////////////////////////
7113   TGeoTranslation* endcapassemblytrans[klayernumber];
7114   for(Int_t i=0; i<klayernumber; i++)
7115         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7116                                                                            -  fgkEndCapSideCoverThickness
7117                                                                            +  endcapassemblycenter[0],
7118                                                                            -  0.5*fgkEndCapCoverPlateThickness
7119                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7120                                                                            +  2.0*endcapassemblycenter[2]
7121                                                                            +  0.5*fgkEndCapSupportLength[i]
7122                                                                            /  TanD(0.5*upedgeangle[i]),
7123                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7124                                                                            -  fgkEndCapCoverPlateWidth[2]
7125                                                                            - (kendcapcoverplatesmallholenumber-1)
7126                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7127   TGeoRotation** endcapassemblyrot[klayernumber];
7128   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7129   for(Int_t i=0; i<klayernumber; i++){
7130    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7131    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7132    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7133    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7134    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7135    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7136    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7137    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7138         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7139         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7140    }
7141   }
7142   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7143                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7144   for(Int_t i=0; i<2*klayernumber; i++){
7145         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7146                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7147                                                                                                                                            endcapassemblymatrix[1][j+2]);
7148         }
7149         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7150   }
7151    /////////////////////////////////////////////////////////////
7152   // Deallocating memory
7153   /////////////////////////////////////////////////////////////
7154   for(Int_t i=0; i<klayernumber; i++){
7155         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7156                 delete endcapassemblyrot[i][j];
7157         }
7158         delete endcapassemblyrot[i];
7159         delete endcapassemblymatrix[i][0];
7160         delete endcapassemblymatrix[i][1];
7161   }
7162   /////////////////////////////////////////////////////////////
7163   }
7164   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7165   /////////////////////////////////////////////////////////////
7166   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7167   /////////////////////////////////////////////////////////////
7168   if (! moth) {
7169     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer5, mother is null!\n");
7170     return;
7171   };
7172   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7173   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7174   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7175                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7176                                                                            +            fgkEndCapSupportCenterLay5Position
7177                                                                            -            fgkEndCapSideCoverLength[2]);
7178   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7179                                                                                                 fgkEndCapSideCoverLength[2]
7180                                                                            -        fgkEndCapSupportCenterLay5Position
7181                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7182   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7183   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7184   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7185         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7186   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7187   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7188    /////////////////////////////////////////////////////////////
7189   // Deallocating memory
7190   /////////////////////////////////////////////////////////////
7191   delete endcapsupportsystemrot;
7192   delete endcapsupportsystemITSCentertrans[1];
7193  }
7194   /////////////////////////////////////////////////////////////
7195   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7196   /////////////////////////////////////////////////////////////
7197   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7198   /////////////////////////////////////////////////////////////
7199   if (! moth) {
7200     printf("Error::AliITSv11GeometrySSD: Can't insert end cap support of layer6, mother is null!\n");
7201     return;
7202   };
7203   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7204   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7205   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7206                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7207                                                                            +            fgkEndCapSupportCenterLay6Position
7208                                                                            -            fgkEndCapSideCoverLength[2]);
7209   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7210                                                                                                 fgkEndCapSideCoverLength[2]
7211                                                                            -        fgkEndCapSupportCenterLay6Position
7212                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7213   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7214   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7215   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7216         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7217   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7218   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7219    /////////////////////////////////////////////////////////////
7220   // Deallocating memory
7221   /////////////////////////////////////////////////////////////
7222   delete endcapsupportsystemrot;
7223   delete endcapsupportsystemITSCentertrans[1];
7224  }
7225  ////////////////////////////////////////////////////////////////////////////////
7226  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7227   /////////////////////////////////////////////////////////////
7228   // Setting Ladder Support of Layer 5. 
7229   /////////////////////////////////////////////////////////////
7230   if (! moth) {
7231     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer5, mother is null!\n");
7232     return;
7233   };
7234   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7235   fMotherVol = moth;
7236   TGeoTranslation* centerITSRingSupportLay5trans[2];
7237   for(Int_t i=0; i<2; i++){
7238         centerITSRingSupportLay5trans[i] = 
7239                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7240     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7241   }
7242  }
7243  ////////////////////////////////////////////////////////////////////////////////
7244  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7245   /////////////////////////////////////////////////////////////
7246   // Setting Ladder Support of Layer 6. 
7247   /////////////////////////////////////////////////////////////
7248   if (! moth) {
7249     printf("Error::AliITSv11GeometrySSD: Can't insert ladder lupport of layer6, mother is null!\n");
7250     return;
7251   };
7252   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7253   fMotherVol = moth;
7254   TGeoTranslation* centerITSRingSupportLay6trans[2];
7255   for(Int_t i=0; i<2; i++){
7256         centerITSRingSupportLay6trans[i] = 
7257                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7258     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7259   }
7260  }
7261  ////////////////////////////////////////////////////////////////////////////////
7262  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7263   /////////////////////////////////////////////////////////////
7264   // Setting Ladder Support of Layer 6. 
7265   /////////////////////////////////////////////////////////////
7266   if (! moth) {
7267     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cone, mother is null!\n");
7268     return;
7269   };
7270   if(!fSSDCone) SetSSDCone();
7271   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7272                                                                 +                                         fgkSSDCentralAL3SupportLength);
7273     moth->AddNode(fSSDCone,1,ssdconetrans);
7274 }
7275  ////////////////////////////////////////////////////////////////////////////////
7276  void AliITSv11GeometrySSD::SetSSDCone(){
7277   /////////////////////////////////////////////////////////////
7278   // Method generating SSDCone 
7279   /////////////////////////////////////////////////////////////
7280   if(!fCreateMaterials) CreateMaterials();
7281   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7282   Double_t ssdpconesectionradiusmax[16];
7283   Double_t ssdpconesectionradiusmin[16];
7284   Double_t ssdpconezsection[16];
7285   TGeoPcon* ssdpconelittleholeshape[8];
7286   TGeoVolume* ssdpconelittlehole[8];
7287   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7288   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7289   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7290                                                       / SinD(fgkSSDPConeAngle)
7291                                                           + ssdpconesectionradiusmin[0];
7292   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7293                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7294                                                           / SinD(fgkSSDPConeAngle);
7295   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7296   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7297                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7298   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7299   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7300                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7301   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7302   ssdpconelittlehole[0]->SetLineColor(4);
7303   /////////////////////////////////////////////////////////////
7304   ssdpconezsection[2] = ssdpconezsection[1];  
7305   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7306   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7307   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7308                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7309                                                           / SinD(fgkSSDPConeAngle);
7310   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7311                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7312   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7313                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7314   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7315                                                                    * TMath::RadToDeg();
7316   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7317                                                                                                           60.-ssdpconelittleholeangle,2);    
7318   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7319                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7320   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7321   ssdpconelittlehole[1]->SetLineColor(4);
7322   TGeoRotation* ssdconelittleholerot[6];
7323   for(Int_t i=0; i<6; i++){
7324         ssdconelittleholerot[i] = new TGeoRotation();
7325     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7326   }
7327   /////////////////////////////////////////////////////////////
7328   ssdpconezsection[4] = ssdpconezsection[3];  
7329   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7330   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7331   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7332                                                           * CosD(fgkSSDPConeAngle)
7333                                                           / SinD(fgkSSDPConeAngle);
7334   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7335   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7336                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7337   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7338   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7339                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7340   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7341   ssdpconelittlehole[2]->SetLineColor(4);
7342   ///////////////////////////////////////////////////
7343   ssdpconezsection[6] = ssdpconezsection[5];  
7344   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7345   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7346   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7347                                                           -ssdpconezsection[0]
7348                                                           * CosD(fgkSSDPConeAngle)
7349                                                           / SinD(fgkSSDPConeAngle);
7350   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7351   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7352                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7353   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7354                                                                    * TMath::RadToDeg();
7355   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7356                                                                                                           45.-ssdpconemiddleholeangle,2);    
7357   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7358                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7359   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7360   ssdpconelittlehole[3]->SetLineColor(4);
7361   TGeoRotation* ssdconemiddleholerot[8];
7362   for(Int_t i=0; i<8; i++){
7363         ssdconemiddleholerot[i] = new TGeoRotation();
7364     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7365   }
7366   /////////////////////////////////////////////////////////////
7367   ssdpconezsection[8] = ssdpconezsection[7];  
7368   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7369   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7370   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7371                                                           * CosD(fgkSSDPConeAngle)
7372                                                           / SinD(fgkSSDPConeAngle);
7373   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7374   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7375                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7376   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7377   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7378                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7379   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7380   ssdpconelittlehole[4]->SetLineColor(4);
7381   /////////////////////////////////////////////////////////////
7382   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7383   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7384                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7385                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7386                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7387                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7388   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7389   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7390                                                                                  * TMath::RadToDeg();
7391   ssdpconezsection[10] = ssdpconezsection[9];
7392   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7393   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7394   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7395                                                           * CosD(fgkSSDPConeAngle)
7396                                                           / SinD(fgkSSDPConeAngle);
7397   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7398   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7399                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7400   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7401                                                                                         ssdpconetrapezoidsectionangle,2);    
7402   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7403                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7404   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7405   ssdpconelittlehole[5]->SetLineColor(4);
7406   TGeoRotation* ssdconeupradiusrot[8];
7407   for(Int_t i=0; i<8; i++){
7408         ssdconeupradiusrot[i] = new TGeoRotation();
7409     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7410   }
7411   /////////////////////////////////////////////////////////////
7412   ssdpconezsection[12] = ssdpconezsection[11];
7413   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7414   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7415   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7416   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7417   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7418   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7419   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7420                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7421   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7422   ssdpconelittlehole[6]->SetLineColor(4);
7423   /////////////////////////////////////////////////////////////
7424   ssdpconezsection[14] = 0.0;
7425   ssdpconezsection[15] = ssdpconezsection[0];
7426   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7427   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7428   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7429   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7430   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7431   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7432                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7433   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7434   ssdpconelittlehole[7]->SetLineColor(4);
7435   /////////////////////////////////////////////////////////////
7436   TGeoTube* ssdtubeconeshape[2];
7437   TGeoVolume* ssdtubecone[2];
7438   TGeoTranslation* ssdtubeconetrans[2];
7439   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7440                                                                            fgkSSDPConeExternalRadius,
7441                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7442   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7443                                                                            0.5*ssdpconezsection[0]); 
7444   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7445   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7446   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7447                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7448                                           + ssdpconezsection[13]);
7449   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7450   ssdtubecone[0]->SetLineColor(4);
7451   ssdtubecone[1]->SetLineColor(4);
7452   /////////////////////////////////////////////////////////////
7453   // Mother Volume Container
7454   /////////////////////////////////////////////////////////////
7455   Double_t ssdconemotherradiusmin[8];
7456   Double_t ssdconemotherradiusmax[8];
7457   Double_t ssdconemothersection[8]; 
7458   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7459   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7460   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7461   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7462   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7463   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7464   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7465   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7466   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7467   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7468   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7469   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7470   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7471   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7472   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7473   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7474   ssdconemothersection[0] = 0.0;
7475   ssdconemothersection[1] = ssdpconezsection[0];
7476   ssdconemothersection[2] = ssdpconezsection[0];
7477   ssdconemothersection[3] = ssdpconezsection[11];
7478   ssdconemothersection[4] = ssdpconezsection[11];
7479   ssdconemothersection[5] = ssdpconezsection[13];
7480   ssdconemothersection[6] = ssdpconezsection[13];
7481   ssdconemothersection[7] = fgkSSDPConeLength;
7482   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7483   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7484                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7485   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7486   /////////////////////////////////////////////////////////////
7487   //Placing the Volumes into Mother 
7488   /////////////////////////////////////////////////////////////
7489   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7490   for(Int_t i=0; i<6; i++){
7491         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7492   }
7493   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7494   for(Int_t i=0; i<8; i++){
7495     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7496   }
7497   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7498   for(Int_t i=0; i<8; i++){
7499     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7500   }
7501   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7502   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7503   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7504   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7505   /////////////////////////////////////////////////////////////
7506   // ITS General Support
7507   /////////////////////////////////////////////////////////////
7508   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7509                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7510   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7511   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7512                                                                              - fgkSSDCentralAL3SupportLength);
7513   ssdcentralsupport->SetLineColor(4);
7514   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7515   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7516                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7517   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7518   TGeoTranslation* ssdcentralal3supportrans[3]; 
7519   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7520   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7521                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7522   ssdcentralal3support->SetLineColor(4);
7523   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7524   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7525   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7526   Double_t ssdpconcentralradiusmin[2];
7527   Double_t ssdpconcentralradiusmax[2];
7528   Double_t ssdpconcentralsection[2];
7529   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7530   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7531   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7532   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7533   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7534   ssdpconcentralsection[1] = 0.;
7535   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7536                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7537   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7538   ssdpconcentralal3->SetLineColor(4);
7539   fSSDCone->AddNode(ssdpconcentralal3,1);
7540   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7541   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7542   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7543                                                                 -2.*fgkSSDCentralAL3SupportLength);
7544   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7545                                                                                                                      *ssdcentralal3supportrot);
7546   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7547   TGeoRotation* ssdconemotherot = new TGeoRotation();
7548   ssdconemotherot->SetAngles(90.,180.,-90.);
7549   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7550                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7551   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7552   fSSDCone->AddNode(ssdconemother,1);
7553   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7554   /////////////////////////////////////////////////////////////
7555   // Deallocating memory
7556   /////////////////////////////////////////////////////////////
7557   delete ssdcentralal3supportrot;
7558   delete ssdcentralal3supportrans[2];
7559   delete ssdconemotherot;
7560   delete ssdconemothertrans;
7561   /////////////////////////////////////////////////////////////
7562  }
7563  ////////////////////////////////////////////////////////////////////////////////
7564  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7565   /////////////////////////////////////////////////////////////
7566   // Setting SSD Cables
7567   /////////////////////////////////////////////////////////////
7568   if (! moth) {
7569     printf("Error::AliITSv11GeometrySSD: Can't insert SSD Cables, mother is null!\n");
7570     return;
7571   };
7572   TGeoVolume* ssdcables = SetSSDCables();
7573   moth->AddNode(ssdcables,1);
7574 }
7575  ////////////////////////////////////////////////////////////////////////////////
7576  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7577   /////////////////////////////////////////////////////////////
7578   // Method generating SSDCables
7579   /////////////////////////////////////////////////////////////
7580   // SSD Layer 5 Cables
7581   //////////////////////////////////////////////////////////////////////////////////////////////////
7582   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7583   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7584   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7585   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7586   //////////////////////////////////////////////////////////////////////////////////////////////////
7587   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7588   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7589                                                                             -  fgkSSDLowerPConeRadius)
7590                                                                             * TanD(fgkSSDPConeAngle);
7591   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7592                                                                               + fgkEndCapSupportCenterLay5Position
7593                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7594   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7595                                                                            - ssdcableslay5startconedistance; 
7596   ssdcablelay5rightsidelength *= ssdcablesfactor;
7597   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7598   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7599                                                                                                 ssdcableslay5rightsideradiusmax,
7600                                                                                                 0.5*ssdcablelay5rightsidelength); 
7601   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7602                                                                                                          ssdcablelay5rightubeshape,
7603                                                                                                          fSSDCopper);
7604   ssdcablelay5righttube->SetLineColor(9);
7605   TGeoTranslation* ssdcablelay5rightrans = 
7606                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7607                                                                                  +              fgkEndCapSupportCenterLay5Position
7608                                                                                  +      0.5*ssdcablelay5rightsidelength);
7609   ////////////////////////////////////
7610   //  Double_t cablescapacity[20];
7611   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7612   ////////////////////////////////////
7613   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7614   ////////////////////////////////////
7615   // TGeoPCone Volumes
7616   ///////////////////////////////////
7617   TGeoPcon* ssdcableslay5pconshape[3];
7618   TGeoVolume* ssdcableslay5pcon[3]; 
7619   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7620   Double_t ssdcableslay5pconzsection[6];
7621   Double_t ssdcableslay5pconrmin[6];
7622   Double_t ssdcableslay5pconrmax[6];
7623   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7624   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7625   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7626   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7627   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7628                                                            + fgkEndCapSupportCenterLay5Position
7629                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7630   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7631                                                            + fgkSSDCentralAL3SupportLength
7632                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7633                                                            * TanD(fgkSSDPConeAngle);      
7634   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7635                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7636   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7637                                                            ssdcableslay5pconshape[0],fSSDCopper);
7638   ssdcableslay5pcon[0]->SetLineColor(9);
7639   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7640 ////////////////////////////////////
7641 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7642 ////////////////////////////////////
7643   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7644   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7645                                                            + fgkSSDCentralAL3SupportLength
7646                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7647                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7648   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7649                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7650                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7651   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7652                                                                                    ssdcableangle,2);   
7653   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7654   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7655   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7656                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7657   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7658   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7659   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7660                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7661   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7662   ssdcableslay5pcon[1]->SetLineColor(9);
7663   ////////////////////////////////////
7664   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7665                                                                                    ssdcableangle,2);   
7666   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7667   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7668   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7669   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7670   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7671   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7672                                                            * TanD(fgkSSDPConeAngle)
7673                                                            + 0.5*fgkSSDCentralSupportLength
7674                                                            + fgkSSDCentralAL3SupportLength;
7675   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7676   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7677                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7678   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7679   ssdcableslay5pcon[2]->SetLineColor(9);
7680 ////////////////////////////////////
7681   TGeoRotation* ssdcableslay5pconrot[4];        
7682   for(Int_t i=0; i<4; i++){
7683    ssdcableslay5pconrot[i] = new TGeoRotation();
7684    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7685    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7686    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7687   }
7688   ////////////////////////////////////
7689   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7690   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7691   ////////////////////////////////////
7692   // Positioning Left SSD Cables Part
7693   ////////////////////////////////////
7694   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7695                                                                                                         - 0.5*ssdcablelay5rightsidelength
7696                                                                                                         - fgkEndCapSupportCenterLay5Position
7697                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7698   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7699   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7700   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7701   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7702   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7703   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7704         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7705         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7706     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7707   }
7708   ////////////////////////////////////
7709   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7710   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7711   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7712   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7713   /////////////////////////////////////////////////////////////
7714   // Water Tubes Layer 5
7715   /////////////////////////
7716   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7717                                                                                      ssdcableslay5rightsideradiusmax
7718                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7719                                                                                      0.5*ssdcablelay5rightsidelength); 
7720   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7721                                                                                                          ssdcablelay5rightubewatershape,
7722                                                                                                          fSSDCoolingTubeWater);
7723   ssdcablelay5rightwatertube->SetLineColor(7);
7724   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7725   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7726   ////////////////////////////////////
7727   // TGeoPCone Water Volumes Layer 
7728   ///////////////////////////////////
7729   TGeoPcon* ssdcableslay5pconwatershape[3];
7730   TGeoVolume* ssdcableslay5pconwater[3]; 
7731   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7732   Double_t ssdcableslay5pconwaterzsection[6];
7733   Double_t ssdcableslay5pcwateronrmin[6];
7734   Double_t ssdcableslay5pconwaterrmax[6];
7735   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7736   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7737                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7738   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7739   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7740                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7741   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7742   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7743   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7744                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7745   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7746                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7747   ssdcableslay5pconwater[0]->SetLineColor(7);
7748   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7749   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7750 ////////////////////////////////////
7751   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7752   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7753   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7754                                                                                                 ssdcableangle,2);   
7755   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7756   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7757                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7758   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7759   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7760                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7761   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7762                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7763   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7764                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7765   ssdcableslay5pconwater[1]->SetLineColor(7);
7766 ////////////////////////////////////
7767   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7768                                                                                                 ssdcableangle,2);   
7769   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7770   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7771                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7772   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7773   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7774                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7775   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7776   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7777   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7778                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7779   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7780                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7781   ssdcableslay5pconwater[2]->SetLineColor(7);
7782 ////////////////////////////////////
7783   TGeoRotation* ssdcableslay5pconwaterot[4];    
7784   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7785   for(Int_t i=0; i<4; i++){
7786    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7787    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7788    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7789         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7790         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7791         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7792         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7793         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7794   }
7795   /////////////////////////
7796   // SSD Layer 6 Cables
7797   /////////////////////////
7798   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7799   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7800   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7801   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7802                                                                                                 ssdcableslay6rightsideradiusmax,
7803                                                                                                 0.5*ssdcablelay6rightsidelength); 
7804   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7805                                                                                                          ssdcablelay6rightubeshape,
7806                                                                                                          fSSDCopper);
7807   ssdcablelay6righttube->SetLineColor(9);
7808   TGeoTranslation* ssdcablelay6rightrans = 
7809                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7810                                                                                  +              fgkEndCapSupportCenterLay6Position
7811                                                                                  +      0.5*ssdcablelay6rightsidelength);
7812   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7813                                                                                                         - 0.5*ssdcablelay6rightsidelength
7814                                                                                                         - fgkEndCapSupportCenterLay6Position
7815                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7816   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7817   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7818   ////////////////////////////////////
7819   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7820   ////////////////////////////////////
7821   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7822                                                                                    ssdcableangle,2);   
7823   TGeoVolume* ssdcableslay6pcon;
7824   Double_t ssdcableslay6pconrmin[2];
7825   Double_t ssdcableslay6pconrmax[2];
7826   Double_t ssdcableslay6pconzsection[2];
7827   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7828   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7829   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7830   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7831   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7832                                                            + fgkEndCapSupportCenterLay6Position
7833                                                            + ssdcablelay6rightsidelength;
7834   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7835   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7836                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7837   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7838                                                            ssdcableslay6pconshape,fSSDCopper);
7839   ssdcableslay6pcon->SetLineColor(9);
7840   for(Int_t i=0; i<4; i++){
7841    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7842    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7843   }
7844   ////////////////////////////////////
7845   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7846   /////////////////////////
7847   // Water Tubes Layer 6
7848   /////////////////////////
7849   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7850                                                                                                                   ssdcableslay6rightsideradiusmax
7851                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7852                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7853   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7854                                                                                                          ssdcablelay6righwatertubeshape,
7855                                                                                                          fSSDCoolingTubeWater);
7856   ssdcablelay6rightwatertube->SetLineColor(7);
7857   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7858   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7859   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7860                                                                                    ssdcableangle,2);   
7861   TGeoVolume* ssdcableslay6waterpcon;
7862   Double_t ssdcableslay6waterpconrmin[2];
7863   Double_t ssdcableslay6waterpconrmax[2];
7864   Double_t ssdcableslay6waterpconzsection[2];
7865   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7866   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7867                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7868   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7869   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7870   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7871                                                            + fgkEndCapSupportCenterLay6Position
7872                                                            + ssdcablelay6rightsidelength;
7873   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7874   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7875                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7876   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7877                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7878   ssdcableslay6waterpcon->SetLineColor(7);
7879   TGeoRotation* ssdcableslay6pconwaterot[4];    
7880   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7881   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7882   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7883   for(Int_t i=0; i<4; i++){
7884    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7885    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7886    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7887                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7888    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7889    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7890   }
7891   ////////////////////////////////////////
7892   // From ITS Ring to Patch Panel3-RB26
7893   ////////////////////////////////////////
7894   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7895   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7896   Double_t ssdcablepatchpanel3RB26zsection[2];
7897   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
7898   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7899                                                                           + fgkSSDCablesLay5RightSideHeight
7900                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7901   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7902   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7903                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7904                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7905   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7906                                                                                  + fgkSSDCentralAL3SupportLength
7907                                                                                  + fgkSSDPConeZLength[0];
7908   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7909   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7910                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7911                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7912   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7913                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7914   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7915                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7916   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7917   TGeoRotation* ssdcablepatchpanel3B26rot[3];
7918   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7919   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7920   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7921                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7922   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7923   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7924                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1],0.0,0.0);
7925   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7926   ////////////////////////////////////
7927   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7928   ////////////////////////////////////////
7929   //  ITS Ring Cables RB26 Part
7930   ////////////////////////////////////////
7931   Double_t ssdcableitsring3BB26pconzsection[2];
7932   Double_t ssdcableitsring3BB26pconrmin[2];
7933   Double_t ssdcableitsring3BB26pconrmax[2];
7934   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7935                                                                           + fgkSSDCentralAL3SupportLength
7936                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7937   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7938   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
7939   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7940                                                                   + fgkSSDCablesLay5RightSideHeight
7941                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
7942   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7943   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7944   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7945   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7946                                                                    -              0.5*ssdcableangle,ssdcableangle
7947                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7948                                                                    -                             fgkSSDCableAngle),2);
7949   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7950                                                                    -              0.5*ssdcableangle,ssdcableangle
7951                                                                    +                      3.0*fgkSSDCableAngle
7952                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7953   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7954                                                                    -              0.5*ssdcableangle,ssdcableangle
7955                                                                    -                      fgkSSDCableAngle
7956                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7957   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7958                                                                    -              0.5*ssdcableangle,ssdcableangle
7959                                                                    +                      3.0*fgkSSDCableAngle
7960                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7961   for(Int_t i=0;i<4;i++)
7962         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7963                                                          ssdcableitsring3BB26pconrmin[j],
7964                                                          ssdcableitsring3BB26pconrmax[j]); 
7965   TGeoVolume* ssdcableitsring3BB26pcon[4];
7966   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7967                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7968   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7969                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7970   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7971                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7972   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7973                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7974   for(Int_t i=0;i<4;i++){
7975         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7976         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7977 }
7978   ////////////////////////////////////
7979   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7980   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7981   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7982   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7983   ////////////////////////////////////////
7984   // From ITS Ring to Patch Panel2-RB24
7985   ////////////////////////////////////////
7986   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7987   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7988   Double_t ssdcablepatchpanel3RB24zsection[2];
7989   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7990   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7991   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7992   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7993                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7994                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7995                                                                           + 0.5*fgkSSDPatchPanelHeigth;
7996   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7997                                                                          -  fgkSSDCentralAL3SupportLength
7998                                                                          -  fgkSSDPConeZLength[0];
7999   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8000   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8001                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8002                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8003   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8004                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8005   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8006                                                                                                 ssdcablepatchpanel3RB24pconshape,
8007                                                                                                 fSSDCopper);
8008   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8009   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8010   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8011   ssdcablepatchpanel3B24rot[0]->SetAngles(0.0,0.0,0.0);
8012   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8013                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8014   ssdcablepatchpanel3B24rot[2]->SetAngles(180.0,0.0,0.0);
8015   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8016                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8017   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8018   ////////////////////////////////////
8019   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8020   ////////////////////////////////////////
8021   //  ITS Ring Cables RB24 Part
8022   ////////////////////////////////////////
8023   Double_t ssdcableitsring3BB24pconzsection[2];
8024   Double_t ssdcableitsring3BB24pconrmin[2];
8025   Double_t ssdcableitsring3BB24pconrmax[2];
8026   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8027   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8028   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8029   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8030                                                                   + fgkSSDCablesLay5RightSideHeight
8031                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8032   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8033   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8034   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8035   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8036                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8037                                                                    -                             fgkSSDCableAngle),2);
8038   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8039                                                                      ssdcableangle-fgkSSDCableAngle
8040                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8041   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8042                                                                    -                      fgkSSDCableAngle
8043                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8044   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8045                                                                                                   ssdcableangle-fgkSSDCableAngle
8046                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8047   for(Int_t i=0;i<4;i++)
8048         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8049                                                          ssdcableitsring3BB24pconrmin[j],
8050                                                          ssdcableitsring3BB24pconrmax[j]); 
8051   TGeoVolume* ssdcableitsring3BB24pcon[4];
8052   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8053                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8054   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8055                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8056   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8057                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8058   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8059                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8060   for(Int_t i=0;i<4;i++){
8061         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8062         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8063 }
8064   ////////////////////////////////////
8065   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8066   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8067   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8068   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8069   ////////////////////////////////////
8070   // Volumes for Material Budget 
8071   ////////////////////////////////////
8072   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8073                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8074                                                                                                          ssdcableslay6rightsideradiusmax
8075                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8076                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8077   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8078                                                                                                          ssdcablelay6materialbudgetubeshape,
8079                                                                                                          fSSDCopper);
8080   ssdcablelay6materialbudgetube->SetLineColor(9);
8081   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8082   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8083
8084   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8085                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8086   TGeoVolume* ssdcablelay6materialbudgetpcon;
8087   Double_t ssdcablelay6materialbudgetpconrmin[2];
8088   Double_t ssdcablelay6materialbudgetpconrmax[2];
8089   Double_t ssdcablelay6materialbudgetpconzsection[2];
8090   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8091                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8092   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8093                                                                                 + fgkSSDCableMaterialBudgetHeight;
8094   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8095   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8096   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8097                                                                                         + fgkEndCapSupportCenterLay6Position
8098                                                                                         + ssdcablelay6rightsidelength;
8099   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8100   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8101                                                   ssdcablelay6materialbudgetpconzsection[i],
8102                                                   ssdcablelay6materialbudgetpconrmin[i],
8103                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8104   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8105                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8106   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8107   for(Int_t i=0; i<4; i++){
8108    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8109    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8110   }
8111 ////////////////////////////////////
8112  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8113   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8114   Double_t ssdcablesvolume = 0.0;
8115   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8116   std::cout << ssdcablesvolume << std::endl;*/
8117   return ssdcablesmother;
8118  }
8119  ////////////////////////////////////////////////////////////////////////////////
8120 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8121                                                                         Double_t height, char* shapename, Int_t isign) const{
8122   /////////////////////////////////////////////////////////////
8123   // Method generating an Arb shape 
8124   /////////////////////////////////////////////////////////////
8125   const Int_t kvertexnumber = 8;
8126   const Int_t ktransvectnumber = 2;
8127   TVector3* vertex[kvertexnumber];
8128   TVector3* transvector[2];
8129   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i] = new TVector3(0.,width[i]);
8130   /////////////////////////////////////////////////////////////
8131   //Setting the vertices for TGeoArb8
8132   /////////////////////////////////////////////////////////////
8133   vertex[0] = new TVector3(*vertexpos[0]);
8134   vertex[1] = new TVector3(*vertexpos[1]);
8135   vertex[2] = new TVector3(*vertex[1]+isign*(*transvector[0]));
8136   vertex[3] = new TVector3(*vertex[0]+isign*(*transvector[0]));
8137   vertex[4] = new TVector3(*vertexpos[2]);
8138   vertex[5] = new TVector3(*vertexpos[3]);
8139   vertex[6] = new TVector3(*vertex[5]+isign*(*transvector[1]));
8140   vertex[7] = new TVector3(*vertex[4]+isign*(*transvector[1]));
8141   /////////////////////////////////////////////////////////////
8142   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8143   for(Int_t i = 0; i<kvertexnumber;i++) 
8144                                                         arbshape->SetVertex(i,vertex[i]->X(),vertex[i]->Y());
8145   /////////////////////////////////////////////////////////////
8146   // Deallocating memory
8147   /////////////////////////////////////////////////////////////
8148   for(Int_t i=0; i< kvertexnumber; i++) delete vertex[i];  
8149   for(Int_t i=0; i< ktransvectnumber; i++) delete transvector[i];  
8150   /////////////////////////////////////////////////////////////
8151   return arbshape;
8152
8153 ///////////////////////////////////////////////////////////////////////////////
8154 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8155                                                                 Double_t rmax, Int_t nedges, Double_t height){
8156   /////////////////////////////////////////////////////////////
8157   // Method generating Arc shape 
8158   /////////////////////////////////////////////////////////////
8159         const Int_t kvertexnumber = 2*nedges+2;
8160         TGeoXtru* arcshape = new TGeoXtru(2);   
8161         TVector3** vertexposition[2];
8162         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8163         Double_t angle = 0.;
8164     for(Int_t i=0; i<nedges+1; i++){ 
8165                 angle = 90.+0.5*phi-i*(phi/nedges);
8166                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8167                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8168         }
8169         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8170         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8171         for(Int_t i=0; i<kvertexnumber; i++){ 
8172                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8173                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8174                 }
8175                 else if(i>=1&&i<nedges+2)
8176                 {
8177                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8178                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8179                 }
8180         else
8181                 {
8182                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8183                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8184                 }
8185     }
8186   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8187   arcshape->DefineSection(0,-0.5*height);
8188   arcshape->DefineSection(1,0.5*height);
8189   /////////////////////////////////////////////////////////////
8190   // Deallocating memory
8191   /////////////////////////////////////////////////////////////
8192   for(Int_t i=0; i<2; i++){
8193         for(Int_t j=0; j<nedges+1; j++)
8194                 delete vertexposition[i][j];
8195         delete [] vertexposition[i];
8196   }
8197   delete [] xvertexpoints;
8198   delete [] yvertexpoints;
8199   /////////////////////////////////////////////////////////////
8200         return arcshape;
8201 }
8202 ////////////////////////////////////////////////////////////////////////////////
8203 TGeoXtru* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8204   ///////////////////////////////////////////////////////////////////////
8205   // Method Generating the Screw Shape  
8206   // radius[0]: outer radius
8207   // radius[1]: inner radius
8208   // edgesnumber[0]: outer number of edges
8209   // edgesnumber[1]: inner number of edges
8210   // section[0]: lower section position
8211   // section[1]: higher section position
8212   ///////////////////////////////////////////////////////////////////////
8213   Double_t outradius = radius[0];
8214   Double_t inradius = radius[1];
8215   Int_t outvertexnumber = edgesnumber[0];
8216   Int_t invertexnumber = edgesnumber[1];
8217   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8218   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber+2];
8219   for(Int_t i=0; i<outvertexnumber+1; i++){
8220         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8221         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8222   }
8223   for(Int_t i=0; i<invertexnumber+1; i++){
8224         xscrewvertex[outvertexnumber+i+1] = inradius*CosD(90.-i*360./invertexnumber);
8225         yscrewvertex[outvertexnumber+i+1] = inradius*SinD(90.-i*360./invertexnumber);
8226   }
8227   TGeoXtru* screwshape = new TGeoXtru(2);
8228   screwshape->DefinePolygon(outvertexnumber+invertexnumber+2,xscrewvertex,yscrewvertex);
8229   screwshape->DefineSection(0,section[0]);
8230   screwshape->DefineSection(1,section[1]);
8231   delete [] xscrewvertex;
8232   delete [] yscrewvertex;
8233   return screwshape;
8234 }
8235 ////////////////////////////////////////////////////////////////////////////////
8236 TGeoXtru* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8237   ///////////////////////////////////////////////////////////////////////
8238   // Method Generating the Hole Shape  
8239   // radius of the Hole
8240   // nedges: number of edges to approximate the circle
8241   ///////////////////////////////////////////////////////////////////////
8242   Int_t vertexnumber = nedges+6;
8243   Double_t* xholevertex = new Double_t[vertexnumber];
8244   Double_t* yholevertex = new Double_t[vertexnumber];
8245   xholevertex[0] = radius;
8246   xholevertex[1] = xholevertex[0];
8247   xholevertex[2] = -xholevertex[1];
8248   xholevertex[3] = xholevertex[2];
8249   xholevertex[4] = xholevertex[0];
8250   yholevertex[0] = 0.;
8251   yholevertex[1] = -radius;
8252   yholevertex[2] = yholevertex[1];
8253   yholevertex[3] = -yholevertex[1];
8254   yholevertex[4] = yholevertex[3];
8255   for(Int_t i=0; i<nedges+1; i++){
8256         xholevertex[i+5] = radius*CosD(i*360./nedges);
8257         yholevertex[i+5] = radius*SinD(i*360./nedges);
8258   }
8259   TGeoXtru* holeshape = new TGeoXtru(2);
8260   holeshape->DefinePolygon(vertexnumber,xholevertex,yholevertex);
8261   holeshape->DefineSection(0,section[0]);
8262   holeshape->DefineSection(1,section[1]);
8263   delete [] xholevertex;
8264   delete [] yholevertex;
8265   return holeshape;
8266 }
8267 ////////////////////////////////////////////////////////////////////////////////
8268 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8269   /////////////////////////////////////////////////////////////
8270   // Given an axis specified by param, it gives the reflection of the point
8271   // respect to the axis
8272   /////////////////////////////////////////////////////////////
8273   TVector3* n = new TVector3(param[0],param[1],param[2]);
8274   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8275   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8276   /////////////////////////////////////////////////////////////
8277   // Deallocating memory
8278   /////////////////////////////////////////////////////////////
8279   delete n;
8280   /////////////////////////////////////////////////////////////
8281   return reflectedvector;
8282 }
8283 ////////////////////////////////////////////////////////////////////////////////
8284 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8285                                                        Double_t dx,
8286                                                        Double_t dy,
8287                                                        Double_t dz) const{
8288   /////////////////////////////////////////////////////////////
8289   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8290   /////////////////////////////////////////////////////////////
8291   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8292   const Double_t *vect = hmatrix->GetTranslation();
8293   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8294   hmatrix->SetTranslation(newvect);
8295   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8296   delete hmatrix;
8297   return matrix;
8298 }
8299 ////////////////////////////////////////////////////////////////////////////////
8300 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8301   /////////////////////////////////////////////////////////////
8302   // Method returning the Medium type 
8303   /////////////////////////////////////////////////////////////
8304   char ch[30];
8305   sprintf(ch, "ITS_%s",mediumName);
8306   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8307   if (! medium)
8308     printf("Error(AliITSv11GeometrySSD)::medium %s not found !\n", mediumName);
8309   return medium;
8310 }
8311 ////////////////////////////////////////////////////////////////////////////////
8312 void AliITSv11GeometrySSD::CreateMaterials(){
8313 ///////////////////////////////////
8314 // This part has to be modified
8315 ///////////////////////////////////
8316   ///////////////////////////////////
8317   // Silicon for Sensor
8318   /////////////////////////////////// 
8319   fSSDSensorMedium = GetMedium("SI$");
8320   ///////////////////////////////////
8321   // Silicon Mixture for Sensor
8322   /////////////////////////////////// 
8323   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8324   fSSDChipGlueMedium = GetMedium("EPOXY$");
8325   ///////////////////////////////////
8326   // Stiffener Components Materials
8327   /////////////////////////////////// 
8328   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8329   ///////////////////////////  
8330   // Stiffener Connectors 
8331   ///////////////////////////  
8332   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8333   ////////////////////////////////  
8334   // Stiffener 0603-1812 Capacitor
8335   ////////////////////////////////  
8336   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8337   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8338   ///////////////////////////  
8339   // Stiffener Hybrid Wire 
8340   ///////////////////////////  
8341   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8342   ///////////////////////////  
8343   // Al for Cooling Block
8344   ///////////////////////////  
8345   fSSDAlCoolBlockMedium = GetMedium("AL$");
8346   //////////////////////////////////////////////////////  
8347   // Kapton and Al for Chip Cable Flex and Ladder Cables
8348   //////////////////////////////////////////////////////  
8349   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8350   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8351   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8352   fSSDAlTraceFlexMedium = GetMedium("AL$");
8353   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8354   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8355   /////////////////////////////////////////////////////////////////  
8356   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8357   //////////////////////////////////////////////////////////////////  
8358   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8359   /////////////////////////////////////////////////////////////////  
8360   // G10 for Detector Leg, TubeHolder
8361   //////////////////////////////////////////////////////////////////  
8362   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8363   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8364   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8365   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8366   /////////////////////////////////////////////////////////////////  
8367   // Water and Phynox for Cooling Tube
8368   //////////////////////////////////////////////////////////////////  
8369   fSSDCoolingTubeWater = GetMedium("WATER$");
8370   fSSDCoolingTubePhynox = GetMedium("INOX$");
8371   /////////////////////////////////////////////////////////////////////
8372   // Material for Support Rings
8373   /////////////////////////////////////////////////////////////////////
8374   fSSDSupportRingAl = GetMedium("AL$");
8375   fSSDRohaCellCone = GetMedium("ROHACELL$");
8376   /////////////////////////////////////////////////////////////////////
8377   fSSDAir = GetMedium("SDD AIR$");
8378   fSSDCopper = GetMedium("COPPER$");
8379   fCreateMaterials = kTRUE;
8380 }
8381 /////////////////////////////////////////////////////////////////////