]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Version of the SSD geometry that fixes the overlaps with residual misalignment.
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySSD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //*************************************************************************
19 // SSD geometry, based on ROOT geometrical modeler
20 //
21 // Enrico Cattaruzza                                    ecattar@ts.infn.it
22 //*************************************************************************
23 #include "TMath.h"
24 #include "TGeoVolume.h"
25 #include "TGeoMatrix.h"
26 #include <TGeoManager.h>
27 #include "TVector3.h"
28 #include "TGeoArb8.h"
29 #include "TList.h"
30 #include "TGeoMatrix.h"
31 #include "TGeoCompositeShape.h"
32 #include "TGeoBoolNode.h"
33 #include "TGeoTube.h"
34 #include "TGeoBBox.h"
35 #include "TGeoXtru.h"
36 #include "TGeoTorus.h"
37 #include "TGeoPgon.h"
38 #include "TGeoPcon.h"
39 #include "TRotation.h"
40 #include "AliITSv11GeometrySSD.h"
41 #include "Riostream.h"
42 /////////////////////////////////////////////////////////////////////////////////
43 // Names of the Sensitive Volumes of Layer 5 and Layer 6
44 /////////////////////////////////////////////////////////////////////////////////
45 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
47 /////////////////////////////////////////////////////////////////////////////////
48 //Parameters for SSD Geometry
49 /////////////////////////////////////////////////////////////////////////////////
50 // Variable for Vertical Disalignement of Modules
51 /////////////////////////////////////////////////////////////////////////////////
52 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
55 // For ladders:
56 const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.2*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
92 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
93 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
94 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
95 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
96 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
97 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
98 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
99 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
100 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
101 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
102 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
103                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
104 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
105 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
106 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
107 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
108                                                                                                           0.25*fgkSSDStiffenerHeight;
109 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
110 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
111 /////////////////////////////////////////////////////////////////////////////////
112 // Cooling Block (lengths are in mm and angles in degrees)
113 /////////////////////////////////////////////////////////////////////////////////
114 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
115 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
116 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
117                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
118 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
119                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
120 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
121                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
122 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
123                                                                                                                                          1.500*fgkmm;
124 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
125                                                                                                                                          0.300*fgkmm;
126 /////////////////////////////////////////////////////////////////////////////////
127 // SSD Sensor (lengths are in mm and angles in degrees)
128 /////////////////////////////////////////////////////////////////////////////////
129 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
130                                                                                                                  "SSDSensorSensitiveVol";
131 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
132 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
133 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
134 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
135                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
136 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
137 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
138 /////////////////////////////////////////////////////////////////////////////////
139 // Flex (lengths are in mm and angles in degrees)
140 /////////////////////////////////////////////////////////////////////////////////
141 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
142 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
143                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
144                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
145                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
146                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
147                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
148 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
149                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
150 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
151                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
152 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
153 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
154 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
155 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
156                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
157 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
158                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
159 /////////////////////////////////////////////////////////////////////////////////
160 // SSD Ladder Cable (lengths are in mm and angles in degrees)
161 /////////////////////////////////////////////////////////////////////////////////
162 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
163 /////////////////////////////////////////////////////////////////////////////////
164 // SSD Module (lengths are in mm and angles in degrees)
165 /////////////////////////////////////////////////////////////////////////////////
166 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
167                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
168 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
169                                                                                                                                         45.600*fgkmm;
170 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
171                                                                                                                                          5.075*fgkmm;
172 /////////////////////////////////////////////////////////////////////////////////
173 // Sensor Support (lengths are in mm and angles in degrees)
174 /////////////////////////////////////////////////////////////////////////////////
175 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
176                                                                                                                                          5.800*fgkmm;
177 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
178                                                                                                                                          2.000*fgkmm;
179 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
180                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
181                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
182 //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
183 //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
184 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
185                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
186 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
187                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
188                                                             +  fgkSSDSensorSideSupportThickness[0])
189                                                                 -  fgkSSDSensorSideSupportLength;
190 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
191                                                                                                                                     5.250*fgkmm;
192 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
193                                                                                                                                         1.680*fgkmm;
194 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
195                                                                   = {fgkSSDSensorSideSupportHeight[0]
196                                                                   +  fgkSSDSensorSideSupportThickness[0],
197                                                                          fgkSSDSensorSideSupportHeight[1]
198                                                                   +  fgkSSDSensorSideSupportThickness[1]};
199 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
200                                                                   =  {fgkSSDSensorSideSupportThickness[0],
201                                                                           fgkSSDSensorSideSupportThickness[1]};
202 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
203                                                                                                                                    19.000*fgkmm;
204 /////////////////////////////////////////////////////////////////////////////////
205 // Chip Cables (lengths are in mm and angles in degrees)
206 /////////////////////////////////////////////////////////////////////////////////
207 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
208                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
209 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
210                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
211                                                                   -  (fgkSSDSensorSideSupportHeight[1]
212                                                                   -   fgkSSDSensorSideSupportHeight[0])
213                                                                   -   fgkSSDModuleVerticalDisalignment
214                                                                   -   fgkSSDCoolingBlockHoleCenter
215                                                                   -   fgkSSDStiffenerHeight
216                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
217                                                                           fgkSSDModuleCoolingBlockToSensor
218                                                                   -   fgkSSDModuleVerticalDisalignment  
219                                                                   -   fgkSSDCoolingBlockHoleCenter
220                                                                   -       fgkSSDStiffenerHeight
221                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
222 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
223                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
224 /////////////////////////////////////////////////////////////////////////////////
225 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
226 /////////////////////////////////////////////////////////////////////////////////
227 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
228                                                                                                                                         3.820*fgkmm;
229 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
230 //                                                                                                                                         3.780;
231 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
232                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
233 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
234                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
235 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
236                                                                                                                                 { 30.00, 90.00};
237 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
238                                                                                                                                          1.78*fgkmm;
239 /////////////////////////////////////////////////////////////////////////////////
240 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
241 /////////////////////////////////////////////////////////////////////////////////
242 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
243                                                                    = fgkSSDModuleSensorSupportDistance
244                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
245 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
247                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
249                                                                                                                                         1.630*fgkmm;
250 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
251 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
252                                                                         = fgkCarbonFiberTriangleLength
253                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
254                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
255                                                                         * TMath::DegToRad());
256 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
257                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
258                                                                         - fgkCarbonFiberSupportWidth)
259                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
260                                                                         - fgkCarbonFiberSupportWidth;
261 /////////////////////////////////////////////////////////////////////////////////
262 // Carbon Fiber Lower Support Parameters (lengths are in mm)
263 /////////////////////////////////////////////////////////////////////////////////
264 const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
265 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
266                                                                                                                                           =  0.950*fgkmm;
267 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
268                                                                                                                                           =  1.600*fgkmm;
269 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
270                                                                                                                                           =  0.830*fgkmm;
271 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
272                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
273 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
274                                                                         = fgkCarbonFiberJunctionWidth
275                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
276                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
277 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
278                                                                         = {fgkCarbonFiberLowerSupportWidth
279                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
280                                                                            fgkCarbonFiberLowerSupportWidth
281                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
282                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
283 /////////////////////////////////////////////////////////////////////////////////
284 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
285 /////////////////////////////////////////////////////////////////////////////////
286 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
287                                                            {0.5 * (fgkSSDLay5LadderLength
288                                                                         -  fgkSSDLay5SensorsNumber
289                                                                         *  fgkCarbonFiberJunctionWidth
290                                                                         -  fgkCarbonFiberLowerSupportWidth),
291                                                                 0.5 * (fgkSSDLay5LadderLength
292                                                                         -  fgkSSDLay5SensorsNumber
293                                                                         *  fgkCarbonFiberJunctionWidth
294                                                                         +  fgkCarbonFiberLowerSupportWidth)};
295 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
296                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
297                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
298 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
299                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
300                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
301 const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
302                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
303 /////////////////////////////////////////////////////////////////////////////////
304 // Cooling Tube Support (lengths are in mm and angles in degrees)
305 /////////////////////////////////////////////////////////////////////////////////
306 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
307 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
308                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
309 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
310 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
311 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
312 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
313                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
314 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
315                                                                                                                                           11.70*fgkmm;
316 /////////////////////////////////////////////////////////////////////////////////
317 // Cooling Tube (lengths are in mm and angles in degrees)
318 /////////////////////////////////////////////////////////////////////////////////
319 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
320 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
321 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
322                                                                                                         fgkCarbonFiberJunctionWidth;
323 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
324                                                                          fgkSSDModuleSensorSupportDistance
325                                                                   +      fgkSSDCoolingBlockLength;
326 const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
327 /////////////////////////////////////////////////////////////////////////////////
328 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
329 /////////////////////////////////////////////////////////////////////////////////
330 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
331                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
332 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
333                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
334 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
335                                                                                                                                           20.0*fgkmm;
336 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
337                                                                                                                                                     40.0;
338 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
339                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
340 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
341                                                                                                                                           2.5*fgkmm;
342 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
343                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
344 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
345                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
346 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
347                                                                                                                                           1.0*fgkmm;
348 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
349                                                                                                                                           6.0*fgkmm;
350 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
351                                                                                                                                           4.0*fgkmm;
352 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
353                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
354 /////////////////////////////////////////////////////////////////////////////////
355 // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
356 /////////////////////////////////////////////////////////////////////////////////
357 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
358 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
359 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
360 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
361 const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
362 /////////////////////////////////////////////////////////////////////////////////
363 // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
364 /////////////////////////////////////////////////////////////////////////////////
365 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
366 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
367 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
368                                                                                                   -  fgkSSDMountingBlockHeight[1]
369                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
370                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
371                                                                                                   -      fgkMountingBlockSupportDownHeight,
372                                                                                                          fgkSSDLay6RadiusMin
373                                                                                                   -  fgkSSDMountingBlockHeight[1]
374                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
375                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
376                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
377 const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
378                                                                                                     -  fgkSSDMountingBlockHeight[1]
379                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
380                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
381                                                                                                         -  fgkMountingBlockSupportRadius[0],
382                                                                                                            fgkSSDLay6RadiusMax
383                                                                                                     -  fgkSSDMountingBlockHeight[1]
384                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
385                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
386                                                                                                         -  fgkMountingBlockSupportRadius[1]};
387 const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeigth = 10.0*fgkmm; // To be verified
388 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
389 const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
390 /////////////////////////////////////////////////////////////////////////////////
391 // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
392 /////////////////////////////////////////////////////////////////////////////////
393 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
394 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
395 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
396 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
397                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
398 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
399                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
400 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
401                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
402 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
403 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
404 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
405 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
406 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
407 const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
408 /////////////////////////////////////////////////////////////////////////////////
409 // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
410 /////////////////////////////////////////////////////////////////////////////////
411 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
412 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
413 const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
414 /////////////////////////////////////////////////////////////////////////////////
415 // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
416 /////////////////////////////////////////////////////////////////////////////////
417 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
418                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
419 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
420 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
421 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
422                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
423 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
424                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
425 const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
426 /////////////////////////////////////////////////////////////////////////////////
427 // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
428 /////////////////////////////////////////////////////////////////////////////////
429 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
430                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
431 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
432                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
433                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
434 const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
435 /////////////////////////////////////////////////////////////////////////////////
436 // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
437 /////////////////////////////////////////////////////////////////////////////////
438 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
439                                                                                                            {62.0*fgkmm,21.87*fgkmm};
440 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
441                                                                                                             {47.0*fgkmm,0.35*fgkmm};
442 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
443                                                                                                                                           1.0*fgkmm;
444 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
445 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
446                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
447 const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
448                                                                                                                                          0.15*fgkmm;
449 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
450                                                                                                                                          19.0*fgkmm;
451 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
452                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
453 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
454                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
455 const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
456                                                                                                                                           2.1*fgkmm;
457 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
458                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
459 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
460                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
461 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
462                                                                                                                                            19*fgkmm; 
463 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
464                                                                                                                                           1.0*fgkmm;
465 const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
466                                                                                                                                           3.6*fgkmm;
467 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
468                                                                                                                                          61.0*fgkmm; 
469 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
470                                                                                                                                          5.97*fgkmm; 
471 const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
472 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
473                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
474                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
475 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
476                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
477 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
478                                                                                                                                           1.0*fgkmm; 
479 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
480                                                                                                                                    = 0.15*fgkmm; 
481 const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
482                                                                                                                                          20.0*fgkmm;
483 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
484 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
485 const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
486 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
487 const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
488 /////////////////////////////////////////////////////////////////////////////////
489 // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
490 /////////////////////////////////////////////////////////////////////////////////
491 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
492 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
493 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
494 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
495 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
496 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 625.0*fgkmm;
497 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
498 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
499 const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
500 /////////////////////////////////////////////////////////////////////////////////
501 // SSD Cone Parameters (lengths are in mm and angles in degrees)
502 /////////////////////////////////////////////////////////////////////////////////
503 const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
504 const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
505 const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
506 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
507 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
508 const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
509 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
510 const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
511 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
512 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
513 const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
514 const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
515 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
516 const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
517 const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
518 const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
519 const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
520 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
521 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
522 const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
523 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
524 const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
525 /////////////////////////////////////////////////////////////////////////////////
526 // SSD Cables Parameters (lengths are in mm and angles in degrees)
527 /////////////////////////////////////////////////////////////////////////////////
528 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
529 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
530 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
531 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay6RightSideHeight = 7.*fgkmm;  // to be fixed in order to reproduce material budget
532 const Double_t AliITSv11GeometrySSD::fgkSSDCableAngle = 22.5;
533 const Double_t AliITSv11GeometrySSD::fgkSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
534 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
535 const Double_t AliITSv11GeometrySSD::fgkSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
536 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
537 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
538 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = 451.3*fgkmm;
539 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = 451.3*fgkmm;
540 const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanelHeigth = 87.5*fgkmm;
541 const Double_t AliITSv11GeometrySSD::fgkSSDCableMaterialBudgetHeight = 20.0*fgkmm;
542 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB26Radius = fgkSSDPConeExternalRadius;
543 //const Double_t AliITSv11GeometrySSD::fgkSSDPatchPanel2RB24Radius = fgkSSDPConeExternalRadius;
544 /////////////////////////////////////////////////////////////////////////////////
545 ClassImp(AliITSv11GeometrySSD)
546 /////////////////////////////////////////////////////////////////////////////////
547 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
548   AliITSv11Geometry(),
549   fSSDChipMedium(),
550   fSSDChipGlueMedium(),
551   fSSDStiffenerMedium(),
552   fSSDStiffenerConnectorMedium(),
553   fSSDStiffener0603CapacitorMedium(),
554   fSSDStiffener1812CapacitorMedium(),
555   fSSDStiffenerHybridWireMedium(),
556   fSSDKaptonFlexMedium(),
557   fSSDAlTraceFlexMedium(),
558   fSSDAlTraceLadderCableMedium(),
559   fSSDKaptonLadderCableMedium(),
560   fSSDKaptonChipCableMedium(),
561   fSSDAlTraceChipCableMedium(),
562   fSSDAlCoolBlockMedium(),
563   fSSDSensorMedium(),
564   fSSDSensorSupportMedium(),
565   fSSDCarbonFiberMedium(),
566   fSSDTubeHolderMedium(),
567   fSSDCoolingTubeWater(),
568   fSSDCoolingTubePhynox(),
569   fSSDSupportRingAl(),
570   fSSDMountingBlockMedium(),
571   fSSDRohaCellCone(),
572   fSSDAir(),
573   fSSDCopper(),
574   fCreateMaterials(kFALSE),
575   fTransformationMatrices(kFALSE),
576   fBasicObjects(kFALSE),
577   fcarbonfiberjunction(),
578   fcoolingtubesupport(),
579   fhybridmatrix(),
580   fssdcoolingblocksystem(),
581   fcoolingblocksystematrix(),
582   fssdstiffenerflex(),
583   fssdendflex(),
584   fendladdercoolingtubesupportmatrix(),
585   fendladdermountingblock(),
586   fendladdermountingblockclip(),
587   fSSDSensor5(),
588   fSSDSensor6(),
589   fSSDLayer5(), 
590   fSSDLayer6(),
591   fMotherVol(),
592   fLay5LadderSupportRing(),
593   fLay6LadderSupportRing(),
594   fgkEndCapSupportSystem(),
595   fSSDCone(),
596   fColorCarbonFiber(4),
597   fColorRyton(5),
598   fColorPhynox(14),
599   fColorSilicon(3),
600   fColorAl(38),
601   fColorKapton(6),
602   fColorPolyhamide(5),
603   fColorStiffener(9),
604   fColorEpoxy(30),
605   fColorWater(7),
606   fColorG10(41)
607 {
608   ////////////////////////
609   // Standard constructor
610   ////////////////////////
611 }
612 /////////////////////////////////////////////////////////////////////////////////
613 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
614   AliITSv11Geometry(s.GetDebug()),
615   fSSDChipMedium(s.fSSDChipMedium),
616   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
617   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
618   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
619   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
620   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
621   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
622   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
623   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
624   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
625   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
626   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
627   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
628   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
629   fSSDSensorMedium(s.fSSDSensorMedium),
630   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
631   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
632   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
633   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
634   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
635   fSSDSupportRingAl(s.fSSDSupportRingAl),
636   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
637   fSSDRohaCellCone(s.fSSDRohaCellCone),
638   fSSDAir(s.fSSDAir),
639   fSSDCopper(s.fSSDCopper),
640   fCreateMaterials(s.fCreateMaterials),
641   fTransformationMatrices(s.fTransformationMatrices),
642   fBasicObjects(s.fBasicObjects),
643   fcarbonfiberjunction(s.fcarbonfiberjunction),
644   fcoolingtubesupport(s.fcoolingtubesupport),
645   fhybridmatrix(s.fhybridmatrix),
646   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
647   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
648   fssdstiffenerflex(s.fssdstiffenerflex),
649   fssdendflex(s.fssdendflex),
650   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
651   fendladdermountingblock(s.fendladdermountingblock),
652   fendladdermountingblockclip(s.fendladdermountingblockclip),
653   fSSDSensor5(s.fSSDSensor5),
654   fSSDSensor6(s.fSSDSensor6),
655   fSSDLayer5(s.fSSDLayer5),     
656   fSSDLayer6(s.fSSDLayer6),
657   fMotherVol(s.fMotherVol),
658   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
659   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
660   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
661   fSSDCone(s.fSSDCone),
662   fColorCarbonFiber(s.fColorCarbonFiber),
663   fColorRyton(s.fColorRyton),
664   fColorPhynox(s.fColorPhynox),
665   fColorSilicon(s.fColorSilicon),
666   fColorAl(s.fColorAl),
667   fColorKapton(s.fColorKapton),
668   fColorPolyhamide(s.fColorPolyhamide),
669   fColorStiffener(s.fColorStiffener),
670   fColorEpoxy(s.fColorEpoxy),
671   fColorWater(s.fColorWater),
672   fColorG10(s.fColorG10)
673 {
674   ////////////////////////
675   // Copy Constructor
676   ////////////////////////
677 }
678 /////////////////////////////////////////////////////////////////////////////////
679 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
680 operator=(const AliITSv11GeometrySSD &s){
681   ////////////////////////
682   // Assignment operator
683   ////////////////////////
684   this->~AliITSv11GeometrySSD();
685   new(this) AliITSv11GeometrySSD(s); 
686   return *this;
687 /*      
688   if(&s == this) return *this;
689   fMotherVol = s.fMotherVol;
690   return *this;
691  */
692 }
693 ///////////////////////////////////////////////////////////////////////////////
694 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
695   ///////////////////////////////////////////////////////////////////////  
696   // Method generating the trasformation matrix for the whole SSD Geometry   
697   ///////////////////////////////////////////////////////////////////////  
698   // Setting some variables for Carbon Fiber Supportmatrix creation
699   //////////////////////////////////////////////////////////////////////
700   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
701                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
702   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
703                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
704                                                                  +      fgkCarbonFiberSupportWidth);
705   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
706                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
707   TGeoRotation* carbonfiberot[3];
708   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
709   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
710   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
711   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
712   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
713                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
714                                                   -  fgkCarbonFiberTriangleLength
715                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
716   ///////////////////////////////////////////
717   //Setting Local Translations and Rotations: 
718   ///////////////////////////////////////////
719   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
720   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
721                                                                          0.5*carbonfibersupportheight,NULL);    
722   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
723                                                                          2.*symmetryplaneposition+transvector[1],
724                                                                          transvector[2], carbonfiberot[2]);
725   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
726   /////////////////////////////////////////////////////////////
727   // Carbon Fiber Support Transformations
728   /////////////////////////////////////////////////////////////
729   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
730   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
731                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
732                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
733                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
734   }             
735   /////////////////////////////////////////////////////////////
736   // Carbon Fiber Junction Transformation
737   /////////////////////////////////////////////////////////////
738   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
739   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
740   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
741   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
742   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
743         localcarbonfiberjunctionmatrix[i] = 
744                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
745         localcarbonfiberjunctionrot[i] = 
746                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
747         localcarbonfiberjunctiontrans[i] = 
748                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
749   }
750   ///////////////////////
751   // Setting Translations
752   ///////////////////////
753   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
754   localcarbonfiberjunctiontrans[1][0] = 
755                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
756   localcarbonfiberjunctiontrans[2][0] = 
757                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
758                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
759                                  fgkCarbonFiberTriangleLength
760                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
761   localcarbonfiberjunctiontrans[0][1] = 
762                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
763   localcarbonfiberjunctiontrans[1][1] = 
764                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
765   localcarbonfiberjunctiontrans[2][1] = 
766                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
767   ////////////////////
768   // Setting Rotations
769   ////////////////////
770   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
771                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
772                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
773   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
774         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
775   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
776   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
777   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
778   ////////////////////////////////////////
779   // Setting Carbon Fiber Junction matrix 
780   ////////////////////////////////////////
781   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
782                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
783                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
784                         localcarbonfiberjunctionmatrix[i][j] = 
785                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
786                                                            *localcarbonfiberjunctionrot[i][j]);
787                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
788          }
789   }
790   /////////////////////////////////////////////////////////////
791   // Carbon Fiber Lower Support Transformations
792   /////////////////////////////////////////////////////////////
793   TGeoTranslation* localcarbonfiberlowersupportrans[2];
794   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
795                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
796                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
797                                                                          0.0);
798   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
799                                                                          fgkCarbonFiberJunctionWidth
800                                                                 -    fgkCarbonFiberLowerSupportWidth
801                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
802                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
803                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
804    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
805    fcarbonfiberlowersupportrans[0] = 
806                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
807    fcarbonfiberlowersupportrans[1] = 
808                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
809   /////////////////////////////////////////////////////////////
810   // SSD Sensor Support Transformations
811   /////////////////////////////////////////////////////////////
812   const Int_t kssdsensorsupportmatrixnumber = 3;
813   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
814   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
815   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
816   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
817         localssdsensorsupportmatrix[i] = 
818                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
819         localssdsensorsupportrot[i] = 
820                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
821         localssdsensorsupportrans[i] = 
822                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
823   }
824   ///////////////////////
825   // Setting Translations
826   ///////////////////////
827   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
828                                                                           0.5*fgkSSDSensorSideSupportWidth,
829                                                                           0.0);
830   localssdsensorsupportrans[1][0] = 
831                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
832   localssdsensorsupportrans[2][0] = 
833                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
834   localssdsensorsupportrans[0][1] = 
835                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
836                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
837                                                                                 0.0);
838   localssdsensorsupportrans[1][1] = 
839                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
840                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
841                                                                     -   fgkSSDModuleSensorSupportDistance,
842                                                                                 0.0);
843   localssdsensorsupportrans[2][1] = 
844                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
845                                                                         -    fgkSSDSensorCenterSupportPosition,
846                                                                                  0.5*fgkSSDSensorCenterSupportWidth
847                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
848                                                                                  fgkSSDSensorCenterSupportThickness[0]);
849   localssdsensorsupportrans[0][2] = 
850                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
851                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
852                                                                                  fgkCarbonFiberJunctionWidth
853                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
854                                                                         +    fgkSSDSensorCenterSupportLength
855                                                                         -    fgkSSDSensorCenterSupportThickness[0])
856                                                                         -    fgkSSDSensorCenterSupportPosition,
857                                                                              0.0);
858   localssdsensorsupportrans[1][2] = 
859                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
860   localssdsensorsupportrans[2][2] = 
861                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
862   ////////////////////
863   // Setting Rotations
864   ////////////////////
865   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
866                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
867                         localssdsensorsupportrot[i][j] = new TGeoRotation();
868   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
869         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
870         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
871   }
872   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
873   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
874   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
875   ////////////////////////////////////////
876   // SSD Sensor Support matrix 
877   ////////////////////////////////////////
878   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
879                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
880                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
881                         localssdsensorsupportmatrix[i][j] = 
882                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
883                                                            *localssdsensorsupportrot[i][j]);
884                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
885          }
886   }
887   /////////////////////////////////////////////////////////////
888   // SSD Cooling Tube Support Transformations
889   /////////////////////////////////////////////////////////////
890   const Int_t kcoolingtubesupportmatrixnumber = 2;
891   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
892   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
893   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
894   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
895                                                                                                         /fgkCoolingTubeSupportRmax);
896   localcoolingtubesupportrans[0] = 
897                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
898                                                 +  2.*(fgkCoolingTubeSupportLength
899                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
900                                                 +  fgkCarbonFiberTriangleLength
901                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
902   localcoolingtubesupportrans[1] = 
903                         new TGeoTranslation(fgkCarbonFiberJunctionLength
904                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
905                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
906                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
907                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
908                     -  0.5*(fgkCarbonFiberLowerSupportWidth
909                                         +          fgkSSDSensorCenterSupportLength
910                     -      fgkSSDSensorCenterSupportThickness[0])
911                                         +  0.5*fgkSSDSensorLength,
912                                         -  0.5*fgkCoolingTubeSupportHeight);  
913   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
914   localcoolingtubesupportrot[i] = new TGeoRotation();
915   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
916   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
917   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
918         localcoolingtubesupportmatrix[i] = 
919                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
920                                                    *localcoolingtubesupportrot[i]);
921   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
922   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
923                                                                 (*localcoolingtubesupportmatrix[0]));
924   /////////////////////////////////////////////////////////////
925   // End Ladder SSD Cooling Tube Support Transformations
926   /////////////////////////////////////////////////////////////
927   TGeoTranslation** localendladdercooltubetrans[2];
928   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
929   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
930   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
931   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
932                                                                                         -          (fgkCoolingTubeSupportLength
933                                                                                         -               fgkCoolingTubeSupportRmax),
934                                                                                                         fgkEndLadderMountingBlockPosition[0]
935                                                                                         -               fgkendladdercoolingsupportdistance[0]
936                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
937                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
938   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
939                                                                                         -          (fgkCoolingTubeSupportLength
940                                                                                         -               fgkCoolingTubeSupportRmax),
941                                                                                                         fgkEndLadderMountingBlockPosition[0]
942                                                                                         +               fgkendladdercoolingsupportdistance[1]
943                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
944                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
945   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
946                                                                                         -       fgkCoolingTubeSupportRmax)
947                                                                                         +               fgkCarbonFiberTriangleLength
948                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
949                                                                                                 0.0,
950                                                                                                 0.0);
951   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
952                                                                                                         fgkendladdercoolingsupportdistance[0]
953                                                                                         +               fgkendladdercoolingsupportdistance[1],
954                                                                                                         0.0);
955   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
956   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
957                                                                                         +               fgkCarbonFiberJunctionLength
958                                                                                         -               fgkCoolingTubeSupportLength,
959                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
960                                                                                         -       0.5*fgkCoolingTubeSupportWidth
961                                                                                                    -fgkendladdercoolingsupportdistance[2],
962                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
963   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
964                                                                                         +               fgkCoolingTubeSupportLength
965                                                                                         -               fgkCoolingTubeSupportRmax
966                                                                                         -               fgkCarbonFiberJunctionLength,
967                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
968                                                                                         -       0.5*fgkCoolingTubeSupportWidth
969                                                                                         -               fgkendladdercoolingsupportdistance[2],
970                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
971   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
972   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
973   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
974   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
975   (*localcoolingtubesupportrot[1]));
976   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
977   (*localcoolingtubesupportrot[1]));
978   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
979   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
980   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
981   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
982   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
983
984   fendladdercoolingtubesupportmatrix[1][0] =    
985                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
986                                                                                    *(*localcoolingtubesupportrot[1]));
987   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
988   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
989   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
990   /////////////////////////////////////////////////////////////
991   // SSD Cooling Tube Transformations
992   /////////////////////////////////////////////////////////////
993   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
994   localcoolingtuberot->SetAngles(0.,90.,0.);
995   TGeoTranslation** localcoolingtubetrans[4];
996   TVector3** localcoolingtubevect[4];
997   for(Int_t i=0; i<4; i++){
998         localcoolingtubevect[i] = new TVector3*[2];
999         localcoolingtubetrans[i] = new TGeoTranslation*[2];
1000         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
1001   }
1002   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1003                                                   -fgkCarbonFiberTriangleLength),
1004                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1005                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1006                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1007                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1008                                                   +      fgkSSDSensorCenterSupportLength
1009                                                   -      fgkSSDSensorCenterSupportThickness[0])+
1010                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
1011                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1012                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1013                                                   -  0.5*fgkCoolingTubeSupportWidth,
1014                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1015   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
1016                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
1017                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
1018                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
1019                                                   +  fgkCoolingTubeSupportWidth,
1020                                                   localcoolingtubevect[0][0]->Z());     
1021   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
1022                                                          +                               fgkCarbonFiberTriangleLength,
1023                                                                                          localcoolingtubevect[0][0]->Y(),
1024                                                                                          localcoolingtubevect[0][0]->Z());
1025   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
1026                                                          +                               fgkCarbonFiberTriangleLength,
1027                                                                                          localcoolingtubevect[0][1]->Y(),
1028                                                                                          localcoolingtubevect[0][1]->Z());
1029   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1030                                                   -     fgkCarbonFiberTriangleLength),
1031                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1032                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1033                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1034                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1035                                                   +      fgkSSDSensorCenterSupportLength
1036                                                   -      fgkSSDSensorCenterSupportThickness[0])
1037                                                   +  fgkSSDModuleStiffenerPosition[1]
1038                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
1039                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1040   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
1041                                                          +                               fgkCarbonFiberTriangleLength,
1042                                                                                          localcoolingtubevect[2][0]->Y(),
1043                                                                                          localcoolingtubevect[2][0]->Z());      
1044   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1045                                                   -     fgkCarbonFiberTriangleLength),
1046                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1047                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1048                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1049                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
1050                                                   +      fgkSSDSensorCenterSupportLength
1051                                                   -      fgkSSDSensorCenterSupportThickness[0])
1052                                                   +      fgkSSDSensorLength
1053                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
1054                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1055   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
1056                                                   + fgkCarbonFiberTriangleLength,
1057                                                         localcoolingtubevect[3][0]->Y(),
1058                                                   - 0.5*fgkCoolingTubeSupportHeight);   
1059   for(Int_t i=0; i<4; i++) 
1060         for(Int_t j=0; j<2; j++){
1061                 localcoolingtubetrans[i][j] = 
1062                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
1063                                                                 localcoolingtubevect[i][j]->Y(),
1064                                                                 localcoolingtubevect[i][j]->Z());
1065                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
1066                                                           *                                     (*localcoolingtuberot));
1067         }
1068   /////////////////////////////////////////////////////////////
1069   // SSD End Ladder Cooling Tube Transformations
1070   /////////////////////////////////////////////////////////////
1071   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1072   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1073   TGeoTranslation** localendlladdercoolingtubetrans[2];
1074   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[6];
1075   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[4];
1076   for(Int_t i=0; i<2; i++)      
1077         for(Int_t j=0; j<(i==0?6:4); j++)       
1078                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1079   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1080                                                                         -        fgkCoolingTubeSupportRmax)
1081                                                                         +        fgkCarbonFiberJunctionLength,
1082                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1083                                                                         -    fgkendladdercoolingsupportdistance[0]),
1084                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1085   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1086                                                                         -        fgkCoolingTubeSupportRmax)
1087                                                                         -        fgkCarbonFiberJunctionLength
1088                                                                         +    fgkCarbonFiberTriangleLength,
1089                                                                           0.5*(fgkEndLadderMountingBlockPosition[0]
1090                                                                         -    fgkendladdercoolingsupportdistance[0]),
1091                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1092   localendlladdercoolingtubetrans[0][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1093                                                                         -   fgkCoolingTubeSupportRmax)
1094                                                                         +       fgkCarbonFiberJunctionLength,
1095                                                                            fgkEndLadderMountingBlockPosition[0]
1096                                                                         -   fgkendladdercoolingsupportdistance[0]
1097                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1098                                                   +                             fgkendladdercoolingsupportdistance[1]
1099                                                   +                             fgkCoolingTubeSupportWidth),
1100                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1101   localendlladdercoolingtubetrans[0][3]->SetTranslation((fgkCoolingTubeSupportLength
1102                                                                         -        fgkCoolingTubeSupportRmax)
1103                                                                         -        fgkCarbonFiberJunctionLength
1104                                                                         +    fgkCarbonFiberTriangleLength,
1105                                                                            fgkEndLadderMountingBlockPosition[0]
1106                                                                         -   fgkendladdercoolingsupportdistance[0]
1107                                                   +                0.5*(fgkendladdercoolingsupportdistance[0]
1108                                                   +                             fgkendladdercoolingsupportdistance[1]
1109                                                   +                             fgkCoolingTubeSupportWidth),
1110                                                                         - 0.5*fgkCoolingTubeSupportHeight);     
1111   localendlladdercoolingtubetrans[0][4]->SetTranslation(-(fgkCoolingTubeSupportLength
1112                                                                         -   fgkCoolingTubeSupportRmax)
1113                                                                         +       fgkCarbonFiberJunctionLength,
1114                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1115                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1116                                                   -                     fgkEndLadderMountingBlockPosition[0]
1117                                                   -                     fgkendladdercoolingsupportdistance[1]           
1118                                                   -                     fgkCoolingTubeSupportWidth),
1119                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1120   localendlladdercoolingtubetrans[0][5]->SetTranslation((fgkCoolingTubeSupportLength
1121                                                                         -        fgkCoolingTubeSupportRmax)
1122                                                                         -        fgkCarbonFiberJunctionLength
1123                                                                         +    fgkCarbonFiberTriangleLength,
1124                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[0]
1125                                                   - 0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
1126                                                   -                     fgkEndLadderMountingBlockPosition[0]
1127                                                   -                     fgkendladdercoolingsupportdistance[1]           
1128                                                   -                     fgkCoolingTubeSupportWidth),
1129                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1130   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1131                                                                         -   fgkCoolingTubeSupportRmax)
1132                                                                         +       fgkCarbonFiberJunctionLength,
1133                                                         - 0.50 * (fgkMountingBlockToSensorSupport
1134                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1135                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1136                                                         +                 fgkSSDSensorOverlap
1137                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1138                                                         -                 fgkendladdercoolingsupportdistance[2]
1139                                                         -                 fgkEndLadderMountingBlockPosition[1]
1140                                                         -                 fgkCoolingTubeSupportWidth)
1141                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1142                                                         -                 fgkendladdercoolingsupportdistance[2]
1143                                                         -                 fgkCoolingTubeSupportWidth,
1144                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1145   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1146                                                   -      fgkCoolingTubeSupportRmax)
1147                                                   -      fgkCarbonFiberJunctionLength
1148                                                   +    fgkCarbonFiberTriangleLength,
1149                                                   - 0.50 * (fgkMountingBlockToSensorSupport
1150                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
1151                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
1152                                                         +                 fgkSSDSensorOverlap
1153                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1154                                                         -                 fgkendladdercoolingsupportdistance[2]
1155                                                         -                 fgkEndLadderMountingBlockPosition[1]
1156                                                         -                 fgkCoolingTubeSupportWidth)
1157                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1158                                                         -                 fgkendladdercoolingsupportdistance[2]
1159                                                         -                 fgkCoolingTubeSupportWidth,
1160                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1161   localendlladdercoolingtubetrans[1][2]->SetTranslation(-(fgkCoolingTubeSupportLength
1162                                                                         -   fgkCoolingTubeSupportRmax)
1163                                                                         +       fgkCarbonFiberJunctionLength,
1164                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1165                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1166                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1167   localendlladdercoolingtubetrans[1][3]->SetTranslation((fgkCoolingTubeSupportLength
1168                                                                         -        fgkCoolingTubeSupportRmax)
1169                                                                         -        fgkCarbonFiberJunctionLength
1170                                                                         +    fgkCarbonFiberTriangleLength,
1171                                                                                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
1172                                                                         - 0.5*fgkendladdercoolingsupportdistance[2],
1173                                                                         - 0.5*fgkCoolingTubeSupportHeight);      
1174   fendladdercoolingtubematrix[0] = new TGeoHMatrix*[6]; 
1175   fendladdercoolingtubematrix[1] = new TGeoHMatrix*[4]; 
1176   for(Int_t i=0; i<2; i++)
1177         for(Int_t j=0; j<(i==0?6:4); j++){
1178                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1179                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1180         }
1181   /////////////////////////////////////////////////////////////
1182   // SSD Hybrid Components Transformations
1183   /////////////////////////////////////////////////////////////
1184   const Int_t khybridmatrixnumber = 3;
1185   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1186   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1187                                             0.5*fgkSSDStiffenerWidth,
1188                                             0.5*fgkSSDStiffenerHeight);
1189   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1190                                             fgkSSDModuleStiffenerPosition[1],0.0);
1191
1192   localhybridtrans[2] = new TGeoTranslation(
1193                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1194                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1195                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1196                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1197                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1198                       -       fgkSSDSensorCenterSupportThickness[0]),
1199                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1200                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1201                                           -       fgkSSDModuleVerticalDisalignment)); 
1202   fhybridmatrix = new TGeoHMatrix();
1203   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1204   /////////////////////////////////////////////////////////////
1205   // SSD Cooling Block Transformations
1206   /////////////////////////////////////////////////////////////
1207   const Int_t kcoolingblockmatrixnumber = 4;    
1208   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1209   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1210                             -  fgkCoolingTubeSupportRmin),0.0,
1211                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1212   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1213                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1214                                0.0,fgkSSDStiffenerHeight);
1215   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1216   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1217   fcoolingblocksystematrix = new TGeoHMatrix();
1218   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1219       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1220   /////////////////////////////////////////////////////////////
1221   // SSD Stiffener Flex Transformations
1222   /////////////////////////////////////////////////////////////
1223   const Int_t klocalflexmatrixnumber = 4;
1224   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1225   for(Int_t i=0; i<fgkflexnumber; i++)    
1226       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1227   for(Int_t i=0; i<fgkflexnumber; i++)
1228       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1229             localflexmatrix[i][j] = new TGeoCombiTrans();
1230   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1231                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1232                                                                   -    fgkSSDStiffenerWidth;
1233   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1234                                         +0.5*fgkSSDStiffenerLength,
1235                                          0.5*fgkSSDStiffenerWidth,
1236                                         -0.5*fgkSSDStiffenerHeight
1237                                         -0.5*fgkSSDFlexHeight[0]);
1238   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1239                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1240                                         -0.5*fgkSSDStiffenerWidth,
1241                                         -0.5*fgkSSDStiffenerHeight
1242                                         -0.5*fgkSSDFlexHeight[0]);
1243   TGeoRotation* localflexrot = new TGeoRotation();
1244   localflexrot->SetAngles(180.,0.,0.);    
1245   localflexmatrix[1][0]->SetRotation(localflexrot);
1246   for(Int_t i=0; i<fgkflexnumber; i++)
1247       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1248             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1249   for(Int_t i=0; i<fgkflexnumber; i++){
1250       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1251       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1252             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1253   }
1254   /////////////////////////////////////////////////////////////
1255   // SSD End Flex Transformations
1256   /////////////////////////////////////////////////////////////
1257   TGeoRotation* localendflexrot = new TGeoRotation();
1258   localendflexrot->SetAngles(0.0,90.0,0.0);
1259   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1260   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1261                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1262   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1263                             * TMath::DegToRad()*ssdflexradiusmax
1264                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1265                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1266                                                                                    - 0.1*fgkSSDFlexFullLength;
1267   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1268                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1269                             +      fgkSSDFlexLength[2];
1270   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1271                               0.5*fgkSSDFlexWidth[0],
1272                               2.*fgkSSDStiffenerHeight
1273                             + 0.5*fgkSSDFlexHeight[0]);      
1274   localendflexmatrix->SetRotation(localendflexrot);
1275   for(Int_t i=0; i<fgkflexnumber; i++) 
1276       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1277   /////////////////////////////////////////////////////////////
1278   // End Ladder Carbon Fiber Junction
1279   /////////////////////////////////////////////////////////////
1280   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1281   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1282   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1283   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1284       localendladdercarbonfiberjunctionmatrix[i] 
1285             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1286       localendladdercarbonfiberjunctionrot[i] 
1287             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1288       localendladdercarbonfiberjunctiontrans[i] 
1289             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1290       fendladdercarbonfiberjunctionmatrix[i]
1291             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1292   }
1293   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1294       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1295             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1296             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1297       }
1298   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1299       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1300           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1301   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1302       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1303                               0.0,0.0);
1304       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1305                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1306                 *                     SinD(fgkCarbonFiberTriangleAngle),
1307                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1308   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1309   }
1310   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1311   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1312   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1313   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1314       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1315       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1316       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1317       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1318             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1319       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1320             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1321                                *localendladdercarbonfiberjunctionglobalrot[i]);
1322   }
1323   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1324       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1325             localendladdercarbonfiberjunctionmatrix[i][j] = 
1326                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1327                                      *localendladdercarbonfiberjunctionrot[i][j]);
1328            fendladdercarbonfiberjunctionmatrix[i][j] =
1329             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1330             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1331       }  
1332   /////////////////////////////////////////////////////////////
1333   // End Ladder Carbon Fiber Support
1334   /////////////////////////////////////////////////////////////
1335   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1336   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1337       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1338       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1339             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1340       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1341   }
1342   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1343       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1344             fendladdercarbonfibermatrix[i][j] = 
1345             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1346             *(*fcarbonfibersupportmatrix[j]));
1347   /////////////////////////////////////////////////////////////
1348   // End Ladder SSD Mounting Block
1349   /////////////////////////////////////////////////////////////
1350   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1351       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1352   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1353       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1354                                 +        fgkSSDMountingBlockLength[1])
1355                                 +  0.5*fgkCarbonFiberTriangleLength,
1356                                 fgkEndLadderMountingBlockPosition[i],
1357                                 -  fgkSSDMountingBlockHeight[1]
1358                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1359   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1360   endladdermountingblockrot->SetAngles(0.,90.,0.);
1361   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1362         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1363   /////////////////////////////////////////////////////////////
1364   // End Ladder SSD Mounting Block Clip Matrix 
1365   /////////////////////////////////////////////////////////////
1366   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1367         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1368   
1369   TGeoRotation* localendladdercliprot = new TGeoRotation();
1370   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1371   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1372                                                                                   -     fgkSSDMountingBlockLength[1])
1373                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1374   localendladdercliprot->SetAngles(90.,180.,-90.);
1375   TGeoCombiTrans* localendladderclipcombitrans = 
1376                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1377   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1378         for(Int_t j=0; j<2; j++){
1379                 fendladdermountingblockclipmatrix[i][j] = 
1380                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1381                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1382         }
1383   /////////////////////////////////////////////////////////////
1384   // End Ladder Carbon Fiber Lower Support
1385   /////////////////////////////////////////////////////////////
1386   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1387       fendladderlowersupptrans[i] = 
1388             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1389                         +  0.5*fgkSSDMountingBlockWidth),
1390                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1391   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1392                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1393                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1394                                                                          0.0);
1395   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1396  /////////////////////////////////////////////////////////////
1397   // Matrix for positioning Ladder into mother volume
1398   /////////////////////////////////////////////////////////////
1399   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1400   for(Int_t i=0; i<fgkladdernumber; i++) 
1401         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1402   TGeoRotation* localladdermotherrot = new TGeoRotation();
1403   localladdermotherrot->SetAngles(0.,90.,0.);  
1404   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1405   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1406   for(Int_t i=0; i<fgkladdernumber; i++){
1407         localladdermothertrans[i] = new TGeoTranslation(0.,
1408                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1409                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1410                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1411                                                           * fgkCarbonFiberJunctionWidth,0.);
1412         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1413                                                                                                                 *localladdermotherrot);
1414         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1415         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1416   }
1417   /////////////////////////////////////////////////////////////
1418   // Ladder Cables Matrices
1419   /////////////////////////////////////////////////////////////
1420   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1421                                              + fgkSSDFlexHeight[1];  
1422   Double_t ssdladdercabletransx[3];
1423   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1424                                                   *   SinD(2.*fgkSSDFlexAngle)
1425                                                   *       CosD(2.*fgkSSDFlexAngle);
1426   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1427                                                   -     ssdladdercabletransx[0]
1428                                                   /     SinD(2.*fgkSSDFlexAngle))
1429                                                   *     CosD(fgkSSDFlexAngle);                                          
1430   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1431                                                   *       TMath::DegToRad()*ssdflexradiusmax
1432                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1433                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1434                                                   -       fgkSSDLadderCableWidth)
1435                                                   *       CosD(2.*fgkSSDFlexAngle);
1436   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1437                                                   *     TanD(2.*fgkSSDFlexAngle),
1438                                                         ssdladdercabletransx[1]
1439                                                   *     TanD(fgkSSDFlexAngle),
1440                                                         ssdladdercabletransx[2]
1441                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1442   TGeoRotation* localladdercablerot[3]; 
1443   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1444   localladdercablerot[0]->SetAngles(90.,0.,0.);
1445   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1446   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1447                                                  *                        (*localladdercablerot[0]));
1448   ////////////////////////////////////////////
1449   // LocalLadderCableCombiTransMatrix
1450   ////////////////////////////////////////////
1451   const Int_t klocalladdersidecablesnumber = 2;
1452   const Int_t klocalladdercombitransnumber = 5;
1453   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1454   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1455          localladdercablecombitransmatrix[i] = 
1456                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1457   ///////////////////////////////////////////
1458   // Left Side Ladder Cables Transformations
1459   ///////////////////////////////////////////
1460   localladdercablecombitransmatrix[0][0]  =
1461                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1462                                                 0.,0.,NULL);
1463   localladdercablecombitransmatrix[0][1] = 
1464         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1465                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1466                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1467                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1468                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1469                                            + fgkSSDSensorCenterSupportLength
1470                                            - fgkSSDSensorCenterSupportThickness[0]),
1471                                            - (fgkSSDModuleCoolingBlockToSensor
1472                                            + 0.5*fgkCoolingTubeSupportHeight
1473                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1474                                            - fgkSSDChipHeight),NULL);
1475   localladdercablecombitransmatrix[0][2] = 
1476                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1477                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1478   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1479                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1480                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1481                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1482                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1483                                                                                                 new TGeoRotation("",180.,0.,0.));
1484   localladdercablecombitransmatrix[0][4] = 
1485                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1486                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1487                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1488                                                           0.,
1489                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1490                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1491                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1492                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1493   ///////////////////////////////////////////
1494   // Rigth Side Ladder Cables Transformations
1495   ///////////////////////////////////////////
1496   TGeoCombiTrans* localladdercablessdmodulematrix = 
1497         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1498                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1499                                                                          fgkSSDStiffenerWidth,
1500                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1501   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1502    localladdercablecombitransmatrix[1][i] = 
1503                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1504                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1505   ///////////////////////////////////////////
1506   // Setting LadderCableHMatrix
1507   ///////////////////////////////////////////
1508   Int_t beamaxistrans[2][3];
1509   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1510   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1511   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1512   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1513   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1514   beamaxistrans[1][2] = beamaxistrans[1][0];
1515   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1516   TGeoRotation* laddercablerot = new TGeoRotation();
1517   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1518   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1519   Double_t* laddercabletransvector;     
1520   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1521         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1522         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1523   }
1524   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1525         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1526                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1527                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1528                         localladdercablehmatrix[i][j]->MultiplyLeft(
1529                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1530         }
1531                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1532                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1533                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1534                                                                          laddercabletransvector[1]
1535                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1536                                         *                                fgkCarbonFiberJunctionWidth,
1537                                                                          laddercabletransvector[2]);
1538                 laddercablecombitrans->SetRotation(*laddercablerot);
1539                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1540                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1541         }
1542     fladdercablematrix[i][2] = 
1543                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1544                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1545         fladdercablematrix[i][3] = 
1546                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1547                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1548   }
1549   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1550         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1551                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1552   ///////////////////////////////////////////
1553   // Setting Ladder HMatrix
1554   ///////////////////////////////////////////
1555   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1556                                                                                                 fgkSSDLay6SensorsNumber};
1557   for(Int_t i=0; i<fgkladdernumber; i++){
1558         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1559         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1560                 fladdermatrix[i][j] = new TGeoHMatrix();
1561                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1562                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1563                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1564         }
1565   }
1566   ///////////////////////////////////////////
1567   // Setting SSD Sensor Matrix 
1568   ///////////////////////////////////////////
1569   TGeoCombiTrans* localssdsensorcombitrans[2];
1570   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1571   localssdsensorrot->SetAngles(0.,90.,0.);      
1572   TGeoTranslation* localssdsensortrans[2];
1573   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1574   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1575                                          fgkCarbonFiberJunctionWidth 
1576                                          - fgkCarbonFiberLowerSupportWidth 
1577                                          - fgkLowerSupportToSensorZ,
1578                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1579                                           -             fgkSSDModuleCoolingBlockToSensor
1580                                           +    (fgkSSDSensorSideSupportHeight[1]
1581                                           -             fgkSSDSensorSideSupportHeight[0]));
1582   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1583                                          fgkCarbonFiberJunctionWidth 
1584                                          - fgkCarbonFiberLowerSupportWidth 
1585                                          - fgkLowerSupportToSensorZ,
1586                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1587                                                         -fgkSSDModuleCoolingBlockToSensor);
1588   for(Int_t i=0; i<2; i++) 
1589         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1590                                                                                                          *localssdsensorrot);   
1591     for(Int_t i=0; i<fgkladdernumber; i++){
1592         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1593         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1594                 switch(i){
1595                         case 0: //Ladder of Layer5  
1596                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1597                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1598                                                                                                 *localssdsensorcombitrans[1])));
1599                         break;
1600                         case 1: //Ladder of Layer6 
1601                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1602                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1603                                                                                                 *localssdsensorcombitrans[0])));
1604                 break;
1605                 }
1606           }
1607   }     
1608   //////////////////////////
1609   // Setting SSD End Ladder  
1610   //////////////////////////
1611   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1612   for(Int_t i=0; i<2; i++){
1613         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1614         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1615         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1616         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1617         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1618         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1619         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1620         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1621    }
1622   /////////////////////////////////////////////////////
1623   // Setting the CombiTransformation to pass ITS center 
1624   /////////////////////////////////////////////////////
1625   Double_t itscentertransz[fgklayernumber];
1626   itscentertransz[0] = fgkSSDLay5LadderLength
1627                                          - fgkLay5CenterITSPosition;
1628   itscentertransz[1] = fgkSSDLay6LadderLength
1629                                          - fgkLay6CenterITSPosition;
1630   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1631                                                    + 0.5*fgkCoolingTubeSupportHeight;
1632   TGeoRotation* itscenterrot[3];
1633   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1634   itscenterrot[0]->SetAngles(90.,180.,-90.);
1635   itscenterrot[1]->SetAngles(0.,90.,0.);
1636   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1637   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1638   for(Int_t i=0; i<fgklayernumber; i++) 
1639         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1640                                                          itssensortransy,
1641                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1642                                                    - itscentertransz[i],itscenterrot[2]);
1643   TGeoRotation** locallayerrot[fgklayernumber];
1644   TGeoTranslation** locallayertrans[fgklayernumber];    
1645   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1646   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1647   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1648                                          - fgkLay5CenterITSPosition);
1649   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1650                                          - fgkLay6CenterITSPosition);
1651   const Int_t kssdlayladdernumber[fgklayernumber] = 
1652                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1653   for(Int_t i=0; i<fgklayernumber; i++){
1654     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1655     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1656         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1657         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1658   }
1659   Double_t layerladderangleposition[fgklayernumber] = 
1660                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1661   Double_t layerradius = 0.;
1662   for(Int_t i=0; i<fgklayernumber; i++){        
1663         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1664                 switch(i){
1665                         case 0: //Ladder of Layer5  
1666                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1667                         break;
1668                         case 1: //Ladder of Layer6 
1669                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1670                 break;
1671                 }
1672                 locallayerrot[i][j] = new TGeoRotation();
1673                 locallayertrans[i][j] = new TGeoTranslation();
1674                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1675                 locallayertrans[i][j]->SetTranslation(layerradius 
1676                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1677                                                             layerradius 
1678                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1679                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1680                                                                          *locallayerrot[i][j]);
1681                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1682                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1683                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1684         }
1685   }
1686   /////////////////////////////////////////////////////////////
1687   // Deallocating memory
1688   /////////////////////////////////////////////////////////////
1689   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1690         delete carbonfiberot[i];
1691         delete localcarbonfibersupportmatrix[i];
1692   }
1693   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1694      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1695        delete localcarbonfiberjunctionmatrix[i][j];
1696            delete localcarbonfiberjunctionrot[i][j];
1697            delete localcarbonfiberjunctiontrans[i][j];
1698            }
1699        delete [] localcarbonfiberjunctionmatrix[i];
1700        delete [] localcarbonfiberjunctionrot[i];
1701        delete [] localcarbonfiberjunctiontrans[i];
1702   }
1703   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1704            delete localcarbonfiberlowersupportrans[i];
1705   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1706      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1707        delete localssdsensorsupportmatrix[i][j];
1708            delete localssdsensorsupportrot[i][j];
1709            delete localssdsensorsupportrans[i][j];
1710            }
1711        delete [] localssdsensorsupportmatrix[i];
1712        delete [] localssdsensorsupportrot[i];
1713        delete [] localssdsensorsupportrans[i];
1714   }
1715   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1716         delete localcoolingtubesupportmatrix[i];
1717         delete localcoolingtubesupportrot[i];
1718         delete localcoolingtubesupportrans[i];
1719   }
1720   for(Int_t i=0; i<4; i++){
1721         for(Int_t j=0; j<2; j++){
1722                 delete localcoolingtubevect[i][j];
1723                 delete localcoolingtubetrans[i][j];
1724         }
1725         delete [] localcoolingtubevect[i];
1726         delete [] localcoolingtubetrans[i];
1727   }
1728  delete endladdermountingblockrot;
1729  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1730  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1731  for(Int_t i=0; i<fgkflexnumber; i++){
1732       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1733             delete localflexmatrix[i][j];
1734       delete [] localflexmatrix[i];
1735  }
1736  delete localendlladdercoolingtuberot;
1737  for(Int_t i=0; i<2; i++){
1738         for(Int_t j=0; j<(i==0?6:4); j++)
1739                 delete localendlladdercoolingtubetrans[i][j];
1740         delete [] localendlladdercoolingtubetrans[i];
1741   }
1742
1743  delete localflexrot;
1744  delete localendflexrot;
1745  delete localendflexmatrix;
1746  for(Int_t i=0; i<fgkladdernumber; i++){ 
1747         delete localladdermothertrans[i];
1748         delete localladdermothercombitrans[i];
1749   }
1750  delete localladdermotherrot;
1751  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1752       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1753             delete localendladdercarbonfiberjunctionmatrix[i][j];
1754             delete localendladdercarbonfiberjunctionrot[i][j];
1755             delete localendladdercarbonfiberjunctiontrans[i][j];
1756       }
1757       delete [] localendladdercarbonfiberjunctionmatrix[i];
1758       delete [] localendladdercarbonfiberjunctionrot[i];
1759       delete [] localendladdercarbonfiberjunctiontrans[i];
1760       delete localendladdercarbonfiberjunctionglobalrot[i];
1761       delete localendladdercarbonfiberjunctionglobaltrans[i];
1762       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1763  }
1764   for(Int_t i=0; i<2; i++){
1765         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1766         delete [] localendladdercooltubetrans[i];
1767   }
1768   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1769       delete localendladdercarbonfibertrans[i];
1770   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1771   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1772         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1773                 delete localladdercablecombitransmatrix[i][j];
1774                 delete []localladdercablecombitransmatrix[i];
1775   }
1776   delete localendladdercliprot;
1777   delete localendladdercliptrans;
1778   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1779         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1780                 delete localladdercablehmatrix[i][j];
1781         delete []localladdercablehmatrix[i];
1782   }
1783   delete laddercablerot;
1784   delete laddercabletrans;
1785   delete laddercablecombitrans;
1786   delete localladdercablessdmodulematrix;
1787   delete localssdsensorrot;     
1788   for(Int_t i=0; i<2; i++){
1789         delete localssdsensortrans[i];
1790         delete localssdsensorcombitrans[i];
1791   }
1792   for(Int_t i=0; i<fgklayernumber; i++){
1793         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1794                 delete locallayerrot[i][j];
1795                 delete locallayertrans[i][j];
1796                 delete locallayercombitrans[i][j];
1797     }
1798         delete [] locallayerrot[i];
1799         delete [] locallayertrans[i];
1800         delete [] locallayercombitrans[i];
1801         delete localbeamaxistrans[i];
1802   }
1803   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1804   for(Int_t i=0; i<fgkladdernumber; i++){
1805         for(Int_t j=0; j<fgkladdernumber; j++)
1806                 delete ladderglobalmatrix[i][j];
1807         delete [] ladderglobalmatrix[i];
1808   }
1809   /////////////////////////////////////////////////////////////
1810   fTransformationMatrices = kTRUE;      
1811 }
1812 ///////////////////////////////////////////////////////////////////////////////
1813 void AliITSv11GeometrySSD::CreateBasicObjects(){
1814   /////////////////////////////////////////////////////////////  
1815   // Method generating the Objects of SSD Geometry    
1816   /////////////////////////////////////////////////////////////
1817   // SSD Sensor
1818   ///////////////////////////////////
1819   SetSSDSensor();
1820   /////////////////////////////////////////////////////////////  
1821   // Carbon Fiber Support    
1822   /////////////////////////////////////////////////////////////  
1823   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1824   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1825       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1826   /////////////////////////////////////////////////////////////
1827   // Carbon Fiber Junction 
1828   /////////////////////////////////////////////////////////////
1829   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1830   /////////////////////////////////////////////////////////////
1831   // Carbon Fiber Lower Support
1832   /////////////////////////////////////////////////////////////
1833   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1834   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1835         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1836   /////////////////////////////
1837   // SSD Sensor Support
1838   /////////////////////////////
1839   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1840                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1841   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1842                                                                          fgkSSDSensorSideSupportThickness[1]};
1843   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1844         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1845                                                                                            fgkSSDSensorSideSupportHeight[i],
1846                                                                                            fgkSSDSensorSideSupportWidth,
1847                                                                                            sidesupporthickness);  
1848         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1849                                                                                            fgkSSDSensorCenterSupportHeight[i],
1850                                                                                            fgkSSDSensorCenterSupportWidth,
1851                                                                                            sidesupporthickness);
1852   }
1853   /////////////////////////////////////////////////////////////
1854   // SSD Cooling Tube Support
1855   /////////////////////////////////////////////////////////////
1856   Int_t edgesnumber = 16;
1857   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1858   /////////////////////////////////////////////////////////////
1859   // SSD Hybrid
1860   /////////////////////////////////////////////////////////////
1861   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1862   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1863         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1864   /////////////////////////////////////////////////////////////
1865   // SSD Cooling Block System
1866   /////////////////////////////////////////////////////////////
1867   fssdcoolingblocksystem = GetCoolingBlockSystem();
1868    /////////////////////////////////////////////////////////////
1869   // SSD Cooling Tube
1870   /////////////////////////////////////////////////////////////
1871   TList* coolingtubelist = GetCoolingTubeList();        
1872   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1873         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1874   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)  
1875         fendladdercoolingtube[i] = 
1876                         (TGeoVolume*)coolingtubelist->At(fgkcoolingtubenumber+i);
1877   /////////////////////////////////////////////////////////////
1878   // SSD Flex  
1879   /////////////////////////////////////////////////////////////
1880   fssdstiffenerflex = GetSSDStiffenerFlex();
1881   fssdendflex = GetSSDEndFlex();
1882   ///////////////////////////////////
1883   // End Ladder Carbon Fiber Junction
1884   ///////////////////////////////////
1885   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1886                                                    fendladdercarbonfiberjunction[i] = 
1887                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1888   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1889     fendladdercarbonfiberjunction[i][0] = 
1890                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1891     fendladdercarbonfiberjunction[i][1] = 
1892                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1893   }
1894   ///////////////////////////////////
1895   // End Ladder Mounting Block
1896   ///////////////////////////////////
1897   fendladdermountingblock = GetSSDMountingBlock();
1898   ///////////////////////////////////
1899   // End Ladder Mounting Block
1900   ///////////////////////////////////
1901   fendladdermountingblockclip = GetMountingBlockClip();
1902   ///////////////////////////////////
1903   // Ladder Support 
1904   ///////////////////////////////////
1905   TList* laddersupportlist = GetMountingBlockSupport(20);
1906   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1907   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1908   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1909   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1910   /////////////////////////////////////////////////////////////
1911   // Deallocating memory
1912   /////////////////////////////////////////////////////////////
1913   delete carbonfibersupportlist;
1914   delete carbonfiberlowersupportlist;
1915   delete ssdhybridcomponentslist;
1916   delete laddersupportlist;
1917   /////////////////////////////////////////////////////////////
1918   fBasicObjects = kTRUE;
1919 }
1920 /////////////////////////////////////////////////////////////////////////////////
1921 void AliITSv11GeometrySSD::SetSSDSensor(){
1922   ////////////////////////////////////////////////////////////////
1923   // Method generating SSD Sensors: it sets the private variables
1924   // fSSDSensor5, fSSDSensor6  
1925   ////////////////////////////////////////////////////////////////
1926   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1927   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1928   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1929                                                 0.5*ssdsensitivewidth,
1930                                                 0.5*fgkSSDSensorHeight,
1931                                                 0.5*ssdsensitivelength);
1932   TGeoVolume* ssdsensorsensitiveLay5 = 
1933         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1934   TGeoVolume* ssdsensorsensitiveLay6 = 
1935         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1936   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1937   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1938   TGeoBBox* ssdsensorinsensitiveshape[2];
1939   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1940                                                 0.5*fgkSSDSensorInsensitiveWidth,
1941                                                 0.5*fgkSSDSensorHeight,
1942                                                 0.5*fgkSSDSensorLength);
1943   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1944                                                 0.5*ssdsensitivewidth,
1945                                                 0.5*fgkSSDSensorHeight,
1946                                                 0.5*fgkSSDSensorInsensitiveWidth);
1947   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1948                                              "SSDSensorInsensitive2"};
1949   TGeoVolume* ssdsensorinsensitive[2];
1950   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1951       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1952                      fSSDSensorMedium);
1953       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1954   }
1955   /////////////////////////////////////////////////////////////
1956   // Virtual Volume containing SSD Sensor  
1957   /////////////////////////////////////////////////////////////
1958   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1959                                                                                              0.5*fgkSSDSensorWidth,
1960                                                                                              0.5*fgkSSDSensorHeight,
1961                                                                                              0.5*fgkSSDSensorLength);
1962   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1963                                                                                  fSSDAir);      
1964   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1965                                                                                  fSSDAir);      
1966   /////////////////////////////////////////////////////////////
1967   for(Int_t i=0; i<4; i++){ 
1968             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1969             ssdsensorinsensitive[1],i<2?1:2,
1970                         new TGeoTranslation(
1971                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1972       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1973                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1974       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1975             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1976             ssdsensorinsensitive[1],i<2?1:2,
1977                         new TGeoTranslation(
1978                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1979       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1980                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1981       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1982   }
1983     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1984     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1985 }
1986 ///////////////////////////////////////////////////////////////////////////////
1987 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1988   /////////////////////////////////////////////////////////////  
1989   // Method generating the Carbon Fiber Support   
1990   /////////////////////////////////////////////////////////////  
1991   const Int_t kvertexnumber = 4;
1992   const Int_t kshapesnumber = 2;
1993   TVector3** vertexposition[kshapesnumber];
1994   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1995   Double_t carbonfibersupportxaxisEdgeproj = 
1996                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1997         *       TMath::DegToRad());
1998   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1999                                  /                         fgkCarbonFiberSupportXAxisLength);
2000   /////////////////////
2001   //Vertex Positioning
2002   ////////////////////
2003   vertexposition[0][0] = new TVector3();
2004   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
2005                                                                           fgkCarbonFiberSupportYAxisLength);
2006   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
2007                                                                           carbonfibersupportxaxisEdgeproj
2008                                            *                      TMath::Tan(theta));
2009   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
2010                                            -                      carbonfibersupportxaxisEdgeproj,
2011                                                                           fgkCarbonFiberSupportYAxisLength
2012                                            -                      vertexposition[0][2]->Y());
2013   ////////////////////////////////////////////////////
2014   //Setting the parameters for Isometry Transformation
2015   ////////////////////////////////////////////////////
2016   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
2017                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
2018                                                                  +      fgkCarbonFiberSupportWidth);
2019   Double_t* param = new Double_t[4]; 
2020   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
2021   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
2022     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
2023                  (GetReflection(vertexposition[0][j],param))->Y());
2024   const char* carbonfibersupportshapename[kshapesnumber] = 
2025                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
2026   const char* carbonfibersupportname[kshapesnumber] = 
2027                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
2028   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
2029   TGeoVolume* carbonfibersupport[kshapesnumber];
2030   TList* carbonfibersupportlist = new TList();
2031   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
2032   Double_t carbonfibersupportheight = 
2033           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2034           *TMath::DegToRad());
2035   for(Int_t i = 0; i< kshapesnumber; i++){
2036    carbonfibersupportshape[i] = 
2037                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
2038                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
2039    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
2040                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
2041    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
2042    carbonfibersupportlist->Add(carbonfibersupport[i]);  
2043    }
2044   /////////////////////////////////////////////////////////////
2045   // Deallocating memory
2046   /////////////////////////////////////////////////////////////
2047   for(Int_t i=0; i< kshapesnumber; i++){
2048      for(Int_t j=0; j< kvertexnumber; j++)
2049            delete vertexposition[i][j];
2050        delete [] vertexposition[i];
2051   }
2052   delete [] param;
2053   /////////////////////////////////////////////////////////////
2054    return carbonfibersupportlist;
2055 }
2056 /////////////////////////////////////////////////////////////////////////////////
2057 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
2058   /////////////////////////////////////////////////////////////
2059   // Method generating SSD Carbon Fiber Junction
2060   /////////////////////////////////////////////////////////////
2061   const Int_t kvertexnumber = 6;
2062   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
2063   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
2064                                             *  TMath::DegToRad()),-1.,0.,0.};
2065   TVector3* vertex[kvertexnumber];
2066   vertex[0] = new TVector3();
2067   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
2068                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
2069                         *                         TMath::DegToRad()),
2070                                                   fgkCarbonFiberJunctionEdge[0]
2071                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
2072                         *                         TMath::DegToRad()));
2073   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
2074                                                    fgkCarbonFiberJunctionEdge[1]);
2075   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
2076   vertex[1] = GetReflection(vertex[5],reflectionparam); 
2077   vertex[2] = GetReflection(vertex[4],reflectionparam); 
2078   Double_t xvertexpoints[6], yvertexpoints[6];
2079   for(Int_t i=0; i<kvertexnumber; i++) 
2080           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
2081   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2082   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
2083   carbonfiberjunctionshape->DefineSection(1,0.5*width);
2084   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
2085                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
2086   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
2087   /////////////////////////////////////////////////////////////
2088   // Deallocating memory
2089   /////////////////////////////////////////////////////////////
2090   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
2091   ///////////////////////////////////////////////////////////// 
2092   return carbonfiberjunction;
2093 }
2094 ////////////////////////////////////////////////////////////////////////////////
2095 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
2096   /////////////////////////////////////////////////////////////
2097   // Method generating the Carbon Fiber Lower Support   
2098   /////////////////////////////////////////////////////////////  
2099   const Int_t kvertexnumber = 4;
2100   const Int_t kshapesnumber = 2;
2101   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
2102                                                                 fgkCarbonFiberLowerSupportWidth};
2103   TVector3** vertexposition[kshapesnumber];
2104   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
2105                                                  new TVector3*[kvertexnumber];
2106   //First Shape Vertex Positioning
2107   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
2108   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
2109                                            -            fgkCarbonFiberLowerSupportLowerLenght);
2110   vertexposition[0][2] = new TVector3();
2111   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
2112   //Second Shape Vertex Positioning
2113   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
2114                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
2115                                  /                              fgkCarbonFiberTriangleLength);
2116   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
2117                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
2118                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2119   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
2120                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
2121                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
2122   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
2123   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
2124                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
2125   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
2126                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
2127   const char* carbonfiberlowersupportname[kshapesnumber] = 
2128                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2129   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2130   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2131   TList* carbonfiberlowersupportlist = new TList();
2132   for(Int_t i = 0; i< kshapesnumber; i++){ 
2133         carbonfiberlowersupportshape[i] = 
2134                                                                 GetArbShape(vertexposition[i],width,
2135                                                                                         fgkCarbonFiberLowerSupportHeight,
2136                                                                                         carbonfiberlowersupportshapename[i]);
2137     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2138                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2139         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2140     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2141   }
2142   /////////////////////////////////////////////////////////////
2143   // Deallocating memory
2144   /////////////////////////////////////////////////////////////
2145   for(Int_t i=0; i< kshapesnumber; i++){
2146      for(Int_t j=0; j< kvertexnumber; j++)
2147            delete vertexposition[i][j];
2148        delete [] vertexposition[i];
2149   }
2150   /////////////////////////////////////////////////////////////
2151   return carbonfiberlowersupportlist;
2152 }
2153 ///////////////////////////////////////////////////////////////////////////////
2154 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2155                                                                  Double_t width, Double_t* thickness)const{
2156   /////////////////////////////////////////////////////////////
2157   // Method generating the Sensor Support   
2158   /////////////////////////////////////////////////////////////  
2159         const Int_t kvertexnumber = 6;
2160         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2161     TVector3* vertexposition[kvertexnumber];
2162         vertexposition[0] = new TVector3();     
2163         vertexposition[1] = new TVector3(0.0,length);   
2164         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2165         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2166         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2167         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2168         Double_t xvertexpoints[6], yvertexpoints[6];
2169         for(Int_t i=0; i<kvertexnumber; i++) 
2170                 xvertexpoints[i] = vertexposition[i]->X(), 
2171                 yvertexpoints[i] = vertexposition[i]->Y();
2172     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2173     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2174     ssdsensorsupportshape->DefineSection(1,0.5*width);
2175     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2176                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2177   /////////////////////////////////////////////////////////////
2178   // Deallocating memory
2179   /////////////////////////////////////////////////////////////
2180         for (Int_t i=0; i<kvertexnumber; i++)
2181                 delete vertexposition[i];
2182   /////////////////////////////////////////////////////////////
2183     return ssdsensorsupport;
2184 }
2185 ////////////////////////////////////////////////////////////////////////////////
2186 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2187   /////////////////////////////////////////////////////////////
2188   // Method generating the Cooling Tube Support
2189   /////////////////////////////////////////////////////////////
2190   if(nedges%2!=0) nedges--;     
2191   const Int_t kvertexnumber = nedges+5;
2192   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2193                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2194   Double_t angle = 90.+phi;
2195   Double_t psi = 90.-phi;
2196   ///////////////////////////////////////
2197   // Vertex Positioning for TGeoXTru
2198   ///////////////////////////////////////
2199   TVector3** vertexposition = new TVector3*[kvertexnumber];
2200   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
2201                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
2202   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2203                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2204   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2205                                                                    fgkCoolingTubeSupportRmax);
2206   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2207                                                                    fgkCoolingTubeSupportRmax);
2208   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2209                                                                     vertexposition[1]->Y());
2210   for(Int_t i=0; i<nedges; i++)
2211         vertexposition[i+5] = 
2212                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
2213                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
2214   ///////////////////////////////////////////////////////////////////////
2215   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2216   ///////////////////////////////////////////////////////////////////////
2217   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2218   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2219   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2220   for(Int_t i=0; i<kvertexnumber; i++){
2221         xvertexpoints[i] = vertexposition[i]->X();
2222         yvertexpoints[i] = vertexposition[i]->Y();
2223   } 
2224   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2225                                                                                         yvertexpoints);
2226   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2227   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2228   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2229                                                                           coolingtubesupportarcshape,
2230                                                                                   fSSDTubeHolderMedium);
2231   coolingtubesupportarc->SetLineColor(fColorG10);
2232   //////////////////////////////////////////////////////////////////////////
2233   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2234   //////////////////////////////////////////////////////////////////////////
2235   TGeoTubeSeg* coolingtubesupportsegshape = 
2236                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2237                                                                                         fgkCoolingTubeSupportRmax,
2238                                                                                         0.5*fgkCoolingTubeSupportWidth,
2239                                                                                         phi,360-phi);
2240   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2241                                                                                         coolingtubesupportsegshape,
2242                                                                                         fSSDTubeHolderMedium);
2243   coolingtubesupportseg->SetLineColor(fColorG10);
2244   //////////////////////////////////////////////////////////////////////////
2245   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2246   //////////////////////////////////////////////////////////////////////////
2247   Double_t* boxorigin = new Double_t[3];
2248   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2249   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2250   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2251                                                                                  0.5*fgkCoolingTubeSupportHeight,
2252                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2253   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2254                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2255   coolingtubesupportbox->SetLineColor(fColorG10);
2256   //////////////////////////////////////////////////////////////////////////
2257   // Cooling Tube for Cooling Tube Support 
2258   //////////////////////////////////////////////////////////////////////////
2259   TGeoXtru* coolingtubearcshape[2];
2260   coolingtubearcshape[0] = new TGeoXtru(2);     
2261   Double_t* xvert = new Double_t[nedges+2];
2262   Double_t* yvert = new Double_t[nedges+2];
2263   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2264   ////////////////////////////////////////
2265   // Positioning the vertices for TGeoXTru
2266   ////////////////////////////////////////
2267   xvert[0] = 0., yvert[0] = 0.;
2268   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2269   for(Int_t i=0; i< nedges; i++)
2270                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2271                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2272   ////////////////////////////////////////
2273   // Defining TGeoXTru PolyGone
2274   ////////////////////////////////////////
2275   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2276   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2277   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2278   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2279                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2280   TGeoVolume* coolingtubearc[2];
2281   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2282                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2283   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2284                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2285   coolingtubearc[0]->SetLineColor(fColorWater);
2286   coolingtubearc[1]->SetLineColor(fColorPhynox);
2287   ////////////////////////////////////////////
2288   // Defining TGeoTubeSeg Part of Cooling Tube
2289   ////////////////////////////////////////////
2290   TGeoTubeSeg* coolingtubesegshape[2];
2291   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2292                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2293   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2294                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2295   TGeoVolume* coolingtubeseg[2];
2296   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2297                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2298   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2299                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2300   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2301   coolingtubeseg[1]->SetLineColor(fColorWater);
2302   /////////////////////////////////////////////////////////////
2303   // Virtual Volume containing Cooling Tube Support  
2304   /////////////////////////////////////////////////////////////
2305   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2306   const Int_t kvirtualvertexnumber = 8;
2307   TVector3* virtualvertex[kvirtualvertexnumber];
2308    ////////////////////////////////////////
2309   // Positioning the vertices for TGeoXTru
2310   ////////////////////////////////////////
2311   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2312   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2313   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2314   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2315   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2316   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2317   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2318   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2319   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2320   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2321         xmothervertex[i] = virtualvertex[i]->X(),
2322         ymothervertex[i] = virtualvertex[i]->Y();
2323   ////////////////////////////////////////
2324   // Defining TGeoXTru PolyGone
2325   ////////////////////////////////////////
2326   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2327                                                                                                                                          ymothervertex);
2328   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2329   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2330   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2331                                                                  virtualCoolingTubeSupportShape,fSSDAir);
2332   ////////////////////////////////////////
2333   // Positioning Volumes in Virtual Volume
2334   ////////////////////////////////////////
2335   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2336   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2337   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2338   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2339   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2340   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2341   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2342   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2343   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2344   /////////////////////////////////////////////////////////////
2345   // Deallocating memory
2346   /////////////////////////////////////////////////////////////
2347   delete [] vertexposition;
2348   delete [] xvertexpoints;
2349   delete [] yvertexpoints;
2350   delete [] xvert;
2351   delete [] yvert;
2352   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2353         delete virtualvertex[i];
2354   /////////////////////////////////////////////////////////////
2355         return virtualcoolingtubesupport;
2356 }
2357 /////////////////////////////////////////////////////////////////////////////////
2358 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2359   /////////////////////////////////////////////////////////////
2360   // Method generating List containing SSD Hybrid Components   
2361   /////////////////////////////////////////////////////////////
2362   TList* ssdhybridlist = new TList();
2363   const Int_t kssdstiffenernumber = 2;
2364   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2365                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2366                                                                   -    fgkSSDStiffenerWidth;
2367   Double_t ssdchipcablesradius[kssdstiffenernumber];
2368   for(Int_t i=0; i<kssdstiffenernumber; i++)
2369           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2370                                -  fgkSSDChipCablesHeight[0]
2371                                -  fgkSSDChipCablesHeight[1]);
2372   /////////////////////////////////////////////////////////////
2373   // Mother Volumes Containers 
2374   /////////////////////////////////////////////////////////////
2375   const Int_t kmothernumber = 2;
2376   const Int_t kmothervertexnumber = 12;
2377   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2378   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2379   ///////////////////////
2380   // Setting the vertices 
2381   ///////////////////////
2382   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
2383   xmothervertex[0][1]  = xmothervertex[0][0]; 
2384   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
2385   xmothervertex[0][3]  = xmothervertex[0][2];
2386   xmothervertex[0][4]  = xmothervertex[0][0];
2387   xmothervertex[0][5]  = xmothervertex[0][4];
2388   xmothervertex[0][6]  = -xmothervertex[0][0];
2389   xmothervertex[0][7]  = xmothervertex[0][6];
2390   xmothervertex[0][8]  = -xmothervertex[0][2];
2391   xmothervertex[0][9]  = xmothervertex[0][8];
2392   xmothervertex[0][10] = xmothervertex[0][7];
2393   xmothervertex[0][11] = xmothervertex[0][10];
2394   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
2395   for(Int_t i = 0; i<kmothernumber; i++){
2396       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
2397                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
2398       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
2399       ymothervertex[i][2]  = ymothervertex[i][1];
2400       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
2401       ymothervertex[i][4]  = ymothervertex[i][3];
2402       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
2403       ymothervertex[i][6]  = ymothervertex[i][5];
2404       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
2405       ymothervertex[i][8]  = ymothervertex[i][7];
2406       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
2407       ymothervertex[i][10] = ymothervertex[i][9];
2408       ymothervertex[i][11] = ymothervertex[i][0];
2409   }
2410   TGeoXtru* ssdhybridmothershape[kmothernumber];
2411 //  TGeoVolume* ssdhybridmother[kmothernumber];
2412   TGeoVolumeAssembly* ssdhybridmother[kmothernumber];
2413   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2414   for(Int_t i=0; i<kmothernumber; i++){
2415       ssdhybridmothershape[i] = new TGeoXtru(2);
2416       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
2417                                           ymothervertex[i]);
2418       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2419                                                -fgkSSDChipCablesHeight[i+2]);
2420       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
2421 //      ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
2422 //                                          fSSDAir);
2423       ssdhybridmother[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2424    }   
2425   /////////////////////////////////////////////////////////////
2426   // SSD Stiffener   
2427   /////////////////////////////////////////////////////////////
2428   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2429                                              0.5*fgkSSDStiffenerLength,
2430                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2431                                              0.5*fgkSSDStiffenerHeight);
2432   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2433                                             fSSDStiffenerMedium);  
2434   ssdstiffener->SetLineColor(fColorStiffener); 
2435   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
2436   for(Int_t i=0; i<kssdstiffenernumber; i++) 
2437       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
2438   /////////////////////////////////////////////////////////////
2439   // SSD Chip System    
2440   /////////////////////////////////////////////////////////////
2441   TList* ssdchipsystemlist = GetSSDChipSystem(); 
2442   Double_t ssdchipseparation = fgkSSDSensorLength
2443                              - 2.*fgkSSDModuleStiffenerPosition[1]
2444                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
2445                              - 0.5*fgkSSDChipWidth);
2446   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
2447                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
2448   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
2449                                       - 0.5*ssdchipsystemlength,
2450                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
2451                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
2452 ////////////////////////////
2453 // Capacitor 0603-2200 nF
2454 ///////////////////////////
2455   const Int_t knapacitor0603number = 5;
2456   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2457                                                                                          0.5*fgkSSDCapacitor0603Length,
2458                                                                                          0.5*(fgkSSDCapacitor0603Width),
2459                                                                                          0.5*fgkSSDCapacitor0603Height);
2460   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2461                                              fSSDStiffener0603CapacitorMedium); 
2462   capacitor0603->SetLineColor(fColorAl);
2463   for(Int_t i=0; i<kmothernumber; i++){
2464       for(Int_t j=0; j<kssdstiffenernumber; j++){
2465             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2466             for(Int_t k=1; k<knapacitor0603number+1; k++){
2467                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2468                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2469                                            j*ssdstiffenerseparation
2470                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2471                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2472                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2473             }
2474       } 
2475       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2476       ssdhybridlist->Add(ssdhybridmother[i]);
2477   }    
2478 /////////////////////////////////////////////////////////////
2479 // Mother Volume Containing Capacitor Part 
2480 /////////////////////////////////////////////////////////////
2481   const Int_t kcapacitormothernumber = 8;
2482   Double_t xcapacitorvertex[kcapacitormothernumber];
2483   Double_t ycapacitorvertex[kcapacitormothernumber];  
2484   ///////////////////////
2485   // Setting the vertices 
2486   ///////////////////////
2487   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2488   xcapacitorvertex[1] = xcapacitorvertex[0];   
2489   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2490   xcapacitorvertex[3] = xcapacitorvertex[2];   
2491   xcapacitorvertex[4] = xcapacitorvertex[0];   
2492   xcapacitorvertex[5] = xcapacitorvertex[0];   
2493   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2494   xcapacitorvertex[7] = xcapacitorvertex[6];   
2495   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2496   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2497   ycapacitorvertex[2] = ycapacitorvertex[1];   
2498   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2499   ycapacitorvertex[4] = ycapacitorvertex[3];   
2500   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2501   ycapacitorvertex[6] = ycapacitorvertex[5];   
2502   ycapacitorvertex[7] = ycapacitorvertex[0];   
2503   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2504   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2505                                               ycapacitorvertex);
2506   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2507   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2508 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2509 //                                          fSSDAir);
2510   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2511 ////////////////////////////
2512 // Connector 
2513 ///////////////////////////
2514   const Int_t kssdconnectornumber = 2;
2515   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2516   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2517   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2518                                    +  fgkSSDConnectorAlHeight};  
2519   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2520   TGeoVolume* ssdconnector[kssdconnectornumber];
2521   for(Int_t i=0; i<kssdconnectornumber; i++){
2522       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2523                                           0.5*fgkSSDConnectorWidth,
2524                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2525                            +              i*fgkSSDConnectorNiHeight),
2526                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2527       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2528                                        i==0 ? fSSDAlTraceFlexMedium 
2529                                             : fSSDStiffenerConnectorMedium);      
2530       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2531   }
2532   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2533   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2534                        +  fgkSSDConnectorPosition[0]
2535                        -  fgkSSDConnectorSeparation
2536                        -  1.5*fgkSSDConnectorLength,
2537                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2538                        -  fgkSSDConnectorPosition[1]
2539                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2540   ssdconnectortrans[1] = new TGeoTranslation(
2541                        -  ssdstiffenershape->GetDX()
2542                        +  fgkSSDConnectorPosition[0]
2543                        -  0.5*fgkSSDConnectorLength,
2544                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2545                        -  fgkSSDConnectorPosition[1]
2546                        -  ssdconnectorshape[0]->GetDY(),0.0);
2547   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2548                        -  fgkSSDConnectorPosition[0]
2549                        +  fgkSSDConnectorSeparation
2550                        +  1.5*fgkSSDConnectorLength,
2551                           -(ssdstiffenershape->GetDY()
2552                        -  fgkSSDConnectorPosition[1]
2553                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2554   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2555                        -  fgkSSDConnectorPosition[0]
2556                        +  0.5*fgkSSDConnectorLength,
2557                           -(ssdstiffenershape->GetDY()
2558                        -  fgkSSDConnectorPosition[1]
2559                        -  ssdconnectorshape[0]->GetDY()),0.0);
2560   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2561       for(Int_t j=0; j<kssdconnectornumber; j++)
2562             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2563 ////////////////////////////
2564 // Capacitor 1812-330 nF
2565 /////////////////////////// 
2566   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2567   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2568                                                                                          0.5*fgkSSDCapacitor1812Length,
2569                                                                                          0.5*fgkSSDCapacitor1812Width,
2570                                                                                          0.5*fgkSSDCapacitor1812Height,
2571             ssdcapacitor1812origin);
2572   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2573                                              fSSDStiffener1812CapacitorMedium); 
2574   capacitor1812->SetLineColor(fColorAl);
2575   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2576                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2577                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2578   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2579 ////////////////////////////
2580 //Hybrid Wire
2581 ////////////////////////////
2582   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2583                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2584                                  - fgkSSDConnectorSeparation;
2585   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2586                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2587   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2588
2589   Double_t wireangle = TMath::ATan(wirex/wirey);
2590   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2591                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2592   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2593                                              fSSDStiffenerHybridWireMedium); 
2594   hybridwire->SetLineColor(fColorPhynox);
2595   TGeoCombiTrans* hybridwirecombitrans[2];
2596   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2597                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2598                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2599                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2600                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2601                                    ssdstiffenershape->GetDZ()
2602                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2603                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2604   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2605                             0.0,
2606                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2607                             0.0,        
2608                             new TGeoRotation("HybridWireRot2",
2609                           - wireangle*TMath::RadToDeg(),0.,0.));
2610   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2611   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2612   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2613   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2614   ssdhybridlist->Add(ssdhybridcapacitormother);
2615   /////////////////////////////////////////////////////////////
2616   // Deallocating memory
2617   /////////////////////////////////////////////////////////////
2618   delete hybridwirecombitrans[0];
2619   delete hybridwirecombitrans[1];
2620   delete ssdchipsystemlist;
2621   return ssdhybridlist;
2622   /////////////////////////////////////////////////////////////
2623 }
2624 ///////////////////////////////////////////////////////////////////////////////
2625 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2626   /////////////////////////////////////////////////////////////
2627   // SSD Cooling Block System
2628   /////////////////////////////////////////////////////////////
2629   // SSD Cooling Block and Cooling Tube Transformations
2630   /////////////////////////////////////////////////////////////
2631   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2632   localcoolingblockrot->SetAngles(0.,90.,0.);
2633   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2634   TVector3* coolingblocktransvector;
2635   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2636                                                                 + fgkSSDCoolingBlockLength,
2637                                                                   fgkSSDSensorLength
2638                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2639                                                                 - fgkSSDCoolingBlockWidth);
2640   const Int_t kcoolingblocktransnumber = 2;
2641   const Int_t kcoolingblocknumber = 4;
2642   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2643   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2644   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2645   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2646   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2647   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2648                                         0.5*fgkSSDCoolingBlockWidth,
2649                                         fgkSSDCoolingBlockHoleCenter);
2650   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2651   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2652   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2653     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2654       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2655                                              j*coolingblocktransvector->Y(),
2656                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2657                                                     + fgkCoolingTubeRmax));
2658       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2659       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2660     }
2661   }
2662   /////////////////////////////////////////////////////////////
2663   // Virtual Volume containing CoolingBlock System   
2664   /////////////////////////////////////////////////////////////
2665   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2666   const Int_t kmothervertexnumber = 16;  
2667   Double_t xmothervertex[kmothervertexnumber];
2668   Double_t ymothervertex[kmothervertexnumber];
2669   ///////////////////////
2670   // Setting the vertices 
2671   ///////////////////////fgkCoolingTubeSupportRmax
2672   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2673   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2674                                    + fgkSSDCoolingBlockWidth;
2675   xmothervertex[2] = coolingblocktransvector->X()
2676                                    + fgkSSDCoolingBlockLength
2677                                    + 4*coolingtubedistance;
2678   ymothervertex[2] = ymothervertex[1];
2679   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2680   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2681   ymothervertex[4] = ymothervertex[0];
2682   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2683   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2684   ymothervertex[6] = ymothervertex[5]; 
2685   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2686                                    - fgkSSDCoolingBlockWidth; 
2687   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2688   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2689                                    - coolingtubedistance;
2690   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2691   ymothervertex[10] = ymothervertex[9];
2692   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2693   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2694   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2695   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2696   ymothervertex[14] = ymothervertex[13];
2697   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2698   //////////////////////////////////////////////////////////
2699   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2700                                                                         xmothervertex,ymothervertex);
2701   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2702                                                                                            + fgkCoolingTubeRmax));
2703   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2704                                                                                            + fgkCoolingTubeRmax));
2705   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2706 //  TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2707 //                                                        coolingsystemothershape,fSSDAir);
2708   /////////////////////////////////////////////////////////////
2709   // SSD Cooling Tube Part 
2710   /////////////////////////////////////////////////////////////
2711   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2712   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2713                                                                                  0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance)); 
2714   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2715                                                                          0.5*(fgkSSDCoolingBlockWidth-fgkSSDTolerance));
2716   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2717   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2718                                                                         fSSDCoolingTubePhynox);
2719   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2720                                                                         fSSDCoolingTubeWater);
2721   coolingtube[0]->SetLineColor(fColorPhynox);
2722   coolingtube[1]->SetLineColor(fColorWater);
2723   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2724   /////////////////////////////////////////////////////////////
2725   // Adding Cooling block to mother volume
2726   /////////////////////////////////////////////////////////////
2727    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2728         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2729         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2730         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2731   }
2732   /////////////////////////////////////////////////////////////
2733   // Deallocating memory
2734   /////////////////////////////////////////////////////////////
2735         delete coolingblocktransvector;
2736         delete localcoolingblockrot;
2737         delete localcoolingtubetrans;
2738         delete localcoolingtuberot;
2739   /////////////////////////////////////////////////////////////
2740   // Checking overlaps  
2741   /////////////////////////////////////////////////////////////
2742         //coolingsystemother->CheckOverlaps(0.01);
2743   /////////////////////////////////////////////////////////////
2744         return coolingsystemother;
2745 }
2746 /////////////////////////////////////////////////////////////////////////////////
2747 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2748   /////////////////////////////////////////////////////////////
2749   // SSD Flex
2750   /////////////////////////////////////////////////////////////
2751   const Int_t kssdflexlayernumber = 2;
2752   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2753   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2754   const Int_t kmothervertexnumber = 17; 
2755   Double_t xmothervertex[kmothervertexnumber];
2756   Double_t ymothervertex[kmothervertexnumber];
2757   /////////////////////////////////////////////
2758   // Auxiliary variables for vertex positioning
2759   /////////////////////////////////////////////
2760   const Int_t kssdflexboxnumber = 5;
2761   Double_t ssdflexboxlength[kssdflexboxnumber];
2762   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2763                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2764                                           *     fgkSSDChipSeparationLength
2765                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2766                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2767   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2768   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2769                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2770   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2771   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2772                                           -     ssdflexboxlength[1];
2773   Double_t ssdflexboxwidth[kssdflexboxnumber];
2774   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2775   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2776   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2777   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2778   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2779   ///////////////////////
2780   // Setting the vertices 
2781   ///////////////////////
2782   xmothervertex[0]  = 0.0;
2783   xmothervertex[1]  = xmothervertex[0];
2784   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2785   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2786                                         + ssdflexboxlength[4];
2787   xmothervertex[4]  = xmothervertex[3];
2788   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2789   xmothervertex[6]  = xmothervertex[5];
2790   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2791   xmothervertex[8]  = xmothervertex[7];
2792   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2793   xmothervertex[10] = xmothervertex[9]; 
2794   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2795   xmothervertex[12] = xmothervertex[11];
2796   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2797   xmothervertex[14] = xmothervertex[13];
2798   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2799   xmothervertex[16] = xmothervertex[15];
2800   ymothervertex[0]  = 0.0;
2801   ymothervertex[1]  = fgkSSDFlexWidth[1];
2802   ymothervertex[2]  = fgkSSDFlexWidth[0];
2803   ymothervertex[3]  = ymothervertex[2];
2804   ymothervertex[4]  = ymothervertex[0];
2805   ymothervertex[5]  = ymothervertex[4];
2806   ymothervertex[6]  = ssdflexboxwidth[2];
2807   ymothervertex[7]  = ymothervertex[6];
2808   ymothervertex[8]  = ymothervertex[0];
2809   ymothervertex[9]  = ymothervertex[8];
2810   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2811   ymothervertex[11] = ymothervertex[10];
2812   ymothervertex[12] = ymothervertex[0];
2813   ymothervertex[13] = ymothervertex[12];
2814   ymothervertex[14] = ymothervertex[7];
2815   ymothervertex[15] = ymothervertex[14];
2816   ymothervertex[16] = ymothervertex[0];
2817   /////////////////////////////////////////////////////////////
2818   // First Mother Volume containing SSDFlex
2819   /////////////////////////////////////////////////////////////
2820   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2821   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2822                                                                     ymothervertex);
2823   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2824   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2825   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2826 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2827 //                                                                                       fSSDAir);
2828   /////////////////////////////////////////////////////////////
2829   // SSDFlex Layer Shapes
2830   /////////////////////////////////////////////////////////////
2831   for(Int_t i=0; i<kssdflexlayernumber; i++){
2832         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2833                                                                    ymothervertex);
2834     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2835         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2836   }
2837   /////////////////////////////////////
2838   // Setting Layers into Mother Volume
2839   /////////////////////////////////////
2840   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2841   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2842                                                                                                  fSSDKaptonFlexMedium};
2843   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2844                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2845   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2846   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2847   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2848         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2849                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2850                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2851         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2852     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2853                                          +                                         fgkSSDFlexHeight[1])); 
2854     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2855   }
2856   return ssdflexmother;
2857 }
2858 /////////////////////////////////////////////////////////////////////////////////
2859 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2860   /////////////////////////////////////////////////////////////
2861   // Method generating SSD End Flex   
2862   /////////////////////////////////////////
2863   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2864                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2865   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2866                                                 * TMath::DegToRad()*ssdflexradiusmax
2867                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2868                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2869                                                         - 0.1*fgkSSDFlexFullLength;
2870   const Int_t knedges = 20;  
2871   const Int_t karcnumber = 2;
2872   TVector3* vertexposition[karcnumber*(knedges+1)];
2873   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2874   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2875   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2876   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2877                                                                                  - 90.0*TMath::DegToRad()};
2878   TVector3* referencetrans[karcnumber];
2879   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2880                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2881                                                                    radius[0]);
2882   referencetrans[1] = new TVector3(referencetrans[0]->X()
2883                                         +              fgkSSDFlexLength[2],
2884      -              fgkSSDStiffenerHeight);
2885 for(Int_t i=0; i<karcnumber; i++){
2886         for(Int_t j=0; j<knedges+1; j++){
2887                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2888                                                                                                radius[i]*SinD(angle[i]));
2889                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2890         }       
2891   }
2892   ///////////////////////
2893   // Setting the vertices 
2894   ///////////////////////
2895   const Int_t kendflexlayernumber = 4;
2896   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2897   TVector3** vertex[kendflexlayernumber];
2898   for(Int_t i=0; i<kendflexlayernumber; i++) 
2899                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2900   TVector3* transvector[kendflexlayernumber+1];
2901   TVector3* deltatransvector = new TVector3();  
2902   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2903   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2904                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2905   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2906         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2907                                         *                 CosD(fgkSSDFlexAngle),
2908                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2909                                         *         SinD(fgkSSDFlexAngle),0.0);   
2910         *transvector[i] = *transvector[i-1]+*deltatransvector;
2911   }
2912   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2913   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2914   for(Int_t i=0; i<karcnumber; i++){
2915         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2916                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2917                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2918                                               /radius[i];
2919         }
2920   }
2921   for(Int_t i=0; i<kendflexlayernumber; i++){
2922         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2923         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2924         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2925                 if(j<(knedges+1)){
2926                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2927                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2928                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2929                         *vertex[i][j+2] += *referencetrans[0];
2930                         vertex[i][4*(knedges+1)-j+1] = 
2931                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2932                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2933                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2934                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2935                 }
2936                 else{
2937                 
2938                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2939                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2940                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2941                         *vertex[i][j+2] += *referencetrans[1];
2942                         vertex[i][4*(knedges+1)-j+1] = 
2943                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2944                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2945                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2946                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2947            }
2948         }
2949   }
2950   /////////////////////////////////////////////////////////////
2951   // First Mother Volume containing SSDEndFlex
2952   /////////////////////////////////////////////////////////////
2953   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2954   Double_t xmothervertex[kendflexvertexnumber];
2955   Double_t ymothervertex[kendflexvertexnumber];
2956   xmothervertex[0] = vertex[0][0]->X(); 
2957   ymothervertex[0] = vertex[0][0]->Y();
2958   for(Int_t i=1; i<kendflexvertexnumber; i++){
2959         if(i<2*(knedges+1)+2){
2960                 xmothervertex[i] = vertex[3][i]->X();
2961                 ymothervertex[i] = vertex[3][i]->Y();
2962         }
2963         else{
2964                 xmothervertex[i] = vertex[0][i]->X();
2965                 ymothervertex[i] = vertex[0][i]->Y();
2966         }
2967   }
2968   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2969                                                                            xmothervertex,ymothervertex);
2970   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2971   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2972 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2973 //                                                               ssdendflexmothershape,fSSDAir);        
2974   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2975   //////////////////////////////////////
2976   // End Flex TGeoXtru Layer Definition 
2977   //////////////////////////////////////
2978   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2979   TGeoVolume* ssdendflex[kendflexlayernumber];
2980   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2981   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2982   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2983   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2984   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2985                                                                                                         fSSDKaptonFlexMedium};
2986   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2987                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2988   for(Int_t i=0; i<kendflexlayernumber; i++){
2989         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2990                 xvertex[i][j] = vertex[i][j]->X();
2991                 yvertex[i][j] = vertex[i][j]->Y();
2992         }
2993   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2994   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2995   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2996   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2997                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2998   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2999   ssdendflexmother->AddNode(ssdendflex[i],1);
3000   }
3001   /////////////////////////////////////////////////////////////
3002   // Deallocating memory
3003   /////////////////////////////////////////////////////////////
3004   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
3005   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
3006   for(Int_t i=0; i<kendflexlayernumber; i++){
3007         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
3008         delete [] vertex[i];
3009   }
3010   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
3011   delete deltatransvector;
3012   /////////////////////////////////////////////////////////////
3013   //ssdendflexmother->CheckOverlaps(0.01);
3014   return ssdendflexmother;
3015 }
3016 ///////////////////////////////////////////////////////////////////////////////
3017 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
3018   /////////////////////////////////////////////////////////////
3019   // Method generating the Mounting Block
3020   /////////////////////////////////////////////////////////////  
3021   const Int_t kvertexnumber = 8;
3022   Double_t xvertex[kvertexnumber];
3023   Double_t yvertex[kvertexnumber];
3024   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3025   xvertex[1] = xvertex[0];
3026   xvertex[2] = -xvertex[0];
3027   xvertex[3] = xvertex[2];
3028   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
3029                          -                                 fgkSSDMountingBlockLength[2]);
3030   xvertex[5] = xvertex[4];
3031   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
3032                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
3033                          -     fgkSSDMountingBlockScrewHoleRadius[0];
3034   xvertex[7] = xvertex[6];
3035   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3036                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3037   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
3038   yvertex[2] = yvertex[1]; 
3039   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
3040   yvertex[4] = yvertex[3];
3041   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
3042                          - fgkSSDMountingBlockHeight[0];
3043   yvertex[6] = yvertex[5];
3044   yvertex[7] = yvertex[0];
3045
3046   ///////////////////////////////////////////////////////////////////////
3047   // TGeoXTru Volume definition for Mounting Block Part
3048   ///////////////////////////////////////////////////////////////////////
3049   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
3050   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
3051   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3052   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3053   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
3054                                                                           ssdmountingblockshape,
3055                                                                                   fSSDMountingBlockMedium);
3056   ssdmountingblock->SetLineColor(fColorG10);
3057   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
3058   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
3059   TGeoRotation* mountingblockrot = new TGeoRotation();
3060   mountingblockrot->SetAngles(90.,180.,-90.);
3061   mountingblockcombitrans->SetRotation(*mountingblockrot);
3062   /////////////////////////////////////////////////////////////
3063   // Generating the Mounting Block Screw Vertices 
3064   /////////////////////////////////////////////////////////////  
3065   const Int_t kscrewvertexnumber = 15;
3066   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
3067                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
3068                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
3069                                  * TMath::RadToDeg();
3070   Double_t phi0 = 90.+alpha;
3071   Double_t phi = 270.-2*alpha;
3072   Double_t deltaphi = phi/kscrewvertexnumber;   
3073   TVector3* screwvertex[kscrewvertexnumber+1];
3074   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
3075         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
3076                                    *CosD(phi0+i*deltaphi),
3077                                    fgkSSDMountingBlockScrewHoleRadius[0]
3078                                    *SinD(phi0+i*deltaphi));
3079   Double_t xscrewvertex[kscrewvertexnumber+6];
3080   Double_t yscrewvertex[kscrewvertexnumber+6];
3081   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
3082   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
3083                                   -               fgkSSDMountingBlockScrewHoleEdge);
3084   xscrewvertex[1] = xscrewvertex[0];
3085   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
3086   xscrewvertex[2] = screwvertex[0]->X();
3087   yscrewvertex[2] = yscrewvertex[1];
3088   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
3089         xscrewvertex[i+3] = screwvertex[i]->X();        
3090         yscrewvertex[i+3] = screwvertex[i]->Y();        
3091   } 
3092   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
3093   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
3094   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
3095   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
3096   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
3097   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
3098   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
3099   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
3100                                                         +                                  fgkSSDMountingBlockHeight[2]);
3101   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
3102                                                                                 ssdmountingblockscrewshape,
3103                                                                                             fSSDMountingBlockMedium);
3104   ssdmountingblockscrew->SetLineColor(fColorG10);
3105   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
3106   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
3107   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3108                                                                         -                                yscrewvertex[1],
3109                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
3110                                                                         -                                fgkSSDMountingBlockHeight[2]
3111                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3112                                                                         +                                fgkSSDMountingBlockHeight[2]
3113                                                                         -                                yvertex[0]));
3114   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3115                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
3116                                                                                                                  yscrewvertex[1]
3117                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3118                                                                                                          +fgkSSDMountingBlockHeight[2]
3119                                                                                                          -yvertex[0]));
3120   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
3121                                                                                                           yscrewvertex[1],
3122                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
3123                                                                         +                                 fgkSSDMountingBlockHeight[2]
3124                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3125                                                                         +                                 fgkSSDMountingBlockHeight[2]
3126                                                                         -                                 yvertex[0]));
3127   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
3128                                                                                                          yscrewvertex[1],
3129                                                                         -                                yscrewvertex[1]
3130                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3131                                                                         +                                fgkSSDMountingBlockHeight[2]
3132                                                                         -                                yvertex[0]));
3133   TGeoRotation* ssdmountingblockscrewrot[4];
3134   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
3135         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
3136     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
3137     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
3138   for(Int_t i=1; i<4; i++) 
3139         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
3140   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
3141   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
3142   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3143   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3144                                                          +                                xvertex[0],yscrewvertex[1]
3145                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3146                                                          +                                fgkSSDMountingBlockHeight[2]
3147                                                          -                                yvertex[0]),0.);      
3148   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3149   for(Int_t i=0; i<4; i++){
3150         ssdmountingblockscrewmatrix[i] = 
3151                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3152         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3153   }
3154   ///////////////////////////////////////////////////////////////////////
3155   // TGeoXtru for Mother Volume 
3156   ///////////////////////////////////////////////////////////////////////
3157   const Int_t kvertexmothernumber = 12;
3158   Double_t xmothervertex[kvertexmothernumber];
3159   Double_t ymothervertex[kvertexmothernumber];
3160   for(Int_t i=0; i<6; i++){
3161         xmothervertex[i] = xvertex[i];
3162         ymothervertex[i] = yvertex[i];
3163   } 
3164   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3165   ymothervertex[6]  = ymothervertex[5];
3166   xmothervertex[7]  = xmothervertex[6];
3167   ymothervertex[7]  = ymothervertex[4];
3168   xmothervertex[8]  = xmothervertex[7]
3169                                         + 0.5*(fgkSSDMountingBlockLength[1]
3170                                         -          fgkSSDMountingBlockLength[2]);
3171   ymothervertex[8]  = ymothervertex[4];
3172   xmothervertex[9]  = xmothervertex[8];
3173   ymothervertex[9]  = ymothervertex[2];
3174   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3175   ymothervertex[10] = ymothervertex[1];
3176   xmothervertex[11] = xmothervertex[10];
3177   ymothervertex[11] = ymothervertex[0];  
3178   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3179   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3180   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3181   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3182   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3183                                                                           ssdmountingblockmothershape,
3184                                                                                   fSSDAir);
3185   /////////////////////////////////////////////////////////////
3186   // Placing the Volumes into Mother Volume 
3187   /////////////////////////////////////////////////////////////
3188   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3189   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3190   for(Int_t i=0; i<4; i++) 
3191         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3192                                                                         ssdmountingblockscrewmatrix[i]);
3193   /////////////////////////////////////////////////////////////
3194   // Deallocating memory
3195   /////////////////////////////////////////////////////////////
3196   delete mountingblockrot;
3197   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3198   delete ssdmountingblockglobalrot; 
3199   delete ssdmountingblockglobaltrans; 
3200   /////////////////////////////////////////////////////////////
3201   return ssdmountingblockmother;
3202 }
3203 ///////////////////////////////////////////////////////////////////////////////
3204  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3205   /////////////////////////////////////////////////////////////
3206   // Method generating the Mounting Block Clip 
3207   /////////////////////////////////////////////////////////////  
3208   const Int_t kmothervertexnumber = 10;
3209   Double_t xmothervertex[kmothervertexnumber];
3210   Double_t ymothervertex[kmothervertexnumber];
3211   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3212                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3213   xmothervertex[1] = xmothervertex[0];
3214   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3215                                    - fgkMountingBlockClibScrewRadius);
3216   xmothervertex[3] = xmothervertex[2]; 
3217   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3218   xmothervertex[5] = xmothervertex[4]; 
3219   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3220   xmothervertex[7] = xmothervertex[6]; 
3221   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3222   xmothervertex[9] = xmothervertex[8]; 
3223   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3224                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3225   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3226   ymothervertex[2] = ymothervertex[1];
3227   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3228                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3229                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3230   ymothervertex[4] = ymothervertex[3];
3231   ymothervertex[5] = ymothervertex[2];
3232   ymothervertex[6] = ymothervertex[5];
3233   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3234   ymothervertex[8] = ymothervertex[7];
3235   ymothervertex[9] = ymothervertex[0];
3236
3237   ///////////////////////////////////////////////////////////////////////
3238   // TGeoXTru Volume definition for Mounting Block Clip Part
3239   ///////////////////////////////////////////////////////////////////////
3240   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3241   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3242   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3243   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3244   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3245                                                                           ssdmountingblockclipshape,fSSDAir);
3246   ssdmountingblockclip->SetLineColor(4);
3247   ///////////////////////////////////////////////////////////////////////
3248   // TGeoXTru Volume definition for Clip 
3249   ///////////////////////////////////////////////////////////////////////
3250   const Int_t kclipvertexnumber = 6;
3251   Double_t xclipvertex[kclipvertexnumber];
3252   Double_t yclipvertex[kclipvertexnumber];
3253   xclipvertex[0] = xmothervertex[0];
3254   xclipvertex[1] = xclipvertex[0];
3255   xclipvertex[2] = xmothervertex[6];
3256   xclipvertex[3] = xclipvertex[2];
3257   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3258   xclipvertex[5] = xclipvertex[4];
3259   yclipvertex[0] = ymothervertex[0];
3260   yclipvertex[1] = ymothervertex[1];
3261   yclipvertex[2] = yclipvertex[1];
3262   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3263   yclipvertex[4] = yclipvertex[3];
3264   yclipvertex[5] = yclipvertex[0];
3265   TGeoXtru* clipshape = new TGeoXtru(2);
3266   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3267   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3268   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3269                                                          +   fgkMountingBlockClibWidth);
3270   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3271   clip->SetLineColor(18);
3272   ///////////////////////////////////////////////////////////////////////
3273   // Ladder Support Piece  
3274   ///////////////////////////////////////////////////////////////////////
3275   const Int_t ksupportvertexnumber = 4;
3276   Double_t xsupportvertex[ksupportvertexnumber];
3277   Double_t ysupportvertex[ksupportvertexnumber];
3278   xsupportvertex[0] = xclipvertex[5];
3279   xsupportvertex[1] = xsupportvertex[0];
3280   xsupportvertex[2] = xmothervertex[9];
3281   xsupportvertex[3] = xsupportvertex[2];
3282   ysupportvertex[0] = yclipvertex[0];
3283   ysupportvertex[1] = yclipvertex[3];
3284   ysupportvertex[2] = ysupportvertex[1];
3285   ysupportvertex[3] = ysupportvertex[0];
3286   TGeoXtru* supportshape = new TGeoXtru(2);
3287   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3288   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3289   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3290   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3291   support->SetLineColor(9);
3292   ///////////////////////////////////////////////////////////////////////
3293   // TGeoXTru Volume definition for Screw   
3294   ///////////////////////////////////////////////////////////////////////
3295   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3296                                                 0.5*fgkMountingBlockClibScrewRadius};
3297   Int_t edgesnumber[2] = {50,6};
3298   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3299                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3300   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3301   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3302   clipscrew->SetLineColor(12);
3303   TGeoRotation* screwrot = new TGeoRotation();
3304   screwrot->SetAngles(0.,90.,0.);
3305   TGeoTranslation* screwtrans = new TGeoTranslation();
3306   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3307                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3308                                                          0.5*fgkSSDMountingBlockWidth+
3309                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3310   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3311   ///////////////////////////////////////////////////////////////////////
3312   // Placing the Volumes
3313   ///////////////////////////////////////////////////////////////////////
3314   ssdmountingblockclip->AddNode(clip,1);
3315   ssdmountingblockclip->AddNode(support,1);
3316   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3317   /////////////////////////////////////////////////////////////
3318   // Deallocating memory
3319   /////////////////////////////////////////////////////////////  
3320   delete screwtrans;
3321   delete screwrot;
3322   /////////////////////////////////////////////////////////////
3323   return ssdmountingblockclip;
3324 }
3325 ///////////////////////////////////////////////////////////////////////////////
3326 TList* AliITSv11GeometrySSD::GetCoolingTubeList()const{
3327   /////////////////////////////////////////////////////////////
3328   // Method generating the Cooling Tube 
3329   /////////////////////////////////////////////////////////////  
3330    TGeoTube** coolingtubeshape[fgkcoolingtubenumber];
3331    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtubeshape[i] = 
3332                                                                                                 new     TGeoTube*[2];
3333    // Ladder Cooling Tubes
3334    coolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3335                                           0.25 * (fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3336                                                   -     2.*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
3337                                                   -0.5*fgkSSDTolerance);
3338    coolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3339                                                                                  coolingtubeshape[0][0]->GetDz());
3340    coolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3341                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]
3342                                                   -                                       fgkSSDSensorOverlap-fgkSSDTolerance));
3343    coolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3344                                                                                  coolingtubeshape[1][0]->GetDz());
3345    coolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3346                                                                                  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDTolerance));
3347    coolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3348                                                                                  coolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3349    // End Ladder Cooling Tubes  
3350    TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3351    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3352    endladdercoolingtubeshape[i] = new   TGeoTube*[2];
3353    endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3354                                                         0.50 * (fgkEndLadderMountingBlockPosition[0]
3355                                                   -                     fgkendladdercoolingsupportdistance[0]-fgkSSDTolerance));
3356    endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3357                                                                         endladdercoolingtubeshape[0][0]->GetDz());
3358    endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3359                                                         0.50 * (fgkendladdercoolingsupportdistance[0]
3360                                                   +                     fgkendladdercoolingsupportdistance[1]
3361                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3362    endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3363                                                                         endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3364    endladdercoolingtubeshape[2][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3365                                                         0.50 * (fgkEndLadderCarbonFiberLowerJunctionLength[0]
3366                                                   -                     fgkEndLadderMountingBlockPosition[0]
3367                                                   -                     fgkendladdercoolingsupportdistance[1]           
3368                                                   -                     fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3369    endladdercoolingtubeshape[2][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3370                                                                         endladdercoolingtubeshape[2][0]->GetDz()-0.5*fgkSSDTolerance);
3371    endladdercoolingtubeshape[3][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3372                                                           0.50 * (fgkMountingBlockToSensorSupport
3373                                                         - 0.50 * (fgkSSDFlexHoleWidth-fgkSSDSensorSideSupportWidth)
3374                                                         -                 fgkSSDStiffenerWidth-fgkSSDModuleStiffenerPosition[1]
3375                                                         +                 fgkSSDSensorOverlap
3376                                                         +                 fgkEndLadderCarbonFiberLowerJunctionLength[1]
3377                                                         -                 fgkendladdercoolingsupportdistance[2]
3378                                                         -                 fgkEndLadderMountingBlockPosition[1]
3379                                                         -                 fgkCoolingTubeSupportWidth-fgkSSDTolerance));
3380    endladdercoolingtubeshape[3][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3381                                                                         endladdercoolingtubeshape[3][0]->GetDz()-0.5*fgkSSDTolerance);
3382    endladdercoolingtubeshape[4][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3383                                                           0.50 * (fgkendladdercoolingsupportdistance[2]-fgkSSDTolerance));
3384    endladdercoolingtubeshape[4][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3385                                                                         endladdercoolingtubeshape[4][0]->GetDz()-0.5*fgkSSDTolerance);
3386    // Ladder Cooling Tubes
3387    TGeoVolume** coolingtube[fgkcoolingtubenumber];
3388    for(Int_t i=0; i<fgkcoolingtubenumber; i++) coolingtube[i] = 
3389                                                                                          new TGeoVolume*[2];
3390    coolingtube[0][0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0][0],
3391                                                                           fSSDCoolingTubePhynox);
3392    coolingtube[0][1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[0][1],
3393                                                                           fSSDCoolingTubeWater);
3394    coolingtube[1][0] = new TGeoVolume("OuterCoolingTube2",coolingtubeshape[1][0],
3395                                                                           fSSDCoolingTubePhynox);
3396    coolingtube[1][1] = new TGeoVolume("InnerCoolingTube2",coolingtubeshape[1][1],
3397                                                                           fSSDCoolingTubeWater);
3398    coolingtube[2][0] = new TGeoVolume("OuterCoolingTube3",coolingtubeshape[2][0],
3399                                                                           fSSDCoolingTubePhynox);
3400    coolingtube[2][1] = new TGeoVolume("InnerCoolingTube3",coolingtubeshape[2][1],
3401                                                                           fSSDCoolingTubeWater);
3402    for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3403         coolingtube[i][0]->SetLineColor(fColorPhynox);
3404         coolingtube[i][1]->SetLineColor(fColorWater);
3405    }
3406    // End Ladder Cooling Tubes  
3407    TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3408    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3409    endladdercoolingtube[i] = new TGeoVolume*[2];
3410    endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3411                                                                 endladdercoolingtubeshape[0][0],
3412                                                                 fSSDCoolingTubePhynox);
3413    endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3414                                                                 endladdercoolingtubeshape[0][1],
3415                                                                 fSSDCoolingTubeWater);
3416    endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3417                                                                 endladdercoolingtubeshape[1][0],
3418                                                                 fSSDCoolingTubePhynox);
3419    endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3420                                                                 endladdercoolingtubeshape[1][1],
3421                                                                 fSSDCoolingTubeWater);
3422    endladdercoolingtube[2][0] = new TGeoVolume("OuterEndLadderCoolingTube3",
3423                                                                 endladdercoolingtubeshape[2][0],
3424                                                                 fSSDCoolingTubePhynox);
3425    endladdercoolingtube[2][1] = new TGeoVolume("InnerEndlLadderCoolingTube3",
3426                                                                 endladdercoolingtubeshape[2][1],
3427                                                                 fSSDCoolingTubeWater);
3428    endladdercoolingtube[3][0] = new TGeoVolume("OuterEndLadderCoolingTube4",
3429                                                                 endladdercoolingtubeshape[3][0],
3430                                                                 fSSDCoolingTubePhynox);
3431    endladdercoolingtube[3][1] = new TGeoVolume("InnerEndlLadderCoolingTube4",
3432                                                                 endladdercoolingtubeshape[3][1],
3433                                                                 fSSDCoolingTubeWater);
3434    endladdercoolingtube[4][0] = new TGeoVolume("OuterEndLadderCoolingTube5",
3435                                                                 endladdercoolingtubeshape[4][0],
3436                                                                 fSSDCoolingTubePhynox);
3437    endladdercoolingtube[4][1] = new TGeoVolume("InnerEndlLadderCoolingTube5",
3438                                                                 endladdercoolingtubeshape[4][1],
3439                                                                 fSSDCoolingTubeWater);
3440    for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3441                 endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3442                 endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3443    }
3444   
3445   /////////////////////////////////////////////////////////////
3446   // Virtual Volume containing Cooling Tubes
3447   /////////////////////////////////////////////////////////////
3448   // Ladder Cooling Tubes
3449   TGeoTube* virtualcoolingtubeshape[fgkcoolingtubenumber];
3450   for(Int_t i=0; i<fgkcoolingtubenumber; i++)
3451   virtualcoolingtubeshape[i] = new TGeoTube(coolingtubeshape[i][1]->GetRmin(),
3452                                                                                         coolingtubeshape[i][0]->GetRmax(),
3453                                                                                         coolingtubeshape[i][0]->GetDz());
3454   TGeoVolume* virtualcoolingtube[fgkcoolingtubenumber];
3455   virtualcoolingtube[0] = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape[0],
3456                                                                           fSSDAir);
3457   virtualcoolingtube[1] = new TGeoVolume("CoolingTube2",virtualcoolingtubeshape[1],
3458                                                                           fSSDAir);
3459   virtualcoolingtube[2] = new TGeoVolume("CoolingTube3",virtualcoolingtubeshape[2],
3460                                                                           fSSDAir);
3461   // End Ladder Cooling Tubes
3462   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3463   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3464   endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3465                                                                                         endladdercoolingtubeshape[i][0]->GetRmax(),
3466                                                                                         endladdercoolingtubeshape[i][0]->GetDz());
3467   TGeoVolume* endladdervirtualcoolingtube[fgkendladdercoolingtubenumber];
3468   endladdervirtualcoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3469                                                                           endladdervirtualcoolingtubeshape[0],
3470                                                                           fSSDAir);
3471   endladdervirtualcoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3472                                                                           endladdervirtualcoolingtubeshape[1],
3473                                                                           fSSDAir);
3474   endladdervirtualcoolingtube[2] = new TGeoVolume("EndLadderCoolingTube3",
3475                                                                           endladdervirtualcoolingtubeshape[2],
3476                                                                           fSSDAir);
3477   endladdervirtualcoolingtube[3] = new TGeoVolume("EndLadderCoolingTube4",
3478                                                                           endladdervirtualcoolingtubeshape[3],
3479                                                                           fSSDAir);
3480   endladdervirtualcoolingtube[4] = new TGeoVolume("EndLadderCoolingTube5",
3481                                                                           endladdervirtualcoolingtubeshape[4],
3482                                                                           fSSDAir);
3483   TList* coolingtubelist = new TList();
3484   for(Int_t i=0; i<fgkcoolingtubenumber; i++){
3485         virtualcoolingtube[i]->AddNode(coolingtube[i][0],1);
3486         virtualcoolingtube[i]->AddNode(coolingtube[i][1],1);
3487     coolingtubelist->Add(virtualcoolingtube[i]);
3488   }
3489         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3490         endladdervirtualcoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3491     coolingtubelist->Add(endladdervirtualcoolingtube[0]);
3492         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3493         endladdervirtualcoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);
3494     coolingtubelist->Add(endladdervirtualcoolingtube[1]);
3495         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][0],1);
3496         endladdervirtualcoolingtube[2]->AddNode(endladdercoolingtube[2][1],1);
3497     coolingtubelist->Add(endladdervirtualcoolingtube[2]);
3498         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][0],1);
3499         endladdervirtualcoolingtube[3]->AddNode(endladdercoolingtube[3][1],1);
3500     coolingtubelist->Add(endladdervirtualcoolingtube[3]);
3501         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][0],1);
3502         endladdervirtualcoolingtube[4]->AddNode(endladdercoolingtube[4][1],1);
3503     coolingtubelist->Add(endladdervirtualcoolingtube[4]);
3504   return coolingtubelist;
3505 }
3506 ///////////////////////////////////////////////////////////////////////////////
3507 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3508   /////////////////////////////////////////////////////////////
3509   // Method generating SSD Cooling Block    
3510   /////////////////////////////////////////////////////////////
3511   const Int_t kvertexnumber = 8;
3512   ///////////////////////////////////////
3513   // Vertex Positioning for TGeoXTru
3514   ///////////////////////////////////////
3515   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3516   vertexposition[0] = new TVector3(0.0,0.0);
3517   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3518   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3519                                           vertexposition[1]->Y());
3520   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3521                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3522   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3523   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3524                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3525   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3526                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3527                                         - fgkSSDCoolingBlockHoleLength[0]
3528                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3529                                           fgkSSDCoolingBlockHeight[0]
3530                                         - fgkSSDCoolingBlockHoleRadius[1],
3531                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3532   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3533                                         - fgkSSDCoolingBlockHoleLength[0]),
3534                                           vertexposition[6]->Y());
3535   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3536                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3537   Double_t phi = 180.-alpha;
3538   Double_t psi = 180.+2.*alpha;
3539   Double_t deltapsi = psi/nedges;
3540   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3541   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3542                                                   fgkSSDCoolingBlockHoleCenter);
3543   for(Int_t i=0; i<nedges+1; i++){
3544         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3545                                                                                                radius*SinD(phi+i*deltapsi));
3546    *vertexposition[kvertexnumber+i] += (*transvector);
3547   }
3548   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3549   for(Int_t i=0; i<kvertexnumber; i++)
3550     vertexposition[kvertexnumber+nedges+1+i] = 
3551                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3552   ///////////////////////////////////////////////////////////////////////
3553   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3554   ///////////////////////////////////////////////////////////////////////
3555   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3556   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3557   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3558   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3559         xvertexpoints[i] = vertexposition[i]->X();
3560         yvertexpoints[i] = vertexposition[i]->Y();
3561   } 
3562   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3563                                                                                         yvertexpoints);
3564   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3565   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3566   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3567                                                                           ssdcoolingblockshape,
3568                                                                                   fSSDAlCoolBlockMedium);
3569   ssdcoolingblock->SetLineColor(fColorAl);
3570   /////////////////////////////////////////////////////////////
3571   // Deallocating memory
3572   /////////////////////////////////////////////////////////////
3573   delete [] vertexposition;
3574   delete xvertexpoints;
3575   delete yvertexpoints;
3576   /////////////////////////////////////////////////////////////
3577   return ssdcoolingblock;
3578 }
3579 /////////////////////////////////////////////////////////////////////////////////
3580 TGeoVolume* AliITSv11GeometrySSD::GetSSDChipCables(Double_t SSDChipCablesHeigth, Int_t nedges){
3581   ///////////////////////////////////////////////////////
3582   const Int_t kssdchipcablesnumber    = 2;
3583   const Int_t kssdchipcableslaynumber = 2;
3584   const Int_t kvertexnumber                       = 4*(nedges+1)+4;
3585   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3586   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3587   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeigth
3588                                                  -  fgkSSDChipCablesHeight[0]
3589                                                  -  fgkSSDChipCablesHeight[1]);
3590   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3591   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3592   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3593                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3594                                                           - ssdchipcablesradius[0]
3595                                                           - fgkSSDChipCablesWidth[1]
3596                                                           - fgkSSDChipCablesWidth[2]);
3597   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3598                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3599                                                           +      fgkSSDChipCablesHeight[1]
3600                                                           +      fgkSSDSensorHeight);
3601   ///////////////////////////////////////////////////////
3602   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3603   ///////////////////////////////////////////////////////
3604   TVector3** vertexposition[kssdchipcableslaynumber];
3605   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3606                                                                                                   new TVector3*[4*(nedges+1)+4];
3607   Double_t ratio[4];
3608   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3609   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3610                    /  ssdchipcablesradius[0]; 
3611   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3612                    /  ssdchipcablesradius[0];
3613   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3614                    +  fgkSSDChipCablesHeight[1])
3615                    /  ssdchipcablesradius[0];
3616   Double_t phi = 180.;
3617   Double_t deltaphi = 180./nedges;
3618   Double_t angle = 0.0;
3619   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3620   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3621   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3622         xvertexpoints[i] = new Double_t[kvertexnumber];
3623         yvertexpoints[i] = new Double_t[kvertexnumber];
3624   }  
3625   TVector3* vertex = new TVector3();
3626   TVector3* transvector[kssdchipcableslaynumber];
3627   transvector[0] = new TVector3(fgkSSDChipWidth,
3628                                                                 SSDChipCablesHeigth-ssdchipcablesradius[0]);
3629   transvector[1] = new TVector3();
3630   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcableslaynumber];
3631   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcableslaynumber];
3632   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcableslaynumber] = 
3633                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3634                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3635   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3636         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3637         transvector[1]->SetY(ssdchipcablesradius[0]
3638                                  +               fgkSSDChipCablesHeight[0]
3639                                  +               fgkSSDChipCablesHeight[1]);  
3640         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3641                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeigth
3642                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3643                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeigth
3644                                                          - i*fgkSSDChipCablesHeight[0]);
3645                 vertexposition[i][2*(nedges+1)+2] = 
3646                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3647                                 +                                fgkSSDChipCablesWidth[1]
3648                                 +                                fgkSSDChipCablesWidth[2],
3649                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3650                                 +                                fgkSSDChipCablesHeight[1]));
3651         vertexposition[i][2*(nedges+1)+3] = 
3652                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3653                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3654                                 -                                fgkSSDChipCablesHeight[i]);
3655             for(Int_t j=0; j<nedges+1; j++){            
3656                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3657                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3658                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3659                         vertexposition[0][(nedges+1)*i+j+2] = 
3660                                                 new TVector3(*vertex+*transvector[i]);
3661                         vertexposition[1][(nedges+1)*i+j+2] = 
3662                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3663                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3664                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3665                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3666                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3667                                                 new TVector3(vertex->X()*ratio[2*i+1]
3668                                                         +                        transvector[i]->X(),
3669                                                                                  vertex->Y()*ratio[2*i+1]
3670                                                         +                transvector[i]->Y());
3671                 }
3672         }
3673         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3674                 for(Int_t j=0; j<kvertexnumber; j++){   
3675                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3676                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3677                 }
3678                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3679                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3680                                                                                 xvertexpoints[i],yvertexpoints[i]);
3681                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3682                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3683                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3684                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3685                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3686                                                           (kssdchipcablesnumber*k+i)%2==0?
3687                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3688                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3689         }
3690         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3691                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3692   }
3693   /////////////////////////////////////////////////////////////
3694   // Mother Volume definition 
3695   /////////////////////////////////////////////////////////////
3696   Double_t ssdchipseparation = fgkSSDSensorLength
3697                                                          - 2.*fgkSSDModuleStiffenerPosition[1]
3698                                                          - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3699                                                          - 0.5*fgkSSDChipWidth)-fgkSSDChipWidth;
3700   Double_t boxorigin[3] = {-0.5*ssdchipseparation,0.,0.5*SSDChipCablesHeigth}; 
3701   Double_t dx = ssdchipseparation+2.*(fgkSSDChipWidth+ssdchipcablesradius[0]
3702                                                           +fgkSSDChipCablesWidth[1]
3703                                                           +fgkSSDChipCablesWidth[2]);
3704   Double_t dy = fgkSSDChipCablesLength[1];
3705   Double_t dz = SSDChipCablesHeigth;
3706   new TGeoBBox(0.5*dx,0.5*dy,0.5*dz,boxorigin);
3707   TGeoVolumeAssembly* ssdchipcablesmother = new TGeoVolumeAssembly("SSDChipCablesMother");
3708 //  TGeoVolume* ssdchipcablesmother = new TGeoVolume("SSDChipCablesMother",
3709 //                        ssdchipcablesmotherbox,fSSDAir);
3710   /////////////////////////////////////////////////////////////
3711   // Rotation and Translation Definition for positioning 
3712   /////////////////////////////////////////////////////////////
3713   TGeoRotation* ssdchipcablesrot[5];
3714   ssdchipcablesrot[0] = new TGeoRotation("",90.,180.,-90);
3715   ssdchipcablesrot[1] = new TGeoRotation("",0.0,90.0,0.0);
3716   ssdchipcablesrot[2] = new TGeoRotation((*ssdchipcablesrot[1])*(*ssdchipcablesrot[0]));
3717   ssdchipcablesrot[3] = new TGeoRotation("",180.,0.0,0.0);
3718   ssdchipcablesrot[4] = new TGeoRotation((*ssdchipcablesrot[3])*(*ssdchipcablesrot[2]));
3719   TGeoCombiTrans* ssdchipcablescombitrans = new TGeoCombiTrans(-ssdchipseparation,
3720                                                                                                                 0.,0.,ssdchipcablesrot[2]);
3721   ssdchipcablesmother->AddNode(ssdchipcable[0],1,ssdchipcablesrot[4]);
3722   ssdchipcablesmother->AddNode(ssdchipcable[1],1,ssdchipcablesrot[4]);
3723   ssdchipcablesmother->AddNode(ssdchipcable[2],1,ssdchipcablescombitrans);
3724   ssdchipcablesmother->AddNode(ssdchipcable[3],1,ssdchipcablescombitrans);
3725   /////////////////////////////////////////////////////////////
3726   // Deallocating memory
3727   /////////////////////////////////////////////////////////////
3728   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3729         delete [] xvertexpoints[i];
3730         delete [] yvertexpoints[i];
3731   }
3732   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3733   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3734   delete vertex; 
3735   delete ssdchipcablesrot[0];
3736   delete ssdchipcablesrot[1];
3737   delete ssdchipcablesrot[3];
3738   /////////////////////////////////////////////////////////////
3739   return ssdchipcablesmother;
3740 }
3741 ///////////////////////////////////////////////////////////////////////////////
3742 TList* AliITSv11GeometrySSD::GetSSDChipSystem(){
3743   /////////////////////////////////////////////////////////////
3744   // SSD Chip Assembly
3745   /////////////////////////////////////////////////////////////
3746   TGeoVolume* ssdchipassembly = GetSSDChips();
3747   TList* ssdchipsystemlist = new TList();
3748 //  const Int_t knedges = 20;
3749   const Int_t knedges = 5;
3750   const Int_t kchipsystemnumber = 2;
3751
3752   TGeoVolumeAssembly* chipsystemother[kchipsystemnumber];
3753   const char* chipsytemothername[kchipsystemnumber] = 
3754                                         {"SSDChipSytemother1","SSDChipSytemother2"};
3755   for(Int_t i=0; i<kchipsystemnumber; i++){
3756     chipsystemother[i] = new TGeoVolumeAssembly(chipsytemothername[i]);
3757   }
3758   /////////////////////////////////////////////////////////////
3759   // SSD Chip Cables
3760   /////////////////////////////////////////////////////////////
3761   TGeoVolume* ssdchipcables[kchipsystemnumber];
3762   TGeoRotation** ssdchipcablesrot[kchipsystemnumber];
3763   TGeoTranslation** ssdchipcablestrans[kchipsystemnumber];
3764   TGeoCombiTrans** ssdchipcablescombitrans[kchipsystemnumber];
3765   //////////////////
3766   for(Int_t i=0; i<kchipsystemnumber; i++){
3767                 ssdchipcables[i] = 
3768                 GetSSDChipCables(fgkSSDChipCablesHeight[i+2],knedges);
3769                 ssdchipcablestrans[i] = new TGeoTranslation*[fgkSSDChipNumber];
3770                 ssdchipcablesrot[i] = new TGeoRotation*[fgkSSDChipNumber];
3771                 ssdchipcablescombitrans[i] = new TGeoCombiTrans*[fgkSSDChipNumber];
3772   }
3773   for(Int_t i=0; i<kchipsystemnumber; i++){
3774         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3775                 ssdchipcablestrans[i][j] = new TGeoTranslation();
3776                 ssdchipcablesrot[i][j] = new TGeoRotation();
3777                 ssdchipcablescombitrans[i][j] = new TGeoCombiTrans();
3778                 ssdchipcablesrot[i][j]->SetAngles(-90.0,0.0,0.0);
3779                 ssdchipcablestrans[i][j]->SetTranslation(j*(fgkSSDChipLength
3780                                                   +                fgkSSDChipSeparationLength),
3781                                                                                         0.5*fgkSSDChipWidth,
3782                                                   -                                     0.5*fgkSSDChipHeight
3783                                                   -                                     fgkSSDChipCablesHeight[i+2]);
3784                 ssdchipcablescombitrans[i][j]->SetRotation(*ssdchipcablesrot[i][j]);
3785                 ssdchipcablescombitrans[i][j]->SetTranslation(*ssdchipcablestrans[i][j]);
3786                 chipsystemother[i]->AddNode(ssdchipcables[i],j+1,ssdchipcablescombitrans[i][j]);
3787         }
3788         chipsystemother[i]->AddNode(ssdchipassembly,i+1);
3789         ssdchipsystemlist->Add(chipsystemother[i]);     
3790   }
3791   /////////////////////////////////////////////////////////////
3792   // Deallocating memory
3793   /////////////////////////////////////////////////////////////
3794   for(Int_t i=0; i<kchipsystemnumber; i++){
3795         for(Int_t j=0; j<fgkSSDChipNumber; j++){
3796                 delete ssdchipcablesrot[i][j];
3797                 delete ssdchipcablestrans[i][j];
3798         }
3799         delete [] ssdchipcablesrot[i];
3800         delete [] ssdchipcablestrans[i];
3801   }
3802   /////////////////////////////////////////////////////////////
3803   return ssdchipsystemlist;
3804 }
3805
3806 //_____________________________________________________________________________
3807 TGeoVolume* AliITSv11GeometrySSD::GetSSDChips() const{
3808   /////////////////////////////////////////////////////////////
3809   // SSD Chip Assembly Generation    
3810   /////////////////////////////////////////////////////////////
3811   const Int_t kssdchiprownumber = 2;
3812   TGeoBBox* ssdchipcompshape[2];
3813   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3814                                                                                 0.5*fgkSSDChipLength,
3815                                                                                 0.5*fgkSSDChipWidth,
3816                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3817   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3818                                                                                 0.5*fgkSSDChipLength,
3819                                                                                 0.5*fgkSSDChipWidth,
3820                                                                                 0.5*fgkSSDChipGlueHeight);
3821   TGeoVolume* ssdchipcomp[2];
3822   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3823   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3824                                                                   fSSDChipGlueMedium);
3825   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3826   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3827   TGeoTranslation* ssdchipcomptrans[2];
3828   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3829   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3830   /////////////////////////////////////////////////////////////
3831   // Virtual Volume containing SSDChip   
3832   /////////////////////////////////////////////////////////////
3833   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3834                                                                                                                  0.5*fgkSSDChipWidth,
3835                                                                                                                  0.5*fgkSSDChipHeight);
3836   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3837   /////////////////////////////////////////////////////////////
3838   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3839   Double_t ssdchipseparation[2] = {fgkSSDChipLength+fgkSSDChipSeparationLength,
3840                                                   fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
3841                                    -  2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
3842                                    -  0.5*fgkSSDChipWidth)};
3843   /////////////////////////////////////////////////////////////
3844   // Virtual Volume containing SSDChipAssembly   
3845   /////////////////////////////////////////////////////////////
3846   TGeoXtru* ssdchipmothershape = new TGeoXtru(2);
3847   const Int_t kssdmothervertexnumber = 2*fgkSSDChipNumber;  
3848   Double_t xmothervertex[kssdmothervertexnumber];
3849   Double_t ymothervertex[kssdmothervertexnumber];
3850   ///////////////////////
3851   // Setting the vertices 
3852   ///////////////////////
3853   xmothervertex[0] = -0.5*fgkSSDChipLength,ymothervertex[0] = -0.5*fgkSSDChipWidth;
3854   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = ssdchipseparation[1]
3855                                    - ymothervertex[0];
3856   xmothervertex[2] = (fgkSSDChipNumber-1)*ssdchipseparation[0]-xmothervertex[0];
3857   ymothervertex[2] = ymothervertex[1];
3858   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
3859   xmothervertex[4] = ssdchipseparation[0]+xmothervertex[0];
3860   ymothervertex[4] = ymothervertex[0];
3861   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = -ymothervertex[4];
3862   xmothervertex[6] = (fgkSSDChipNumber-1)*ssdchipseparation[0]
3863                                    + (0.5*fgkSSDChipLength-fgkSSDChipWidth);
3864   ymothervertex[6] = ymothervertex[5];
3865   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
3866                                    - fgkSSDChipWidth;
3867   xmothervertex[8] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3868   ymothervertex[8] = ymothervertex[7];
3869   xmothervertex[9] = -0.5*fgkSSDChipLength+fgkSSDChipWidth;
3870   ymothervertex[9] = ymothervertex[6];
3871   xmothervertex[10] = -xmothervertex[0], ymothervertex[10] = ymothervertex[9];
3872   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[0];
3873   //////////////////////////////////////////////////////////
3874   ssdchipmothershape->DefinePolygon(kssdmothervertexnumber,
3875                                                                         xmothervertex,ymothervertex);
3876   ssdchipmothershape->DefineSection(0,-0.5*fgkSSDChipHeight);
3877   ssdchipmothershape->DefineSection(1, 0.5*fgkSSDChipHeight);
3878 //  TGeoVolume* ssdchipmother = new TGeoVolume("SSDChipContainer",
3879 //                                                        ssdchipmothershape,fSSDAir);
3880   TGeoVolumeAssembly* ssdchipmother = new TGeoVolumeAssembly("SSDChipContainer");
3881    /////////////////////////////////////////////////////////////
3882   for(Int_t i=0; i<kssdchiprownumber; i++)
3883     for(Int_t j=0; j<fgkSSDChipNumber; j++) 
3884                 ssdchipmother->AddNode(ssdchip,fgkSSDChipNumber*i+j+1,
3885                 new TGeoTranslation(j*ssdchipseparation[0],i*ssdchipseparation[1],0.));
3886   return ssdchipmother;
3887 }
3888 /////////////////////////////////////////////////////////////////////////////////
3889 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3890   /////////////////////////////////////////////////////////////
3891   // Method returning a List containing pointers to Ladder Cable Volumes    
3892   /////////////////////////////////////////////////////////////
3893   const Int_t kladdercablesegmentnumber = 2;
3894   /////////////////////////////////////////
3895   // LadderSegmentBBox Volume
3896   /////////////////////////////////////////
3897   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3898   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3899                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3900
3901
3902   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3903                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3904   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3905
3906   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3907                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3908                                                                                            0.5*fgkSSDFlexWidth[0],
3909                                                                                            0.5*fgkSSDLadderCableWidth,
3910                                                                        0.5*fgkSSDFlexHeight[0]),
3911                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3912                                                                                            0.5*fgkSSDFlexWidth[0],
3913                                                                                            0.5*fgkSSDLadderCableWidth,
3914                                                                                            fgkSSDFlexHeight[0]
3915                                                                                            +0.5*fgkSSDFlexHeight[1])
3916                                                                                    };
3917   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3918   static TGeoVolume* laddercablesegmentarbassembly = 
3919                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3920
3921   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3922   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3923
3924   if (laddercablesegmentbboxshape[0] == 0) { 
3925     // Initialise static shapes and volumes 
3926   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3927                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3928                                                                            0.5*fgkSSDFlexWidth[0],
3929                                                                            0.5*fgkSSDLadderCableWidth,
3930                                                                            0.5*fgkSSDFlexHeight[i]); 
3931
3932   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3933                         laddercablesegmentbbox[i] =
3934                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3935                                                                                  laddercablesegmentbboxshape[i],
3936                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3937             fSSDKaptonLadderCableMedium));
3938                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3939                                                                                                                    fColorPolyhamide);
3940   }
3941   
3942   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3943                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3944                                                                                             laddercablesegmentbboxtrans[i]);
3945 /////////////////////////////////////////
3946 // LadderSegmentArb8 Volume
3947 /////////////////////////////////////////
3948   const Int_t kvertexnumber = 4;
3949   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3950   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3951                                                                                                   new TVector3*[kvertexnumber];
3952 //Shape Vertex Positioning
3953   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3954         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3955         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3956                                                                                                                   i*fgkSSDFlexHeight[0]);
3957         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3958                                                                                    +                         fgkSSDFlexHeight[1]
3959                                                                                    +                      i*fgkSSDFlexHeight[0]);
3960         laddercablesegmentvertexposition[i][3] = 
3961                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3962                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3963   }
3964   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3965                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3966   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3967                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3968
3969   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3970                                         GetArbShape(laddercablesegmentvertexposition[i],
3971                                                                 laddercablesegmentwidth[i],
3972                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3973                                                                 laddercablesegmentarbshapename[i]);
3974   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3975                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3976
3977   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3978                          laddercablesegmentarb[i] =
3979                                                    new TGeoVolume(laddercablesegmentarbname[i],
3980                                                                                   laddercablesegmentarbshape[i],
3981                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3982             fSSDKaptonLadderCableMedium)); 
3983                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3984                                                                                                                    fColorPolyhamide);
3985 }
3986   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3987   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3988                                                                                                  90.,90,-90.);   
3989   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3990                                                                                                   0.,90.,0.);    
3991   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3992                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3993                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3994                                                          + fgkSSDFlexWidth[0],0.,0.,
3995                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3996                                                      *(*laddercablesegmentarbrot[0])));
3997   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3998   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3999                                                                                    laddercablesegmentarbcombitrans);
4000   }  // End of static initialisations
4001 /////////////////////////////////////////
4002 // End Ladder Cable Volume
4003 // Note: this part depends explicitly on the length passed as an argument to the function
4004 /////////////////////////////////////////
4005   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
4006   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
4007                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
4008   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
4009                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
4010                                                                            0.5*ssdendladdercablelength,
4011                                                                            0.5*fgkSSDLadderCableWidth,
4012                                                                            0.5*fgkSSDFlexHeight[i]);
4013   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
4014                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
4015   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
4016   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
4017                         ladderendcablesegmentbbox[i] =
4018                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
4019                                                                                  ladderendcablesegmentbboxshape[i],
4020                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
4021             fSSDKaptonLadderCableMedium));
4022                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
4023                                                                                                                    fColorPolyhamide);
4024   }
4025   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
4026   ladderendcablesegmentbboxtrans[0] = 
4027                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
4028                                                                                            0.5*ssdendladdercablelength,
4029                                                                                            0.5*fgkSSDLadderCableWidth,
4030                                                                                            0.5*fgkSSDFlexHeight[0]);
4031   ladderendcablesegmentbboxtrans[1] = 
4032                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
4033                                                                                            0.5*ssdendladdercablelength,
4034                                                                                            0.5*fgkSSDLadderCableWidth,
4035                                                                                            fgkSSDFlexHeight[0]
4036                                                                                            +0.5*fgkSSDFlexHeight[1]);
4037   TGeoVolume* ladderendcablesegmentbboxassembly = 
4038                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
4039   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
4040                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
4041                                                                                             ladderendcablesegmentbboxtrans[i]);
4042 /////////////////////////////////////////
4043   TList* laddercablesegmentlist = new TList();
4044   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
4045   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
4046   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
4047   return laddercablesegmentlist;
4048 }
4049
4050 /////////////////////////////////////////////////////////////////////////////////
4051 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
4052   /////////////////////////////////////////////////////////////
4053   // Method generating Ladder Cable Volumes Assemblies    
4054   /////////////////////////////////////////////////////////////
4055   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
4056   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
4057   for(Int_t i=0; i<n; i++){
4058          TGeoTranslation* laddercabletrans = new TGeoTranslation(
4059                                                         i*(fgkCarbonFiberJunctionWidth),
4060                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4061                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4062     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
4063         if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
4064   }
4065   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
4066                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4067                                                                  fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
4068                                           (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
4069   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
4070   return laddercable;
4071 }
4072 /////////////////////////////////////////////////////////////////////////////////
4073 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
4074   /////////////////////////////////////////////////////////////
4075   // Method generating Ladder Cable Volumes Assembly   
4076   /////////////////////////////////////////////////////////////
4077   TGeoVolume* laddercableassembly = new TGeoVolumeAssembly("LadderCableAssembly");
4078   char laddercabletransname[100];
4079   for(Int_t i=0; i<n; i++){ 
4080         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
4081     laddercableassembly->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
4082         new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0.,0.));
4083   }
4084   return laddercableassembly;
4085 }
4086 /////////////////////////////////////////////////////////////////////////////////
4087 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
4088   /////////////////////////////////////////////////////////////
4089   // Method generating Ladder Cable List Assemblies  
4090   /////////////////////////////////////////////////////////////  
4091   const Int_t kladdercableassemblynumber = 2;
4092   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
4093   TGeoVolume* ladderCable[kladdercableassemblynumber];
4094   char laddercableassemblyname[100];
4095   TList* laddercableassemblylist = new TList();
4096   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
4097         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
4098         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
4099         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
4100                                          new TGeoCombiTrans((n-1)
4101                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
4102                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
4103                                                                                         0.,new TGeoRotation("",180,0.,0.)));
4104         laddercableassemblylist->Add(ladderCable[i]);
4105 }
4106   return laddercableassemblylist;
4107 }
4108 ///////////////////////////////////////////////////////////////////////////////
4109 void AliITSv11GeometrySSD::SetLadderSegment(){
4110   /////////////////////////////////////////////////////////////
4111   // Method Generating Ladder Segment Array
4112   /////////////////////////////////////////////////////////////
4113   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
4114   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
4115   if(!fCreateMaterials) CreateMaterials();
4116   if(!fTransformationMatrices) CreateTransformationMatrices();
4117   if(!fBasicObjects) CreateBasicObjects();
4118   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
4119   // Placing Carbon Fiber Support       
4120         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
4121                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4122                                                                                         fcarbonfibersupportmatrix[j]);  
4123                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4124                                                                                         fcarbonfibersupportmatrix[j]);
4125   }
4126   // Placing Carbon Fiber Junction
4127     for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++)
4128         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
4129                                                                    fcarbonfiberjunctionmatrix[j]);
4130   // Placing Carbon Fiber Lower Support
4131         for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++)
4132                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
4133                                                            fcarbonfiberlowersupportrans[j]);    
4134   // Placing SSD Sensor Support
4135     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
4136         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
4137                                                                      fssdsensorsupport[1][i],
4138                                                            j+1,fssdsensorsupportmatrix[j]);
4139   // Placing SSD Cooling Tube Support 
4140         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
4141                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4142                                                                    fcoolingtubesupportmatrix[j]);
4143   // Placing SSD Cooling Tube  
4144         for(Int_t j=0; j<2; j++)
4145                 for(Int_t k=0; k<2; k++){
4146                 fladdersegment[i]->AddNode(fcoolingtube[0],2*j+k+1,fcoolingtubematrix[j][k]);
4147                 fladdersegment[i]->AddNode(fcoolingtube[j+1],k+1,fcoolingtubematrix[2+j][k]);
4148                 }
4149   // Placing SSD Hybrid
4150     switch(i){
4151         case 0: 
4152                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
4153                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4154                 break;
4155     case 1:
4156                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
4157                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
4158                 break;
4159         }
4160         // Placing Cooling Block System
4161     fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
4162         // Placing SSD Flex
4163         for(Int_t j=0; j<fgkflexnumber; j++){
4164       fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
4165       fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
4166         }
4167    }
4168 }
4169 ///////////////////////////////////////////////////////////////////////////////
4170 void AliITSv11GeometrySSD::SetEndLadderSegment(){
4171   /////////////////////////////////////////////////////////////
4172   // Method Generating End Ladder
4173   /////////////////////////////////////////////////////////////
4174   // End Ladder Carbon Fiber Junction 
4175   /////////////////////////////////////////////////////////////
4176   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
4177   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
4178   if(!fCreateMaterials) CreateMaterials();
4179   if(!fTransformationMatrices) CreateTransformationMatrices();
4180   if(!fBasicObjects) CreateBasicObjects();
4181   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
4182         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
4183                 fendladdersegment[i]->AddNode(j==2 ? 
4184                                                         fendladdercarbonfiberjunction[i][1] : 
4185                                                         fendladdercarbonfiberjunction[i][0],
4186                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
4187   }
4188   /////////////////////////////////////////////////////////////
4189   // End Ladder Carbon Fiber Support 
4190   /////////////////////////////////////////////////////////////
4191   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
4192       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
4193                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
4194                   fendladdercarbonfibermatrix[i][j]);   
4195           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
4196                   fendladdercarbonfibermatrix[i][j]);   
4197       }
4198   /////////////////////////////////////////////////////////////
4199   // End Ladder Mounting Block
4200   /////////////////////////////////////////////////////////////
4201   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4202        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
4203                                      fendladdermountingblockcombitrans[i]);
4204   /////////////////////////////////////////////////////////////
4205   // End Ladder Mounting Block Clip
4206   /////////////////////////////////////////////////////////////
4207   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
4208         for(Int_t j=0; j<2; j++)
4209                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
4210                                               fendladdermountingblockclipmatrix[i][j]);
4211   /////////////////////////////////////////////////////////////
4212   // End Ladder Lower Supports
4213   /////////////////////////////////////////////////////////////
4214   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
4215                                 fendladderlowersupptrans[0]);
4216   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
4217                                 fendladderlowersupptrans[1]);
4218   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
4219                                 fendladderlowersupptrans[2]);
4220   /////////////////////////////////////////////////////////////
4221   // End Ladder Cooling Tube Support
4222   /////////////////////////////////////////////////////////////
4223   for(Int_t i=0; i<2; i++) 
4224         for(Int_t j=0; j<(i==0?4:2); j++)   
4225                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
4226                                               fendladdercoolingtubesupportmatrix[i][j]);
4227   /////////////////////////////////////////////////////////////
4228   // End Ladder Cooling Tube Support
4229   /////////////////////////////////////////////////////////////
4230 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]);                                                                          
4231 //  fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);                                                                          
4232   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[0][2]);                                                                    
4233   fendladdersegment[0]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[0][3]);                                                                    
4234   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],1,fendladdercoolingtubematrix[0][4]);                                                                    
4235   fendladdersegment[0]->AddNode(fendladdercoolingtube[2],2,fendladdercoolingtubematrix[0][5]);                                                                    
4236   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],1,fendladdercoolingtubematrix[1][0]);                                                                    
4237   fendladdersegment[1]->AddNode(fendladdercoolingtube[3],2,fendladdercoolingtubematrix[1][1]);                                                                    
4238   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],1,fendladdercoolingtubematrix[1][2]);                                                                    
4239   fendladdersegment[1]->AddNode(fendladdercoolingtube[4],2,fendladdercoolingtubematrix[1][3]);                            
4240 }
4241 ///////////////////////////////////////////////////////////////////////////////
4242 void AliITSv11GeometrySSD::SetLadder(){
4243   /////////////////////////////////////////////////////////////
4244   // Method Generating Ladder of Layer 5 and 6
4245   /////////////////////////////////////////////////////////////  
4246   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
4247                                                                                                 fgkSSDLay6SensorsNumber};
4248   /////////////////////////////////////////////////////////////////////////////                                         
4249   /// Generating Ladder Mother Volume Containing Ladder 
4250   /////////////////////////////////////////////////////////////////////////////          
4251   TGeoXtru* laddershape[fgkladdernumber];       
4252   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
4253   const Int_t kmothervertexnumber = 8;  
4254   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
4255   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
4256   ///////////////////////
4257   // Setting the vertices 
4258   ///////////////////////
4259   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
4260                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
4261   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
4262   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
4263   xmothervertex[0][1] = xmothervertex[0][0];
4264   ymothervertex[0][1] = 0.0;
4265   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
4266                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
4267   ymothervertex[0][2] = ymothervertex[0][1];
4268   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
4269   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
4270   xmothervertex[0][4] = -xmothervertex[0][3];
4271   ymothervertex[0][4] = ymothervertex[0][3];
4272   xmothervertex[0][5] = -xmothervertex[0][2];
4273   ymothervertex[0][5] = ymothervertex[0][2];
4274   xmothervertex[0][6] = -xmothervertex[0][1];
4275   ymothervertex[0][6] = ymothervertex[0][1];
4276   xmothervertex[0][7] = -xmothervertex[0][0];
4277   ymothervertex[0][7] = ymothervertex[0][0];
4278   for(Int_t i=0; i<kmothervertexnumber; i++){
4279         xmothervertex[1][i] = xmothervertex[0][i];
4280         ymothervertex[1][i] = ymothervertex[0][i];
4281   }
4282 ///////////////////////////////////////////////////////////////////////////
4283 // Disalignement Mother Volume corrections 25/08/08
4284 ///////////////////////////////////////////////////////////////////////////
4285   TGeoXtru* leftladdershape1[fgkladdernumber];  
4286   TGeoXtru* leftladdershape2[fgkladdernumber];  
4287   TGeoXtru* centersensorladdershape[fgkladdernumber];   
4288   TGeoXtru* rightladdershape1[fgkladdernumber]; 
4289   TGeoXtru* rightladdershape2[fgkladdernumber]; 
4290   for(Int_t i=0; i<fgkladdernumber; i++){
4291     leftladdershape1[i] = new TGeoXtru(2);
4292     leftladdershape2[i] = new TGeoXtru(2);
4293     centersensorladdershape[i] = new TGeoXtru(2);
4294     rightladdershape1[i] = new TGeoXtru(2);
4295     rightladdershape2[i] = new TGeoXtru(2);
4296   }
4297   //////////////////////////////////////
4298   // Setting the names for shapes  
4299   //////////////////////////////////////
4300   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
4301   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
4302   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
4303   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
4304   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
4305   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
4306   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
4307   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
4308   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
4309   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
4310   //////////////////////////////////////
4311   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
4312   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
4313   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
4314   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
4315   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
4316   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
4317   for(Int_t i=0; i<fgkladdernumber; i++) {
4318     for(Int_t j=0; j<kmothervertexnumber; j++){
4319       xcentersensorvertex[i][j] = xmothervertex[i][j];
4320       ycentersensorvertex[i][j] = ymothervertex[i][j];
4321       xend1laddervertex[i][j] = xmothervertex[i][j];
4322       yend1laddervertex[i][j] = ymothervertex[i][j];
4323       xend2laddervertex[i][j] = xmothervertex[i][j];
4324       yend2laddervertex[i][j] = ymothervertex[i][j];
4325     }
4326     // Add some space around sensors to accommodate misalignments
4327     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
4328     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
4329     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
4330     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
4331     
4332     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
4333     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
4334     
4335     // Center Ladder Piece
4336     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
4337                                               ycentersensorvertex[i]);
4338     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4339                                                  + 1.45*fgkSSDMountingBlockWidth);
4340     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
4341                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4342                                                  - 2.4*fgkSSDMountingBlockWidth);
4343
4344     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
4345
4346     // Cuts off first corner (neg x)
4347     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
4348     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
4349     // Cuts off last part (pos x)
4350     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
4351     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
4352
4353     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
4354                                        yend1laddervertex[i]);
4355     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4356     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4357                                          - fgkEndLadderMountingBlockPosition[0]);
4358     
4359     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
4360                                        yend2laddervertex[i]);
4361     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4362                                          - fgkEndLadderMountingBlockPosition[0]); 
4363     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4364                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4365
4366     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4367                                         yend1laddervertex[i]);
4368     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4369                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4370                                         -2.4*fgkSSDMountingBlockWidth);
4371     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4372                                         + fgkEndLadderMountingBlockPosition[1]);
4373
4374     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4375                                         yend2laddervertex[i]);
4376     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4377                                            + fgkEndLadderMountingBlockPosition[1]);
4378     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4379                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4380   }
4381   TGeoCompositeShape* laddershapecontainer[2];
4382   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4383                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4384                                                    "+Lay5CenterSensorContainer"
4385                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4386   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4387                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4388                                                    "+Lay6CenterSensorContainer"
4389                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4390   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4391   for(Int_t i=0; i<fgkladdernumber; i++){
4392     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4393     fladder[i]->SetLineColor(4);
4394   }
4395 ///////////////////////////////////////////////////////////////////////////
4396  if(!fCreateMaterials) CreateMaterials();
4397  if(!fTransformationMatrices) CreateTransformationMatrices();
4398  if(!fBasicObjects) CreateBasicObjects();
4399  SetLadderSegment(); 
4400  SetEndLadderSegment();
4401   for(Int_t i=0; i<fgkladdernumber; i++){
4402         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4403         //////////////////////////                                              
4404         /// Placing Ladder Segment
4405         //////////////////////////              
4406                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4407                                                                      fladdersegment[i==0 ? 1 : 0],
4408                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4409         //////////////////////////                                              
4410         /// Placing SSD Sensor
4411         //////////////////////////              
4412         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4413                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4414                                                         fssdsensormatrix[i][j]);
4415         }
4416         ///////////////////////////////                                         
4417         /// Placing End Ladder Segment
4418         ///////////////////////////////         
4419         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4420         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4421    }
4422 /////////////////////////////////////////////////////////////////////////////                                           
4423 /// Placing Ladder Cables
4424 /////////////////////////////////////////////////////////////////////////////           
4425   Int_t sidecablenumber[2][2];
4426   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4427   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4428   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4429   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4430   Double_t carbonfibertomoduleposition[3];
4431   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4432   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4433                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4434          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4435          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4436          -            fgkSSDSensorCenterSupportThickness[0]);
4437   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4438                                                                  +   0.5*fgkCoolingTubeSupportHeight
4439          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4440   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4441   Double_t ssdendladdercablelength[4];
4442   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4443                                                          + fgkSSDSensorLength
4444                                                          - fgkSSDModuleStiffenerPosition[1]
4445                                                          - fgkSSDStiffenerWidth 
4446                                                          - fgkSSDFlexWidth[0]
4447                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4448   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4449                                                          + fgkSSDModuleStiffenerPosition[1]
4450                                                          + fgkSSDStiffenerWidth
4451                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4452   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4453                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4454                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4455                                                          - kendladdercablecorrection;
4456   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4457                                                          + carbonfibertomoduleposition[1]
4458                                                          - fgkSSDModuleStiffenerPosition[1]
4459                                                          - fgkSSDStiffenerWidth)
4460                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4461   TList* laddercableassemblylist[4];
4462   const Int_t kendladdercablesnumber = 4;
4463   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4464         for(Int_t j=0; j<kendladdercablesnumber; j++){
4465                 laddercableassemblylist[j] = 
4466                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4467                                                                    ssdendladdercablelength[j]);
4468                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4469                                                                         j<2?1:2,fladdercablematrix[i][j]);
4470   }
4471 }
4472 ////////////////////////////////////////////////////////////////////////////////
4473 void AliITSv11GeometrySSD::SetLayer(){
4474 ////////////////////////////////////////////////////////////////////////////////
4475   // Creating Ladder of Layer 5 and Layer 6
4476   /////////////////////////////////////////////////////////////
4477   if(!fCreateMaterials) CreateMaterials();
4478   if(!fTransformationMatrices) CreateTransformationMatrices();
4479   if(!fBasicObjects) CreateBasicObjects();
4480   SetLadder(); // Generating the ladder of Layer5 and Layer6
4481   const Int_t kssdlayladdernumber[fgklayernumber] = 
4482                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4483   /////////////////////////////////////////////////////////////
4484   // Generating mother volumes for Layer5 and Layer6
4485   /////////////////////////////////////////////////////////////
4486   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4487   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4488   Int_t *ladderindex[fgklayernumber];
4489   Int_t index[fgklayernumber] = {8,9};
4490   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4491   for(Int_t i=0; i<fgklayernumber; i++) 
4492         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4493                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4494                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4495                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4496                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4497         }
4498   /////////////////////////////////////////////////////////////
4499   // Deallocating memory
4500   /////////////////////////////////////////////////////////////
4501   for(Int_t i=0; i<fgklayernumber; i++) delete ladderindex[i];
4502 }
4503 ////////////////////////////////////////////////////////////////////////////////
4504 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4505   /////////////////////////////////////////////////////////////
4506   // Insert the layer 5 in the mother volume. 
4507   /////////////////////////////////////////////////////////////
4508   if (! moth) {
4509     AliError("Can't insert layer5, mother is null!\n");
4510     return;
4511   };
4512   if(!fSSDLayer5) SetLayer();
4513   fMotherVol = moth;
4514   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4515                                                                                 + fgkLay5CenterITSPosition);
4516   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4517  }
4518 ////////////////////////////////////////////////////////////////////////////////
4519 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4520   /////////////////////////////////////////////////////////////
4521   // Insert the layer 6 in the mother volume. 
4522   /////////////////////////////////////////////////////////////
4523   if (! moth) {
4524     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4525     return;
4526   };
4527   if(!fSSDLayer6) SetLayer();
4528   fMotherVol = moth;
4529   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4530                                                                                 + fgkLay6CenterITSPosition);
4531   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4532  }
4533  ////////////////////////////////////////////////////////////////////////////////
4534  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4535   /////////////////////////////////////////////////////////////
4536   // Method generating the Arc structure of Ladder Support 
4537   /////////////////////////////////////////////////////////////
4538   const Int_t kssdlayladdernumber[fgklayernumber] = 
4539                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4540   Double_t mountingsupportedge[fgklayernumber];
4541   Double_t mountingblockratio[fgklayernumber];
4542   Double_t theta[fgklayernumber];
4543   Double_t phi[fgklayernumber];
4544   Double_t psi0[fgklayernumber];
4545   Double_t deltapsi[fgklayernumber];
4546   TVector3* mountingsupportedgevector[fgklayernumber];
4547   for(Int_t i=0; i<fgklayernumber; i++){
4548         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4549     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4550                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4551                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4552                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4553                                                           / kssdlayladdernumber[i])));
4554     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4555     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4556         mountingsupportedgevector[i] = new TVector3();
4557         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4558         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4559                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4560                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4561     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4562     deltapsi[i] = (theta[i]+phi[i])/nedges;
4563   }
4564   TVector3** vertex[fgklayernumber];
4565   TList* vertexlist[fgklayernumber];
4566   Int_t indexedge[fgklayernumber] = {0,0};
4567   for(Int_t i=0; i<fgklayernumber; i++){
4568         vertex[i] = new TVector3*[nedges+1];
4569         vertexlist[i] = new TList();
4570   } 
4571   for(Int_t i=0; i<fgklayernumber; i++){
4572         for(Int_t j=0; j<nedges+1; j++){
4573                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4574                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4575                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4576                 vertexlist[i]->Add(vertex[i][j]);
4577         }
4578         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4579   }
4580   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4581   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4582   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4583   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4584   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4585   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4586   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4587   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4588   for(Int_t i=0; i<fgklayernumber; i++){
4589     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4590     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4591     xcentervertex[i] = new Double_t[indexedge[i]+3];
4592     ycentervertex[i] = new Double_t[indexedge[i]+3];
4593         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4594         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4595         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4596         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4597         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4598                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4599                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4600                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4601                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4602                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4603                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4604                 if(j<indexedge[i]+1){
4605                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4606                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4607                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4608                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4609                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4610                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4611                 }
4612         }
4613         xsidevertex[i][1] = xsidevertex[i][0]; 
4614         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4615         xsidevertex[i][2] = xsidevertex[i][3]; 
4616         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4617         xcentervertex[i][1] = xcentervertex[i][0]; 
4618         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4619         xcentervertex[i][2] = xcentervertex[i][3]; 
4620         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4621         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4622         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4623         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4624         ycenterlowervertex[i][0] = ysidevertex[i][0];
4625         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4626         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4627   }
4628   /////////////////////////////////////////////////////////////
4629   // Building the Arc Structure of Ladder Supports 
4630   /////////////////////////////////////////////////////////////
4631   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4632   TGeoXtru* centermountingsupportshape[fgklayernumber];
4633   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4634   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4635   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4636   TGeoVolume* centermountingblocksupport[fgklayernumber];
4637   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4638   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4639   char sidemountingblockname[100];
4640   char centermountingblockname[100];
4641   char sideladdersupportpiecename[100];
4642   char centerladdersupportpiecename[100];
4643   for(Int_t i=0; i<fgklayernumber; i++){ 
4644         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4645         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4646         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4647         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4648         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4649     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4650                                                                                                 xsidevertex[i],ysidevertex[i]);
4651     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4652                                                                                                          -fgkMountingBlockSupportWidth[0]);
4653     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4654     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4655                                                                           sidemountingblocksupportshape[i],
4656                                                                                   fSSDAlCoolBlockMedium);
4657         sidemountingblocksupport[i]->SetLineColor(9);
4658         centermountingsupportshape[i] = new TGeoXtru(2);
4659     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4660                                                                                                 xcentervertex[i],ycentervertex[i]);
4661         centermountingsupportshape[i]->DefineSection(0,0.);
4662     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4663                                                                                                   -fgkMountingBlockSupportWidth[0]);
4664
4665     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4666                                                                           centermountingsupportshape[i],
4667                                                                                   fSSDAlCoolBlockMedium);
4668         centermountingblocksupport[i]->SetLineColor(9);
4669         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4670     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4671                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4672         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4673                                                                                                          -fgkMountingBlockSupportWidth[0]);
4674     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4675     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4676                                                                           sideladdersupportpieceshape[i],
4677                                                                                   fSSDCarbonFiberMedium);
4678         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4679         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4680     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4681                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4682         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4683     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4684                                                                                                   -fgkMountingBlockSupportWidth[0]);
4685     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4686                                                                           centerladdersupportpieceshape[i],
4687                                                                                   fSSDCarbonFiberMedium);
4688         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4689   }
4690   /////////////////////////////////////////////////////////////
4691   // Building the Up Structure of Ladder Supports 
4692   /////////////////////////////////////////////////////////////
4693   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4694   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4695   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4696   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4697   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4698   //////////////////////////////////////////////////////////
4699   // Setting the volume for TGeoXtru Mounting Block Piece  
4700   //////////////////////////////////////////////////////////
4701   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4702   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4703   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4704   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4705   TGeoVolume* mountingblockpieceup[fgklayernumber];
4706   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4707   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4708   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4709   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4710   char mountingblockpiecedownname[100];
4711   char mountingblockpieceupname[100];
4712   for(Int_t i=0; i<fgklayernumber; i++){
4713     ///////////////////////////
4714     // Mounting Block Down Vertex
4715     ///////////////////////////
4716         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4717     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4718         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4719         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4720                                               + fgkMountingBlockSupportDownHeight 
4721                                               - fgkSSDLadderVerticalDisalignment;
4722         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4723         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4724                                                                                 + fgkSSDMountingBlockHeight[1]
4725                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4726                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4727         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4728         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4729         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4730         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4731         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4732         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4733         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4734         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4735                                                                                 + fgkSSDMountingBlockHeight[2]
4736                                                                                 - fgkSSDMountingBlockHeight[0];
4737         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4738         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4739         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4740         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4741         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4742                                                                                                          mountingblockpiecedownyvertex[i]);
4743         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4744         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4745         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4746                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4747         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4748
4749     ///////////////////////////
4750     // Mounting Block Up Vertex
4751     ///////////////////////////
4752         mountingblockpieceupshape[i] = new TGeoXtru(2);
4753         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4754         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4755         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4756                                                                                 + fgkMountingBlockSupportUpHeight[i]
4757                                               - fgkSSDLadderVerticalDisalignment;
4758         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4759         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4760                                                                                 + fgkSSDMountingBlockHeight[1]
4761                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4762                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4763         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4764         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4765         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4766         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4767         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4768         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4769         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4770         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4771                                                                                 + fgkSSDMountingBlockHeight[2]
4772                                                                                 - fgkSSDMountingBlockHeight[0];
4773         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4774         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4775         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4776         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4777
4778         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4779                                                                                                          mountingblockpieceupyvertex[i]);
4780         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4781         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4782         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4783                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4784         mountingblockpieceup[i]->SetLineColor(fColorG10);
4785  }
4786   ///////////////////////////////////////////////////////////////////
4787   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4788   ///////////////////////////////////////////////////////////////////
4789   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4790   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4791   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4792   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4793   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4794   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4795   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4796   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4797   char mountingblocksupportrapezoidowname[100];
4798   char mountingblocksupportrapezoidupname[100];
4799   Double_t scalefactor = 3./4.;
4800   for(Int_t i=0; i<fgklayernumber; i++){
4801   ////////////////////////////////////////////
4802   // Mounting Block Support Down Trapezoid Vertex 
4803   ////////////////////////////////////////////
4804         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4805         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4806                                                                                                  - mountingsupportedge[i];
4807         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4808         mountingblocksupportrapezoidownxvertex[i][1] = 
4809                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4810         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4811                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4812                                                                                              - mountingblockpiecedownyvertex[i][0]);
4813         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4814         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4815         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4816         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4817         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4818         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4819
4820         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4821                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4822         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4823                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4824         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4825         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4826         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4827                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4828         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4829   ////////////////////////////////////////////
4830   // Mounting Block Support Up Trapezoid Vertex 
4831   ////////////////////////////////////////////
4832         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4833         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4834                                                                                                  - mountingsupportedge[i];
4835         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4836         mountingblocksupportrapezoidupxvertex[i][1] = 
4837                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4838         mountingblocksupportrapezoidupyvertex[i][1] = 
4839                                                                                                mountingblockpieceupyvertex[i][0]
4840                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4841                                                                                              - mountingblockpieceupyvertex[i][0]);
4842         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4843         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4844         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4845         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4846         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4847         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4848
4849         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4850                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4851         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4852                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4853         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4854         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4855         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4856                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4857         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4858   }
4859   ///////////////////////////////////////////////////////////////////
4860   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4861   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4862   Double_t boxoriginup[fgklayernumber][2][3];
4863   Double_t boxorigindown[fgklayernumber][2][3];
4864   char mountingblocksupportboxdownname[100];
4865   char mountingblocksupportboxupname[100];
4866   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4867   mountingblocksupportrot->SetAngles(90.,180.,-90);
4868   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4869   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4870   TGeoHMatrix* laddersupportmatrix[2];
4871   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4872   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4873   /////////////////////////////////////////////////////////////
4874   // Creating Mother Volume for Containment
4875   /////////////////////////////////////////////////////////////
4876   Double_t *xmothervertex[fgklayernumber];
4877   Double_t *ymothervertex[fgklayernumber];
4878   for(Int_t i=0; i<fgklayernumber; i++){
4879         xmothervertex[i] = new Double_t[8];
4880         ymothervertex[i] = new Double_t[8];
4881   }  
4882   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4883   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4884   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4885   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4886   char upmotheladdersupportname[100];
4887   char downmotheladdersupportname[100];
4888   for(Int_t i=0; i<fgklayernumber; i++){
4889         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4890                                                     -  mountingsupportedge[i];
4891         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4892         xmothervertex[i][1] = xmothervertex[i][0];
4893         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4894                                                         + fgkMountingBlockSupportWidth[0];
4895         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4896         ymothervertex[i][2] = ymothervertex[i][1];
4897         xmothervertex[i][3] = xmothervertex[i][2];
4898         ymothervertex[i][3] = -ymothervertex[i][0];
4899         xmothervertex[i][4] = -xmothervertex[i][0];
4900         ymothervertex[i][4] = ymothervertex[i][3];
4901         xmothervertex[i][5] = xmothervertex[i][4];
4902         ymothervertex[i][5] = -ymothervertex[i][1];
4903         xmothervertex[i][6] = -xmothervertex[i][2];
4904         ymothervertex[i][6] = ymothervertex[i][5];
4905         xmothervertex[i][7] = xmothervertex[i][6];
4906         ymothervertex[i][7] = ymothervertex[i][0];
4907
4908         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4909         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4910
4911         downmotherladdersupportshape[i] = new TGeoXtru(2);
4912         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4913         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4914         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4915                                                                    +                       fgkMountingBlockSupportDownHeight
4916                                                                    +                       fgkSSDMountingBlockHeight[1]
4917                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4918                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4919                                                        - fgkSSDLadderVerticalDisalignment);
4920         
4921 //                                                 - fgkSSDModuleVerticalDisalignment);
4922         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4923
4924         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4925                                                                           downmotherladdersupportshape[i],fSSDAir);
4926     upmotherladdersupportshape[i] = new TGeoXtru(2);
4927         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4928         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4929     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4930                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4931                                                                    +                       fgkSSDMountingBlockHeight[1]
4932                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4933                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4934                                                  - fgkSSDLadderVerticalDisalignment);
4935
4936      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4937                                                                                           upmotherladdersupportshape[i],fSSDAir);
4938   }
4939   for(Int_t i=0; i<fgklayernumber; i++){
4940         /////////////////////////
4941         // Setting the box origin
4942         /////////////////////////
4943         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4944         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4945                                                    +  0.5*fgkMountingBlockSupportDownHeight
4946                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4947         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4948                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4949   
4950         boxorigindown[i][1][0] = 0.0;
4951         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4952         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4953                                                    -      fgkMountingBlockSupportWidth[0]);
4954                                                    
4955         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4956         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4957                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4958                                - 0.5*fgkSSDLadderVerticalDisalignment;
4959         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4960                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4961   
4962         boxoriginup[i][1][0] = 0.0;
4963         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4964         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4965                                                  - fgkMountingBlockSupportWidth[0]);
4966   
4967         /////////////////////////
4968     // Setting the boxes    
4969         /////////////////////////
4970         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4971                                                                                  +  fgkSSDMountingBlockLength[0]),
4972                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4973                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4974                                                                                         boxorigindown[i][0]);
4975         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4976                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4977                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4978                                                                                  -  fgkMountingBlockSupportWidth[0]),
4979                                                                                         boxorigindown[i][1]);
4980                                                                                         
4981         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4982                                                                                  +  fgkSSDMountingBlockLength[0]),
4983                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4984                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4985                                                                                         boxoriginup[i][0]);
4986
4987         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4988                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4989                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4990                                                                      -  fgkMountingBlockSupportWidth[0]),
4991                                                                                         boxoriginup[i][1]);
4992         ///////////////////////////////////////
4993         // Adding the Volumes to Mother Volume    
4994         ///////////////////////////////////////
4995         for(Int_t j=0; j<2; j++){
4996                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4997                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4998                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4999                                                                                   mountingblocksupportboxdownshape[i][j],
5000                                                                                   fSSDCarbonFiberMedium);
5001                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
5002                                                                                   mountingblocksupportboxupshape[i][j],
5003                                                                                   fSSDCarbonFiberMedium);
5004                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
5005                 mountingblocksupportboxup[i][j]->SetLineColor(9);
5006                 for(Int_t k=0; k<2; k++){
5007                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
5008                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
5009                 }
5010         }
5011         for(Int_t k=0; k<2; k++){
5012                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
5013                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
5014                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5015                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5016                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
5017                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
5018                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
5019                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
5020                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5021                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
5022                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
5023                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
5024         }
5025   }
5026   TList* laddersupportlist = new TList();
5027   laddersupportlist->Add(downmotherladdersupport[0]); 
5028   laddersupportlist->Add(upmotherladdersupport[0]); 
5029   laddersupportlist->Add(downmotherladdersupport[1]); 
5030   laddersupportlist->Add(upmotherladdersupport[1]); 
5031   /////////////////////////////////////////////////////////////
5032   // Deallocating memory
5033   /////////////////////////////////////////////////////////////
5034   for(Int_t i=0; i<fgklayernumber; i++){
5035         for(Int_t j=0; j<nedges+1; j++)
5036                 delete vertex[i][j];
5037         delete mountingsupportedgevector[i];
5038         delete [] vertex[i];
5039         delete vertexlist[i];
5040         delete [] xsidevertex[i];
5041         delete [] ysidevertex[i];
5042         delete [] xcentervertex[i];
5043         delete [] ycentervertex[i];
5044         delete [] xsidelowervertex[i];
5045         delete [] ysidelowervertex[i];
5046         delete [] xcenterlowervertex[i];
5047         delete [] ycenterlowervertex[i];
5048   }
5049   delete [] xsidevertex;
5050   delete [] ysidevertex;
5051   delete [] xcentervertex;
5052   delete [] ycentervertex;
5053   delete [] xsidelowervertex;
5054   delete [] ysidelowervertex;
5055   delete [] xcenterlowervertex;
5056   delete [] ycenterlowervertex;
5057   delete globalrefladdersupportrot;
5058   delete mountingblocksupportrot;
5059   /////////////////////
5060   return laddersupportlist;     
5061 }
5062  ////////////////////////////////////////////////////////////////////////////////
5063 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
5064 //////////////////////////////////////////
5065 // Method Generating Ladder Support Ring
5066 //////////////////////////////////////////
5067   if(!fCreateMaterials) CreateMaterials();
5068   if(!fTransformationMatrices) CreateTransformationMatrices();
5069   if(!fBasicObjects) CreateBasicObjects();
5070   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
5071   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
5072     const Int_t kssdlayladdernumber[fgklayernumber] = 
5073                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
5074   Double_t mountingsupportedge[fgklayernumber];
5075   Double_t mountingblockratio[fgklayernumber];
5076   Double_t theta[fgklayernumber];
5077   Double_t phi[fgklayernumber];
5078   for(Int_t i=0; i<fgklayernumber; i++){
5079         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
5080     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
5081                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
5082                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
5083                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
5084                                                           / kssdlayladdernumber[i])));
5085     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
5086                          / fgkMountingBlockSupportRadius[i]);
5087     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
5088   }
5089   TGeoRotation* globalrot = new TGeoRotation();
5090   globalrot->SetAngles(0.,-90.,0.); 
5091   TGeoRotation** laddersupportrot[fgklayernumber];
5092   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
5093   for(Int_t i=0; i<fgklayernumber; i++){                
5094         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
5095         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
5096         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
5097                 laddersupportrot[i][j] = new TGeoRotation();
5098                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
5099                 switch(i){
5100                         case 0: //Ladder of Layer5  
5101                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5102                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
5103                                                                             laddersupportmatrix[i][j]); 
5104                         break;
5105                         case 1: //Ladder of Layer6 
5106                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
5107                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
5108                                                                               laddersupportmatrix[i][j]); 
5109                         break;
5110                 }
5111     }
5112   }
5113   /////////////////////////////////////////////////////////////
5114   // Creating Lower Ladder Support 
5115   /////////////////////////////////////////////////////////////
5116   TVector3** ringsupportvertex[fgklayernumber];         
5117   Double_t angle = 360./nedges;
5118   for(Int_t i=0; i<fgklayernumber; i++){
5119     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
5120         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
5121                                                         *                          TMath::Cos(theta[i]));
5122         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
5123                                                         -                          mountingsupportedge[i],
5124                                                                                    ringsupportvertex[i][0]->Y());
5125         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
5126                                                                                    ringsupportvertex[i][1]->Y());                                                                               
5127     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
5128         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
5129            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
5130            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
5131            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
5132            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
5133         }
5134         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
5135     for(Int_t j=0; j<nedges+1; j++){
5136                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
5137                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*CosD(90.0-j*angle),
5138                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeigth)*SinD(90.0-j*angle));
5139         }
5140   }
5141   Double_t **xmothervertex = new Double_t*[fgklayernumber];
5142   Double_t **ymothervertex = new Double_t*[fgklayernumber];
5143   for(Int_t i=0; i<fgklayernumber; i++){
5144         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5145         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
5146         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
5147                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
5148                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
5149         }
5150   }
5151 ////////////////////////////////////////////////////////////////////////////////
5152 // Start Corrections 13/06/08
5153 ////////////////////////////////////////////////////////////////////////////////
5154   char lowerladderpconsupportname[100];
5155   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
5156   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
5157   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
5158   Double_t lowerladderpconradiusmax[fgklayernumber];
5159   Double_t lowerladderpconradiusmin[fgklayernumber];
5160   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5161   lowerladdersupportrot->SetAngles(90.,180.,-90);
5162   for(Int_t i=0; i<fgklayernumber; i++){
5163         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
5164                                                                 *                          TMath::Cos(theta[i]);
5165     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeigth;
5166   } 
5167   for(Int_t i=0; i<fgklayernumber; i++){
5168 ///////////////////////////  Modified Version ?///////////////////
5169     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
5170         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
5171                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
5172                                                          lowerladderpconradiusmax[i]);
5173         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
5174         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
5175     lowerladderpconsupport[i]->SetLineColor(fColorAl);
5176         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
5177         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
5178  }
5179 ////////////////////////////////////////////////////////////////////////////////
5180 // End Corrections 13/06/08
5181 ////////////////////////////////////////////////////////////////////////////////
5182   /*char lowerladdersupportname[30];
5183   TGeoXtru* lowerladdersupportshape[fgklayernumber];
5184   TGeoVolume* lowerladdersupport[fgklayernumber];
5185   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
5186   lowerladdersupportrot->SetAngles(90.,180.,-90);
5187   for(Int_t i=0; i<fgklayernumber; i++){
5188         lowerladdersupportshape[i] = new TGeoXtru(2);
5189         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
5190                                                                                           xmothervertex[i],ymothervertex[i]);
5191         lowerladdersupportshape[i]->DefineSection(0,0.);
5192     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
5193         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
5194     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
5195                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
5196         lowerladdersupport[i]->SetLineColor(fColorAl);
5197         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
5198         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
5199   }*/
5200   /////////////////////////////////////////////////////////////
5201   // Deallocating memory
5202   /////////////////////////////////////////////////////////////
5203   for(Int_t i=0; i<fgklayernumber; i++){
5204         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
5205                 delete ringsupportvertex[i][j];
5206         delete [] ringsupportvertex[i];
5207   }
5208   for(Int_t i=0; i<fgklayernumber; i++){
5209         delete [] xmothervertex[i];
5210         delete [] ymothervertex[i];
5211   }
5212   delete xmothervertex;
5213   delete ymothervertex; 
5214   delete globalrot;
5215   for(Int_t i=0; i<fgklayernumber; i++){
5216         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
5217                 delete laddersupportrot[i][j];
5218         delete [] laddersupportrot[i];
5219   }
5220  }  
5221  ////////////////////////////////////////////////////////////////////////////////
5222  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
5223   /////////////////////////////////////////////////////////////
5224   // Method generating Endcap CoverPlate
5225   /////////////////////////////////////////////////////////////
5226   // Holes Definition 
5227   ///////////////////
5228   Int_t nendcapcoverplateholedges = 30;
5229   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
5230   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
5231                                                           0.5*fgkEndCapCoverPlateThickness};
5232   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
5233                                                                                                               nendcapcoverplateholedges,holesection);
5234   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
5235                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
5236   endcapcoverplatesmallhole->SetLineColor(6);
5237   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
5238                                                                                                               nendcapcoverplateholedges,holesection);
5239   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
5240                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
5241   endcapcoverplatebighole->SetLineColor(6);
5242   //////////////////////////
5243   // Screw Piece Definition 
5244   //////////////////////////
5245   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
5246   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
5247                                                                                                       CosD(0.5*smallscrewangle),
5248                                                                                                       0.5*fgkEndCapCoverPlateThickness);
5249   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
5250                                                                                                 endcapsmallscrewpieceshape,
5251                                                                                                 fSSDCoolingTubePhynox);
5252   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
5253   ///////////////////
5254   // Box Definition 
5255   ///////////////////
5256   TGeoBBox* endcapcoverplateboxshape[4];
5257   TGeoVolume* endcapcoverplatebox[4];
5258   Double_t boxorigin[5][3];
5259   boxorigin[0][0] = 0.;
5260   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
5261   boxorigin[0][2] = 0.;
5262
5263   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
5264   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
5265   boxorigin[1][2] = 0.;
5266
5267   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
5268                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
5269   boxorigin[2][1] = boxorigin[1][1];
5270   boxorigin[2][2] = 0.;
5271
5272   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
5273                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
5274   boxorigin[3][1] = boxorigin[1][1];
5275   boxorigin[3][2] = 0.;
5276
5277   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5278                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
5279                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
5280                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
5281
5282   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5283                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5284                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5285                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5286                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
5287
5288   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
5289                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5290                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5291                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5292                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
5293
5294   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
5295                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
5296                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
5297                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
5298                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
5299   
5300   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
5301                                                                            fSSDAlCoolBlockMedium);
5302   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
5303                                                                            fSSDAlCoolBlockMedium);
5304   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
5305                                                                            fSSDAlCoolBlockMedium);
5306   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
5307                                                                            fSSDAlCoolBlockMedium);
5308   endcapcoverplatebox[0]->SetLineColor(6);
5309   endcapcoverplatebox[1]->SetLineColor(6);
5310   endcapcoverplatebox[2]->SetLineColor(6);
5311   endcapcoverplatebox[3]->SetLineColor(6);
5312   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
5313   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
5314                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
5315                                                                                         0.5*fgkEndCapCoverPlateThickness,
5316                                                                                         endcapfillingboxorigin);
5317   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
5318                                                                            fSSDAlCoolBlockMedium);
5319   endcapfillingbox->SetLineColor(6);
5320   ////////////////////////////
5321   // Contour shape Definition 
5322   ////////////////////////////
5323   const Int_t kcontourvertexnumber = 10;
5324   Double_t xcontourvertex[kcontourvertexnumber];
5325   Double_t ycontourvertex[kcontourvertexnumber];
5326   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
5327   xcontourvertex[1] = xcontourvertex[0];
5328   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5329   xcontourvertex[3] = xcontourvertex[2];
5330   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
5331   xcontourvertex[5] = xcontourvertex[4];
5332   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5333   xcontourvertex[7] = xcontourvertex[6];
5334   xcontourvertex[8] = xcontourvertex[4];
5335   xcontourvertex[9] = xcontourvertex[8];
5336   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5337                                         - (kendcapcoverplatesmallholenumber[1]-1)
5338                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5339   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5340                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5341   ycontourvertex[2] = ycontourvertex[1];
5342   ycontourvertex[3] = ycontourvertex[0];
5343   ycontourvertex[4] = ycontourvertex[3];
5344   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5345   ycontourvertex[6] = ycontourvertex[5];
5346   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5347                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5348                                         + fgkEndCapCoverPlateSmallHoleRadius;
5349   ycontourvertex[8] = ycontourvertex[7];
5350   ycontourvertex[9] = ycontourvertex[0];
5351
5352   Double_t xboxin, dxboxin, yboxin, dyboxin;
5353   Double_t xboxout, dxboxout, yboxout, dyboxout;
5354   Double_t coordmin, coordmax;
5355   coordmin = -fgkEndCapCoverPlateLength[0];
5356   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5357   xboxout = 0.5*(coordmin+coordmax);
5358   dxboxout = 0.5*(coordmax-coordmin);
5359   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5360                                         - (kendcapcoverplatesmallholenumber[1]-1)
5361                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5362   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5363                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5364   yboxout = 0.5*(coordmin+coordmax);
5365   dyboxout = 0.5*(coordmax-coordmin);
5366   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5367   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5368   xboxin = 0.5*(coordmin+coordmax);
5369   dxboxin = 0.5*(coordmax-coordmin);
5370   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5371   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5372                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5373                                         + fgkEndCapCoverPlateSmallHoleRadius;
5374   yboxin = 0.5*(coordmin+coordmax);
5375   dyboxin = 0.5*(coordmax-coordmin);
5376   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5377   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5378                                                          xboxout, yboxout, 0.);
5379   trendCapCoverPlateContourboxout->RegisterYourself();
5380   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5381   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5382                                                          xboxin, yboxin, 0.);
5383   trendCapCoverPlateContourboxin->RegisterYourself();
5384   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5385         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5386
5387   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5388                                                                            fSSDAlCoolBlockMedium);
5389   contour->SetLineColor(6);
5390   /////////////////////////////
5391   // Hole Contour Shape Definition 
5392   ////////////////////////////
5393   coordmin = xcontourvertex[0];
5394   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5395   xboxout = 0.5*(coordmin+coordmax);
5396   dxboxout = 0.5*(coordmax-coordmin);
5397   coordmin = ycontourvertex[1];
5398   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5399   yboxout = 0.5*(coordmin+coordmax);
5400   dyboxout = 0.5*(coordmax-coordmin);
5401   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5402                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5403   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5404   xboxin = 0.5*(coordmin+coordmax);
5405   dxboxin = 0.5*(coordmax-coordmin);
5406   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5407                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5408   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5409   yboxin = 0.5*(coordmin+coordmax);
5410   dyboxin = 0.5*(coordmax-coordmin);
5411   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5412   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5413                                                          xboxout, yboxout, 0.);
5414   trendCapCoverPlateContourboxout1->RegisterYourself();
5415   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5416   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5417                                                          xboxin, yboxin, 0.);
5418   trendCapCoverPlateContourboxin1->RegisterYourself();
5419   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5420         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5421
5422
5423   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5424   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5425   xboxout = 0.5*(coordmin+coordmax);
5426   dxboxout = 0.5*(coordmax-coordmin);
5427   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5428                                                    - fgkEndCapCoverPlateWidth[0]);
5429   coordmax = ycontourvertex[0];
5430   yboxout = 0.5*(coordmin+coordmax);
5431   dyboxout = 0.5*(coordmax-coordmin);
5432   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5433                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5434   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5435   xboxin = 0.5*(coordmin+coordmax);
5436   dxboxin = 0.5*(coordmax-coordmin);
5437   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5438                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5439                                                    - fgkEndCapCoverPlateWidth[0]
5440                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5441   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5442   yboxin = 0.5*(coordmin+coordmax);
5443   dyboxin = 0.5*(coordmax-coordmin);
5444   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5445   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5446                                                          xboxout, yboxout, 0.);
5447   trendCapCoverPlateContourboxout2->RegisterYourself();
5448   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5449   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5450                                                          xboxin, yboxin, 0.);
5451   trendCapCoverPlateContourboxin2->RegisterYourself();
5452   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5453         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5454   
5455 //  const Int_t kholecontourvertexnumber = 10;
5456
5457   Double_t xholecontourvertex[2][kcontourvertexnumber];
5458   Double_t yholecontourvertex[2][kcontourvertexnumber];
5459   xholecontourvertex[0][0] = xcontourvertex[0];
5460   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5461   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5462   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5463   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5464                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5465                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5466   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5467   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5468                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5469   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5470   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5471   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5472   
5473   yholecontourvertex[0][0] = ycontourvertex[1];
5474   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5475   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5476   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5477   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5478   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5479                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5480   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5481   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5482   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5483   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5484
5485   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5486   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5487   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5488   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5489   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5490                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5491                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5492   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5493   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5494                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5495   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5496   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5497   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5498   
5499   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5500                                                    - fgkEndCapCoverPlateWidth[0]);
5501   yholecontourvertex[1][1] = ycontourvertex[0];
5502   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5503   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5504   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5505   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5506                                                    - fgkEndCapCoverPlateWidth[0]
5507                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5508   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5509   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5510   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5511   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5512
5513   TGeoVolume* holecontour[2];
5514   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5515                                                                   fSSDAlCoolBlockMedium);
5516   holecontour[0]->SetLineColor(6);
5517   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5518                                                                   fSSDAlCoolBlockMedium);
5519   holecontour[1]->SetLineColor(6);
5520   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5521                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5522   TGeoTranslation*  bigholetrans[3];
5523   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5524                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5525   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5526                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5527                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5528   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5529                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5530   /////////////////////////////////
5531   // Mother Volume Xtru Definition 
5532   /////////////////////////////////
5533   const Int_t kmothervertexnumber = 12;
5534   Double_t xmothervertex[kmothervertexnumber];  
5535   Double_t ymothervertex[kmothervertexnumber];  
5536   xmothervertex[0]  = xcontourvertex[0];
5537   xmothervertex[1]  = xmothervertex[0];
5538   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5539   xmothervertex[3]  = xmothervertex[2];
5540   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5541   xmothervertex[5]  = xmothervertex[4];
5542   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5543   xmothervertex[7]  = xmothervertex[6];
5544   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5545                                         + fgkEndCapCoverPlateLength[2]; 
5546   xmothervertex[9]  = xmothervertex[8];
5547   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5548   xmothervertex[11] = xmothervertex[10];
5549   
5550   ymothervertex[0]  = ycontourvertex[0];
5551   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5552   ymothervertex[2]  = ymothervertex[1];
5553   ymothervertex[3]  = ycontourvertex[1];
5554   ymothervertex[4]  = ymothervertex[3];
5555   ymothervertex[5]  = ymothervertex[1];
5556   ymothervertex[6]  = ymothervertex[5];
5557   ymothervertex[7]  = ymothervertex[0];
5558   ymothervertex[8]  = ymothervertex[7];
5559   ymothervertex[9]  = ymothervertex[8]
5560                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5561   ymothervertex[10] = ymothervertex[9];
5562   ymothervertex[11] = ymothervertex[8];
5563   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5564   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5565   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5566   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5567   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5568   ////////////////////////////////////////
5569   // Adding Nodes
5570   ////////////////////////////////////////
5571 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5572   TGeoTranslation*** endcapcoverplatesmallholetrans;
5573   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5574   Double_t transx[4] = {0,
5575                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5576                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5577                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5578                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5579                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5580   Int_t index = 0;
5581   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5582         endcapcoverplatesmallholetrans[i] = 
5583                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5584     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5585                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5586             endcapcoverplatesmallholetrans[i][j] = 
5587                 new TGeoTranslation(transx[i],
5588                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5589             if(index!=10){ 
5590                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5591                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5592                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5593                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5594                 }
5595                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5596                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5597                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5598     }
5599   }
5600   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5601   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5602   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5603   mothercoverplate->AddNode(endcapfillingbox,1);
5604   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5605   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5606   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5607   mothercoverplate->AddNode(holecontour[0],1);
5608   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5609   mothercoverplate->AddNode(holecontour[1],1);  
5610   mothercoverplate->AddNode(contour,1);
5611   /////////////////////////////////
5612   return mothercoverplate;      
5613  }
5614  ////////////////////////////////////////////////////////////////////////////////
5615  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5616   /////////////////////////////////////////////////////////////
5617   // Getting EndCap Cooling Tube 
5618   /////////////////////////////////////////////////////////////
5619   TGeoTorus* endcapcoolingtubetorushape[5];
5620   TGeoVolume* endcapcoolingtubetorus[5];
5621   TGeoTube* endcapcoolingtubeshape[4];
5622   TGeoVolume* endcapcoolingtube[4];
5623   char endcapcoolingtubetorusname[100];
5624   char endcapcoolingtubename[100];
5625   TGeoTorus* endcapcoolingwatertubetorushape[5];
5626   TGeoVolume* endcapcoolingwatertubetorus[5];
5627   TGeoTube* endcapcoolingwatertubeshape[4];
5628   TGeoVolume* endcapcoolingwatertube[4];
5629   char endcapcoolingwatertubetorusname[100];
5630   char endcapcoolingwatertubename[100];
5631   for(Int_t i=0; i<5; i++){
5632         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5633         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5634         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5635         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5636         if(i==3){
5637                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5638                                                                                 fgkEndCapCoolingTubeRadiusMin,
5639                                                                                 fgkEndCapCoolingTubeRadiusMax,
5640                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5641                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5642                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5643                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5644     }
5645         else{
5646                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5647                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5648                                                                            fgkEndCapCoolingTubeRadiusMin,
5649                                                                            fgkEndCapCoolingTubeRadiusMax,
5650                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5651                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5652                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5653                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5654                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5655         }
5656         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5657                                                                                            endcapcoolingtubetorushape[i],
5658                                                                                            fSSDCoolingTubePhynox);
5659         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5660                                                                                                         endcapcoolingwatertubetorushape[i],
5661                                                                                                         fSSDCoolingTubeWater);
5662     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5663     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5664     if(i<4){
5665                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5666                                                                   fgkEndCapCoolingTubeRadiusMax,
5667                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5668                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5669                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5670         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5671                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5672         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5673                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5674                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5675                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5676         }
5677   }
5678   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5679   /////////////////////////////////////////
5680   // Transformation for Volume Positioning 
5681   /////////////////////////////////////////
5682   TGeoCombiTrans* coolingtubecombitrans[6];
5683   TGeoRotation* coolingtuberot[8];
5684   TGeoTranslation* coolingtubetrans[6];
5685   TGeoHMatrix* coolingtubematrix[4];
5686   TGeoCombiTrans* torustubecombitrans[4];
5687   TGeoRotation* torustuberot[7];
5688   TGeoTranslation* torustubetrans[4];
5689   TGeoHMatrix* torustubematrix[5];
5690   TGeoCombiTrans* coolingwatertubecombitrans[6];
5691   TGeoRotation* coolingwatertuberot[8];
5692   TGeoTranslation* coolingwatertubetrans[6];
5693   TGeoHMatrix* coolingwatertubematrix[4];
5694   TGeoCombiTrans* toruswatertubecombitrans[4];
5695   TGeoRotation* toruswatertuberot[7];
5696   TGeoTranslation* toruswatertubetrans[4];
5697   TGeoHMatrix* toruswatertubematrix[5];
5698   for(Int_t i=0; i<8; i++){
5699     if(i<6){
5700          coolingtubetrans[i] = new TGeoTranslation();
5701          coolingwatertubetrans[i] = new TGeoTranslation();
5702     }
5703     if(i<8){
5704          coolingtuberot[i] = new TGeoRotation();
5705          coolingwatertuberot[i] = new TGeoRotation();
5706     }
5707     if(i<4){
5708          torustubetrans[i] = new TGeoTranslation();
5709          toruswatertubetrans[i] = new TGeoTranslation();
5710     }
5711     if(i<7){
5712          torustuberot[i] = new TGeoRotation();
5713          toruswatertuberot[i] = new TGeoRotation();
5714         }
5715   }
5716   /////////////////////////////////////////
5717   // Transformation for Inox Volume Positioning 
5718   /////////////////////////////////////////
5719   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5720                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5721   coolingtuberot[0]->SetAngles(0.,90.,0.);
5722   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5723                                                                                                 *coolingtuberot[0]);
5724                                                                                                 
5725   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5726   coolingtuberot[1]->SetAngles(0.,90.,0.);
5727   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5728                                                                                                 *coolingtuberot[1]);
5729
5730   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5731                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5732                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5733                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5734                                                                           0.);
5735   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5736   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5737                                                                                                 *coolingtuberot[2]);
5738
5739   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5740                                            *                             (*coolingtubecombitrans[1]));
5741
5742   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5743                                                                          endcapcoolingtubeshape[1]->GetDz());
5744   torustuberot[0]->SetAngles(0.,90.,0.); 
5745   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5746
5747   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5748
5749   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5750                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5751   coolingtuberot[3]->SetAngles(0.,90.,0.);
5752   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5753                                                                                                 *coolingtuberot[3]);
5754   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5755   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5756   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5757   
5758   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5759                                                                         endcapcoolingtubeshape[2]->GetDz());
5760   torustuberot[1]->SetAngles(0.,90.,0.); 
5761   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5762   torustuberot[2]->SetAngles(180.,0.,0.); 
5763   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5764   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5765
5766   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5767                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5768   torustuberot[3]->SetAngles(0.,90.,0.); 
5769   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5770   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5771   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5772   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5773
5774   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5775                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5776   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5777   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5778                                                                                                 *coolingtuberot[5]);
5779   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5780   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5781   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5782   
5783   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5784                                                                         endcapcoolingtubeshape[0]->GetDz());
5785   torustuberot[5]->SetAngles(0.,90.,0.); 
5786   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5787   torustuberot[6]->SetAngles(-90.,0.,0.); 
5788   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5789   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5790   
5791   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5792                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5793   coolingtuberot[6]->SetAngles(0.,90.,0.);
5794   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5795                                                                                                 *coolingtuberot[6]);
5796   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5797   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5798   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5799     /////////////////////////////////////////
5800   // Transformation for Water Volume Positioning 
5801   /////////////////////////////////////////
5802   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5803                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5804   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5805   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5806                                                                                                      *coolingwatertuberot[0]);
5807
5808   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5809   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5810   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5811                                                                                                      *coolingwatertuberot[1]);
5812
5813   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5814                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5815                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5816                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5817                                                                               0.);
5818   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5819   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5820                                                                                                     *coolingwatertuberot[2]);
5821
5822   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5823                                            *                                 (*coolingwatertubecombitrans[1]));
5824                                            
5825   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5826                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5827   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5828   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5829                                                                                                    *toruswatertuberot[0]);
5830
5831   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5832                                                   *                                     (*toruswatertubecombitrans[0]));
5833
5834   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5835                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5836   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5837   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5838                                                                                                      *coolingwatertuberot[3]);
5839   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5840   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5841                                                         *                                 (*coolingwatertubecombitrans[3]));
5842   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5843
5844   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5845                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5846   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5847   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5848                                                                                                    *toruswatertuberot[1]);
5849   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5850   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5851                                                   *                 (*toruswatertubecombitrans[1]));
5852   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5853   
5854   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5855                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5856   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5857   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5858                                                                                                    *toruswatertuberot[3]);
5859   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5860   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5861                                                   *                                     (*toruswatertubecombitrans[2]));
5862   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5863
5864   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5865                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5866   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5867   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5868                                                                                                      *coolingwatertuberot[5]);
5869   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5870   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5871                                                         *                                 (*coolingwatertubecombitrans[4]));
5872   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5873   
5874   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5875                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5876   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5877   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5878                                                                                                    *toruswatertuberot[5]);
5879   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5880   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5881                                                   *                 (*toruswatertubecombitrans[3]));
5882   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5883   
5884   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5885                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5886   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5887   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5888                                                                                                      *coolingwatertuberot[6]);
5889   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5890   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5891                                                         *                                 (*coolingwatertubecombitrans[5]));
5892   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5893   /////////////////////////////////////////
5894   // Positioning Volumes
5895   /////////////////////////////////////////
5896   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5897   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5898   
5899   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5900   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5901
5902   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5903   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5904  
5905   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5906   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5907
5908   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5909   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5910
5911   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5912   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5913
5914   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5915   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5916
5917   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5918   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5919   
5920   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5921   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5922  
5923   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5924   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5925   /////////////////////////////////////////////////////////////
5926   // Deallocating memory
5927   /////////////////////////////////////////////////////////////
5928   for(Int_t i=0; i<8; i++){
5929     if(i<6){
5930          delete coolingtubetrans[i];
5931          delete coolingwatertubetrans[i];
5932          if(i!=0){
5933           delete coolingtubecombitrans[i];
5934           delete coolingwatertubecombitrans[i];
5935          }
5936         }
5937     if(i<8){
5938           delete coolingtuberot[i];
5939           delete coolingwatertuberot[i];
5940     }
5941     if(i<4){
5942                 delete torustubetrans[i];
5943                 delete toruswatertubetrans[i];
5944                 delete torustubecombitrans[i];
5945                 delete toruswatertubecombitrans[i];
5946         } 
5947     if(i<7){
5948          delete torustuberot[i];
5949          delete toruswatertuberot[i];
5950         }
5951   }
5952   /////////////////////////////////////////////////////////////
5953   return endcapcoolingtubemother;
5954  }
5955  ////////////////////////////////////////////////////////////////////////////////
5956  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5957   /////////////////////////////////////////////////////////////
5958   // Getting EndCap Cover Side 
5959   /////////////////////////////////////////////////////////////
5960   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5961   const Int_t kvertexnumber = 15; 
5962   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5963   xvertex[0]  = 0.0;
5964   xvertex[1]  = xvertex[0];
5965   xvertex[2]  = fgkEndCapSideCoverLength[0];
5966   xvertex[3]  = fgkEndCapSideCoverLength[1];
5967   xvertex[4]  = xvertex[3];
5968   xvertex[5]  = fgkEndCapSideCoverLength[2];
5969   xvertex[6]  = xvertex[5];
5970   xvertex[7]  = xvertex[2];
5971   xvertex[8]  = xvertex[7];
5972   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5973   xvertex[10] = xvertex[9];
5974   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5975                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5976                           * fgkEndCapSideCoverLength[4];
5977   xvertex[12] = xvertex[11];
5978   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5979                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5980                           * fgkEndCapSideCoverLength[4];
5981   xvertex[14] = xvertex[13];
5982   yvertex[0]  = 0.0;
5983   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5984   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5985   yvertex[3]  = yvertex[2];
5986   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5987   yvertex[5]  = yvertex[4];
5988   yvertex[6]  = yvertex[0];
5989   yvertex[7]  = yvertex[6];
5990   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5991   yvertex[9]  = yvertex[8];
5992   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5993   yvertex[11] = yvertex[10];
5994   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5995   yvertex[13] = yvertex[12];
5996   yvertex[14] = yvertex[6];
5997   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5998   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5999   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
6000   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
6001   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
6002   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
6003   endcapsidecovershapein->SetName("endcapsidecovershapein");
6004   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
6005   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
6006   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
6007
6008
6009   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
6010   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
6011                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
6012   endcapsidecover->SetLineColor(fColorPhynox);
6013   ////////////////////////////////////////////
6014   // Defininition of Mother Volume
6015   ////////////////////////////////////////////
6016   const Int_t kmothervertexnumber = 7;
6017   Double_t xmothervertex[kmothervertexnumber]; 
6018   Double_t ymothervertex[kmothervertexnumber]; 
6019   for(Int_t i=0; i<kmothervertexnumber; i++){
6020         xmothervertex[i] = xvertex[i];
6021         ymothervertex[i] = yvertex[i];
6022   }
6023   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
6024   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
6025   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
6026   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
6027   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
6028                                                                 endcapsidecovermothershape,fSSDAir);
6029   ////////////////////////////////////////////
6030   endcapsidecovermother->AddNode(endcapsidecover,1);
6031   TGeoBBox* endcapsidecoverboxshape[4];
6032   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
6033                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
6034                                                                0.5*fgkEndCapSideCoverLength[4],
6035                                                                    0.5*fgkEndCapSideCoverThickness); 
6036   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
6037                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
6038                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
6039                                                          -     fgkEndCapSideCoverLength[4]),
6040                                                                    0.5*fgkEndCapSideCoverThickness); 
6041   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
6042                                                                0.5*fgkEndCapSideCoverLength[4],
6043                                                                    0.5*fgkEndCapSideCoverThickness); 
6044   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
6045                                                                0.5*fgkEndCapSideCoverWidth[5],
6046                                                                    0.5*fgkEndCapSideCoverThickness); 
6047   TGeoVolume* endcapsidecoverbox[4];
6048   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
6049   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
6050   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
6051   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
6052   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
6053 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
6054   TGeoTranslation** endcapsidecoverboxtrans;
6055   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
6056   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
6057                                                          +                                         fgkEndCapSideCoverLength[0],
6058                                                                                                    endcapsidecoverboxshape[0]->GetDY()
6059                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
6060   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
6061                                                          +                     xvertex[11],
6062                                                                                                    endcapsidecoverboxshape[1]->GetDY()
6063                                                          +                     yvertex[12],0.);
6064   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
6065                                                          +                     xvertex[11],
6066                                                                                                    endcapsidecoverboxshape[2]->GetDY()
6067                                                          +                     yvertex[12]
6068                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
6069                                                          +                     fgkEndCapSideCoverWidth[5],0.);
6070   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
6071   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
6072   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
6073   for(Int_t i=0; i<2; i++)
6074         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
6075                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
6076                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
6077                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6078                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6079                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
6080                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
6081                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
6082         }
6083   for(Int_t i=0; i<2; i++)
6084         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
6085                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
6086                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
6087                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
6088                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
6089                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
6090                                                         +fgkEndCapSideCoverLength[4]),0.0);
6091                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
6092                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
6093                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
6094                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
6095         }
6096         return endcapsidecovermother;
6097  } 
6098  ////////////////////////////////////////////////////////////////////////////////
6099  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
6100  ////////////////////////////////////////////////////////////////////////////////
6101  // Method returning Interface Card A, Interface Card B, Supply Card 
6102  ////////////////////////////////////////////////////////////////////////////////
6103  /////////////////////
6104  // Supply Card
6105  /////////////////////
6106  // Electronic Board Back Al Plane
6107  const Int_t kelectboardbackvertexnumber = 8;
6108  Double_t xelectboardback[kelectboardbackvertexnumber];
6109  Double_t yelectboardback[kelectboardbackvertexnumber];
6110  xelectboardback[0] = 0.0;
6111  xelectboardback[1] = xelectboardback[0];
6112  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
6113  xelectboardback[3] = xelectboardback[2];
6114  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
6115  xelectboardback[5] = xelectboardback[4];
6116  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
6117  xelectboardback[7] = xelectboardback[6];
6118  
6119  yelectboardback[0] = 0.0;
6120  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
6121  yelectboardback[2] = yelectboardback[1];
6122  yelectboardback[3] = yelectboardback[0];
6123  yelectboardback[4] = yelectboardback[3];
6124  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
6125  yelectboardback[6] = yelectboardback[5];
6126  yelectboardback[7] = yelectboardback[4];
6127  TGeoXtru* electboardbackshape = new TGeoXtru(2);
6128  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
6129                                                                         xelectboardback,yelectboardback); 
6130  electboardbackshape->DefineSection(0,0.0);
6131  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
6132  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
6133                                                                                          electboardbackshape,fSSDSupportRingAl);
6134  electboardback->SetLineColor(fColorAl);
6135  // Electronic Board Kapton Layer
6136  const Int_t kelectlayervertexnumber = 8;
6137  Double_t xelectlayer[kelectlayervertexnumber];
6138  Double_t yelectlayer[kelectlayervertexnumber];
6139  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
6140  xelectlayer[1] = xelectlayer[0];
6141  xelectlayer[2] = fgkEndCapCardElectBoardLength;
6142  xelectlayer[3] = xelectlayer[2];
6143  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
6144      
6145  yelectlayer[0] = 0.0;
6146  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
6147  yelectlayer[2] = yelectlayer[1];
6148  yelectlayer[3] = yelectlayer[0];
6149  yelectlayer[4] = yelectlayer[3];
6150  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
6151  yelectlayer[6] = yelectlayer[5];
6152  yelectlayer[7] = yelectlayer[4];
6153  TGeoXtru* electlayershape = new TGeoXtru(2);
6154  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
6155  electlayershape->DefineSection(0,0.0);
6156  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
6157  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
6158                                                                                          electlayershape,fSSDKaptonFlexMedium);
6159  electlayer->SetLineColor(fColorKapton);
6160  // JMD Connector Female
6161  const Int_t kjmdconnectorvertexnumber = 6;
6162  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6163  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
6164  xjmdconnectorvertex[0] = 0.0; 
6165  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
6166  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
6167  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
6168  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
6169  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
6170
6171  yjmdconnectorvertex[0] = 0.0; 
6172  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
6173  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
6174  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
6175  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
6176  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
6177  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
6178  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
6179                                                                   yjmdconnectorvertex); 
6180  jmdconnectorshape->DefineSection(0,0.0);
6181  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
6182  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
6183                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
6184  jmdconnector->SetLineColor(fColorG10);
6185  // Top Cable Connector
6186  const Int_t kcableconnectorvertexnumber = 8;
6187  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
6188  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
6189  xconnectorvertex[0] = 0.0;
6190  xconnectorvertex[1] = xconnectorvertex[0];
6191  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
6192  xconnectorvertex[3] = xconnectorvertex[2];
6193  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
6194                                          - fgkEndCapCardCableConnectorLength[2];
6195  xconnectorvertex[5] = xconnectorvertex[4];
6196  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
6197  xconnectorvertex[7] = xconnectorvertex[6];
6198
6199  yconnectorvertex[0] = 0.0;
6200  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
6201  yconnectorvertex[2] = yconnectorvertex[1];
6202  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
6203  yconnectorvertex[4] = yconnectorvertex[3];
6204  yconnectorvertex[5] = yconnectorvertex[1];
6205  yconnectorvertex[6] = yconnectorvertex[5];
6206  yconnectorvertex[7] = yconnectorvertex[0];
6207  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
6208  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
6209                                                                     yconnectorvertex); 
6210  cableconnectorshape->DefineSection(0,0.0);
6211  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
6212  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
6213                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
6214  cableconnector->SetLineColor(fColorG10);
6215  // Strip Connection
6216  TGeoBBox* endcapstripconnectionshape = 
6217                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
6218                                                                                          0.5*fgkEndCapStripConnectionThickness,
6219                                                                                          0.5*fgkEndCapStripConnectionWidth);
6220  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
6221                                                                                                         endcapstripconnectionshape,
6222                                                                                                         fSSDSupportRingAl);
6223  endcapstripconnection->SetLineColor(fColorAl);
6224  // Interface Card B
6225  const Int_t kcardBvertexnumber = 12; 
6226  Double_t xcardBvertexnumber[kcardBvertexnumber];
6227  Double_t ycardBvertexnumber[kcardBvertexnumber];
6228
6229  xcardBvertexnumber[0]  = 0.0;
6230  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
6231  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
6232  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
6233  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
6234  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
6235  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
6236  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
6237  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
6238  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
6239  xcardBvertexnumber[10] = xcardBvertexnumber[7];
6240  xcardBvertexnumber[11] = xcardBvertexnumber[10];
6241  
6242  ycardBvertexnumber[0]  = 0.0;
6243  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
6244  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
6245  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
6246  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
6247  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
6248  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
6249  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
6250  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
6251  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
6252  ycardBvertexnumber[10] = ycardBvertexnumber[9];
6253  ycardBvertexnumber[11] = ycardBvertexnumber[0];
6254
6255  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
6256  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
6257  interfacecardBshape->DefineSection(0,0.);
6258  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
6259  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
6260                                                                                          fSSDMountingBlockMedium);
6261  interfacecardB->SetLineColor(46);
6262  // Interface Card B Electronic Board
6263  const Int_t kelectboardcardBvertexnumber = 14; 
6264  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
6265  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
6266
6267  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
6268  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
6269  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
6270  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
6271  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
6272  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
6273  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
6274  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
6275  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
6276  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
6277  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
6278  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
6279  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
6280  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
6281
6282  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
6283  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
6284  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
6285  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
6286  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
6287  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
6288  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
6289  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
6290  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
6291  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
6292  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
6293  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
6294  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
6295  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
6296
6297  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
6298  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
6299                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
6300  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
6301  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
6302                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
6303  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
6304                                                                                           fSSDSupportRingAl);
6305  electboardcardB->SetLineColor(fColorAl);
6306  // Generating Stiffener 2
6307  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
6308                                                                                            0.5*fgkEndCapStiffenerThickness,
6309                                                                                            0.5*fgkEndCapStiffenerLength);
6310  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
6311  endcapstiffener->SetLineColor(fColorAl);   
6312  // Generating Mother Interface Card B Container
6313  const Int_t kinterfacecardBmothervertexnumber = 10;
6314  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6315  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
6316
6317  xinterfacecardBmothervertex[0] = 0.0;
6318  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
6319  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
6320                                                                 + fgkEndCapInterfaceCardBThickness;
6321  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
6322  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
6323                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
6324  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
6325  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
6326  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
6327  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
6328                                                                 + fgkEndCapCardJMDConnectorLength[0];
6329  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
6330
6331  yinterfacecardBmothervertex[0] = 0.0;
6332  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
6333                                                                 + fgkEndCapInterfaceCardBWidth[1]
6334                                                                 + fgkEndCapInterfaceCardBWidth[2];
6335  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6336  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6337  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6338  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6339  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6340  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6341                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6342                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6343  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6344  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6345  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6346  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6347                                                                                   xinterfacecardBmothervertex,
6348                                                                                   yinterfacecardBmothervertex);
6349  interfacecardBmothershape->DefineSection(0,-1.e-15);
6350  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6351  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6352                                                                                                    interfacecardBmothershape,fSSDAir);
6353  electboardcardB->SetLineColor(fColorAl);
6354  // Positioning Volumes Mother Interface Card B Container 
6355  TGeoRotation* interfacecardBrot = new TGeoRotation();
6356  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6357  interfacecardBrot->SetAngles(90.,-90.,-90.);
6358  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6359  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6360  TGeoRotation* electboardcardBrot = new TGeoRotation();
6361  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6362  electboardcardBrot->SetAngles(90.,90.,-90.);
6363  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6364  TGeoCombiTrans* electboardcardBcombitrans = 
6365                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6366  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6367  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6368  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6369  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6370  TGeoTranslation* jmdconnectorcardBtrans[3];
6371  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6372  for(Int_t i=0; i<3; i++){
6373    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6374                                                          + fgkEndCapCardJMDConnectorLength[0], 
6375                                                            fgkEndCapCardElectBoardLayerWidth[1],
6376                                                            0.5*fgkEndCapCardJMDConnectorThickness
6377                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6378                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6379                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6380    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6381                                                                                                            *jmdconnectorcardBrot);
6382    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6383  }
6384  // Mother Supply Card Container 
6385  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6386  // Interface Card Container
6387  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6388  // Placing Volumes in Mother Supply Card Container
6389  // JMD Connector Positioning
6390  TGeoTranslation* jmdconnectortrans[2];
6391  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6392  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6393                                                                                         fgkEndCapCardElectBoardBackLength[0]
6394                                           -                                             fgkEndCapCardJMDConnectorThickness
6395                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6396  TGeoRotation* jmdconnectorot = new TGeoRotation();
6397  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6398                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6399                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6400                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6401                                                                       fgkEndCapCardJMDConnectorThickness
6402                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6403  jmdconnectorot->SetAngles(90.,180.,-90);
6404  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6405                                                                                 * jmdconnectorot);
6406  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6407  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6408  // Top Cable Connector Placing
6409  TGeoRotation* cableconnectorot[2];
6410  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6411  TGeoTranslation* cableconnectortrans[3];
6412  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6413  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6414  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6415  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6416  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6417                                                                                                                            *cableconnectorot[0]);
6418  TGeoHMatrix* cableconnectormatrix[2];
6419  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6420                                                         new TGeoHMatrix((*cableconnectorot[1])
6421                                                                                    *(*cableconnectorcombitrans));
6422  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6423                                            -                               fgkEndCapCardCableConnectorThickness,
6424                                                                                 fgkEndCapCardCableConnectorLength[0]
6425                                            +                            fgkEndCapCardCableConnectorToLayer);
6426  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6427                                            -                2.*fgkEndCapCardCableConnectorThickness
6428                                            -                            fgkEndCapCardCableConnectorDistance,
6429                                                                                 fgkEndCapCardCableConnectorLength[0]
6430                                            +                            fgkEndCapCardCableConnectorToLayer);
6431  for(Int_t i=0; i<2; i++){
6432         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6433     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6434  }
6435  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6436  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6437  electboardbackrot->SetAngles(90.,-90.,-90.);
6438  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6439                                                         +                fgkEndCapCardJMDConnectorLength[0]
6440                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6441  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6442                                                                                                                            *electboardbackrot);
6443  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6444  // Electronic Board Kapton Layer Positioning
6445  TGeoRotation* electlayerrot = new TGeoRotation();
6446  TGeoTranslation* electlayertrans[2];
6447  TGeoCombiTrans* electlayercombitrans[2];
6448  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6449  electlayerrot->SetAngles(90.,-90.,-90.);
6450  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6451                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6452  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6453                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6454                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6455  for(Int_t i=0; i<2; i++){
6456         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6457         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6458  }
6459  // Placing Volumes in Mother Interface Card Container
6460  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6461  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6462  for(Int_t i=0; i<2; i++){
6463         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6464  }
6465  /////////////////////////////////////////////////////////////
6466  // Generation of Card Interface Container
6467  /////////////////////////////////////////////////////////////
6468  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6469                                                   - fgkEndCapCardJMDConnectorLength[0]
6470                                                   - fgkEndCapInterfaceCardBThickness
6471                                                   - 9.*fgkEndCapStripConnectionThickness
6472                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6473  const Int_t kcardinterfacecontainervertexnumber = 14;
6474  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6475  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6476  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6477                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6478  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6479  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6480                                                                    + fgkEndCapStripConnectionThickness
6481                                                                    - fgkEndCapCardElectBoardLayerThickness
6482                                                                    - fgkEndCapCardCableConnectorWidth[0];
6483  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6484  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6485  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6486  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6487                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6488  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6489  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6490                                                                    + fgkEndCapInterfaceCardBThickness;
6491  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6492  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6493                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6494  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6495  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6496                                    - fgkEndCapInterfaceElectBoardCardBThickness
6497                                                                    + fgkEndCapCardJMDConnectorLength[0]
6498                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6499  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6500
6501  ycardinterfacecontainervertex[0]  = 0.;
6502  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6503                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6504                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6505  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6506  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6507                                                                    - fgkEndCapStripConnectionWidth;
6508  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6509  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6510  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6511  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6512                                                                    + fgkEndCapInterfaceCardBWidth[1]
6513                                                                    + fgkEndCapInterfaceCardBWidth[2];
6514  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6515  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6516  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6517  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6518  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6519  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6520  
6521  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6522  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6523                                                                                   xcardinterfacecontainervertex,
6524                                                                                   ycardinterfacecontainervertex);
6525  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6526                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6527  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6528                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6529  TGeoVolume** cardinterfacecontainer;
6530  cardinterfacecontainer = new TGeoVolume*[4];
6531  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6532                                                                                         interfacecardmothershape,fSSDAir); 
6533  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6534                                                                                         interfacecardmothershape,fSSDAir); 
6535  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6536                                                                                         interfacecardmothershape,fSSDAir); 
6537  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6538                                                                                         interfacecardmothershape,fSSDAir); 
6539  /////////////////////////////////
6540  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6541  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6542  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6543  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6544  /////////////////////////////////
6545  TGeoRotation* endcapstripconnectionrot[2];
6546  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6547  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6548  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6549  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6550                                                                         *                                 (*endcapstripconnectionrot[0]));
6551  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6552  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6553                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6554                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6555                                                                                         -endcapstripconnectionshape->GetDZ(),
6556                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6557  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6558  TGeoTranslation* cardinterfacetrans[9];
6559  TGeoHMatrix* cardinterfacematrix[9]; 
6560  for(Int_t i=0; i<7; i++){ 
6561         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6562                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6563                                                                                                 0.0,0.0);  
6564         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6565                                                    *                             (*endcapstripconnectionmatrix));
6566  }
6567  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6568                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6569                                                                                                 0.0,0.0);  
6570  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6571                                                 *                                 (*endcapstripconnectionmatrix));
6572  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6573                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6574                                                                                                 0.0,0.0);  
6575  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6576                                                 *                                 (*endcapstripconnectionmatrix));
6577
6578  for(Int_t i=0; i<4; i++){
6579         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6580                                                                            cardinterfacematrix[7]);                             
6581         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6582                                                                            cardinterfacematrix[8]);                             
6583  }
6584  TGeoTranslation* mothersupplycardtrans = 
6585                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6586                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6587                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6588  TGeoHMatrix* mothersupplycardmatrix[7];
6589  Int_t index[4] = {1,1,1,1};
6590  for(Int_t i=0; i<7; i++){
6591         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6592                                                         *                                 (*mothersupplycardtrans));
6593         for(Int_t j=0; j<4; j++){
6594                 switch(j){
6595                         case 0: //Layer5 EndCap Left Side  
6596                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6597                                                                                                    cardinterfacematrix[i]);                             
6598                                 if(i!=0){
6599                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6600                                                                                                            mothersupplycardmatrix[i]);                  
6601                                         index[j]++;
6602
6603                                 }
6604                         break;
6605                         case 1: //Layer5 EndCap Rigth Side  
6606                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6607                                                                                                    cardinterfacematrix[i]);                     
6608                                 if(i>0&&i<6){
6609                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6610                                                                                                            mothersupplycardmatrix[i]);                  
6611                                         index[j]++;
6612                                 }
6613                         break;
6614                         case 2: //Layer6 EndCap Left Side  
6615                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6616                                                                                                    cardinterfacematrix[i]);                             
6617                                 if(i!=6){
6618                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6619                                                                                                            mothersupplycardmatrix[i]);                  
6620                                         index[j]++;
6621                                 }
6622                         break;
6623                         case 3: //Layer6 EndCap Right Side  
6624                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6625                                                                                                    cardinterfacematrix[i]);                             
6626                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6627                                                                                                    mothersupplycardmatrix[i]);                  
6628                                 index[j]++;
6629                         break;
6630                 }
6631         }
6632  }
6633  // Positioning Interface 
6634  TGeoTranslation* motherinterfacecardtrans = 
6635                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6636                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6637                                                          -fgkEndCapCardElectBoardLayerThickness
6638                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6639  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6640                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6641  // Positioning Interface Card B 
6642  TGeoTranslation* interfacecardBmothertrans = 
6643                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6644                                                                                 + 2.*fgkEndCapStripConnectionThickness
6645                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6646                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6647                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6648  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6649                                                                                                                          interfacecardBmothertrans);
6650  // Positioning Stiffener 
6651  TGeoTranslation* endcapstiffenertrans = 
6652                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6653                                                                            +    2.0*fgkEndCapStripConnectionThickness
6654                                                                            +    fgkEndCapInterfaceCardBThickness
6655                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6656                                                                            +    stiffenertransx
6657                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6658                                                                                         endcapstiffenershape->GetDZ()
6659                                                                            -    0.5*(fgkEndCapStiffenerLength
6660                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6661  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6662  /////////////////////////////////////////////////////////////
6663  // Deallocating memory
6664  /////////////////////////////////////////////////////////////
6665  delete interfacecardBrot;
6666  delete interfacecardBtrans;
6667  delete electboardcardBtrans;
6668  delete electboardcardBrot; 
6669  delete jmdconnectorcardBrot;
6670  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6671  delete jmdconnectorot;
6672  delete jmdconnectortrans[1];
6673  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6674  delete cableconnectorcombitrans;
6675  delete electboardbacktrans;
6676  delete electboardbackrot;
6677  delete electlayerrot;
6678  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6679  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6680  delete mothersupplycardtrans;
6681  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6682  /////////////////////////////////////////////////////////////
6683  return cardinterfacecontainer;
6684  }
6685  ////////////////////////////////////////////////////////////////////////////////
6686  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6687   /////////////////////////////////////////////////////////////
6688   // Method returning EndCap Mother Volume
6689   /////////////////////////////////////////////////////////////
6690   const Int_t kendcapcoverplatesmallholenumber = 9;
6691   Double_t endcapmotherorigin[3];
6692   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6693                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6694                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6695   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6696                                           -                      fgkEndCapCoverPlateWidth[2]
6697                                           -       (kendcapcoverplatesmallholenumber-1)
6698                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6699                                           +  0.5*(fgkEndCapSideCoverLength[2]
6700                                           +               fgkEndCapCoverPlateWidth[1]
6701                                           -       fgkEndCapCoverPlateWidth[0])
6702                                           -      (fgkEndCapCoverPlateWidth[1]
6703                                           -       fgkEndCapCoverPlateWidth[0]);
6704   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6705                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6706                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6707                                                 +      fgkEndCapSideCoverWidth[1]
6708                                                 +      fgkEndCapSideCoverThickness
6709                                                 +      fgkEndCapKaptonFoilThickness);
6710   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6711                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6712                                                           +              2.0* fgkEndCapSideCoverThickness),
6713                                                                          0.5* (fgkEndCapSideCoverLength[2]
6714                                                           +                    fgkEndCapCoverPlateWidth[1]
6715                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6716                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6717                                                       +                                    fgkEndCapSideCoverWidth[1]
6718                                                           +                                       fgkEndCapSideCoverThickness
6719                                                       +                                   fgkEndCapKaptonFoilThickness),
6720                                                                                          endcapmotherorigin);
6721   TGeoVolume** endcapassembly;  
6722   endcapassembly = new TGeoVolume*[4];
6723   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6724                                                                                         endcapmothershape,fSSDAir); 
6725   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6726                                                                                         endcapmothershape,fSSDAir); 
6727   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6728                                                                                         endcapmothershape,fSSDAir); 
6729   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6730                                                                                         endcapmothershape,fSSDAir); 
6731  /////////////////////////////////
6732  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6733  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6734  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6735  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6736  /////////////////////////////////
6737   /////////////////////////////////////////////////////
6738   // Placing Endcap Cover Plate
6739   /////////////////////////////////////////////////////
6740   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6741   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6742   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6743   TGeoCombiTrans* endcapcoverplatecombitrans = 
6744                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6745                                                                                          endcapcoverplaterot);
6746   TGeoTranslation* endcapcoverplatetrans = 
6747                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6748   TGeoHMatrix* endcapcoverplatematrix = 
6749                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6750                                                                           *       (*endcapcoverplatecombitrans));
6751   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6752   /////////////////////////////////////////////////////
6753   // Placing Endcap Side Cover
6754   /////////////////////////////////////////////////////
6755   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6756   TGeoRotation* endcapsidecoverot[2];
6757   TGeoCombiTrans* endcapsidecovercombitrans[3];
6758   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6759   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6760   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6761                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6762                                                                                         - fgkEndCapCoverPlateWidth[2]
6763                                                                                     - (kendcapcoverplatesmallholenumber-1)
6764                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6765                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6766                                                                                         + fgkEndCapSideCoverLength[2],
6767                                                                                           0.5*(fgkEndCapSideCoverThickness
6768                                                                                         + fgkEndCapCoverPlateThickness)
6769                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6770                                                                                           endcapsidecoverot[0]);
6771   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6772   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6773                                                                                                         0.5*fgkEndCapCoverPlateThickness
6774                                                                                                         -fgkEndCapSideCoverWidth[1],
6775                                                                                                         endcapsidecoverot[1]);
6776   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6777                                                                                                         +fgkEndCapCoverPlateLength[3]
6778                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6779                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6780                                                                                                         0.5*fgkEndCapCoverPlateThickness
6781                                                                                                         -fgkEndCapSideCoverWidth[1],
6782                                                                                                         endcapsidecoverot[1]);
6783   TGeoHMatrix* endcapsidecovermatrix[2];
6784   for(Int_t i=0; i<2; i++){
6785    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6786                                                         *                                 (*endcapsidecovercombitrans[0]));
6787         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6788                                                                                                                 endcapsidecovermatrix[i]);
6789   }
6790   /////////////////////////////////////////////////////
6791   // Placing Endcap Cooling Tube
6792   /////////////////////////////////////////////////////
6793   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6794   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6795   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6796   TGeoCombiTrans* endcapccolingtubecombitrans 
6797                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6798                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6799                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6800                                                 - fgkEndCapCoolingTubeToCoverSide,
6801                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6802                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6803   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6804                                                                                                           endcapccolingtubecombitrans);
6805   /////////////////////////////////////////////////////
6806   // Placing Screws 
6807   /////////////////////////////////////////////////////
6808   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6809                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6810   Int_t screwcoverplatedgesnumber[2] = {20,20};
6811   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6812                                                                                 fgkEndCapCoverPlateThickness
6813                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6814   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6815                                                                                                  screwcoverplatedgesnumber,
6816                                                                                                  screwcoverplatesection);
6817   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6818                                                                                            screwcoverplateshape,
6819                                                                                            fSSDCoolingTubePhynox); 
6820   screwcoverplate->SetLineColor(12);
6821   Double_t transx[4] = {0,
6822                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6823                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6824                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6825                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6826                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6827   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6828 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6829   TGeoTranslation*** endcapcoverplatescrewtrans;
6830   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6831   Int_t index = 0;
6832   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6833         endcapcoverplatescrewtrans[i] = 
6834                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6835     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6836                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6837         if(index==1||index==9||index==28||index==36){
6838                         endcapcoverplatescrewtrans[i][j] = 
6839                                 new TGeoTranslation(transx[i],
6840                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6841                                                                         fgkEndCapSideCoverThickness);
6842                 }
6843                 else{
6844                         endcapcoverplatescrewtrans[i][j] = 
6845                                 new TGeoTranslation(transx[i],
6846                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6847                                                                         0.);
6848                 }
6849             if(index!=19) 
6850                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6851                                                                                           endcapcoverplatescrewtrans[i][j]);
6852         }
6853   }
6854   /////////////////////////////////////////////////////
6855   // Placing Cover Plate Clips 
6856   /////////////////////////////////////////////////////
6857   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6858                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6859                                                                                                          0.5*fgkEndCapSideCoverThickness);
6860   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6861                                                                                                         endcapcoverplateclipshape,
6862                                                                                                         fSSDCoolingTubePhynox);
6863   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6864                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6865                                                                                                          0.5*fgkEndCapSideCoverThickness);
6866   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6867                                                                                                         endcapcoverplatedownclipshape,
6868                                                                                                         fSSDCoolingTubePhynox);
6869   TGeoTranslation* endcapcoverplatecliptrans[4];
6870   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6871                                                            -                     fgkEndCapCoverPlateLength[0]
6872                                                            -                     fgkEndCapSideCoverThickness,
6873                                                                                                          0.0,
6874                                                                                                  0.5*(fgkEndCapSideCoverThickness
6875                                                            +                                              fgkEndCapCoverPlateThickness));
6876   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6877                                                            -                     fgkEndCapCoverPlateLength[0]
6878                                                            -                     fgkEndCapSideCoverThickness,
6879                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6880                                                            *                                     fgkEndCapSideCoverWidth[5],
6881                                                                                                  0.5*(fgkEndCapSideCoverThickness
6882                                                            +                                              fgkEndCapCoverPlateThickness));
6883   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6884                                                            -                     fgkEndCapCoverPlateLength[0]
6885                                                            +                                     fgkEndCapCoverPlateLength[1]
6886                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6887                                                            -                                     fgkEndCapCoverPlateClipLength
6888                                                            +                                 fgkEndCapSideCoverThickness,
6889                                                                                                          0.0,
6890                                                                                                  0.5*(fgkEndCapSideCoverThickness
6891                                                            +                                              fgkEndCapCoverPlateThickness));
6892   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6893                                                            -                     fgkEndCapCoverPlateLength[0]
6894                                                            +                                     fgkEndCapCoverPlateLength[1]
6895                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6896                                                            -                                     fgkEndCapCoverPlateClipLength
6897                                                            +                                 fgkEndCapSideCoverThickness,
6898                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6899                                                            *                                     fgkEndCapSideCoverWidth[5],
6900                                                                                                  0.5*(fgkEndCapSideCoverThickness
6901                                                            +                                              fgkEndCapCoverPlateThickness));
6902   endcapcoverplateclip->SetLineColor(fColorPhynox);
6903   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6904   for(Int_t i=0; i<4; i++) 
6905         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6906                                                                                                    endcapcoverplatecliptrans[i]);  
6907   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6908   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6909                                                                    -                     fgkEndCapCoverPlateLength[0]
6910                                                                    -                     fgkEndCapSideCoverThickness,
6911                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6912                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6913                                                                                                         0.5*(fgkEndCapSideCoverThickness
6914                                                                +                                         fgkEndCapCoverPlateThickness)
6915                                                                    -                     fgkEndCapSideCoverWidth[1]
6916                                                                    -                                     fgkEndCapSideCoverThickness);
6917   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6918                                                                    -                     fgkEndCapCoverPlateLength[0]
6919                                                                    -                     fgkEndCapSideCoverThickness,
6920                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6921                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6922                                                                    +                            fgkEndCapSideCoverLength[2]
6923                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6924                                                                                                         0.5*(fgkEndCapSideCoverThickness
6925                                                                +                                         fgkEndCapCoverPlateThickness)
6926                                                                    -                     fgkEndCapSideCoverWidth[1]
6927                                                                    -                                     fgkEndCapSideCoverThickness);
6928   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6929                                                                    -                     fgkEndCapCoverPlateLength[0]
6930                                                                    +                     fgkEndCapSideCoverThickness
6931                                                                    +                     fgkEndCapCoverPlateLength[1]
6932                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6933                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6934                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6935                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6936                                                                                                         0.5*(fgkEndCapSideCoverThickness
6937                                                                +                                         fgkEndCapCoverPlateThickness)
6938                                                                    -                     fgkEndCapSideCoverWidth[1]
6939                                                                    -                                     fgkEndCapSideCoverThickness);
6940   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6941                                                                    -                     fgkEndCapCoverPlateLength[0]
6942                                                                    +                     fgkEndCapSideCoverThickness
6943                                                                    +                     fgkEndCapCoverPlateLength[1]
6944                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6945                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6946                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6947                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6948                                                                    +                                 fgkEndCapSideCoverLength[2]
6949                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6950                                                                                                         0.5*(fgkEndCapSideCoverThickness
6951                                                                +                                         fgkEndCapCoverPlateThickness)
6952                                                                    -                     fgkEndCapSideCoverWidth[1]
6953                                                                    -                                     fgkEndCapSideCoverThickness);
6954   for(Int_t i=0; i<4; i++)
6955         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6956                                                                                                    endcapcoverplatedowncliptrans[i]);
6957   /////////////////////////////////////////////////////
6958   // Placing Kapton Foil
6959   /////////////////////////////////////////////////////
6960   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6961                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6962                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6963   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6964                                                                                                 endcapkaptonfoilshape,
6965                                                                                                 fSSDKaptonFlexMedium);
6966   endcapkaptonfoil->SetLineColor(8);
6967   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6968                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6969                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6970                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6971                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6972                                                                              -                     fgkEndCapSideCoverWidth[1]
6973                                                                                  -                     fgkEndCapSideCoverThickness);
6974   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6975   /////////////////////////////////////////////////////////////
6976   // Placing Electronic Tubes
6977   /////////////////////////////////////////////////////////////
6978   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6979                                                                              - fgkEndCapInterfaceCardBThickness
6980                                                                              - 9.*fgkEndCapStripConnectionThickness
6981                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6982                                                                                fgkEndCapKaptonFoilWidth
6983                                                                              - fgkEndCapInterfaceCardBThickness
6984                                                                              - 9.*fgkEndCapStripConnectionThickness
6985                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6986                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6987   TGeoVolume* endcapeffectivecables[2];
6988   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6989                                                                                          fgkEndCapEffectiveCableRadiusMax,
6990                                                                                          endcapeffectivecableswidth[0],
6991                                                                                          10,"EndCapEffectiveCables1"); 
6992   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6993                                                                                          fgkEndCapEffectiveCableRadiusMax,
6994                                                                                          endcapeffectivecableswidth[1],
6995                                                                                          25,"EndCapEffectiveCables2"); 
6996   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6997   TGeoTranslation* endcapeffectivecablestrans[2];
6998   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6999                                           -                                                        0.5*endcapeffectivecableswidth[0]
7000                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
7001                                           -                                                               fgkEndCapCoverPlateWidth[2]
7002                                           -                                             (kendcapcoverplatesmallholenumber-1)
7003                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7004                                           +                                             fgkEndCapSideCoverLength[2],
7005                                           -                     0.5*fgkEndCapCoverPlateThickness
7006                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
7007                                           -                                              fgkEndCapInterfaceCardBWidth[0]
7008                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
7009   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
7010                                           -                                                        0.5*endcapeffectivecableswidth[1]
7011                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
7012                                           -                                                               fgkEndCapCoverPlateWidth[2]
7013                                           -                                             (kendcapcoverplatesmallholenumber-1)
7014                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7015                                           +                                         fgkEndCapSideCoverLength[2],
7016                                           -                     0.5*fgkEndCapCoverPlateThickness
7017                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
7018                                           -                                              fgkEndCapInterfaceCardBWidth[0])
7019                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
7020   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
7021   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
7022   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
7023                                                                                                                    *endcapeffectivecablesrot);
7024   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
7025                                                                                                                    *endcapeffectivecablesrot);
7026 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
7027 //                                                                                                        endcapeffectivecablescombitrans[0]);
7028   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
7029                                                                                                           endcapeffectivecablescombitrans[1]);
7030   /////////////////////////////////////////////////////////////
7031   // Placing End Cap Cards
7032   /////////////////////////////////////////////////////////////
7033   TGeoVolume** endcapcards = GetEndCapCards();
7034   TGeoRotation* endcapcardsrot[2];
7035   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
7036   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
7037   TGeoTranslation* endcapcardstrans[2]; 
7038   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
7039                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
7040   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
7041   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
7042   TGeoHMatrix* endcapcardsmatrix[2];
7043   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
7044   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
7045                                                   - fgkEndCapCardJMDConnectorLength[0]
7046                                                   - fgkEndCapInterfaceCardBThickness
7047                                                   - 9.*fgkEndCapStripConnectionThickness
7048                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
7049   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
7050                                           -                                             fgkEndCapCoverPlateLength[0]
7051                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
7052                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
7053                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
7054                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
7055                                           -                                                               fgkEndCapInterfaceCardBThickness
7056                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
7057                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
7058                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
7059                                           -                                                               fgkEndCapCoverPlateWidth[2]
7060                                           -                                             (kendcapcoverplatesmallholenumber-1)
7061                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
7062                                           +                     fgkEndCapKaptonFoilWidth,
7063                                                                                           0.5*fgkEndCapCoverPlateThickness
7064                                           -                                                     fgkEndCapSideCoverWidth[1]);
7065   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
7066   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
7067    /////////////////////////////////////////////////////////////
7068   // Deallocating memory
7069   /////////////////////////////////////////////////////////////
7070   delete endcapcoverplaterot;
7071   delete endcapcoverplatecombitrans;
7072   delete endcapcoverplatetrans;
7073   for(Int_t i=0; i<3; i++){
7074    delete endcapsidecovercombitrans[i];
7075    if(i<2) delete endcapsidecoverot[i]; 
7076   }
7077   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
7078   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
7079   delete endcapcardsmatrix[0];
7080   return endcapassembly;
7081  } 
7082  ////////////////////////////////////////////////////////////////////////////////
7083  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
7084                                                                                                                         Double_t radiusmax, 
7085                                                                                                                         Double_t width, 
7086                                                                                                                         Int_t ncables,
7087                                                                                                                         const char* volname){
7088   /////////////////////////////////////////////////////////////
7089   // Generating EndCap High Voltage Tubes 
7090   /////////////////////////////////////////////////////////////
7091   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
7092   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
7093
7094   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
7095   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
7096                                                                                                    effectiveouteradius,0.5*width);
7097   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
7098                                                                                                 effectiveinnertubeshape,
7099                                                                                                 fSSDStiffenerConnectorMedium);
7100   effectiveinnertube->SetLineColor(41);
7101   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
7102                                                                                                 effectiveoutertubeshape,
7103                                                                                                 fSSDKaptonChipCableMedium);
7104   effectiveoutertube->SetLineColor(39);
7105   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
7106   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
7107   effectivemothertube->AddNode(effectiveinnertube,1);
7108   effectivemothertube->AddNode(effectiveoutertube,1);
7109   return effectivemothertube;
7110  } 
7111  ////////////////////////////////////////////////////////////////////////////////
7112  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
7113   /////////////////////////////////////////////////////////////
7114   // Generating EndCap Support Layer 5 and Layer 6 
7115   /////////////////////////////////////////////////////////////
7116   const Int_t knedges = 5;
7117   ///////////////////////////////////////////////
7118   // Setting the vertices for TGeoXtru Up Volume
7119   ///////////////////////////////////////////////
7120   const Int_t klayernumber = 2;
7121   Double_t xupvertex[klayernumber][knedges+3];
7122   Double_t yupvertex[klayernumber][knedges+3];
7123   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
7124   Double_t middledgeangle[klayernumber] = {0.0,0.0};
7125   Double_t middlepsi[klayernumber] = {0.0,0.0};
7126   for(Int_t i=0; i<klayernumber; i++){
7127         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
7128         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
7129         xupvertex[i][2] = -xupvertex[i][1];
7130         xupvertex[i][3] = -xupvertex[i][0];
7131
7132         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
7133         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
7134         yupvertex[i][2] =  yupvertex[i][1];
7135         yupvertex[i][3] =  yupvertex[i][0];
7136         
7137     middledgeangle[i] = upedgeangle[i]/knedges;
7138     middlepsi[i] = 90.0-0.5*upedgeangle[i];
7139     for(Int_t j=1; j<knedges; j++){
7140                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
7141                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
7142         }
7143   }
7144   ////////////////////////////////////
7145   // Generating Up TGeoXtru
7146   ////////////////////////////////////
7147   TGeoXtru* upendcapsupportshape[klayernumber];
7148   TGeoVolume* upendcapsupport[klayernumber]; 
7149   char upendcapsupportname[100]; 
7150   for(Int_t i=0; i<klayernumber; i++){
7151    upendcapsupportshape[i] = new TGeoXtru(2);
7152    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
7153    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
7154    upendcapsupportshape[i]->DefineSection(0,0.);
7155    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7156    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
7157                                                                         fSSDSupportRingAl);
7158    upendcapsupport[i]->SetLineColor(5);
7159   }
7160   ///////////////////////////////////////////////
7161   // Setting the vertices for TGeoXtru Down Volume
7162   ///////////////////////////////////////////////
7163   Double_t xdownvertex[klayernumber][2*(knedges+1)];
7164   Double_t ydownvertex[klayernumber][2*(knedges+1)];
7165   for(Int_t i=0; i<klayernumber; i++){
7166         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
7167         xdownvertex[i][1] =  xupvertex[i][0];
7168         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
7169         ydownvertex[i][1] =  yupvertex[i][0];
7170         for(Int_t j=0; j<knedges; j++){
7171                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
7172                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
7173         } 
7174         for(Int_t j=0; j<knedges; j++){
7175                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7176                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
7177                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
7178                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
7179         }
7180   }
7181   ////////////////////////////////////
7182   // Generating Down TGeoXtru
7183   ////////////////////////////////////  
7184   TGeoXtru* downendcapsupportshape[klayernumber];
7185   TGeoVolume* downendcapsupport[klayernumber]; 
7186   char downendcapsupportname[100]; 
7187   for(Int_t i=0; i<klayernumber; i++){
7188         downendcapsupportshape[i] = new TGeoXtru(2);
7189     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
7190         downendcapsupportshape[i] = new TGeoXtru(2);
7191         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
7192     if(i==0){
7193                 downendcapsupportshape[i]->DefineSection(0,0.);
7194                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
7195     }
7196         else{
7197                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
7198                                                                  -                 fgkEndCapSupportLowWidth[i]);
7199                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
7200         }
7201     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
7202                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
7203         downendcapsupport[i]->SetLineColor(5);
7204   }
7205   ///////////////////////////////////////////////
7206   // Setting TGeoPgon Volume
7207   ///////////////////////////////////////////////
7208   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7209                                                                                                    fgkSSDLay6LadderNumber};
7210   TGeoPgon* endcapsupportmothershape[klayernumber];
7211   TGeoVolume** endcapsupportmother;
7212   endcapsupportmother = new TGeoVolume*[klayernumber];
7213   char endcapsupportmothername[100];
7214   for(Int_t i=0; i<klayernumber; i++){
7215         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7216     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
7217         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
7218     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
7219                                                                                           ydownvertex[i][0],yupvertex[i][1]);
7220     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
7221                                                                                         fSSDAir);       
7222   }
7223   ////////////////////////////////////
7224   TGeoRotation** endcapsupportrot[klayernumber];
7225   for(Int_t i=0; i<2; i++){
7226         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
7227         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7228            endcapsupportrot[i][j] = new TGeoRotation();
7229            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
7230        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
7231        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
7232         }
7233   }
7234   return endcapsupportmother;
7235  } 
7236  ////////////////////////////////////////////////////////////////////////////////
7237  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
7238   /////////////////////////////////////////////////////////////
7239   // Setting End Cap Support Layer 5 and 6. 
7240   /////////////////////////////////////////////////////////////
7241   const Int_t kendcapcoverplatesmallholenumber = 9;
7242   const Int_t klayernumber = 2;
7243   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
7244                                                                                                    fgkSSDLay6LadderNumber};
7245   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
7246                                                                                 360.0/kssdlayladdernumber[1]};
7247   TGeoVolume** endcapsupport = EndCapSupport();
7248   TGeoVolume** endcapassembly = GetEndCapAssembly();
7249   TGeoPgon* endcapsupportshape[klayernumber];
7250   Double_t* radiusmin[klayernumber];
7251   Double_t* radiusmax[klayernumber];
7252   for(Int_t i=0; i<klayernumber; i++){
7253     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
7254         radiusmin[i] = endcapsupportshape[i]->GetRmin();
7255         radiusmax[i] = endcapsupportshape[i]->GetRmax();
7256   }  
7257   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
7258   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
7259                                                                           endcapassemblyshape->GetDY(),
7260                                                                           endcapassemblyshape->GetDZ()};
7261   ///////////////////////////////////////////////
7262   // Setting TGeoPgon Volume for Mother Container
7263   ///////////////////////////////////////////////
7264   TGeoPgon* endcapsupportsystemshape[klayernumber];
7265   char endcapsupportsystemothername[100];
7266   for(Int_t i=0; i<klayernumber; i++){
7267         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
7268     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
7269         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
7270                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
7271                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7272                                                                                            +2.*endcapassemblycenter[2])
7273                                                                                            /CosD(0.5*upedgeangle[i]));  
7274     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
7275                                                                                                  -(fgkEndCapCoverPlateWidth[1]
7276                                                                                              - fgkEndCapCoverPlateWidth[0]),
7277                                                                                            *radiusmin[i],
7278                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
7279                                                                                            +2.*endcapassemblycenter[2])
7280                                                                                            /CosD(0.5*upedgeangle[i]));
7281   }
7282   fgkEndCapSupportSystem = new TGeoVolume*[4];
7283   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
7284                                                                           endcapsupportsystemshape[0],fSSDAir); 
7285   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
7286                                                                           endcapsupportsystemshape[0],fSSDAir); 
7287   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
7288                                                                           endcapsupportsystemshape[1],fSSDAir); 
7289   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
7290                                                                           endcapsupportsystemshape[1],fSSDAir); 
7291   ///////////////////////////////////////////////
7292   TGeoTranslation* endcapassemblytrans[klayernumber];
7293   for(Int_t i=0; i<klayernumber; i++)
7294         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
7295                                                                            -  fgkEndCapSideCoverThickness
7296                                                                            +  endcapassemblycenter[0],
7297                                                                            -  0.5*fgkEndCapCoverPlateThickness
7298                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
7299                                                                            +  2.0*endcapassemblycenter[2]
7300                                                                            +  0.5*fgkEndCapSupportLength[i]
7301                                                                            /  TanD(0.5*upedgeangle[i]),
7302                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
7303                                                                            -  fgkEndCapCoverPlateWidth[2]
7304                                                                            - (kendcapcoverplatesmallholenumber-1)
7305                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
7306   TGeoRotation** endcapassemblyrot[klayernumber];
7307   TGeoHMatrix** endcapassemblymatrix[klayernumber];
7308   for(Int_t i=0; i<klayernumber; i++){
7309    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
7310    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
7311    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
7312    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
7313    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
7314    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
7315    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
7316    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
7317         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
7318         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
7319    }
7320   }
7321   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
7322                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
7323   for(Int_t i=0; i<2*klayernumber; i++){
7324         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
7325                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
7326                                                                                                                                            endcapassemblymatrix[1][j+2]);
7327         }
7328         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
7329   }
7330    /////////////////////////////////////////////////////////////
7331   // Deallocating memory
7332   /////////////////////////////////////////////////////////////
7333   for(Int_t i=0; i<klayernumber; i++){
7334         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
7335                 delete endcapassemblyrot[i][j];
7336         }
7337         delete endcapassemblyrot[i];
7338         delete endcapassemblymatrix[i][0];
7339         delete endcapassemblymatrix[i][1];
7340   }
7341   /////////////////////////////////////////////////////////////
7342   }
7343   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7344   /////////////////////////////////////////////////////////////
7345   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7346   /////////////////////////////////////////////////////////////
7347   if (! moth) {
7348     AliError("Can't insert end cap support of layer5, mother is null!\n");
7349     return;
7350   };
7351   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7352   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7353   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7354                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7355                                                                            +            fgkEndCapSupportCenterLay5Position
7356                                                                            -            fgkEndCapSideCoverLength[2]);
7357   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7358                                                                                                 fgkEndCapSideCoverLength[2]
7359                                                                            -        fgkEndCapSupportCenterLay5Position
7360                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7361   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7362   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7363   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7364         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7365   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7366   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7367    /////////////////////////////////////////////////////////////
7368   // Deallocating memory
7369   /////////////////////////////////////////////////////////////
7370   delete endcapsupportsystemrot;
7371   delete endcapsupportsystemITSCentertrans[1];
7372  }
7373   /////////////////////////////////////////////////////////////
7374   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7375   /////////////////////////////////////////////////////////////
7376   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7377   /////////////////////////////////////////////////////////////
7378   if (! moth) {
7379     AliError("Can't insert end cap support of layer6, mother is null!\n");
7380     return;
7381   };
7382   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7383   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7384   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7385                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7386                                                                            +            fgkEndCapSupportCenterLay6Position
7387                                                                            -            fgkEndCapSideCoverLength[2]);
7388   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7389                                                                                                 fgkEndCapSideCoverLength[2]
7390                                                                            -        fgkEndCapSupportCenterLay6Position
7391                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7392   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7393   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7394   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7395         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7396   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7397   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7398    /////////////////////////////////////////////////////////////
7399   // Deallocating memory
7400   /////////////////////////////////////////////////////////////
7401   delete endcapsupportsystemrot;
7402   delete endcapsupportsystemITSCentertrans[1];
7403  }
7404  ////////////////////////////////////////////////////////////////////////////////
7405  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7406   /////////////////////////////////////////////////////////////
7407   // Setting Ladder Support of Layer 5. 
7408   /////////////////////////////////////////////////////////////
7409   if (! moth) {
7410     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7411     return;
7412   };
7413   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7414   fMotherVol = moth;
7415   TGeoTranslation* centerITSRingSupportLay5trans[2];
7416   for(Int_t i=0; i<2; i++){
7417         centerITSRingSupportLay5trans[i] = 
7418                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7419     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7420   }
7421  }
7422  ////////////////////////////////////////////////////////////////////////////////
7423  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7424   /////////////////////////////////////////////////////////////
7425   // Setting Ladder Support of Layer 6. 
7426   /////////////////////////////////////////////////////////////
7427   if (! moth) {
7428     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7429     return;
7430   };
7431   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7432   fMotherVol = moth;
7433   TGeoTranslation* centerITSRingSupportLay6trans[2];
7434   for(Int_t i=0; i<2; i++){
7435         centerITSRingSupportLay6trans[i] = 
7436                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7437     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7438   }
7439  }
7440  ////////////////////////////////////////////////////////////////////////////////
7441  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7442   /////////////////////////////////////////////////////////////
7443   // Setting Ladder Support of Layer 6. 
7444   /////////////////////////////////////////////////////////////
7445   if (! moth) {
7446     AliError("Can't insert SSD Cone, mother is null!\n");
7447     return;
7448   };
7449   if(!fSSDCone) SetSSDCone();
7450   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7451                                                                 +                                         fgkSSDCentralAL3SupportLength);
7452     moth->AddNode(fSSDCone,1,ssdconetrans);
7453 }
7454  ////////////////////////////////////////////////////////////////////////////////
7455  void AliITSv11GeometrySSD::SetSSDCone(){
7456   /////////////////////////////////////////////////////////////
7457   // Method generating SSDCone 
7458   /////////////////////////////////////////////////////////////
7459   if(!fCreateMaterials) CreateMaterials();
7460   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7461   Double_t ssdpconesectionradiusmax[16];
7462   Double_t ssdpconesectionradiusmin[16];
7463   Double_t ssdpconezsection[16];
7464   TGeoPcon* ssdpconelittleholeshape[8];
7465   TGeoVolume* ssdpconelittlehole[8];
7466   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7467   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7468   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7469                                                       / SinD(fgkSSDPConeAngle)
7470                                                           + ssdpconesectionradiusmin[0];
7471   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7472                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7473                                                           / SinD(fgkSSDPConeAngle);
7474   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7475   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7476                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7477   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7478   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7479                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7480   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7481   ssdpconelittlehole[0]->SetLineColor(4);
7482   /////////////////////////////////////////////////////////////
7483   ssdpconezsection[2] = ssdpconezsection[1];  
7484   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7485   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7486   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7487                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7488                                                           / SinD(fgkSSDPConeAngle);
7489   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7490                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7491   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7492                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7493   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7494                                                                    * TMath::RadToDeg();
7495   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7496                                                                                                           60.-ssdpconelittleholeangle,2);    
7497   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7498                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7499   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7500   ssdpconelittlehole[1]->SetLineColor(4);
7501   TGeoRotation* ssdconelittleholerot[6];
7502   for(Int_t i=0; i<6; i++){
7503         ssdconelittleholerot[i] = new TGeoRotation();
7504     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7505   }
7506   /////////////////////////////////////////////////////////////
7507   ssdpconezsection[4] = ssdpconezsection[3];  
7508   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7509   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7510   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7511                                                           * CosD(fgkSSDPConeAngle)
7512                                                           / SinD(fgkSSDPConeAngle);
7513   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7514   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7515                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7516   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7517   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7518                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7519   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7520   ssdpconelittlehole[2]->SetLineColor(4);
7521   ///////////////////////////////////////////////////
7522   ssdpconezsection[6] = ssdpconezsection[5];  
7523   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7524   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7525   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7526                                                           -ssdpconezsection[0]
7527                                                           * CosD(fgkSSDPConeAngle)
7528                                                           / SinD(fgkSSDPConeAngle);
7529   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7530   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7531                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7532   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7533                                                                    * TMath::RadToDeg();
7534   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7535                                                                                                           45.-ssdpconemiddleholeangle,2);    
7536   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7537                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7538   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7539   ssdpconelittlehole[3]->SetLineColor(4);
7540   TGeoRotation* ssdconemiddleholerot[8];
7541   for(Int_t i=0; i<8; i++){
7542         ssdconemiddleholerot[i] = new TGeoRotation();
7543     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7544   }
7545   /////////////////////////////////////////////////////////////
7546   ssdpconezsection[8] = ssdpconezsection[7];  
7547   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7548   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7549   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7550                                                           * CosD(fgkSSDPConeAngle)
7551                                                           / SinD(fgkSSDPConeAngle);
7552   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7553   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7554                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7555   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7556   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7557                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7558   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7559   ssdpconelittlehole[4]->SetLineColor(4);
7560   /////////////////////////////////////////////////////////////
7561   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7562   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7563                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7564                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7565                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7566                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7567   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7568   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7569                                                                                  * TMath::RadToDeg();
7570   ssdpconezsection[10] = ssdpconezsection[9];
7571   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7572   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7573   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7574                                                           * CosD(fgkSSDPConeAngle)
7575                                                           / SinD(fgkSSDPConeAngle);
7576   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7577   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7578                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7579   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7580                                                                                         ssdpconetrapezoidsectionangle,2);    
7581   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7582                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7583   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7584   ssdpconelittlehole[5]->SetLineColor(4);
7585   TGeoRotation* ssdconeupradiusrot[8];
7586   for(Int_t i=0; i<8; i++){
7587         ssdconeupradiusrot[i] = new TGeoRotation();
7588     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7589   }
7590   /////////////////////////////////////////////////////////////
7591   ssdpconezsection[12] = ssdpconezsection[11];
7592   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7593   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7594   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7595   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7596   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7597   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7598   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7599                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7600   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7601   ssdpconelittlehole[6]->SetLineColor(4);
7602   /////////////////////////////////////////////////////////////
7603   ssdpconezsection[14] = 0.0;
7604   ssdpconezsection[15] = ssdpconezsection[0];
7605   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7606   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7607   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7608   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7609   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7610   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7611                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7612   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7613   ssdpconelittlehole[7]->SetLineColor(4);
7614   /////////////////////////////////////////////////////////////
7615   TGeoTube* ssdtubeconeshape[2];
7616   TGeoVolume* ssdtubecone[2];
7617   TGeoTranslation* ssdtubeconetrans[2];
7618   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7619                                                                            fgkSSDPConeExternalRadius,
7620                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7621   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7622                                                                            0.5*ssdpconezsection[0]); 
7623   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7624   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7625   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7626                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7627                                           + ssdpconezsection[13]);
7628   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7629   ssdtubecone[0]->SetLineColor(4);
7630   ssdtubecone[1]->SetLineColor(4);
7631   /////////////////////////////////////////////////////////////
7632   // Mother Volume Container
7633   /////////////////////////////////////////////////////////////
7634   Double_t ssdconemotherradiusmin[8];
7635   Double_t ssdconemotherradiusmax[8];
7636   Double_t ssdconemothersection[8]; 
7637   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7638   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7639   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7640   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7641   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7642   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7643   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7644   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7645   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7646   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7647   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7648   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7649   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7650   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7651   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7652   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7653   ssdconemothersection[0] = 0.0;
7654   ssdconemothersection[1] = ssdpconezsection[0];
7655   ssdconemothersection[2] = ssdpconezsection[0];
7656   ssdconemothersection[3] = ssdpconezsection[11];
7657   ssdconemothersection[4] = ssdpconezsection[11];
7658   ssdconemothersection[5] = ssdpconezsection[13];
7659   ssdconemothersection[6] = ssdpconezsection[13];
7660   ssdconemothersection[7] = fgkSSDPConeLength;
7661   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7662   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7663                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7664   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7665   /////////////////////////////////////////////////////////////
7666   //Placing the Volumes into Mother 
7667   /////////////////////////////////////////////////////////////
7668   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7669   for(Int_t i=0; i<6; i++){
7670         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7671   }
7672   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7673   for(Int_t i=0; i<8; i++){
7674     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7675   }
7676   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7677   for(Int_t i=0; i<8; i++){
7678     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7679   }
7680   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7681   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7682   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7683   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7684   /////////////////////////////////////////////////////////////
7685   // ITS General Support
7686   /////////////////////////////////////////////////////////////
7687   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7688                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7689   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7690   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7691                                                                              - fgkSSDCentralAL3SupportLength);
7692   ssdcentralsupport->SetLineColor(4);
7693   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7694   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7695                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7696   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7697   TGeoTranslation* ssdcentralal3supportrans[3]; 
7698   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7699   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7700                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7701   ssdcentralal3support->SetLineColor(4);
7702   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7703   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7704   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7705   Double_t ssdpconcentralradiusmin[2];
7706   Double_t ssdpconcentralradiusmax[2];
7707   Double_t ssdpconcentralsection[2];
7708   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7709   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7710   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7711   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7712   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7713   ssdpconcentralsection[1] = 0.;
7714   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7715                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7716   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7717   ssdpconcentralal3->SetLineColor(4);
7718   fSSDCone->AddNode(ssdpconcentralal3,1);
7719   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7720   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7721   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7722                                                                 -2.*fgkSSDCentralAL3SupportLength);
7723   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7724                                                                                                                      *ssdcentralal3supportrot);
7725   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7726   TGeoRotation* ssdconemotherot = new TGeoRotation();
7727   ssdconemotherot->SetAngles(90.,180.,-90.);
7728   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7729                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7730   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7731   fSSDCone->AddNode(ssdconemother,1);
7732   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7733   /////////////////////////////////////////////////////////////
7734   // Deallocating memory
7735   /////////////////////////////////////////////////////////////
7736   delete ssdcentralal3supportrot;
7737   delete ssdcentralal3supportrans[2];
7738   delete ssdconemotherot;
7739   delete ssdconemothertrans;
7740   /////////////////////////////////////////////////////////////
7741  }
7742  ////////////////////////////////////////////////////////////////////////////////
7743  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7744   /////////////////////////////////////////////////////////////
7745   // Setting SSD Cables
7746   /////////////////////////////////////////////////////////////
7747   if (! moth) {
7748     AliError("Can't insert SSD Cables, mother is null!\n");
7749     return;
7750   };
7751   TGeoVolume* ssdcables = SetSSDCables();
7752   moth->AddNode(ssdcables,1);
7753 }
7754  ////////////////////////////////////////////////////////////////////////////////
7755  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7756   /////////////////////////////////////////////////////////////
7757   // Method generating SSDCables
7758   /////////////////////////////////////////////////////////////
7759   // SSD Layer 5 Cables
7760   //////////////////////////////////////////////////////////////////////////////////////////////////
7761   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7762   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7763   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7764   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7765   //////////////////////////////////////////////////////////////////////////////////////////////////
7766   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7767   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7768                                                                             -  fgkSSDLowerPConeRadius)
7769                                                                             * TanD(fgkSSDPConeAngle);
7770   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7771                                                                               + fgkEndCapSupportCenterLay5Position
7772                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7773   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7774                                                                            - ssdcableslay5startconedistance; 
7775   ssdcablelay5rightsidelength *= ssdcablesfactor;
7776   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7777   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7778                                                                                                 ssdcableslay5rightsideradiusmax,
7779                                                                                                 0.5*ssdcablelay5rightsidelength); 
7780   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7781                                                                                                          ssdcablelay5rightubeshape,
7782                                                                                                          fSSDCopper);
7783   ssdcablelay5righttube->SetLineColor(9);
7784   TGeoTranslation* ssdcablelay5rightrans = 
7785                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7786                                                                                  +              fgkEndCapSupportCenterLay5Position
7787                                                                                  +      0.5*ssdcablelay5rightsidelength);
7788   ////////////////////////////////////
7789   //  Double_t cablescapacity[20];
7790   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7791   ////////////////////////////////////
7792   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7793   ////////////////////////////////////
7794   // TGeoPCone Volumes
7795   ///////////////////////////////////
7796   TGeoPcon* ssdcableslay5pconshape[3];
7797   TGeoVolume* ssdcableslay5pcon[3]; 
7798   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7799   Double_t ssdcableslay5pconzsection[6];
7800   Double_t ssdcableslay5pconrmin[6];
7801   Double_t ssdcableslay5pconrmax[6];
7802   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7803   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7804   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7805   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7806   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7807                                                            + fgkEndCapSupportCenterLay5Position
7808                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7809   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7810                                                            + fgkSSDCentralAL3SupportLength
7811                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7812                                                            * TanD(fgkSSDPConeAngle);      
7813   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7814                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7815   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7816                                                            ssdcableslay5pconshape[0],fSSDCopper);
7817   ssdcableslay5pcon[0]->SetLineColor(9);
7818   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7819 ////////////////////////////////////
7820 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7821 ////////////////////////////////////
7822   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7823   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7824                                                            + fgkSSDCentralAL3SupportLength
7825                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7826                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7827   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7828                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7829                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7830   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7831                                                                                    ssdcableangle,2);   
7832   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7833   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7834   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7835                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7836   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7837   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7838   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7839                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7840   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7841   ssdcableslay5pcon[1]->SetLineColor(9);
7842   ////////////////////////////////////
7843   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7844                                                                                    ssdcableangle,2);   
7845   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7846   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7847   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7848   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7849   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7850   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7851                                                            * TanD(fgkSSDPConeAngle)
7852                                                            + 0.5*fgkSSDCentralSupportLength
7853                                                            + fgkSSDCentralAL3SupportLength;
7854   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7855   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7856                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7857   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7858   ssdcableslay5pcon[2]->SetLineColor(9);
7859 ////////////////////////////////////
7860   TGeoRotation* ssdcableslay5pconrot[4];        
7861   for(Int_t i=0; i<4; i++){
7862    ssdcableslay5pconrot[i] = new TGeoRotation();
7863    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7864    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7865    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7866   }
7867   ////////////////////////////////////
7868   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7869   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7870   ////////////////////////////////////
7871   // Positioning Left SSD Cables Part
7872   ////////////////////////////////////
7873   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7874                                                                                                         - 0.5*ssdcablelay5rightsidelength
7875                                                                                                         - fgkEndCapSupportCenterLay5Position
7876                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7877   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7878   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7879   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7880   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7881   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7882   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7883         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7884         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7885     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7886   }
7887   ////////////////////////////////////
7888   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7889   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7890   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7891   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7892   /////////////////////////////////////////////////////////////
7893   // Water Tubes Layer 5
7894   /////////////////////////
7895   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7896                                                                                      ssdcableslay5rightsideradiusmax
7897                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7898                                                                                      0.5*ssdcablelay5rightsidelength); 
7899   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7900                                                                                                          ssdcablelay5rightubewatershape,
7901                                                                                                          fSSDCoolingTubeWater);
7902   ssdcablelay5rightwatertube->SetLineColor(7);
7903   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7904   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7905   ////////////////////////////////////
7906   // TGeoPCone Water Volumes Layer 
7907   ///////////////////////////////////
7908   TGeoPcon* ssdcableslay5pconwatershape[3];
7909   TGeoVolume* ssdcableslay5pconwater[3]; 
7910   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7911   Double_t ssdcableslay5pconwaterzsection[6];
7912   Double_t ssdcableslay5pcwateronrmin[6];
7913   Double_t ssdcableslay5pconwaterrmax[6];
7914   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7915   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7916                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7917   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7918   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7919                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7920   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7921   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7922   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7923                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7924   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7925                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7926   ssdcableslay5pconwater[0]->SetLineColor(7);
7927   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7928   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7929 ////////////////////////////////////
7930   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7931   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7932   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7933                                                                                                 ssdcableangle,2);   
7934   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7935   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7936                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7937   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7938   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7939                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7940   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7941                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7942   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7943                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7944   ssdcableslay5pconwater[1]->SetLineColor(7);
7945 ////////////////////////////////////
7946   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7947                                                                                                 ssdcableangle,2);   
7948   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7949   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7950                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7951   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7952   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7953                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7954   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7955   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7956   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7957                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7958   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7959                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7960   ssdcableslay5pconwater[2]->SetLineColor(7);
7961 ////////////////////////////////////
7962   TGeoRotation* ssdcableslay5pconwaterot[4];    
7963   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7964   for(Int_t i=0; i<4; i++){
7965    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7966    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7967    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7968         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7969         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7970         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7971         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7972         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7973   }
7974   /////////////////////////
7975   // SSD Layer 6 Cables
7976   /////////////////////////
7977   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7978   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7979   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7980   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7981                                                                                                 ssdcableslay6rightsideradiusmax,
7982                                                                                                 0.5*ssdcablelay6rightsidelength); 
7983   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7984                                                                                                          ssdcablelay6rightubeshape,
7985                                                                                                          fSSDCopper);
7986   ssdcablelay6righttube->SetLineColor(9);
7987   TGeoTranslation* ssdcablelay6rightrans = 
7988                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7989                                                                                  +              fgkEndCapSupportCenterLay6Position
7990                                                                                  +      0.5*ssdcablelay6rightsidelength);
7991   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7992                                                                                                         - 0.5*ssdcablelay6rightsidelength
7993                                                                                                         - fgkEndCapSupportCenterLay6Position
7994                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7995   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7996   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7997   ////////////////////////////////////
7998   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7999   ////////////////////////////////////
8000   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
8001                                                                                    ssdcableangle,2);   
8002   TGeoVolume* ssdcableslay6pcon;
8003   Double_t ssdcableslay6pconrmin[2];
8004   Double_t ssdcableslay6pconrmax[2];
8005   Double_t ssdcableslay6pconzsection[2];
8006   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
8007   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
8008   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
8009   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
8010   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8011                                                            + fgkEndCapSupportCenterLay6Position
8012                                                            + ssdcablelay6rightsidelength;
8013   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
8014   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
8015                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
8016   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
8017                                                            ssdcableslay6pconshape,fSSDCopper);
8018   ssdcableslay6pcon->SetLineColor(9);
8019   for(Int_t i=0; i<4; i++){
8020    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
8021    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8022   }
8023   ////////////////////////////////////
8024   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
8025   /////////////////////////
8026   // Water Tubes Layer 6
8027   /////////////////////////
8028   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
8029                                                                                                                   ssdcableslay6rightsideradiusmax
8030                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
8031                                                                                                                   0.5*ssdcablelay6rightsidelength); 
8032   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
8033                                                                                                          ssdcablelay6righwatertubeshape,
8034                                                                                                          fSSDCoolingTubeWater);
8035   ssdcablelay6rightwatertube->SetLineColor(7);
8036   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
8037   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
8038   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
8039                                                                                    ssdcableangle,2);   
8040   TGeoVolume* ssdcableslay6waterpcon;
8041   Double_t ssdcableslay6waterpconrmin[2];
8042   Double_t ssdcableslay6waterpconrmax[2];
8043   Double_t ssdcableslay6waterpconzsection[2];
8044   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
8045   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
8046                                                             + fgkSSDCablesLay5RightSideWaterHeight;
8047   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
8048   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
8049   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8050                                                            + fgkEndCapSupportCenterLay6Position
8051                                                            + ssdcablelay6rightsidelength;
8052   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8053   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
8054                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
8055   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
8056                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
8057   ssdcableslay6waterpcon->SetLineColor(7);
8058   TGeoRotation* ssdcableslay6pconwaterot[4];    
8059   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
8060   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
8061   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
8062   for(Int_t i=0; i<4; i++){
8063    ssdcableslay6pconwaterot[i] = new TGeoRotation();
8064    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
8065    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
8066                                                                                  * (*ssdcableslay6pconwaterot[i]));   
8067    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
8068    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
8069   }
8070   ////////////////////////////////////////
8071   // From ITS Ring to Patch Panel3-RB26
8072   ////////////////////////////////////////
8073   Double_t ssdcablepatchpanel3BB26radiusmin[2];
8074   Double_t ssdcablepatchpanel3BB26radiusmax[2];
8075   Double_t ssdcablepatchpanel3RB26zsection[2];
8076   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeigth+2.8;
8077   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
8078                                                                           + fgkSSDCablesLay5RightSideHeight
8079                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8080   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
8081   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
8082                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8083                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8084   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
8085                                                                                  + fgkSSDCentralAL3SupportLength
8086                                                                                  + fgkSSDPConeZLength[0];
8087   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
8088   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
8089                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8090                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8091   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
8092                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
8093   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
8094                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
8095   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
8096   TGeoRotation* ssdcablepatchpanel3B26rot[3];
8097   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
8098   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
8099   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
8100                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8101   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
8102   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
8103                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
8104   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
8105   ////////////////////////////////////
8106   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
8107   ////////////////////////////////////////
8108   //  ITS Ring Cables RB26 Part
8109   ////////////////////////////////////////
8110   Double_t ssdcableitsring3BB26pconzsection[2];
8111   Double_t ssdcableitsring3BB26pconrmin[2];
8112   Double_t ssdcableitsring3BB26pconrmax[2];
8113   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
8114                                                                           + fgkSSDCentralAL3SupportLength
8115                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
8116   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
8117   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8118   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
8119                                                                   + fgkSSDCablesLay5RightSideHeight
8120                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8121   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
8122   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
8123   TGeoPcon* ssdcableitsring3BB26pconshape[4];
8124   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
8125                                                                    -              0.5*ssdcableangle,ssdcableangle
8126                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
8127                                                                    -                             fgkSSDCableAngle),2);
8128   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8129                                                                    -              0.5*ssdcableangle,ssdcableangle
8130                                                                    +                      3.0*fgkSSDCableAngle
8131                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8132   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
8133                                                                    -              0.5*ssdcableangle,ssdcableangle
8134                                                                    -                      fgkSSDCableAngle
8135                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
8136   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
8137                                                                    -              0.5*ssdcableangle,ssdcableangle
8138                                                                    +                      3.0*fgkSSDCableAngle
8139                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
8140   for(Int_t i=0;i<4;i++)
8141         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
8142                                                          ssdcableitsring3BB26pconrmin[j],
8143                                                          ssdcableitsring3BB26pconrmax[j]); 
8144   TGeoVolume* ssdcableitsring3BB26pcon[4];
8145   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
8146                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
8147   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
8148                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
8149   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
8150                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
8151   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
8152                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
8153   for(Int_t i=0;i<4;i++){
8154         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
8155         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
8156 }
8157   ////////////////////////////////////
8158   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
8159   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
8160   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
8161   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
8162   ////////////////////////////////////////
8163   // From ITS Ring to Patch Panel2-RB24
8164   ////////////////////////////////////////
8165   Double_t ssdcablepatchpanel3BB24radiusmin[2];
8166   Double_t ssdcablepatchpanel3BB24radiusmax[2];
8167   Double_t ssdcablepatchpanel3RB24zsection[2];
8168   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
8169   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
8170   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
8171   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
8172                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
8173                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
8174                                                                           + 0.5*fgkSSDPatchPanelHeigth;
8175   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
8176                                                                          -  fgkSSDCentralAL3SupportLength
8177                                                                          -  fgkSSDPConeZLength[0];
8178   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
8179   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
8180                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8181                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
8182   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
8183                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
8184   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
8185                                                                                                 ssdcablepatchpanel3RB24pconshape,
8186                                                                                                 fSSDCopper);
8187   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
8188   TGeoRotation* ssdcablepatchpanel3B24rot[3];
8189   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
8190   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
8191   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
8192                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8193   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
8194   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
8195                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
8196   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
8197   ////////////////////////////////////
8198   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
8199   ////////////////////////////////////////
8200   //  ITS Ring Cables RB24 Part
8201   ////////////////////////////////////////
8202   Double_t ssdcableitsring3BB24pconzsection[2];
8203   Double_t ssdcableitsring3BB24pconrmin[2];
8204   Double_t ssdcableitsring3BB24pconrmax[2];
8205   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
8206   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
8207   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeigth;
8208   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
8209                                                                   + fgkSSDCablesLay5RightSideHeight
8210                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeigth;
8211   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
8212   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
8213   TGeoPcon* ssdcableitsring3BB24pconshape[4];
8214   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8215                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
8216                                                                    -                             fgkSSDCableAngle),2);
8217   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
8218                                                                      ssdcableangle-fgkSSDCableAngle
8219                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8220   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
8221                                                                    -                      fgkSSDCableAngle
8222                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
8223   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
8224                                                                                                   ssdcableangle-fgkSSDCableAngle
8225                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
8226   for(Int_t i=0;i<4;i++)
8227         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
8228                                                          ssdcableitsring3BB24pconrmin[j],
8229                                                          ssdcableitsring3BB24pconrmax[j]); 
8230   TGeoVolume* ssdcableitsring3BB24pcon[4];
8231   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
8232                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
8233   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
8234                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
8235   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
8236                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
8237   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
8238                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
8239   for(Int_t i=0;i<4;i++){
8240         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
8241         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
8242 }
8243   ////////////////////////////////////
8244   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
8245   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
8246   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
8247   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
8248   ////////////////////////////////////
8249   // Volumes for Material Budget 
8250   ////////////////////////////////////
8251   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
8252                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
8253                                                                                                          ssdcableslay6rightsideradiusmax
8254                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
8255                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
8256   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
8257                                                                                                          ssdcablelay6materialbudgetubeshape,
8258                                                                                                          fSSDCopper);
8259   ssdcablelay6materialbudgetube->SetLineColor(9);
8260   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
8261   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
8262
8263   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
8264                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
8265   TGeoVolume* ssdcablelay6materialbudgetpcon;
8266   Double_t ssdcablelay6materialbudgetpconrmin[2];
8267   Double_t ssdcablelay6materialbudgetpconrmax[2];
8268   Double_t ssdcablelay6materialbudgetpconzsection[2];
8269   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
8270                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
8271   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
8272                                                                                 + fgkSSDCableMaterialBudgetHeight;
8273   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
8274   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
8275   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
8276                                                                                         + fgkEndCapSupportCenterLay6Position
8277                                                                                         + ssdcablelay6rightsidelength;
8278   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
8279   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
8280                                                   ssdcablelay6materialbudgetpconzsection[i],
8281                                                   ssdcablelay6materialbudgetpconrmin[i],
8282                                                   ssdcablelay6materialbudgetpconrmax[i]); 
8283   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
8284                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
8285   ssdcablelay6materialbudgetpcon->SetLineColor(9);
8286   for(Int_t i=0; i<4; i++){
8287    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
8288    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
8289   }
8290 ////////////////////////////////////
8291  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
8292   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
8293   Double_t ssdcablesvolume = 0.0;
8294   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
8295   std::cout << ssdcablesvolume << std::endl;*/
8296   return ssdcablesmother;
8297  }
8298  ////////////////////////////////////////////////////////////////////////////////
8299 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
8300                                             Double_t height, const char* shapename, Int_t isign) const{
8301   /////////////////////////////////////////////////////////////
8302   // Method generating an Arb shape 
8303   /////////////////////////////////////////////////////////////
8304   const Int_t kvertexnumber = 8;
8305   const Int_t ktransvectnumber = 2;
8306   TVector3 vertex[kvertexnumber];
8307   TVector3 transvector[2];
8308   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
8309   /////////////////////////////////////////////////////////////
8310   //Setting the vertices for TGeoArb8
8311   /////////////////////////////////////////////////////////////
8312   vertex[0] = *vertexpos[0];
8313   vertex[1] = *vertexpos[1];
8314   vertex[2] = vertex[1]; 
8315   vertex[3] = vertex[0]; 
8316   vertex[4] = *vertexpos[2];
8317   vertex[5] = *vertexpos[3];
8318   vertex[6] = vertex[5];
8319   vertex[7] = vertex[4];
8320
8321   // NB: order of points is clockwise
8322   if (isign < 0) {
8323     vertex[2] -= transvector[0];
8324     vertex[3] -= transvector[0];
8325     vertex[6] -= transvector[1];
8326     vertex[7] -= transvector[1];
8327   }
8328   else {
8329     vertex[0] += transvector[0];
8330     vertex[1] += transvector[0];
8331     vertex[4] += transvector[1];
8332     vertex[5] += transvector[1];
8333   }
8334
8335   /////////////////////////////////////////////////////////////
8336   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8337   for(Int_t i = 0; i<kvertexnumber;i++) {
8338     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
8339   }
8340
8341   return arbshape;
8342
8343 ///////////////////////////////////////////////////////////////////////////////
8344 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8345                                                                 Double_t rmax, Int_t nedges, Double_t height){
8346   /////////////////////////////////////////////////////////////
8347   // Method generating Arc shape 
8348   /////////////////////////////////////////////////////////////
8349         const Int_t kvertexnumber = 2*nedges+2;
8350         TGeoXtru* arcshape = new TGeoXtru(2);   
8351         TVector3** vertexposition[2];
8352         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8353         Double_t angle = 0.;
8354     for(Int_t i=0; i<nedges+1; i++){ 
8355                 angle = 90.+0.5*phi-i*(phi/nedges);
8356                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8357                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8358         }
8359         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8360         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8361         for(Int_t i=0; i<kvertexnumber; i++){ 
8362                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8363                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8364                 }
8365                 else if(i>=1&&i<nedges+2)
8366                 {
8367                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8368                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8369                 }
8370         else
8371                 {
8372                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8373                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8374                 }
8375     }
8376   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8377   arcshape->DefineSection(0,-0.5*height);
8378   arcshape->DefineSection(1,0.5*height);
8379   /////////////////////////////////////////////////////////////
8380   // Deallocating memory
8381   /////////////////////////////////////////////////////////////
8382   for(Int_t i=0; i<2; i++){
8383         for(Int_t j=0; j<nedges+1; j++)
8384                 delete vertexposition[i][j];
8385         delete [] vertexposition[i];
8386   }
8387   delete [] xvertexpoints;
8388   delete [] yvertexpoints;
8389   /////////////////////////////////////////////////////////////
8390         return arcshape;
8391 }
8392 ////////////////////////////////////////////////////////////////////////////////
8393 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8394   ///////////////////////////////////////////////////////////////////////
8395   // Method Generating the Screw Shape  
8396   // radius[0]: outer radius
8397   // radius[1]: inner radius
8398   // edgesnumber[0]: outer number of edges
8399   // edgesnumber[1]: inner number of edges
8400   // section[0]: lower section position
8401   // section[1]: higher section position
8402   ///////////////////////////////////////////////////////////////////////
8403   Double_t outradius = radius[0];
8404   Double_t inradius = radius[1];
8405   Int_t outvertexnumber = edgesnumber[0];
8406   Int_t invertexnumber = edgesnumber[1];
8407   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8408   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8409   for(Int_t i=0; i<outvertexnumber; i++){
8410         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8411         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8412   }
8413   for(Int_t i=0; i<invertexnumber; i++){
8414         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8415         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8416   }
8417   TGeoXtru* screwshapeout = new TGeoXtru(2);
8418   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8419   screwshapeout->DefineSection(0,section[0]);
8420   screwshapeout->DefineSection(1,section[1]);
8421   TGeoXtru* screwshapein = new TGeoXtru(2);
8422   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8423   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8424   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8425   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8426   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8427   
8428   delete [] xscrewvertex;
8429   delete [] yscrewvertex;
8430   return screwshape;
8431 }
8432 ////////////////////////////////////////////////////////////////////////////////
8433 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8434   ///////////////////////////////////////////////////////////////////////
8435   // Method Generating the Hole Shape  
8436   // radius of the Hole
8437   // nedges: number of edges to approximate the circle
8438   ///////////////////////////////////////////////////////////////////////
8439   Double_t* xholevertex = new Double_t[nedges];
8440   Double_t* yholevertex = new Double_t[nedges];
8441   Double_t z  = 0.5*(section[0]+section[1]);
8442   Double_t dz = 0.5*(section[1]-section[0]);
8443   TGeoTranslation *tr = 0;
8444   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8445      tr = new TGeoTranslation(0.,0.,z);
8446      tr->RegisterYourself();
8447   }   
8448   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8449   for(Int_t i=0; i<nedges; i++){
8450         xholevertex[i] = radius*CosD(i*360./nedges);
8451         yholevertex[i] = radius*SinD(i*360./nedges);
8452   }
8453   TGeoXtru* holeshapeout = new TGeoXtru(2);
8454   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8455   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8456   holeshapeout->DefineSection(1,section[1]+0.01);
8457   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8458   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8459   
8460   delete [] xholevertex;
8461   delete [] yholevertex;
8462   return holeshape;
8463 }
8464 ////////////////////////////////////////////////////////////////////////////////
8465 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8466   /////////////////////////////////////////////////////////////
8467   // Given an axis specified by param, it gives the reflection of the point
8468   // respect to the axis
8469   /////////////////////////////////////////////////////////////
8470   TVector3* n = new TVector3(param[0],param[1],param[2]);
8471   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8472   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8473   /////////////////////////////////////////////////////////////
8474   // Deallocating memory
8475   /////////////////////////////////////////////////////////////
8476   delete n;
8477   /////////////////////////////////////////////////////////////
8478   return reflectedvector;
8479 }
8480 ////////////////////////////////////////////////////////////////////////////////
8481 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8482                                                        Double_t dx,
8483                                                        Double_t dy,
8484                                                        Double_t dz) const{
8485   /////////////////////////////////////////////////////////////
8486   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8487   /////////////////////////////////////////////////////////////
8488   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8489   const Double_t *vect = hmatrix->GetTranslation();
8490   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8491   hmatrix->SetTranslation(newvect);
8492   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8493   delete hmatrix;
8494   return matrix;
8495 }
8496 ////////////////////////////////////////////////////////////////////////////////
8497 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8498   /////////////////////////////////////////////////////////////
8499   // Method returning the Medium type 
8500   /////////////////////////////////////////////////////////////
8501   char ch[100];
8502   sprintf(ch, "ITS_%s",mediumName);
8503   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8504   if (! medium)
8505     AliError(Form("medium %s not found !\n", mediumName));
8506   return medium;
8507 }
8508 ////////////////////////////////////////////////////////////////////////////////
8509 void AliITSv11GeometrySSD::CreateMaterials(){
8510 ///////////////////////////////////
8511 // This part has to be modified
8512 ///////////////////////////////////
8513   ///////////////////////////////////
8514   // Silicon for Sensor
8515   /////////////////////////////////// 
8516   fSSDSensorMedium = GetMedium("SI$");
8517   ///////////////////////////////////
8518   // Silicon Mixture for Sensor
8519   /////////////////////////////////// 
8520   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8521   fSSDChipGlueMedium = GetMedium("EPOXY$");
8522   ///////////////////////////////////
8523   // Stiffener Components Materials
8524   /////////////////////////////////// 
8525   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8526   ///////////////////////////  
8527   // Stiffener Connectors 
8528   ///////////////////////////  
8529   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8530   ////////////////////////////////  
8531   // Stiffener 0603-1812 Capacitor
8532   ////////////////////////////////  
8533   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8534   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8535   ///////////////////////////  
8536   // Stiffener Hybrid Wire 
8537   ///////////////////////////  
8538   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8539   ///////////////////////////  
8540   // Al for Cooling Block
8541   ///////////////////////////  
8542   fSSDAlCoolBlockMedium = GetMedium("AL$");
8543   //////////////////////////////////////////////////////  
8544   // Kapton and Al for Chip Cable Flex and Ladder Cables
8545   //////////////////////////////////////////////////////  
8546   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8547   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8548   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8549   fSSDAlTraceFlexMedium = GetMedium("AL$");
8550   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8551   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8552   /////////////////////////////////////////////////////////////////  
8553   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8554   //////////////////////////////////////////////////////////////////  
8555   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8556   /////////////////////////////////////////////////////////////////  
8557   // G10 for Detector Leg, TubeHolder
8558   //////////////////////////////////////////////////////////////////  
8559   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8560   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8561   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8562   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8563   /////////////////////////////////////////////////////////////////  
8564   // Water and Phynox for Cooling Tube
8565   //////////////////////////////////////////////////////////////////  
8566   fSSDCoolingTubeWater = GetMedium("WATER$");
8567   fSSDCoolingTubePhynox = GetMedium("INOX$");
8568   /////////////////////////////////////////////////////////////////////
8569   // Material for Support Rings
8570   /////////////////////////////////////////////////////////////////////
8571   fSSDSupportRingAl = GetMedium("AL$");
8572   fSSDRohaCellCone = GetMedium("ROHACELL$");
8573   /////////////////////////////////////////////////////////////////////
8574   fSSDAir = GetMedium("SDD AIR$");
8575   fSSDCopper = GetMedium("COPPER$");
8576   fCreateMaterials = kTRUE;
8577 }
8578 /////////////////////////////////////////////////////////////////////