]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySSD.cxx
Access to RecPoints done with AliITSRecPointContainer in QA classes. Update of ESD...
[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.520*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   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::fgkSSDMountingBlockScrewHoleHeight      =  
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::fgkLadderSupportHeight = 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::fgkSSDPatchPanelHeight = 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   fcoolingtube(0),
585   fendladdercoolingtubesupportmatrix(),
586   fendladdermountingblock(),
587   fendladdermountingblockclip(),
588   fSSDSensor5(),
589   fSSDSensor6(),
590   fSSDLayer5(), 
591   fSSDLayer6(),
592   fMotherVol(),
593   fLay5LadderSupportRing(),
594   fLay6LadderSupportRing(),
595   fgkEndCapSupportSystem(),
596   fSSDCone(),
597   fColorCarbonFiber(4),
598   fColorRyton(5),
599   fColorPhynox(14),
600   fColorSilicon(3),
601   fColorAl(38),
602   fColorKapton(6),
603   fColorPolyhamide(5),
604   fColorStiffener(9),
605   fColorEpoxy(30),
606   fColorWater(7),
607   fColorG10(41)
608 {
609   ////////////////////////
610   // Standard constructor
611   ////////////////////////
612 }
613 /////////////////////////////////////////////////////////////////////////////////
614 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
615   AliITSv11Geometry(s.GetDebug()),
616   fSSDChipMedium(s.fSSDChipMedium),
617   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
618   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
619   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
620   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
621   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
622   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
623   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
624   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
625   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
626   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
627   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
628   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
629   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
630   fSSDSensorMedium(s.fSSDSensorMedium),
631   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
632   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
633   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
634   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
635   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
636   fSSDSupportRingAl(s.fSSDSupportRingAl),
637   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
638   fSSDRohaCellCone(s.fSSDRohaCellCone),
639   fSSDAir(s.fSSDAir),
640   fSSDCopper(s.fSSDCopper),
641   fCreateMaterials(s.fCreateMaterials),
642   fTransformationMatrices(s.fTransformationMatrices),
643   fBasicObjects(s.fBasicObjects),
644   fcarbonfiberjunction(s.fcarbonfiberjunction),
645   fcoolingtubesupport(s.fcoolingtubesupport),
646   fhybridmatrix(s.fhybridmatrix),
647   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
648   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
649   fssdstiffenerflex(s.fssdstiffenerflex),
650   fssdendflex(s.fssdendflex),
651   fcoolingtube(s.fcoolingtube),
652   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
653   fendladdermountingblock(s.fendladdermountingblock),
654   fendladdermountingblockclip(s.fendladdermountingblockclip),
655   fSSDSensor5(s.fSSDSensor5),
656   fSSDSensor6(s.fSSDSensor6),
657   fSSDLayer5(s.fSSDLayer5),     
658   fSSDLayer6(s.fSSDLayer6),
659   fMotherVol(s.fMotherVol),
660   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
661   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
662   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
663   fSSDCone(s.fSSDCone),
664   fColorCarbonFiber(s.fColorCarbonFiber),
665   fColorRyton(s.fColorRyton),
666   fColorPhynox(s.fColorPhynox),
667   fColorSilicon(s.fColorSilicon),
668   fColorAl(s.fColorAl),
669   fColorKapton(s.fColorKapton),
670   fColorPolyhamide(s.fColorPolyhamide),
671   fColorStiffener(s.fColorStiffener),
672   fColorEpoxy(s.fColorEpoxy),
673   fColorWater(s.fColorWater),
674   fColorG10(s.fColorG10)
675 {
676   ////////////////////////
677   // Copy Constructor
678   ////////////////////////
679 }
680 /////////////////////////////////////////////////////////////////////////////////
681 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
682 operator=(const AliITSv11GeometrySSD &s){
683   ////////////////////////
684   // Assignment operator
685   ////////////////////////
686   this->~AliITSv11GeometrySSD();
687   new(this) AliITSv11GeometrySSD(s); 
688   return *this;
689 /*      
690   if(&s == this) return *this;
691   fMotherVol = s.fMotherVol;
692   return *this;
693  */
694 }
695 ///////////////////////////////////////////////////////////////////////////////
696 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
697   ///////////////////////////////////////////////////////////////////////  
698   // Method generating the trasformation matrix for the whole SSD Geometry   
699   ///////////////////////////////////////////////////////////////////////  
700   // Setting some variables for Carbon Fiber Supportmatrix creation
701   //////////////////////////////////////////////////////////////////////
702   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
703                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
704   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
705                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
706                                                                  +      fgkCarbonFiberSupportWidth);
707   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
708                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
709   TGeoRotation* carbonfiberot[3];
710   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
711   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
712   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
713   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
714   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
715                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
716                                                   -  fgkCarbonFiberTriangleLength
717                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
718   ///////////////////////////////////////////
719   //Setting Local Translations and Rotations: 
720   ///////////////////////////////////////////
721   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
722   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
723                                                                          0.5*carbonfibersupportheight,NULL);    
724   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
725                                                                          2.*symmetryplaneposition+transvector[1],
726                                                                          transvector[2], carbonfiberot[2]);
727   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
728   /////////////////////////////////////////////////////////////
729   // Carbon Fiber Support Transformations
730   /////////////////////////////////////////////////////////////
731   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
732   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
733                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
734                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
735                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
736   }             
737   /////////////////////////////////////////////////////////////
738   // Carbon Fiber Junction Transformation
739   /////////////////////////////////////////////////////////////
740   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
741   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
742   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
743   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
744   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
745         localcarbonfiberjunctionmatrix[i] = 
746                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
747         localcarbonfiberjunctionrot[i] = 
748                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
749         localcarbonfiberjunctiontrans[i] = 
750                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
751   }
752   ///////////////////////
753   // Setting Translations
754   ///////////////////////
755   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
756   localcarbonfiberjunctiontrans[1][0] = 
757                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
758   localcarbonfiberjunctiontrans[2][0] = 
759                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
760                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
761                                  fgkCarbonFiberTriangleLength
762                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
763   localcarbonfiberjunctiontrans[0][1] = 
764                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
765   localcarbonfiberjunctiontrans[1][1] = 
766                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
767   localcarbonfiberjunctiontrans[2][1] = 
768                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
769   ////////////////////
770   // Setting Rotations
771   ////////////////////
772   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
773                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
774                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
775   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
776         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
777   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
778   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
779   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
780   ////////////////////////////////////////
781   // Setting Carbon Fiber Junction matrix 
782   ////////////////////////////////////////
783   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
784                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
785                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
786                         localcarbonfiberjunctionmatrix[i][j] = 
787                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
788                                                            *localcarbonfiberjunctionrot[i][j]);
789                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
790          }
791   }
792   /////////////////////////////////////////////////////////////
793   // Carbon Fiber Lower Support Transformations
794   /////////////////////////////////////////////////////////////
795   TGeoTranslation* localcarbonfiberlowersupportrans[2];
796   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
797                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
798                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
799                                                                          0.0);
800   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
801                                                                          fgkCarbonFiberJunctionWidth
802                                                                 -    fgkCarbonFiberLowerSupportWidth
803                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
804                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
805                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
806    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
807    fcarbonfiberlowersupportrans[0] = 
808                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
809    fcarbonfiberlowersupportrans[1] = 
810                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
811   /////////////////////////////////////////////////////////////
812   // SSD Sensor Support Transformations
813   /////////////////////////////////////////////////////////////
814   const Int_t kssdsensorsupportmatrixnumber = 3;
815   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
816   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
817   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
818   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
819         localssdsensorsupportmatrix[i] = 
820                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
821         localssdsensorsupportrot[i] = 
822                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
823         localssdsensorsupportrans[i] = 
824                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
825   }
826   ///////////////////////
827   // Setting Translations
828   ///////////////////////
829   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
830                                                                           0.5*fgkSSDSensorSideSupportWidth,
831                                                                           0.0);
832   localssdsensorsupportrans[1][0] = 
833                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
834   localssdsensorsupportrans[2][0] = 
835                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
836   localssdsensorsupportrans[0][1] = 
837                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
838                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
839                                                                                 0.0);
840   localssdsensorsupportrans[1][1] = 
841                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
842                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
843                                                                     -   fgkSSDModuleSensorSupportDistance,
844                                                                                 0.0);
845   localssdsensorsupportrans[2][1] = 
846                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
847                                                                         -    fgkSSDSensorCenterSupportPosition,
848                                                                                  0.5*fgkSSDSensorCenterSupportWidth
849                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
850                                                                                  fgkSSDSensorCenterSupportThickness[0]);
851   localssdsensorsupportrans[0][2] = 
852                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
853                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
854                                                                                  fgkCarbonFiberJunctionWidth
855                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
856                                                                         +    fgkSSDSensorCenterSupportLength
857                                                                         -    fgkSSDSensorCenterSupportThickness[0])
858                                                                         -    fgkSSDSensorCenterSupportPosition,
859                                                                              0.0);
860   localssdsensorsupportrans[1][2] = 
861                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
862   localssdsensorsupportrans[2][2] = 
863                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
864   ////////////////////
865   // Setting Rotations
866   ////////////////////
867   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
868                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
869                         localssdsensorsupportrot[i][j] = new TGeoRotation();
870   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
871         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
872         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
873   }
874   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
875   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
876   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
877   ////////////////////////////////////////
878   // SSD Sensor Support matrix 
879   ////////////////////////////////////////
880   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
881                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
882                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
883                         localssdsensorsupportmatrix[i][j] = 
884                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
885                                                            *localssdsensorsupportrot[i][j]);
886                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
887          }
888   }
889   /////////////////////////////////////////////////////////////
890   // SSD Cooling Tube Support Transformations
891   /////////////////////////////////////////////////////////////
892   const Int_t kcoolingtubesupportmatrixnumber = 2;
893   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
894   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
895   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
896   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
897                                                                                                         /fgkCoolingTubeSupportRmax);
898   localcoolingtubesupportrans[0] = 
899                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
900                                                 +  2.*(fgkCoolingTubeSupportLength
901                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
902                                                 +  fgkCarbonFiberTriangleLength
903                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
904   localcoolingtubesupportrans[1] = 
905                         new TGeoTranslation(fgkCarbonFiberJunctionLength
906                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
907                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
908                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
909                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
910                     -  0.5*(fgkCarbonFiberLowerSupportWidth
911                                         +          fgkSSDSensorCenterSupportLength
912                     -      fgkSSDSensorCenterSupportThickness[0])
913                                         +  0.5*fgkSSDSensorLength,
914                                         -  0.5*fgkCoolingTubeSupportHeight);  
915   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
916   localcoolingtubesupportrot[i] = new TGeoRotation();
917   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
918   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
919   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
920         localcoolingtubesupportmatrix[i] = 
921                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
922                                                    *localcoolingtubesupportrot[i]);
923   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
924   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
925                                                                 (*localcoolingtubesupportmatrix[0]));
926   /////////////////////////////////////////////////////////////
927   // End Ladder SSD Cooling Tube Support Transformations
928   /////////////////////////////////////////////////////////////
929   TGeoTranslation** localendladdercooltubetrans[2];
930   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
931   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
932   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
933   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
934                                                                                         -          (fgkCoolingTubeSupportLength
935                                                                                         -               fgkCoolingTubeSupportRmax),
936                                                                                                         fgkEndLadderMountingBlockPosition[0]
937                                                                                         -               fgkendladdercoolingsupportdistance[0]
938                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
939                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
940   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
941                                                                                         -          (fgkCoolingTubeSupportLength
942                                                                                         -               fgkCoolingTubeSupportRmax),
943                                                                                                         fgkEndLadderMountingBlockPosition[0]
944                                                                                         +               fgkendladdercoolingsupportdistance[1]
945                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
946                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
947   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
948                                                                                         -       fgkCoolingTubeSupportRmax)
949                                                                                         +               fgkCarbonFiberTriangleLength
950                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
951                                                                                                 0.0,
952                                                                                                 0.0);
953   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
954                                                                                                         fgkendladdercoolingsupportdistance[0]
955                                                                                         +               fgkendladdercoolingsupportdistance[1],
956                                                                                                         0.0);
957   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
958   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
959                                                                                         +               fgkCarbonFiberJunctionLength
960                                                                                         -               fgkCoolingTubeSupportLength,
961                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
962                                                                                         -       0.5*fgkCoolingTubeSupportWidth
963                                                                                                    -fgkendladdercoolingsupportdistance[2],
964                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
965   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
966                                                                                         +               fgkCoolingTubeSupportLength
967                                                                                         -               fgkCoolingTubeSupportRmax
968                                                                                         -               fgkCarbonFiberJunctionLength,
969                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
970                                                                                         -       0.5*fgkCoolingTubeSupportWidth
971                                                                                         -               fgkendladdercoolingsupportdistance[2],
972                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
973   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
974   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
975   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
976   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
977   (*localcoolingtubesupportrot[1]));
978   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
979   (*localcoolingtubesupportrot[1]));
980   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
981   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
982   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
983   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
984   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
985
986   fendladdercoolingtubesupportmatrix[1][0] =    
987                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
988                                                                                    *(*localcoolingtubesupportrot[1]));
989   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
990   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
991   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
992   /////////////////////////////////////////////////////////////
993   // SSD Cooling Tube Transformations
994   /////////////////////////////////////////////////////////////
995   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
996   localcoolingtuberot->SetAngles(0.,90.,0.);
997   TGeoTranslation* localcoolingtubetrans[2];
998   TVector3* localcoolingtubevect[2];
999
1000   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1001                                                   -fgkCarbonFiberTriangleLength),
1002                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
1003                                             - fgkCarbonFiberLowerSupportWidth 
1004                                             - fgkLowerSupportToSensorZ ,
1005                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1006   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
1007                                               localcoolingtubevect[0]->Y(),
1008                                               localcoolingtubevect[0]->Z());
1009         for(Int_t j=0; j<2; j++){
1010                 localcoolingtubetrans[j] = 
1011                         new TGeoTranslation(localcoolingtubevect[j]->X(),
1012                                                                 localcoolingtubevect[j]->Y(),
1013                                                                 localcoolingtubevect[j]->Z());
1014                 fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
1015                                                           *                                     (*localcoolingtuberot));
1016         }
1017   /////////////////////////////////////////////////////////////
1018   // SSD End Ladder Cooling Tube Transformations
1019   /////////////////////////////////////////////////////////////
1020   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1021   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1022   TGeoTranslation** localendlladdercoolingtubetrans[2];
1023   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
1024   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
1025   for(Int_t i=0; i<2; i++)      
1026         for(Int_t j=0; j<2; j++)        
1027                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1028
1029   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
1030   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1031                                                                         -        fgkCoolingTubeSupportRmax)
1032                                                                         +        fgkCarbonFiberJunctionLength,
1033                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1034                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1035   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1036                                                                         -        fgkCoolingTubeSupportRmax)
1037                                                                         -        fgkCarbonFiberJunctionLength
1038                                                                         +    fgkCarbonFiberTriangleLength,
1039                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1040                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1041
1042   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1043                                                           -   fgkCoolingTubeSupportRmax)
1044                                                         +       fgkCarbonFiberJunctionLength,
1045                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1046                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1047   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1048                                                   -      fgkCoolingTubeSupportRmax)
1049                                                   -      fgkCarbonFiberJunctionLength
1050                                                   +    fgkCarbonFiberTriangleLength,
1051                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1052                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1053   for(Int_t i=0; i<2; i++)
1054         for(Int_t j=0; j<2; j++){
1055                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1056                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1057         }
1058   /////////////////////////////////////////////////////////////
1059   // SSD Hybrid Components Transformations
1060   /////////////////////////////////////////////////////////////
1061   const Int_t khybridmatrixnumber = 3;
1062   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1063   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1064                                             0.5*fgkSSDStiffenerWidth,
1065                                             0.5*fgkSSDStiffenerHeight);
1066   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1067                                             fgkSSDModuleStiffenerPosition[1],0.0);
1068
1069   localhybridtrans[2] = new TGeoTranslation(
1070                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1071                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1072                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1073                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1074                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1075                       -       fgkSSDSensorCenterSupportThickness[0]),
1076                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1077                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1078                                           -       fgkSSDModuleVerticalDisalignment)); 
1079   fhybridmatrix = new TGeoHMatrix();
1080   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1081   /////////////////////////////////////////////////////////////
1082   // SSD Cooling Block Transformations
1083   /////////////////////////////////////////////////////////////
1084   const Int_t kcoolingblockmatrixnumber = 4;    
1085   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
1086   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
1087                             -  fgkCoolingTubeSupportRmin),0.0,
1088                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1089   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
1090                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
1091                                0.0,fgkSSDStiffenerHeight);
1092   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
1093   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
1094   fcoolingblocksystematrix = new TGeoHMatrix();
1095   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
1096       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
1097   /////////////////////////////////////////////////////////////
1098   // SSD Stiffener Flex Transformations
1099   /////////////////////////////////////////////////////////////
1100   const Int_t klocalflexmatrixnumber = 4;
1101   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1102   for(Int_t i=0; i<fgkflexnumber; i++)    
1103       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1104   for(Int_t i=0; i<fgkflexnumber; i++)
1105       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1106             localflexmatrix[i][j] = new TGeoCombiTrans();
1107   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1108                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1109                                                                   -    fgkSSDStiffenerWidth;
1110   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1111                                         +0.5*fgkSSDStiffenerLength,
1112                                          0.5*fgkSSDStiffenerWidth,
1113                                         -0.5*fgkSSDStiffenerHeight
1114                                         -0.5*fgkSSDFlexHeight[0]);
1115   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1116                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1117                                         -0.5*fgkSSDStiffenerWidth,
1118                                         -0.5*fgkSSDStiffenerHeight
1119                                         -0.5*fgkSSDFlexHeight[0]);
1120   TGeoRotation* localflexrot = new TGeoRotation();
1121   localflexrot->SetAngles(180.,0.,0.);    
1122   localflexmatrix[1][0]->SetRotation(localflexrot);
1123   for(Int_t i=0; i<fgkflexnumber; i++)
1124       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1125             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1126   for(Int_t i=0; i<fgkflexnumber; i++){
1127       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1128       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1129             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1130   }
1131   /////////////////////////////////////////////////////////////
1132   // SSD End Flex Transformations
1133   /////////////////////////////////////////////////////////////
1134   TGeoRotation* localendflexrot = new TGeoRotation();
1135   localendflexrot->SetAngles(0.0,90.0,0.0);
1136   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1137   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1138                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1139   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1140                             * TMath::DegToRad()*ssdflexradiusmax
1141                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1142                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1143                                                                                    - 0.1*fgkSSDFlexFullLength;
1144   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1145                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1146                             +      fgkSSDFlexLength[2];
1147   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1148                               0.5*fgkSSDFlexWidth[0],
1149                               2.*fgkSSDStiffenerHeight
1150                             + 0.5*fgkSSDFlexHeight[0]);      
1151   localendflexmatrix->SetRotation(localendflexrot);
1152   for(Int_t i=0; i<fgkflexnumber; i++) 
1153       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1154   /////////////////////////////////////////////////////////////
1155   // End Ladder Carbon Fiber Junction
1156   /////////////////////////////////////////////////////////////
1157   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1158   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1159   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1160   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1161       localendladdercarbonfiberjunctionmatrix[i] 
1162             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1163       localendladdercarbonfiberjunctionrot[i] 
1164             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1165       localendladdercarbonfiberjunctiontrans[i] 
1166             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1167       fendladdercarbonfiberjunctionmatrix[i]
1168             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1169   }
1170   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1171       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1172             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1173             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1174       }
1175   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1176       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1177           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1178   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1179       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1180                               0.0,0.0);
1181       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1182                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1183                 *                     SinD(fgkCarbonFiberTriangleAngle),
1184                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1185   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1186   }
1187   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1188   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1189   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1190   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1191       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1192       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1193       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1194       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1195             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1196       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1197             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1198                                *localendladdercarbonfiberjunctionglobalrot[i]);
1199   }
1200   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1201       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1202             localendladdercarbonfiberjunctionmatrix[i][j] = 
1203                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1204                                      *localendladdercarbonfiberjunctionrot[i][j]);
1205            fendladdercarbonfiberjunctionmatrix[i][j] =
1206             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1207             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1208       }  
1209   /////////////////////////////////////////////////////////////
1210   // End Ladder Carbon Fiber Support
1211   /////////////////////////////////////////////////////////////
1212   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1213   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1214       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1215       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1216             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1217       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1218   }
1219   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1220       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1221             fendladdercarbonfibermatrix[i][j] = 
1222             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1223             *(*fcarbonfibersupportmatrix[j]));
1224   /////////////////////////////////////////////////////////////
1225   // End Ladder SSD Mounting Block
1226   /////////////////////////////////////////////////////////////
1227   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1228       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1229   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1230       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1231                                 +        fgkSSDMountingBlockLength[1])
1232                                 +  0.5*fgkCarbonFiberTriangleLength,
1233                                 fgkEndLadderMountingBlockPosition[i],
1234                                 -  fgkSSDMountingBlockHeight[1]
1235                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1236   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1237   endladdermountingblockrot->SetAngles(0.,90.,0.);
1238   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1239         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1240   /////////////////////////////////////////////////////////////
1241   // End Ladder SSD Mounting Block Clip Matrix 
1242   /////////////////////////////////////////////////////////////
1243   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1244         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1245   
1246   TGeoRotation* localendladdercliprot = new TGeoRotation();
1247   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1248   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1249                                                                                   -     fgkSSDMountingBlockLength[1])
1250                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1251   localendladdercliprot->SetAngles(90.,180.,-90.);
1252   TGeoCombiTrans* localendladderclipcombitrans = 
1253                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1254   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1255         for(Int_t j=0; j<2; j++){
1256                 fendladdermountingblockclipmatrix[i][j] = 
1257                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1258                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1259         }
1260   /////////////////////////////////////////////////////////////
1261   // End Ladder Carbon Fiber Lower Support
1262   /////////////////////////////////////////////////////////////
1263   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1264       fendladderlowersupptrans[i] = 
1265             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1266                         +  0.5*fgkSSDMountingBlockWidth),
1267                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1268   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1269                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1270                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1271                                                                          0.0);
1272   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1273  /////////////////////////////////////////////////////////////
1274   // Matrix for positioning Ladder into mother volume
1275   /////////////////////////////////////////////////////////////
1276   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1277   for(Int_t i=0; i<fgkladdernumber; i++) 
1278         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1279   TGeoRotation* localladdermotherrot = new TGeoRotation();
1280   localladdermotherrot->SetAngles(0.,90.,0.);  
1281   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1282   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1283   for(Int_t i=0; i<fgkladdernumber; i++){
1284         localladdermothertrans[i] = new TGeoTranslation(0.,
1285                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1286                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1287                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1288                                                           * fgkCarbonFiberJunctionWidth,0.);
1289         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1290                                                                                                                 *localladdermotherrot);
1291         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1292         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1293   }
1294   /////////////////////////////////////////////////////////////
1295   // Ladder Cables Matrices
1296   /////////////////////////////////////////////////////////////
1297   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1298                                              + fgkSSDFlexHeight[1];  
1299   Double_t ssdladdercabletransx[3];
1300   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1301                                                   *   SinD(2.*fgkSSDFlexAngle)
1302                                                   *       CosD(2.*fgkSSDFlexAngle);
1303   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1304                                                   -     ssdladdercabletransx[0]
1305                                                   /     SinD(2.*fgkSSDFlexAngle))
1306                                                   *     CosD(fgkSSDFlexAngle);                                          
1307   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1308                                                   *       TMath::DegToRad()*ssdflexradiusmax
1309                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1310                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1311                                                   -       fgkSSDLadderCableWidth)
1312                                                   *       CosD(2.*fgkSSDFlexAngle);
1313   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1314                                                   *     TanD(2.*fgkSSDFlexAngle),
1315                                                         ssdladdercabletransx[1]
1316                                                   *     TanD(fgkSSDFlexAngle),
1317                                                         ssdladdercabletransx[2]
1318                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1319   TGeoRotation* localladdercablerot[3]; 
1320   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1321   localladdercablerot[0]->SetAngles(90.,0.,0.);
1322   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1323   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1324                                                  *                        (*localladdercablerot[0]));
1325   //TGeoRotation* localladdercablerot = new TGeoRotation();     
1326   //localladdercablerot->SetAngles(90.,0.,0.);
1327   ////////////////////////////////////////////
1328   // LocalLadderCableCombiTransMatrix
1329   ////////////////////////////////////////////
1330   const Int_t klocalladdersidecablesnumber = 2;
1331   const Int_t klocalladdercombitransnumber = 5;
1332   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1333   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1334          localladdercablecombitransmatrix[i] = 
1335                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1336   ///////////////////////////////////////////
1337   // Left Side Ladder Cables Transformations
1338   ///////////////////////////////////////////
1339   localladdercablecombitransmatrix[0][0]  =
1340                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1341                                                 0.,0.,NULL);
1342   localladdercablecombitransmatrix[0][1] = 
1343         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1344                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1345                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1346                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1347                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1348                                            + fgkSSDSensorCenterSupportLength
1349                                            - fgkSSDSensorCenterSupportThickness[0]),
1350                                            - (fgkSSDModuleCoolingBlockToSensor
1351                                            + 0.5*fgkCoolingTubeSupportHeight
1352                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1353                                            - fgkSSDChipHeight),NULL);
1354   localladdercablecombitransmatrix[0][2] = 
1355                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1356                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1357   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1358                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1359                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1360                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1361                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1362                                                                                                 new TGeoRotation("",180.,0.,0.));
1363   localladdercablecombitransmatrix[0][4] = 
1364                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1365                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1366                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1367                                                           0.,
1368                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1369                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1370                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1371                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1372   ///////////////////////////////////////////
1373   // Rigth Side Ladder Cables Transformations
1374   ///////////////////////////////////////////
1375   TGeoCombiTrans* localladdercablessdmodulematrix = 
1376         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1377                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1378                                                                          fgkSSDStiffenerWidth,
1379                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1380   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1381    localladdercablecombitransmatrix[1][i] = 
1382                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1383                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1384   ///////////////////////////////////////////
1385   // Setting LadderCableHMatrix
1386   ///////////////////////////////////////////
1387   Int_t beamaxistrans[2][3];
1388   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1389   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1390   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1391   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1392   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1393   beamaxistrans[1][2] = beamaxistrans[1][0];
1394   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1395   TGeoRotation* laddercablerot = new TGeoRotation();
1396   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1397   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1398   Double_t* laddercabletransvector;     
1399   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1400         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1401         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1402   }
1403   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1404         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1405                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1406                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1407                         localladdercablehmatrix[i][j]->MultiplyLeft(
1408                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1409         }
1410                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1411                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1412                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1413                                                                          laddercabletransvector[1]
1414                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1415                                         *                                fgkCarbonFiberJunctionWidth,
1416                                                                          laddercabletransvector[2]);
1417                 laddercablecombitrans->SetRotation(*laddercablerot);
1418                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1419                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1420         }
1421     fladdercablematrix[i][2] = 
1422                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1423                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1424         fladdercablematrix[i][3] = 
1425                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1426                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1427   }
1428   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1429         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1430                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1431   ///////////////////////////////////////////
1432   // Setting Ladder HMatrix
1433   ///////////////////////////////////////////
1434   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1435                                                                                                 fgkSSDLay6SensorsNumber};
1436   for(Int_t i=0; i<fgkladdernumber; i++){
1437         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1438         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1439                 fladdermatrix[i][j] = new TGeoHMatrix();
1440                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1441                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1442                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1443         }
1444   }
1445   ///////////////////////////////////////////
1446   // Setting SSD Sensor Matrix 
1447   ///////////////////////////////////////////
1448   TGeoCombiTrans* localssdsensorcombitrans[2];
1449   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1450   localssdsensorrot->SetAngles(0.,90.,0.);      
1451   TGeoTranslation* localssdsensortrans[2];
1452   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1453   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1454                                          fgkCarbonFiberJunctionWidth 
1455                                          - fgkCarbonFiberLowerSupportWidth 
1456                                          - fgkLowerSupportToSensorZ,
1457                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1458                                           -             fgkSSDModuleCoolingBlockToSensor
1459                                           +    (fgkSSDSensorSideSupportHeight[1]
1460                                           -             fgkSSDSensorSideSupportHeight[0]));
1461   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1462                                          fgkCarbonFiberJunctionWidth 
1463                                          - fgkCarbonFiberLowerSupportWidth 
1464                                          - fgkLowerSupportToSensorZ,
1465                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1466                                                         -fgkSSDModuleCoolingBlockToSensor);
1467
1468   for(Int_t i=0; i<2; i++) 
1469         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1470                                                                                                          *localssdsensorrot);   
1471     for(Int_t i=0; i<fgkladdernumber; i++){
1472         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1473         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1474                 switch(i){
1475                         case 0: //Ladder of Layer5  
1476                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1477                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1478                                                                                                 *localssdsensorcombitrans[1])));
1479                         break;
1480                         case 1: //Ladder of Layer6 
1481                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1482                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1483                                                                                                 *localssdsensorcombitrans[0])));
1484                 break;
1485                 }
1486           }
1487   }     
1488   //////////////////////////
1489   // Setting SSD End Ladder  
1490   //////////////////////////
1491   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1492   for(Int_t i=0; i<2; i++){
1493         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1494         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1495         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1496         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1497         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1498         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1499         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1500         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1501    }
1502   /////////////////////////////////////////////////////
1503   // Setting the CombiTransformation to pass ITS center 
1504   /////////////////////////////////////////////////////
1505   Double_t itscentertransz[fgklayernumber];
1506   itscentertransz[0] = fgkSSDLay5LadderLength
1507                                          - fgkLay5CenterITSPosition;
1508   itscentertransz[1] = fgkSSDLay6LadderLength
1509                                          - fgkLay6CenterITSPosition;
1510   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1511                                                    + 0.5*fgkCoolingTubeSupportHeight;
1512   TGeoRotation* itscenterrot[3];
1513   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1514   itscenterrot[0]->SetAngles(90.,180.,-90.);
1515   itscenterrot[1]->SetAngles(0.,90.,0.);
1516   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1517   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1518   for(Int_t i=0; i<fgklayernumber; i++) 
1519         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1520                                                          itssensortransy,
1521                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1522                                                    - itscentertransz[i],itscenterrot[2]);
1523   TGeoRotation** locallayerrot[fgklayernumber];
1524   TGeoTranslation** locallayertrans[fgklayernumber];    
1525   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1526   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1527   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1528                                          - fgkLay5CenterITSPosition);
1529   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1530                                          - fgkLay6CenterITSPosition);
1531   const Int_t kssdlayladdernumber[fgklayernumber] = 
1532                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1533   for(Int_t i=0; i<fgklayernumber; i++){
1534     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1535     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1536         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1537         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1538   }
1539   Double_t layerladderangleposition[fgklayernumber] = 
1540                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1541   Double_t layerradius = 0.;
1542   for(Int_t i=0; i<fgklayernumber; i++){        
1543         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1544                 switch(i){
1545                         case 0: //Ladder of Layer5  
1546                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1547                         break;
1548                         case 1: //Ladder of Layer6 
1549                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1550                 break;
1551                 }
1552                 locallayerrot[i][j] = new TGeoRotation();
1553                 locallayertrans[i][j] = new TGeoTranslation();
1554                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1555                 locallayertrans[i][j]->SetTranslation(layerradius 
1556                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1557                                                             layerradius 
1558                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1559                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1560                                                                          *locallayerrot[i][j]);
1561                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1562                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1563                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1564         }
1565   }
1566   /////////////////////////////////////////////////////////////
1567   // Deallocating memory
1568   /////////////////////////////////////////////////////////////
1569   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1570         delete carbonfiberot[i];
1571         delete localcarbonfibersupportmatrix[i];
1572   }
1573   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1574      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1575        delete localcarbonfiberjunctionmatrix[i][j];
1576            delete localcarbonfiberjunctionrot[i][j];
1577            delete localcarbonfiberjunctiontrans[i][j];
1578            }
1579        delete [] localcarbonfiberjunctionmatrix[i];
1580        delete [] localcarbonfiberjunctionrot[i];
1581        delete [] localcarbonfiberjunctiontrans[i];
1582   }
1583   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1584            delete localcarbonfiberlowersupportrans[i];
1585   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1586      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1587        delete localssdsensorsupportmatrix[i][j];
1588            delete localssdsensorsupportrot[i][j];
1589            delete localssdsensorsupportrans[i][j];
1590            }
1591        delete [] localssdsensorsupportmatrix[i];
1592        delete [] localssdsensorsupportrot[i];
1593        delete [] localssdsensorsupportrans[i];
1594   }
1595   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1596         delete localcoolingtubesupportmatrix[i];
1597         delete localcoolingtubesupportrot[i];
1598         delete localcoolingtubesupportrans[i];
1599   }
1600   for(Int_t j=0; j<2; j++){
1601     delete localcoolingtubevect[j];
1602     delete localcoolingtubetrans[j];
1603   }
1604  delete endladdermountingblockrot;
1605  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1606  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1607  for(Int_t i=0; i<fgkflexnumber; i++){
1608       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1609             delete localflexmatrix[i][j];
1610       delete [] localflexmatrix[i];
1611  }
1612  delete localendlladdercoolingtuberot;
1613  for(Int_t i=0; i<2; i++){
1614         for(Int_t j=0; j<2; j++)
1615           delete localendlladdercoolingtubetrans[i][j];
1616         delete [] localendlladdercoolingtubetrans[i];
1617   }
1618
1619  delete localflexrot;
1620  delete localendflexrot;
1621  delete localendflexmatrix;
1622  for(Int_t i=0; i<fgkladdernumber; i++){ 
1623         delete localladdermothertrans[i];
1624         delete localladdermothercombitrans[i];
1625   }
1626  delete localladdermotherrot;
1627  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1628       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1629             delete localendladdercarbonfiberjunctionmatrix[i][j];
1630             delete localendladdercarbonfiberjunctionrot[i][j];
1631             delete localendladdercarbonfiberjunctiontrans[i][j];
1632       }
1633       delete [] localendladdercarbonfiberjunctionmatrix[i];
1634       delete [] localendladdercarbonfiberjunctionrot[i];
1635       delete [] localendladdercarbonfiberjunctiontrans[i];
1636       delete localendladdercarbonfiberjunctionglobalrot[i];
1637       delete localendladdercarbonfiberjunctionglobaltrans[i];
1638       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1639  }
1640   for(Int_t i=0; i<2; i++){
1641         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1642         delete [] localendladdercooltubetrans[i];
1643   }
1644   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1645       delete localendladdercarbonfibertrans[i];
1646   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1647   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1648         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1649                 delete localladdercablecombitransmatrix[i][j];
1650                 delete []localladdercablecombitransmatrix[i];
1651   }
1652   delete localendladdercliprot;
1653   delete localendladdercliptrans;
1654   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1655         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1656                 delete localladdercablehmatrix[i][j];
1657         delete []localladdercablehmatrix[i];
1658   }
1659   delete laddercablerot;
1660   delete laddercabletrans;
1661   delete laddercablecombitrans;
1662   delete localladdercablessdmodulematrix;
1663   delete localssdsensorrot;     
1664   for(Int_t i=0; i<2; i++){
1665         delete localssdsensortrans[i];
1666         delete localssdsensorcombitrans[i];
1667   }
1668   for(Int_t i=0; i<fgklayernumber; i++){
1669         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1670                 delete locallayerrot[i][j];
1671                 delete locallayertrans[i][j];
1672                 delete locallayercombitrans[i][j];
1673     }
1674         delete [] locallayerrot[i];
1675         delete [] locallayertrans[i];
1676         delete [] locallayercombitrans[i];
1677         delete localbeamaxistrans[i];
1678   }
1679   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1680   for(Int_t i=0; i<fgkladdernumber; i++){
1681         for(Int_t j=0; j<fgkladdernumber; j++)
1682                 delete ladderglobalmatrix[i][j];
1683         delete [] ladderglobalmatrix[i];
1684   }
1685   /////////////////////////////////////////////////////////////
1686   fTransformationMatrices = kTRUE;      
1687 }
1688 ///////////////////////////////////////////////////////////////////////////////
1689 void AliITSv11GeometrySSD::CreateBasicObjects(){
1690   /////////////////////////////////////////////////////////////  
1691   // Method generating the Objects of SSD Geometry    
1692   /////////////////////////////////////////////////////////////
1693   // SSD Sensor
1694   ///////////////////////////////////
1695   SetSSDSensor();
1696   /////////////////////////////////////////////////////////////  
1697   // Carbon Fiber Support    
1698   /////////////////////////////////////////////////////////////  
1699   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1700   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1701       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1702   /////////////////////////////////////////////////////////////
1703   // Carbon Fiber Junction 
1704   /////////////////////////////////////////////////////////////
1705   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1706   /////////////////////////////////////////////////////////////
1707   // Carbon Fiber Lower Support
1708   /////////////////////////////////////////////////////////////
1709   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1710   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1711         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1712   /////////////////////////////
1713   // SSD Sensor Support
1714   /////////////////////////////
1715   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1716                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1717   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1718                                                                          fgkSSDSensorSideSupportThickness[1]};
1719   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1720         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1721                                                                                            fgkSSDSensorSideSupportHeight[i],
1722                                                                                            fgkSSDSensorSideSupportWidth,
1723                                                                                            sidesupporthickness);  
1724         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1725                                                                                            fgkSSDSensorCenterSupportHeight[i],
1726                                                                                            fgkSSDSensorCenterSupportWidth,
1727                                                                                            sidesupporthickness);
1728   }
1729   /////////////////////////////////////////////////////////////
1730   // SSD Cooling Tube Support
1731   /////////////////////////////////////////////////////////////
1732   Int_t edgesnumber = 3;
1733   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1734   /////////////////////////////////////////////////////////////
1735   // SSD Hybrid
1736   /////////////////////////////////////////////////////////////
1737   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1738   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1739         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1740   /////////////////////////////////////////////////////////////
1741   // SSD Cooling Block System
1742   /////////////////////////////////////////////////////////////
1743   fssdcoolingblocksystem = GetCoolingBlockSystem();
1744    /////////////////////////////////////////////////////////////
1745   // SSD Cooling Tube
1746   /////////////////////////////////////////////////////////////
1747   CreateCoolingTubes();
1748   /////////////////////////////////////////////////////////////
1749   // SSD Flex  
1750   /////////////////////////////////////////////////////////////
1751   fssdstiffenerflex = GetSSDStiffenerFlex();
1752   fssdendflex = GetSSDEndFlex();
1753   ///////////////////////////////////
1754   // End Ladder Carbon Fiber Junction
1755   ///////////////////////////////////
1756   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1757                                                    fendladdercarbonfiberjunction[i] = 
1758                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1759   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1760     fendladdercarbonfiberjunction[i][0] = 
1761                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1762     fendladdercarbonfiberjunction[i][1] = 
1763                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1764   }
1765   ///////////////////////////////////
1766   // End Ladder Mounting Block
1767   ///////////////////////////////////
1768   fendladdermountingblock = GetSSDMountingBlock();
1769   ///////////////////////////////////
1770   // End Ladder Mounting Block
1771   ///////////////////////////////////
1772   fendladdermountingblockclip = GetMountingBlockClip();
1773   ///////////////////////////////////
1774   // Ladder Support 
1775   ///////////////////////////////////
1776   TList* laddersupportlist = GetMountingBlockSupport(20);
1777   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1778   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1779   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1780   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1781   /////////////////////////////////////////////////////////////
1782   // Deallocating memory
1783   /////////////////////////////////////////////////////////////
1784   delete carbonfibersupportlist;
1785   delete carbonfiberlowersupportlist;
1786   delete ssdhybridcomponentslist;
1787   delete laddersupportlist;
1788   /////////////////////////////////////////////////////////////
1789   fBasicObjects = kTRUE;
1790 }
1791 /////////////////////////////////////////////////////////////////////////////////
1792 void AliITSv11GeometrySSD::SetSSDSensor(){
1793   ////////////////////////////////////////////////////////////////
1794   // Method generating SSD Sensors: it sets the private variables
1795   // fSSDSensor5, fSSDSensor6  
1796   ////////////////////////////////////////////////////////////////
1797   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1798   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1799   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1800                                                 0.5*ssdsensitivewidth,
1801                                                 0.5*fgkSSDSensorHeight,
1802                                                 0.5*ssdsensitivelength);
1803   TGeoVolume* ssdsensorsensitiveLay5 = 
1804         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1805   TGeoVolume* ssdsensorsensitiveLay6 = 
1806         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1807   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1808   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1809   TGeoBBox* ssdsensorinsensitiveshape[2];
1810   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1811                                                 0.5*fgkSSDSensorInsensitiveWidth,
1812                                                 0.5*fgkSSDSensorHeight,
1813                                                 0.5*fgkSSDSensorLength);
1814   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1815                                                 0.5*ssdsensitivewidth,
1816                                                 0.5*fgkSSDSensorHeight,
1817                                                 0.5*fgkSSDSensorInsensitiveWidth);
1818   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1819                                              "SSDSensorInsensitive2"};
1820   TGeoVolume* ssdsensorinsensitive[2];
1821   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1822       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1823                      fSSDSensorMedium);
1824       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1825   }
1826   /////////////////////////////////////////////////////////////
1827   // Virtual Volume containing SSD Sensor  
1828   /////////////////////////////////////////////////////////////
1829   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1830                                                                                              0.5*fgkSSDSensorWidth,
1831                                                                                              0.5*fgkSSDSensorHeight,
1832                                                                                              0.5*fgkSSDSensorLength);
1833   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1834                                                                                  fSSDAir);      
1835   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1836                                                                                  fSSDAir);      
1837   /////////////////////////////////////////////////////////////
1838   for(Int_t i=0; i<4; i++){ 
1839             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1840             ssdsensorinsensitive[1],i<2?1:2,
1841                         new TGeoTranslation(
1842                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1843       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1844                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1845       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1846             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1847             ssdsensorinsensitive[1],i<2?1:2,
1848                         new TGeoTranslation(
1849                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1850       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1851                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1852       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1853   }
1854     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1855     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1856 }
1857 ///////////////////////////////////////////////////////////////////////////////
1858 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1859   /////////////////////////////////////////////////////////////  
1860   // Method generating the Carbon Fiber Support   
1861   /////////////////////////////////////////////////////////////  
1862   const Int_t kvertexnumber = 4;
1863   const Int_t kshapesnumber = 2;
1864   TVector3** vertexposition[kshapesnumber];
1865   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1866   Double_t carbonfibersupportxaxisEdgeproj = 
1867                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1868         *       TMath::DegToRad());
1869   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1870                                  /                         fgkCarbonFiberSupportXAxisLength);
1871   /////////////////////
1872   //Vertex Positioning
1873   ////////////////////
1874   vertexposition[0][0] = new TVector3();
1875   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1876                                                                           fgkCarbonFiberSupportYAxisLength);
1877   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1878                                                                           carbonfibersupportxaxisEdgeproj
1879                                            *                      TMath::Tan(theta));
1880   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1881                                            -                      carbonfibersupportxaxisEdgeproj,
1882                                                                           fgkCarbonFiberSupportYAxisLength
1883                                            -                      vertexposition[0][2]->Y());
1884   ////////////////////////////////////////////////////
1885   //Setting the parameters for Isometry Transformation
1886   ////////////////////////////////////////////////////
1887   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1888                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1889                                                                  +      fgkCarbonFiberSupportWidth);
1890   Double_t* param = new Double_t[4]; 
1891   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1892   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1893     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1894                  (GetReflection(vertexposition[0][j],param))->Y());
1895   const char* carbonfibersupportshapename[kshapesnumber] = 
1896                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1897   const char* carbonfibersupportname[kshapesnumber] = 
1898                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1899   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1900   TGeoVolume* carbonfibersupport[kshapesnumber];
1901   TList* carbonfibersupportlist = new TList();
1902   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1903   Double_t carbonfibersupportheight = 
1904           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1905           *TMath::DegToRad());
1906   for(Int_t i = 0; i< kshapesnumber; i++){
1907    carbonfibersupportshape[i] = 
1908                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1909                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1910    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1911                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1912    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1913    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1914    }
1915   /////////////////////////////////////////////////////////////
1916   // Deallocating memory
1917   /////////////////////////////////////////////////////////////
1918   for(Int_t i=0; i< kshapesnumber; i++){
1919      for(Int_t j=0; j< kvertexnumber; j++)
1920            delete vertexposition[i][j];
1921        delete [] vertexposition[i];
1922   }
1923   delete [] param;
1924   /////////////////////////////////////////////////////////////
1925    return carbonfibersupportlist;
1926 }
1927 /////////////////////////////////////////////////////////////////////////////////
1928 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1929   /////////////////////////////////////////////////////////////
1930   // Method generating SSD Carbon Fiber Junction
1931   /////////////////////////////////////////////////////////////
1932   const Int_t kvertexnumber = 6;
1933   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
1934   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1935                                             *  TMath::DegToRad()),-1.,0.,0.};
1936   TVector3* vertex[kvertexnumber];
1937   vertex[0] = new TVector3();
1938   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
1939                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1940                         *                         TMath::DegToRad()),
1941                                                   fgkCarbonFiberJunctionEdge[0]
1942                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
1943                         *                         TMath::DegToRad()));
1944   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
1945                                                    fgkCarbonFiberJunctionEdge[1]);
1946   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
1947   vertex[1] = GetReflection(vertex[5],reflectionparam); 
1948   vertex[2] = GetReflection(vertex[4],reflectionparam); 
1949   Double_t xvertexpoints[6], yvertexpoints[6];
1950   for(Int_t i=0; i<kvertexnumber; i++) 
1951           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
1952   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
1953   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
1954   carbonfiberjunctionshape->DefineSection(1,0.5*width);
1955   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
1956                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
1957   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
1958   /////////////////////////////////////////////////////////////
1959   // Deallocating memory
1960   /////////////////////////////////////////////////////////////
1961   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
1962   ///////////////////////////////////////////////////////////// 
1963   return carbonfiberjunction;
1964 }
1965 ////////////////////////////////////////////////////////////////////////////////
1966 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
1967   /////////////////////////////////////////////////////////////
1968   // Method generating the Carbon Fiber Lower Support   
1969   /////////////////////////////////////////////////////////////  
1970   const Int_t kvertexnumber = 4;
1971   const Int_t kshapesnumber = 2;
1972   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
1973                                                                 fgkCarbonFiberLowerSupportWidth};
1974   TVector3** vertexposition[kshapesnumber];
1975   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
1976                                                  new TVector3*[kvertexnumber];
1977   //First Shape Vertex Positioning
1978   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
1979   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
1980                                            -            fgkCarbonFiberLowerSupportLowerLenght);
1981   vertexposition[0][2] = new TVector3();
1982   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
1983   //Second Shape Vertex Positioning
1984   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
1985                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
1986                                  /                              fgkCarbonFiberTriangleLength);
1987   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
1988                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
1989                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1990   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
1991                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
1992                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1993   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
1994   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
1995                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
1996   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
1997                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
1998   const char* carbonfiberlowersupportname[kshapesnumber] = 
1999                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2000   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2001   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2002   TList* carbonfiberlowersupportlist = new TList();
2003   for(Int_t i = 0; i< kshapesnumber; i++){ 
2004         carbonfiberlowersupportshape[i] = 
2005                                                                 GetArbShape(vertexposition[i],width,
2006                                                                                         fgkCarbonFiberLowerSupportHeight,
2007                                                                                         carbonfiberlowersupportshapename[i]);
2008     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2009                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2010         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2011     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2012   }
2013   /////////////////////////////////////////////////////////////
2014   // Deallocating memory
2015   /////////////////////////////////////////////////////////////
2016   for(Int_t i=0; i< kshapesnumber; i++){
2017      for(Int_t j=0; j< kvertexnumber; j++)
2018            delete vertexposition[i][j];
2019        delete [] vertexposition[i];
2020   }
2021   /////////////////////////////////////////////////////////////
2022   return carbonfiberlowersupportlist;
2023 }
2024 ///////////////////////////////////////////////////////////////////////////////
2025 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2026                                                                  Double_t width, Double_t* thickness)const{
2027   /////////////////////////////////////////////////////////////
2028   // Method generating the Sensor Support   
2029   /////////////////////////////////////////////////////////////  
2030         const Int_t kvertexnumber = 6;
2031         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2032     TVector3* vertexposition[kvertexnumber];
2033         vertexposition[0] = new TVector3();     
2034         vertexposition[1] = new TVector3(0.0,length);   
2035         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2036         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2037         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2038         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2039         Double_t xvertexpoints[6], yvertexpoints[6];
2040         for(Int_t i=0; i<kvertexnumber; i++) 
2041                 xvertexpoints[i] = vertexposition[i]->X(), 
2042                 yvertexpoints[i] = vertexposition[i]->Y();
2043     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2044     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2045     ssdsensorsupportshape->DefineSection(1,0.5*width);
2046     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2047                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2048   /////////////////////////////////////////////////////////////
2049   // Deallocating memory
2050   /////////////////////////////////////////////////////////////
2051         for (Int_t i=0; i<kvertexnumber; i++)
2052                 delete vertexposition[i];
2053   /////////////////////////////////////////////////////////////
2054     return ssdsensorsupport;
2055 }
2056 ////////////////////////////////////////////////////////////////////////////////
2057 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2058   /////////////////////////////////////////////////////////////
2059   // Method generating the Cooling Tube Support
2060   /////////////////////////////////////////////////////////////
2061   if(nedges%2!=0) nedges--;     
2062   const Int_t kvertexnumber = nedges+5;
2063   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2064                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2065   Double_t angle = 90.+phi;
2066   Double_t psi = 90.-phi;
2067   ///////////////////////////////////////
2068   // Vertex Positioning for TGeoXTru
2069   ///////////////////////////////////////
2070   TVector3** vertexposition = new TVector3*[kvertexnumber];
2071
2072   Double_t Router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
2073   vertexposition[0] = new TVector3(Router*CosD(angle),
2074                                                                    Router*SinD(angle));
2075   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2076                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2077   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2078                                                                    fgkCoolingTubeSupportRmax);
2079   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2080                                                                    fgkCoolingTubeSupportRmax);
2081   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2082                                                                     vertexposition[1]->Y());
2083
2084   for(Int_t i=0; i<nedges; i++)
2085         vertexposition[i+5] = 
2086                 new TVector3(Router*CosD(psi+i*(2.*phi/nedges)),
2087                              Router*SinD(psi+i*(2.*phi/nedges)));
2088   ///////////////////////////////////////////////////////////////////////
2089   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2090   ///////////////////////////////////////////////////////////////////////
2091   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2092   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2093   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2094   for(Int_t i=0; i<kvertexnumber; i++){
2095         xvertexpoints[i] = vertexposition[i]->X();
2096         yvertexpoints[i] = vertexposition[i]->Y();
2097   } 
2098   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2099                                                                                         yvertexpoints);
2100   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2101   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2102   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2103                                                                           coolingtubesupportarcshape,
2104                                                                                   fSSDTubeHolderMedium);
2105   coolingtubesupportarc->SetLineColor(fColorG10);
2106   //////////////////////////////////////////////////////////////////////////
2107   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2108   //////////////////////////////////////////////////////////////////////////
2109   TGeoTubeSeg* coolingtubesupportsegshape = 
2110                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2111                                                                                         fgkCoolingTubeSupportRmax,
2112                                                                                         0.5*fgkCoolingTubeSupportWidth,
2113                                                                                         phi,360-phi);
2114   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2115                                                                                         coolingtubesupportsegshape,
2116                                                                                         fSSDTubeHolderMedium);
2117   coolingtubesupportseg->SetLineColor(fColorG10);
2118   //////////////////////////////////////////////////////////////////////////
2119   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2120   //////////////////////////////////////////////////////////////////////////
2121   Double_t* boxorigin = new Double_t[3];
2122   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2123   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2124   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2125                                                                                  0.5*fgkCoolingTubeSupportHeight,
2126                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2127   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2128                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2129   coolingtubesupportbox->SetLineColor(fColorG10);
2130   //////////////////////////////////////////////////////////////////////////
2131   // Cooling Tube for Cooling Tube Support 
2132   //////////////////////////////////////////////////////////////////////////
2133   TGeoXtru* coolingtubearcshape[2];
2134   coolingtubearcshape[0] = new TGeoXtru(2);     
2135   Double_t* xvert = new Double_t[nedges+2];
2136   Double_t* yvert = new Double_t[nedges+2];
2137   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2138   ////////////////////////////////////////
2139   // Positioning the vertices for TGeoXTru
2140   ////////////////////////////////////////
2141   xvert[0] = 0., yvert[0] = 0.;
2142   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2143   for(Int_t i=0; i< nedges; i++)
2144                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2145                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2146   ////////////////////////////////////////
2147   // Defining TGeoXTru PolyGone
2148   ////////////////////////////////////////
2149   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2150   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2151   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2152   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2153                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2154   TGeoVolume* coolingtubearc[2];
2155   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2156                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2157   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2158                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2159   coolingtubearc[0]->SetLineColor(fColorWater);
2160   coolingtubearc[1]->SetLineColor(fColorPhynox);
2161   ////////////////////////////////////////////
2162   // Defining TGeoTubeSeg Part of Cooling Tube
2163   ////////////////////////////////////////////
2164   TGeoTubeSeg* coolingtubesegshape[2];
2165   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2166                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2167   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2168                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2169   TGeoVolume* coolingtubeseg[2];
2170   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2171                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2172   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2173                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2174   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2175   coolingtubeseg[1]->SetLineColor(fColorWater);
2176   /////////////////////////////////////////////////////////////
2177   // Virtual Volume containing Cooling Tube Support  
2178   /////////////////////////////////////////////////////////////
2179   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2180   const Int_t kvirtualvertexnumber = 8;
2181   TVector3* virtualvertex[kvirtualvertexnumber];
2182    ////////////////////////////////////////
2183   // Positioning the vertices for TGeoXTru
2184   ////////////////////////////////////////
2185   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2186   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2187   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2188   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2189   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2190   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2191   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2192   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2193   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2194   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2195         xmothervertex[i] = virtualvertex[i]->X(),
2196         ymothervertex[i] = virtualvertex[i]->Y();
2197   ////////////////////////////////////////
2198   // Defining TGeoXTru PolyGone
2199   ////////////////////////////////////////
2200   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2201                                                                                                                                          ymothervertex);
2202   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2203   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2204   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2205     virtualCoolingTubeSupportShape,fSSDAir); */
2206   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
2207
2208   ////////////////////////////////////////
2209   // Positioning Volumes in Virtual Volume
2210   ////////////////////////////////////////
2211   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2212   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2213   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2214   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2215   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2216   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2217   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2218   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2219   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2220   /////////////////////////////////////////////////////////////
2221   // Deallocating memory
2222   /////////////////////////////////////////////////////////////
2223   delete [] vertexposition;
2224   delete [] xvertexpoints;
2225   delete [] yvertexpoints;
2226   delete [] xvert;
2227   delete [] yvert;
2228   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2229         delete virtualvertex[i];
2230   /////////////////////////////////////////////////////////////
2231         return virtualcoolingtubesupport;
2232 }
2233 /////////////////////////////////////////////////////////////////////////////////
2234 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2235   /////////////////////////////////////////////////////////////
2236   // Method generating List containing SSD Hybrid Components   
2237   /////////////////////////////////////////////////////////////
2238   TList* ssdhybridlist = new TList();
2239   const Int_t kssdstiffenernumber = 2;
2240   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2241                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2242                                                                   -    fgkSSDStiffenerWidth;
2243   Double_t ssdchipcablesradius[kssdstiffenernumber];
2244   for(Int_t i=0; i<kssdstiffenernumber; i++)
2245           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2246                                -  fgkSSDChipCablesHeight[0]
2247                                -  fgkSSDChipCablesHeight[1]);
2248   /////////////////////////////////////////////////////////////
2249   // Mother Volumes Containers 
2250   /////////////////////////////////////////////////////////////
2251   const Int_t kmothernumber = 2;
2252   const Int_t kmothervertexnumber = 8;
2253   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2254   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2255
2256   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
2257   TGeoVolume* ssdhybridmother[kmothernumber][2];
2258
2259   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
2260   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
2261   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
2262
2263   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2264   for(Int_t i=0; i<kmothernumber; i++){
2265     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
2266     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
2267     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
2268     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2269       -fgkSSDChipCablesHeight[i+2];
2270     
2271     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
2272     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
2273     xmothervertex[i][3] = xmothervertex[i][2];
2274     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1];
2275
2276     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
2277     ymothervertex[i][4] = ymothervertex[i][3];
2278     xmothervertex[i][5] = xmothervertex[i][4];
2279     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i];
2280
2281     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
2282     ymothervertex[i][6] = ymothervertex[i][5];
2283     
2284     xmothervertex[i][7] = xmothervertex[i][6];
2285     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
2286     /*
2287     for (Int_t j = 0; j<8; j++) {
2288       cout << "vtx " << j << " " <<  xmothervertex[i][j] << " " << ymothervertex[i][j] << endl;
2289     }
2290     */
2291     TGeoXtru *shape = new TGeoXtru(2);
2292     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
2293     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
2294     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
2295     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
2296     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
2297     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2298    }   
2299   /////////////////////////////////////////////////////////////
2300   // SSD Stiffener   
2301   /////////////////////////////////////////////////////////////
2302   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2303                                              0.5*fgkSSDStiffenerLength,
2304                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2305                                              0.5*fgkSSDStiffenerHeight);
2306   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2307                                             fSSDStiffenerMedium);  
2308   ssdstiffener->SetLineColor(fColorStiffener); 
2309
2310 ////////////////////////////
2311 // Capacitor 0603-2200 nF
2312 ///////////////////////////
2313   const Int_t knapacitor0603number = 5;
2314   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2315                                                0.5*fgkSSDCapacitor0603Length,
2316                                                0.5*(fgkSSDCapacitor0603Width),
2317                                                0.5*fgkSSDCapacitor0603Height);
2318   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2319                                              fSSDStiffener0603CapacitorMedium); 
2320   capacitor0603->SetLineColor(fColorAl);
2321
2322   TGeoVolume* ssdchip = GetSSDChip();
2323
2324   const Int_t knedges = 5;
2325   TGeoVolume *ssdchipcables[2];
2326
2327   for(Int_t i=0; i<kmothernumber; i++){
2328     for(Int_t j=0; j<kssdstiffenernumber; j++){
2329       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
2330       for(Int_t k=1; k<knapacitor0603number+1; k++){
2331         ssdhybridmother[i][j]->AddNode(capacitor0603,k,
2332                                        new TGeoCombiTrans("",
2333                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
2334                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
2335                                                           (k-3.)/6*fgkSSDStiffenerLength,
2336                                                           hybridmotherrotInv));
2337       }
2338     }
2339     
2340     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
2341     for(Int_t k=0; k<fgkSSDChipNumber; k++){
2342       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
2343                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
2344                                                             - fgkSSDChipCablesHeight[i+2],
2345                                                             (k+0.5-fgkSSDChipNumber/2)*
2346                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
2347       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
2348                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
2349                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
2350                                                      hybridmotherrotInv);
2351       for(Int_t j=0; j<kssdstiffenernumber; j++){
2352         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
2353         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
2354       }
2355     }  
2356     // Final placement by assembly
2357     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
2358     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
2359     ssdhybridlist->Add(ssdhybridassembly[i]);
2360   }    
2361   /////////////////////////////////////////////////////////////
2362   // Mother Volume Containing Capacitor Part 
2363   /////////////////////////////////////////////////////////////
2364   const Int_t kcapacitormothernumber = 8;
2365   Double_t xcapacitorvertex[kcapacitormothernumber];
2366   Double_t ycapacitorvertex[kcapacitormothernumber];  
2367   ///////////////////////
2368   // Setting the vertices 
2369   ///////////////////////
2370   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2371   xcapacitorvertex[1] = xcapacitorvertex[0];   
2372   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2373   xcapacitorvertex[3] = xcapacitorvertex[2];   
2374   xcapacitorvertex[4] = xcapacitorvertex[0];   
2375   xcapacitorvertex[5] = xcapacitorvertex[0];   
2376   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2377   xcapacitorvertex[7] = xcapacitorvertex[6];   
2378   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2379   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2380   ycapacitorvertex[2] = ycapacitorvertex[1];   
2381   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2382   ycapacitorvertex[4] = ycapacitorvertex[3];   
2383   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2384   ycapacitorvertex[6] = ycapacitorvertex[5];   
2385   ycapacitorvertex[7] = ycapacitorvertex[0];   
2386   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2387   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2388                                               ycapacitorvertex);
2389   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2390   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2391 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2392 //                                          fSSDAir);
2393   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2394 ////////////////////////////
2395 // Connector 
2396 ///////////////////////////
2397   const Int_t kssdconnectornumber = 2;
2398   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2399   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2400   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2401                                    +  fgkSSDConnectorAlHeight};  
2402   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2403   TGeoVolume* ssdconnector[kssdconnectornumber];
2404   for(Int_t i=0; i<kssdconnectornumber; i++){
2405       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2406                                           0.5*fgkSSDConnectorWidth,
2407                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2408                            +              i*fgkSSDConnectorNiHeight),
2409                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2410       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2411                                        i==0 ? fSSDAlTraceFlexMedium 
2412                                             : fSSDStiffenerConnectorMedium);      
2413       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2414   }
2415   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2416   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2417                        +  fgkSSDConnectorPosition[0]
2418                        -  fgkSSDConnectorSeparation
2419                        -  1.5*fgkSSDConnectorLength,
2420                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2421                        -  fgkSSDConnectorPosition[1]
2422                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2423   ssdconnectortrans[1] = new TGeoTranslation(
2424                        -  ssdstiffenershape->GetDX()
2425                        +  fgkSSDConnectorPosition[0]
2426                        -  0.5*fgkSSDConnectorLength,
2427                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2428                        -  fgkSSDConnectorPosition[1]
2429                        -  ssdconnectorshape[0]->GetDY(),0.0);
2430   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2431                        -  fgkSSDConnectorPosition[0]
2432                        +  fgkSSDConnectorSeparation
2433                        +  1.5*fgkSSDConnectorLength,
2434                           -(ssdstiffenershape->GetDY()
2435                        -  fgkSSDConnectorPosition[1]
2436                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2437   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2438                        -  fgkSSDConnectorPosition[0]
2439                        +  0.5*fgkSSDConnectorLength,
2440                           -(ssdstiffenershape->GetDY()
2441                        -  fgkSSDConnectorPosition[1]
2442                        -  ssdconnectorshape[0]->GetDY()),0.0);
2443   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2444       for(Int_t j=0; j<kssdconnectornumber; j++)
2445             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2446 ////////////////////////////
2447 // Capacitor 1812-330 nF
2448 /////////////////////////// 
2449   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2450   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2451                                                                                          0.5*fgkSSDCapacitor1812Length,
2452                                                                                          0.5*fgkSSDCapacitor1812Width,
2453                                                                                          0.5*fgkSSDCapacitor1812Height,
2454             ssdcapacitor1812origin);
2455   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2456                                              fSSDStiffener1812CapacitorMedium); 
2457   capacitor1812->SetLineColor(fColorAl);
2458   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2459                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2460                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2461   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2462 ////////////////////////////
2463 //Hybrid Wire
2464 ////////////////////////////
2465   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2466                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2467                                  - fgkSSDConnectorSeparation;
2468   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2469                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2470   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2471
2472   Double_t wireangle = TMath::ATan(wirex/wirey);
2473   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2474                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2475   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2476                                              fSSDStiffenerHybridWireMedium); 
2477   hybridwire->SetLineColor(fColorPhynox);
2478   TGeoCombiTrans* hybridwirecombitrans[2];
2479   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2480                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2481                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2482                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2483                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2484                                    ssdstiffenershape->GetDZ()
2485                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2486                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2487   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2488                             0.0,
2489                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2490                             0.0,        
2491                             new TGeoRotation("HybridWireRot2",
2492                           - wireangle*TMath::RadToDeg(),0.,0.));
2493   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2494   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2495   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2496   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2497   ssdhybridlist->Add(ssdhybridcapacitormother);
2498   /////////////////////////////////////////////////////////////
2499   // Deallocating memory
2500   /////////////////////////////////////////////////////////////
2501   delete hybridwirecombitrans[0];
2502   delete hybridwirecombitrans[1];
2503   return ssdhybridlist;
2504   /////////////////////////////////////////////////////////////
2505 }
2506 ///////////////////////////////////////////////////////////////////////////////
2507 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2508   /////////////////////////////////////////////////////////////
2509   // SSD Cooling Block System
2510   /////////////////////////////////////////////////////////////
2511   // SSD Cooling Block and Cooling Tube Transformations
2512   /////////////////////////////////////////////////////////////
2513   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2514   localcoolingblockrot->SetAngles(0.,90.,0.);
2515   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2516   TVector3* coolingblocktransvector;
2517   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2518                                                                 + fgkSSDCoolingBlockLength,
2519                                                                   fgkSSDSensorLength
2520                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2521                                                                 - fgkSSDCoolingBlockWidth);
2522   const Int_t kcoolingblocktransnumber = 2;
2523   const Int_t kcoolingblocknumber = 4;
2524   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2525   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2526   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2527   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2528   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2529   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2530                                         0.5*fgkSSDCoolingBlockWidth,
2531                                         fgkSSDCoolingBlockHoleCenter);
2532   TGeoCombiTrans localcoolingtubematrix (*localcoolingtubetrans,*localcoolingtuberot);
2533   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2534   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2535     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2536       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X()+2*coolingtubedistance,
2537                                              j*coolingblocktransvector->Y(),
2538                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2539                                                     + fgkCoolingTubeRmax));
2540       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2541       coolingtubematrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingtubematrix);
2542     }
2543   }
2544   /////////////////////////////////////////////////////////////
2545   // Virtual Volume containing CoolingBlock System   
2546   /////////////////////////////////////////////////////////////
2547   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2548   const Int_t kmothervertexnumber = 16;  
2549   Double_t xmothervertex[kmothervertexnumber];
2550   Double_t ymothervertex[kmothervertexnumber];
2551   ///////////////////////
2552   // Setting the vertices 
2553   ///////////////////////fgkCoolingTubeSupportRmax
2554   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2555   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2556                                    + fgkSSDCoolingBlockWidth;
2557   xmothervertex[2] = coolingblocktransvector->X()
2558                                    + fgkSSDCoolingBlockLength
2559                                    + 4*coolingtubedistance;
2560   ymothervertex[2] = ymothervertex[1];
2561   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2562   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2563   ymothervertex[4] = ymothervertex[0];
2564   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2565   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2566   ymothervertex[6] = ymothervertex[5]; 
2567   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2568                                    - fgkSSDCoolingBlockWidth; 
2569   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2570   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2571                                    - coolingtubedistance;
2572   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2573   ymothervertex[10] = ymothervertex[9];
2574   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2575   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2576   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2577   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2578   ymothervertex[14] = ymothervertex[13];
2579   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2580   //////////////////////////////////////////////////////////
2581   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2582                                                                         xmothervertex,ymothervertex);
2583   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2584                                                                                            + fgkCoolingTubeRmax));
2585   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2586                                                                                            + fgkCoolingTubeRmax));
2587   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2588   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2589   /////////////////////////////////////////////////////////////
2590   // Adding Cooling block to mother volume
2591   /////////////////////////////////////////////////////////////
2592   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2593     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2594   }
2595   /////////////////////////////////////////////////////////////
2596   // Deallocating memory
2597   /////////////////////////////////////////////////////////////
2598   delete coolingblocktransvector;
2599   delete localcoolingblockrot;
2600
2601   return coolingsystemother;
2602 }
2603 /////////////////////////////////////////////////////////////////////////////////
2604 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2605   /////////////////////////////////////////////////////////////
2606   // SSD Flex
2607   /////////////////////////////////////////////////////////////
2608   const Int_t kssdflexlayernumber = 2;
2609   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2610   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2611   const Int_t kmothervertexnumber = 17; 
2612   Double_t xmothervertex[kmothervertexnumber];
2613   Double_t ymothervertex[kmothervertexnumber];
2614   /////////////////////////////////////////////
2615   // Auxiliary variables for vertex positioning
2616   /////////////////////////////////////////////
2617   const Int_t kssdflexboxnumber = 5;
2618   Double_t ssdflexboxlength[kssdflexboxnumber];
2619   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2620                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2621                                           *     fgkSSDChipSeparationLength
2622                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2623                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2624   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2625   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2626                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2627   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2628   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2629                                           -     ssdflexboxlength[1];
2630   Double_t ssdflexboxwidth[kssdflexboxnumber];
2631   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2632   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2633   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2634   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2635   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2636   ///////////////////////
2637   // Setting the vertices 
2638   ///////////////////////
2639   xmothervertex[0]  = 0.0;
2640   xmothervertex[1]  = xmothervertex[0];
2641   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2642   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2643                                         + ssdflexboxlength[4];
2644   xmothervertex[4]  = xmothervertex[3];
2645   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2646   xmothervertex[6]  = xmothervertex[5];
2647   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2648   xmothervertex[8]  = xmothervertex[7];
2649   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2650   xmothervertex[10] = xmothervertex[9]; 
2651   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2652   xmothervertex[12] = xmothervertex[11];
2653   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2654   xmothervertex[14] = xmothervertex[13];
2655   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2656   xmothervertex[16] = xmothervertex[15];
2657   ymothervertex[0]  = 0.0;
2658   ymothervertex[1]  = fgkSSDFlexWidth[1];
2659   ymothervertex[2]  = fgkSSDFlexWidth[0];
2660   ymothervertex[3]  = ymothervertex[2];
2661   ymothervertex[4]  = ymothervertex[0];
2662   ymothervertex[5]  = ymothervertex[4];
2663   ymothervertex[6]  = ssdflexboxwidth[2];
2664   ymothervertex[7]  = ymothervertex[6];
2665   ymothervertex[8]  = ymothervertex[0];
2666   ymothervertex[9]  = ymothervertex[8];
2667   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2668   ymothervertex[11] = ymothervertex[10];
2669   ymothervertex[12] = ymothervertex[0];
2670   ymothervertex[13] = ymothervertex[12];
2671   ymothervertex[14] = ymothervertex[7];
2672   ymothervertex[15] = ymothervertex[14];
2673   ymothervertex[16] = ymothervertex[0];
2674   /////////////////////////////////////////////////////////////
2675   // First Mother Volume containing SSDFlex
2676   /////////////////////////////////////////////////////////////
2677   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2678   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2679                                                                     ymothervertex);
2680   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2681   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2682   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
2683 //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2684 //                                                                                       fSSDAir);
2685   /////////////////////////////////////////////////////////////
2686   // SSDFlex Layer Shapes
2687   /////////////////////////////////////////////////////////////
2688   for(Int_t i=0; i<kssdflexlayernumber; i++){
2689         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2690                                                                    ymothervertex);
2691     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2692         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2693   }
2694   /////////////////////////////////////
2695   // Setting Layers into Mother Volume
2696   /////////////////////////////////////
2697   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2698   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2699                                                                                                  fSSDKaptonFlexMedium};
2700   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2701                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2702   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2703   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2704   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2705         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2706                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2707                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2708         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2709     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2710                                          +                                         fgkSSDFlexHeight[1])); 
2711     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2712   }
2713   return ssdflexmother;
2714 }
2715 /////////////////////////////////////////////////////////////////////////////////
2716 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2717   /////////////////////////////////////////////////////////////
2718   // Method generating SSD End Flex   
2719   /////////////////////////////////////////
2720   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2721                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2722   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2723                                                 * TMath::DegToRad()*ssdflexradiusmax
2724                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2725                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
2726                                                         - 0.1*fgkSSDFlexFullLength;
2727   const Int_t knedges = 20;  
2728   const Int_t karcnumber = 2;
2729   TVector3* vertexposition[karcnumber*(knedges+1)];
2730   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2731   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2732   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2733   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2734                                                                                  - 90.0*TMath::DegToRad()};
2735   TVector3* referencetrans[karcnumber];
2736   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2737                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2738                                                                    radius[0]);
2739   referencetrans[1] = new TVector3(referencetrans[0]->X()
2740                                         +              fgkSSDFlexLength[2],
2741      -              fgkSSDStiffenerHeight);
2742 for(Int_t i=0; i<karcnumber; i++){
2743         for(Int_t j=0; j<knedges+1; j++){
2744                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2745                                                                                                radius[i]*SinD(angle[i]));
2746                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2747         }       
2748   }
2749   ///////////////////////
2750   // Setting the vertices 
2751   ///////////////////////
2752   const Int_t kendflexlayernumber = 4;
2753   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2754   TVector3** vertex[kendflexlayernumber];
2755   for(Int_t i=0; i<kendflexlayernumber; i++) 
2756                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2757   TVector3* transvector[kendflexlayernumber+1];
2758   TVector3* deltatransvector = new TVector3();  
2759   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2760   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2761                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2762   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2763         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2764                                         *                 CosD(fgkSSDFlexAngle),
2765                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2766                                         *         SinD(fgkSSDFlexAngle),0.0);   
2767         *transvector[i] = *transvector[i-1]+*deltatransvector;
2768   }
2769   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2770   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2771   for(Int_t i=0; i<karcnumber; i++){
2772         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2773                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2774                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2775                                               /radius[i];
2776         }
2777   }
2778   for(Int_t i=0; i<kendflexlayernumber; i++){
2779         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2780         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2781         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2782                 if(j<(knedges+1)){
2783                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2784                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2785                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2786                         *vertex[i][j+2] += *referencetrans[0];
2787                         vertex[i][4*(knedges+1)-j+1] = 
2788                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2789                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2790                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2791                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2792                 }
2793                 else{
2794                 
2795                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2796                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2797                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2798                         *vertex[i][j+2] += *referencetrans[1];
2799                         vertex[i][4*(knedges+1)-j+1] = 
2800                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2801                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2802                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2803                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2804            }
2805         }
2806   }
2807   /////////////////////////////////////////////////////////////
2808   // First Mother Volume containing SSDEndFlex
2809   /////////////////////////////////////////////////////////////
2810   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2811   Double_t xmothervertex[kendflexvertexnumber];
2812   Double_t ymothervertex[kendflexvertexnumber];
2813   xmothervertex[0] = vertex[0][0]->X(); 
2814   ymothervertex[0] = vertex[0][0]->Y();
2815   for(Int_t i=1; i<kendflexvertexnumber; i++){
2816         if(i<2*(knedges+1)+2){
2817                 xmothervertex[i] = vertex[3][i]->X();
2818                 ymothervertex[i] = vertex[3][i]->Y();
2819         }
2820         else{
2821                 xmothervertex[i] = vertex[0][i]->X();
2822                 ymothervertex[i] = vertex[0][i]->Y();
2823         }
2824   }
2825   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2826                                                                            xmothervertex,ymothervertex);
2827   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2828   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2829 //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2830 //                                                               ssdendflexmothershape,fSSDAir);        
2831   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
2832   //////////////////////////////////////
2833   // End Flex TGeoXtru Layer Definition 
2834   //////////////////////////////////////
2835   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2836   TGeoVolume* ssdendflex[kendflexlayernumber];
2837   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2838   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2839   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2840   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2841   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2842                                                                                                         fSSDKaptonFlexMedium};
2843   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2844                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2845   for(Int_t i=0; i<kendflexlayernumber; i++){
2846         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2847                 xvertex[i][j] = vertex[i][j]->X();
2848                 yvertex[i][j] = vertex[i][j]->Y();
2849         }
2850   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2851   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2852   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2853   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2854                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2855   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2856   ssdendflexmother->AddNode(ssdendflex[i],1);
2857   }
2858   /////////////////////////////////////////////////////////////
2859   // Deallocating memory
2860   /////////////////////////////////////////////////////////////
2861   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2862   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2863   for(Int_t i=0; i<kendflexlayernumber; i++){
2864         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2865         delete [] vertex[i];
2866   }
2867   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2868   delete deltatransvector;
2869   /////////////////////////////////////////////////////////////
2870   //ssdendflexmother->CheckOverlaps(0.01);
2871   return ssdendflexmother;
2872 }
2873 ///////////////////////////////////////////////////////////////////////////////
2874 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
2875   /////////////////////////////////////////////////////////////
2876   // Method generating the Mounting Block
2877   /////////////////////////////////////////////////////////////  
2878   const Int_t kvertexnumber = 8;
2879   Double_t xvertex[kvertexnumber];
2880   Double_t yvertex[kvertexnumber];
2881   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
2882   xvertex[1] = xvertex[0];
2883   xvertex[2] = -xvertex[0];
2884   xvertex[3] = xvertex[2];
2885   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
2886                          -                                 fgkSSDMountingBlockLength[2]);
2887   xvertex[5] = xvertex[4];
2888   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
2889                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
2890                          -     fgkSSDMountingBlockScrewHoleRadius[0];
2891   xvertex[7] = xvertex[6];
2892   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
2893                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
2894   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
2895   yvertex[2] = yvertex[1]; 
2896   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
2897   yvertex[4] = yvertex[3];
2898   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
2899                          - fgkSSDMountingBlockHeight[0];
2900   yvertex[6] = yvertex[5];
2901   yvertex[7] = yvertex[0];
2902
2903   ///////////////////////////////////////////////////////////////////////
2904   // TGeoXTru Volume definition for Mounting Block Part
2905   ///////////////////////////////////////////////////////////////////////
2906   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
2907   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
2908   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
2909   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
2910   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
2911                                                                           ssdmountingblockshape,
2912                                                                                   fSSDMountingBlockMedium);
2913   ssdmountingblock->SetLineColor(fColorG10);
2914   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
2915   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
2916   TGeoRotation* mountingblockrot = new TGeoRotation();
2917   mountingblockrot->SetAngles(90.,180.,-90.);
2918   mountingblockcombitrans->SetRotation(*mountingblockrot);
2919   /////////////////////////////////////////////////////////////
2920   // Generating the Mounting Block Screw Vertices 
2921   /////////////////////////////////////////////////////////////  
2922   const Int_t kscrewvertexnumber = 15;
2923   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
2924                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
2925                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
2926                                  * TMath::RadToDeg();
2927   Double_t phi0 = 90.+alpha;
2928   Double_t phi = 270.-2*alpha;
2929   Double_t deltaphi = phi/kscrewvertexnumber;   
2930   TVector3* screwvertex[kscrewvertexnumber+1];
2931   for(Int_t i=0; i<kscrewvertexnumber+1; i++)   
2932         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
2933                                    *CosD(phi0+i*deltaphi),
2934                                    fgkSSDMountingBlockScrewHoleRadius[0]
2935                                    *SinD(phi0+i*deltaphi));
2936   Double_t xscrewvertex[kscrewvertexnumber+6];
2937   Double_t yscrewvertex[kscrewvertexnumber+6];
2938   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
2939   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
2940                                   -               fgkSSDMountingBlockScrewHoleEdge);
2941   xscrewvertex[1] = xscrewvertex[0];
2942   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
2943   xscrewvertex[2] = screwvertex[0]->X();
2944   yscrewvertex[2] = yscrewvertex[1];
2945   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
2946         xscrewvertex[i+3] = screwvertex[i]->X();        
2947         yscrewvertex[i+3] = screwvertex[i]->Y();        
2948   } 
2949   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
2950   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
2951   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
2952   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
2953   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
2954   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
2955   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
2956   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
2957                                                         +                                  fgkSSDMountingBlockHeight[2]);
2958   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
2959                                                                                 ssdmountingblockscrewshape,
2960                                                                                             fSSDMountingBlockMedium);
2961   ssdmountingblockscrew->SetLineColor(fColorG10);
2962   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
2963   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
2964   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
2965                                                                         -                                yscrewvertex[1],
2966                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
2967                                                                         -                                fgkSSDMountingBlockHeight[2]
2968                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2969                                                                         +                                fgkSSDMountingBlockHeight[2]
2970                                                                         -                                yvertex[0]));
2971   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
2972                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
2973                                                                                                                  yscrewvertex[1]
2974                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2975                                                                                                          +fgkSSDMountingBlockHeight[2]
2976                                                                                                          -yvertex[0]));
2977   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
2978                                                                                                           yscrewvertex[1],
2979                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
2980                                                                         +                                 fgkSSDMountingBlockHeight[2]
2981                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2982                                                                         +                                 fgkSSDMountingBlockHeight[2]
2983                                                                         -                                 yvertex[0]));
2984   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
2985                                                                                                          yscrewvertex[1],
2986                                                                         -                                yscrewvertex[1]
2987                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
2988                                                                         +                                fgkSSDMountingBlockHeight[2]
2989                                                                         -                                yvertex[0]));
2990   TGeoRotation* ssdmountingblockscrewrot[4];
2991   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
2992         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.); 
2993     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.); 
2994     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.); 
2995   for(Int_t i=1; i<4; i++) 
2996         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
2997   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
2998   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);      
2999   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
3000   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
3001                                                          +                                xvertex[0],yscrewvertex[1]
3002                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
3003                                                          +                                fgkSSDMountingBlockHeight[2]
3004                                                          -                                yvertex[0]),0.);      
3005   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
3006   for(Int_t i=0; i<4; i++){
3007         ssdmountingblockscrewmatrix[i] = 
3008                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
3009         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
3010   }
3011   ///////////////////////////////////////////////////////////////////////
3012   // TGeoXtru for Mother Volume 
3013   ///////////////////////////////////////////////////////////////////////
3014   const Int_t kvertexmothernumber = 12;
3015   Double_t xmothervertex[kvertexmothernumber];
3016   Double_t ymothervertex[kvertexmothernumber];
3017   for(Int_t i=0; i<6; i++){
3018         xmothervertex[i] = xvertex[i];
3019         ymothervertex[i] = yvertex[i];
3020   } 
3021   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
3022   ymothervertex[6]  = ymothervertex[5];
3023   xmothervertex[7]  = xmothervertex[6];
3024   ymothervertex[7]  = ymothervertex[4];
3025   xmothervertex[8]  = xmothervertex[7]
3026                                         + 0.5*(fgkSSDMountingBlockLength[1]
3027                                         -          fgkSSDMountingBlockLength[2]);
3028   ymothervertex[8]  = ymothervertex[4];
3029   xmothervertex[9]  = xmothervertex[8];
3030   ymothervertex[9]  = ymothervertex[2];
3031   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
3032   ymothervertex[10] = ymothervertex[1];
3033   xmothervertex[11] = xmothervertex[10];
3034   ymothervertex[11] = ymothervertex[0];  
3035   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
3036   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
3037   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
3038   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3039   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
3040                                                                           ssdmountingblockmothershape,
3041                                                                                   fSSDAir);
3042   /////////////////////////////////////////////////////////////
3043   // Placing the Volumes into Mother Volume 
3044   /////////////////////////////////////////////////////////////
3045   ssdmountingblockmother->AddNode(ssdmountingblock,1);
3046   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
3047   for(Int_t i=0; i<4; i++) 
3048         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
3049                                                                         ssdmountingblockscrewmatrix[i]);
3050   /////////////////////////////////////////////////////////////
3051   // Deallocating memory
3052   /////////////////////////////////////////////////////////////
3053   delete mountingblockrot;
3054   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
3055   delete ssdmountingblockglobalrot; 
3056   delete ssdmountingblockglobaltrans; 
3057   /////////////////////////////////////////////////////////////
3058   return ssdmountingblockmother;
3059 }
3060 ///////////////////////////////////////////////////////////////////////////////
3061  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
3062   /////////////////////////////////////////////////////////////
3063   // Method generating the Mounting Block Clip 
3064   /////////////////////////////////////////////////////////////  
3065   const Int_t kmothervertexnumber = 10;
3066   Double_t xmothervertex[kmothervertexnumber];
3067   Double_t ymothervertex[kmothervertexnumber];
3068   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
3069                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
3070   xmothervertex[1] = xmothervertex[0];
3071   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
3072                                    - fgkMountingBlockClibScrewRadius);
3073   xmothervertex[3] = xmothervertex[2]; 
3074   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
3075   xmothervertex[5] = xmothervertex[4]; 
3076   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
3077   xmothervertex[7] = xmothervertex[6]; 
3078   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
3079   xmothervertex[9] = xmothervertex[8]; 
3080   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
3081                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
3082   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
3083   ymothervertex[2] = ymothervertex[1];
3084   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
3085                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
3086                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
3087   ymothervertex[4] = ymothervertex[3];
3088   ymothervertex[5] = ymothervertex[2];
3089   ymothervertex[6] = ymothervertex[5];
3090   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
3091   ymothervertex[8] = ymothervertex[7];
3092   ymothervertex[9] = ymothervertex[0];
3093
3094   ///////////////////////////////////////////////////////////////////////
3095   // TGeoXTru Volume definition for Mounting Block Clip Part
3096   ///////////////////////////////////////////////////////////////////////
3097   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
3098   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3099   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3100   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3101   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
3102                                                                           ssdmountingblockclipshape,fSSDAir);
3103   ssdmountingblockclip->SetLineColor(4);
3104   ///////////////////////////////////////////////////////////////////////
3105   // TGeoXTru Volume definition for Clip 
3106   ///////////////////////////////////////////////////////////////////////
3107   const Int_t kclipvertexnumber = 6;
3108   Double_t xclipvertex[kclipvertexnumber];
3109   Double_t yclipvertex[kclipvertexnumber];
3110   xclipvertex[0] = xmothervertex[0];
3111   xclipvertex[1] = xclipvertex[0];
3112   xclipvertex[2] = xmothervertex[6];
3113   xclipvertex[3] = xclipvertex[2];
3114   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
3115   xclipvertex[5] = xclipvertex[4];
3116   yclipvertex[0] = ymothervertex[0];
3117   yclipvertex[1] = ymothervertex[1];
3118   yclipvertex[2] = yclipvertex[1];
3119   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
3120   yclipvertex[4] = yclipvertex[3];
3121   yclipvertex[5] = yclipvertex[0];
3122   TGeoXtru* clipshape = new TGeoXtru(2);
3123   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
3124   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
3125   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
3126                                                          +   fgkMountingBlockClibWidth);
3127   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
3128   clip->SetLineColor(18);
3129   ///////////////////////////////////////////////////////////////////////
3130   // Ladder Support Piece  
3131   ///////////////////////////////////////////////////////////////////////
3132   const Int_t ksupportvertexnumber = 4;
3133   Double_t xsupportvertex[ksupportvertexnumber];
3134   Double_t ysupportvertex[ksupportvertexnumber];
3135   xsupportvertex[0] = xclipvertex[5];
3136   xsupportvertex[1] = xsupportvertex[0];
3137   xsupportvertex[2] = xmothervertex[9];
3138   xsupportvertex[3] = xsupportvertex[2];
3139   ysupportvertex[0] = yclipvertex[0];
3140   ysupportvertex[1] = yclipvertex[3];
3141   ysupportvertex[2] = ysupportvertex[1];
3142   ysupportvertex[3] = ysupportvertex[0];
3143   TGeoXtru* supportshape = new TGeoXtru(2);
3144   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
3145   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
3146   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
3147   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
3148   support->SetLineColor(9);
3149   ///////////////////////////////////////////////////////////////////////
3150   // TGeoXTru Volume definition for Screw   
3151   ///////////////////////////////////////////////////////////////////////
3152   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
3153                                                 0.5*fgkMountingBlockClibScrewRadius};
3154   Int_t edgesnumber[2] = {50,6};
3155   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
3156                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
3157   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
3158   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
3159   clipscrew->SetLineColor(12);
3160   TGeoRotation* screwrot = new TGeoRotation();
3161   screwrot->SetAngles(0.,90.,0.);
3162   TGeoTranslation* screwtrans = new TGeoTranslation();
3163   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
3164                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
3165                                                          0.5*fgkSSDMountingBlockWidth+
3166                                                         -0.5*fgkMountingBlockSupportWidth[0]);
3167   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
3168   ///////////////////////////////////////////////////////////////////////
3169   // Placing the Volumes
3170   ///////////////////////////////////////////////////////////////////////
3171   ssdmountingblockclip->AddNode(clip,1);
3172   ssdmountingblockclip->AddNode(support,1);
3173   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
3174   /////////////////////////////////////////////////////////////
3175   // Deallocating memory
3176   /////////////////////////////////////////////////////////////  
3177   delete screwtrans;
3178   delete screwrot;
3179   /////////////////////////////////////////////////////////////
3180   return ssdmountingblockclip;
3181 }
3182 ///////////////////////////////////////////////////////////////////////////////
3183 void AliITSv11GeometrySSD::CreateCoolingTubes() {
3184   /////////////////////////////////////////////////////////////
3185   // Method generating the Cooling Tube 
3186   // sets fcoolingtube and returns list for endladdercoolingtube
3187   /////////////////////////////////////////////////////////////  
3188   TGeoTube *coolingtubeshape[2];
3189   // Ladder Cooling Tubes
3190
3191   // MvL: Simplified cooling tubes
3192   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,0.5*fgkCoolingTubeLength);
3193   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,coolingtubeshape[0]->GetDz());
3194
3195   // End Ladder Cooling Tubes   
3196   TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
3197   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3198     endladdercoolingtubeshape[i] = new  TGeoTube*[2];
3199
3200   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
3201   endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3202                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0] - sensZshift));
3203   endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3204                                                  endladdercoolingtubeshape[0][0]->GetDz());
3205   endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
3206                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1] + sensZshift));
3207   endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
3208                                                  endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
3209   // Ladder Cooling Tubes
3210   TGeoVolume* coolingtube[2];
3211   coolingtube[0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0], fSSDCoolingTubePhynox);
3212   coolingtube[1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[1], fSSDCoolingTubeWater);
3213   coolingtube[0]->SetLineColor(fColorPhynox);
3214   coolingtube[1]->SetLineColor(fColorWater);
3215
3216   // End Ladder Cooling Tubes   
3217   TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
3218   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
3219     endladdercoolingtube[i] = new TGeoVolume*[2];
3220   endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
3221                                               endladdercoolingtubeshape[0][0],
3222                                               fSSDCoolingTubePhynox);
3223   endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
3224                                               endladdercoolingtubeshape[0][1],
3225                                               fSSDCoolingTubeWater);
3226   endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
3227                                               endladdercoolingtubeshape[1][0],
3228                                               fSSDCoolingTubePhynox);
3229   endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
3230                                               endladdercoolingtubeshape[1][1],
3231                                               fSSDCoolingTubeWater);
3232   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
3233     endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
3234     endladdercoolingtube[i][1]->SetLineColor(fColorWater);
3235   }
3236   
3237   /////////////////////////////////////////////////////////////
3238   // Virtual Volume containing Cooling Tubes
3239   /////////////////////////////////////////////////////////////
3240   // Ladder Cooling Tubes
3241   TGeoTube* virtualcoolingtubeshape = new TGeoTube(coolingtubeshape[1]->GetRmin(),
3242                                                    coolingtubeshape[0]->GetRmax(),
3243                                                    coolingtubeshape[0]->GetDz());
3244   fcoolingtube = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape, fSSDAir);
3245   fcoolingtube->AddNode(coolingtube[0],1);
3246   fcoolingtube->AddNode(coolingtube[1],1);
3247
3248   // End Ladder Cooling Tubes
3249   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
3250   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
3251     endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
3252                                                        endladdercoolingtubeshape[i][0]->GetRmax(),
3253                                                        endladdercoolingtubeshape[i][0]->GetDz());
3254   fendladdercoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
3255                                             endladdervirtualcoolingtubeshape[0],
3256                                             fSSDAir);
3257   fendladdercoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
3258                                             endladdervirtualcoolingtubeshape[1],
3259                                             fSSDAir);
3260   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
3261   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
3262   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
3263   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);  
3264 }
3265 ///////////////////////////////////////////////////////////////////////////////
3266 TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
3267   /////////////////////////////////////////////////////////////
3268   // Method generating SSD Cooling Block    
3269   /////////////////////////////////////////////////////////////
3270   const Int_t kvertexnumber = 8;
3271   ///////////////////////////////////////
3272   // Vertex Positioning for TGeoXTru
3273   ///////////////////////////////////////
3274   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
3275   vertexposition[0] = new TVector3(0.0,0.0);
3276   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1]);
3277   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
3278                                           vertexposition[1]->Y());
3279   vertexposition[3] = new TVector3(vertexposition[2]->X(),
3280                                           vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2]);
3281   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y());
3282   vertexposition[5] = new TVector3(vertexposition[4]->X(),
3283                                         + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1]);
3284   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
3285                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
3286                                         - fgkSSDCoolingBlockHoleLength[0]
3287                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
3288                                           fgkSSDCoolingBlockHeight[0]
3289                                         - fgkSSDCoolingBlockHoleRadius[1],
3290                                           fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0]);
3291   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
3292                                         - fgkSSDCoolingBlockHoleLength[0]),
3293                                           vertexposition[6]->Y());
3294   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
3295                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
3296   Double_t phi = 180.-alpha;
3297   Double_t psi = 180.+2.*alpha;
3298   Double_t deltapsi = psi/nedges;
3299   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
3300   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
3301                                                   fgkSSDCoolingBlockHoleCenter);
3302   for(Int_t i=0; i<nedges+1; i++){
3303         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
3304                                                                                                radius*SinD(phi+i*deltapsi));
3305    *vertexposition[kvertexnumber+i] += (*transvector);
3306   }
3307   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
3308   for(Int_t i=0; i<kvertexnumber; i++)
3309     vertexposition[kvertexnumber+nedges+1+i] = 
3310                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
3311   ///////////////////////////////////////////////////////////////////////
3312   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
3313   ///////////////////////////////////////////////////////////////////////
3314   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
3315   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
3316   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
3317   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
3318         xvertexpoints[i] = vertexposition[i]->X();
3319         yvertexpoints[i] = vertexposition[i]->Y();
3320   } 
3321   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
3322                                                                                         yvertexpoints);
3323   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
3324   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
3325   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
3326                                                                           ssdcoolingblockshape,
3327                                                                                   fSSDAlCoolBlockMedium);
3328   ssdcoolingblock->SetLineColor(fColorAl);
3329   /////////////////////////////////////////////////////////////
3330   // Deallocating memory
3331   /////////////////////////////////////////////////////////////
3332   delete [] vertexposition;
3333   delete [] xvertexpoints;
3334   delete [] yvertexpoints;
3335   /////////////////////////////////////////////////////////////
3336   return ssdcoolingblock;
3337 }
3338 /////////////////////////////////////////////////////////////////////////////////
3339 void AliITSv11GeometrySSD::GetSSDChipCables(TGeoVolume *&cableL, TGeoVolume *&cableR, Double_t SSDChipCablesHeight, Int_t nedges){
3340   ///////////////////////////////////////////////////////
3341   static const Int_t kssdchipcablesnumber    = 2;  // Number of cables: left and right
3342   static const Int_t kssdchipcableslaynumber = 2;  // Number of layers: Al and Kapton
3343   static const Int_t kvertexnumber                        = 4*(nedges+1)+4;
3344   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
3345   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
3346   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeight
3347                                                  -  fgkSSDChipCablesHeight[0]
3348                                                  -  fgkSSDChipCablesHeight[1]);
3349   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
3350   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
3351   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
3352                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
3353                                                           - ssdchipcablesradius[0]
3354                                                           - fgkSSDChipCablesWidth[1]
3355                                                           - fgkSSDChipCablesWidth[2]);
3356   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
3357                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
3358                                                           +      fgkSSDChipCablesHeight[1]
3359                                                           +      fgkSSDSensorHeight);
3360   ///////////////////////////////////////////////////////
3361   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
3362   ///////////////////////////////////////////////////////
3363   TVector3** vertexposition[kssdchipcableslaynumber];
3364   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
3365                                                                                                   new TVector3*[4*(nedges+1)+4];
3366   Double_t ratio[4];
3367   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
3368   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
3369                    /  ssdchipcablesradius[0]; 
3370   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
3371                    /  ssdchipcablesradius[0];
3372   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
3373                    +  fgkSSDChipCablesHeight[1])
3374                    /  ssdchipcablesradius[0];
3375   Double_t phi = 180.;
3376   Double_t deltaphi = 180./nedges;
3377   Double_t angle = 0.0;
3378   Double_t **xvertexpoints = new Double_t*[kssdchipcableslaynumber];
3379   Double_t **yvertexpoints = new Double_t*[kssdchipcableslaynumber];
3380   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3381         xvertexpoints[i] = new Double_t[kvertexnumber];
3382         yvertexpoints[i] = new Double_t[kvertexnumber];
3383   }  
3384   TVector3* vertex = new TVector3();
3385   TVector3* transvector[kssdchipcableslaynumber];
3386   transvector[0] = new TVector3(fgkSSDChipWidth,
3387                                                                 SSDChipCablesHeight-ssdchipcablesradius[0]);
3388   transvector[1] = new TVector3();
3389   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcablesnumber];
3390   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcablesnumber];
3391   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcablesnumber] = 
3392                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
3393                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
3394   for(Int_t k=0; k<kssdchipcablesnumber; k++){
3395         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
3396         transvector[1]->SetY(ssdchipcablesradius[0]
3397                                  +               fgkSSDChipCablesHeight[0]
3398                                  +               fgkSSDChipCablesHeight[1]);  
3399         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3400                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeight
3401                                                          - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1]);
3402                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeight
3403                                                          - i*fgkSSDChipCablesHeight[0]);
3404                 vertexposition[i][2*(nedges+1)+2] = 
3405                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
3406                                 +                                fgkSSDChipCablesWidth[1]
3407                                 +                                fgkSSDChipCablesWidth[2],
3408                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
3409                                 +                                fgkSSDChipCablesHeight[1]));
3410         vertexposition[i][2*(nedges+1)+3] = 
3411                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
3412                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
3413                                 -                                fgkSSDChipCablesHeight[i]);
3414             for(Int_t j=0; j<nedges+1; j++){            
3415                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
3416                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
3417                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
3418                         vertexposition[0][(nedges+1)*i+j+2] = 
3419                                                 new TVector3(*vertex+*transvector[i]);
3420                         vertexposition[1][(nedges+1)*i+j+2] = 
3421                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
3422                                                                          vertex->Y()*ratio[2*i]+transvector[i]->Y());
3423                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
3424                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
3425                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
3426                                                 new TVector3(vertex->X()*ratio[2*i+1]
3427                                                         +                        transvector[i]->X(),
3428                                                                                  vertex->Y()*ratio[2*i+1]
3429                                                         +                transvector[i]->Y());
3430                 }
3431         }
3432         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
3433                 for(Int_t j=0; j<kvertexnumber; j++){   
3434                         xvertexpoints[i][j] = vertexposition[i][j]->X();
3435                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
3436                 }
3437                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
3438                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
3439                                                                                 xvertexpoints[i],yvertexpoints[i]);
3440                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3441                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3442                 ssdchipcable[kssdchipcablesnumber*k+i] = 
3443                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
3444                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
3445                                                           (kssdchipcablesnumber*k+i)%2==0?
3446                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
3447                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
3448         }
3449         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
3450                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
3451   }
3452   /////////////////////////////////////////////////////////////
3453   // Mother Volume definition 
3454   /////////////////////////////////////////////////////////////
3455   static const Int_t kmothervertexnumber = 8;
3456   Double_t xmothervertex[kmothervertexnumber];
3457   Double_t ymothervertex[kmothervertexnumber];
3458   xmothervertex[0] = xvertexpoints[0][1];
3459   ymothervertex[0] = yvertexpoints[0][1];
3460   xmothervertex[1] = xvertexpoints[0][2+nedges/2];
3461   ymothervertex[1] = yvertexpoints[0][1];
3462   xmothervertex[2] = xvertexpoints[0][2+nedges/2];
3463   ymothervertex[2] = yvertexpoints[0][2+nedges];
3464   xmothervertex[3] = xvertexpoints[0][3+nedges];
3465   ymothervertex[3] = yvertexpoints[0][3+nedges];
3466   xmothervertex[4] = xvertexpoints[0][3+2*nedges];
3467   ymothervertex[4] = yvertexpoints[0][3+2*nedges];
3468   xmothervertex[5] = xvertexpoints[0][4+2*nedges];
3469   ymothervertex[5] = yvertexpoints[0][4+2*nedges];
3470   xmothervertex[6] = xvertexpoints[1][5+2*nedges];
3471   ymothervertex[6] = yvertexpoints[1][5+2*nedges];
3472   xmothervertex[7] = xvertexpoints[0][1];
3473   ymothervertex[7] = yvertexpoints[1][5+2*nedges];
3474   TGeoXtru *ssdchipcablemothershape = new TGeoXtru(2);
3475   ssdchipcablemothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
3476   ssdchipcablemothershape->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
3477   ssdchipcablemothershape->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
3478
3479   cableL = new TGeoVolume("SSDChipCableMotherLeft",ssdchipcablemothershape,fSSDAir);
3480   cableR = new TGeoVolume("SSDChipCableMotherRight",ssdchipcablemothershape,fSSDAir);
3481
3482   cableL->AddNode(ssdchipcable[0],1);
3483   cableL->AddNode(ssdchipcable[1],1);
3484   cableR->AddNode(ssdchipcable[2],1);
3485   cableR->AddNode(ssdchipcable[3],1);  
3486
3487   /////////////////////////////////////////////////////////////
3488   // Deallocating memory
3489   /////////////////////////////////////////////////////////////
3490   for(Int_t i=0; i<kssdchipcableslaynumber;i++){
3491         delete [] xvertexpoints[i];
3492         delete [] yvertexpoints[i];
3493   }
3494   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
3495   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
3496   delete vertex; 
3497   /////////////////////////////////////////////////////////////
3498 }
3499 //_____________________________________________________________________________
3500 TGeoVolume* AliITSv11GeometrySSD::GetSSDChip() const{
3501   /////////////////////////////////////////////////////////////
3502   // SSD Chip Assembly Generation    
3503   /////////////////////////////////////////////////////////////
3504   TGeoBBox* ssdchipcompshape[2];
3505   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
3506                                                                                 0.5*fgkSSDChipLength,
3507                                                                                 0.5*fgkSSDChipWidth,
3508                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
3509   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
3510                                                                                 0.5*fgkSSDChipLength,
3511                                                                                 0.5*fgkSSDChipWidth,
3512                                                                                 0.5*fgkSSDChipGlueHeight);
3513   TGeoVolume* ssdchipcomp[2];
3514   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
3515   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
3516                                                                   fSSDChipGlueMedium);
3517   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
3518   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
3519   TGeoTranslation* ssdchipcomptrans[2];
3520   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
3521   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
3522   /////////////////////////////////////////////////////////////
3523   // Virtual Volume containing SSDChip   
3524   /////////////////////////////////////////////////////////////
3525   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
3526                                                                                                                  0.5*fgkSSDChipWidth,
3527                                                                                                                  0.5*fgkSSDChipHeight);
3528   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
3529   /////////////////////////////////////////////////////////////
3530   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
3531   return ssdchip;
3532 }
3533 /////////////////////////////////////////////////////////////////////////////////
3534 TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
3535   /////////////////////////////////////////////////////////////
3536   // Method returning a List containing pointers to Ladder Cable Volumes    
3537   //
3538   // Return list contains 3 assemblies: cable box, cable arb shape and the end part of the cable
3539   //                                    each contains 2 volumes, one for polyamide and one for aluminium
3540   /////////////////////////////////////////////////////////////
3541   const Int_t kladdercablesegmentnumber = 2;
3542   /////////////////////////////////////////
3543   // LadderSegmentBBox Volume
3544   /////////////////////////////////////////
3545   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
3546   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
3547                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
3548
3549
3550   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
3551                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
3552   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
3553
3554   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
3555                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
3556                                                                                            0.5*fgkSSDFlexWidth[0],
3557                                                                                            0.5*fgkSSDLadderCableWidth,
3558                                                                        0.5*fgkSSDFlexHeight[0]),
3559                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
3560                                                                                            0.5*fgkSSDFlexWidth[0],
3561                                                                                            0.5*fgkSSDLadderCableWidth,
3562                                                                                            fgkSSDFlexHeight[0]
3563                                                                                            +0.5*fgkSSDFlexHeight[1])
3564                                                                                    };
3565   static TGeoVolume* laddercablesegmentbboxassembly =                                              new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
3566   static TGeoVolume* laddercablesegmentarbassembly = 
3567                                                    new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
3568
3569   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
3570   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
3571
3572   if (laddercablesegmentbboxshape[0] == 0) { 
3573     // Initialise static shapes and volumes 
3574   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
3575                                                   new TGeoBBox(laddercablesegmentbboxshapename[i],
3576                                                                            0.5*fgkSSDFlexWidth[0],
3577                                                                            0.5*fgkSSDLadderCableWidth,
3578                                                                            0.5*fgkSSDFlexHeight[i]); 
3579
3580   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3581                         laddercablesegmentbbox[i] =
3582                                                   new TGeoVolume(laddercablesegmentbboxname[i],
3583                                                                                  laddercablesegmentbboxshape[i],
3584                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3585             fSSDKaptonLadderCableMedium));
3586                         laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3587                                                                                                                    fColorPolyhamide);
3588   }
3589   
3590   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3591                 laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
3592                                                                                             laddercablesegmentbboxtrans[i]);
3593 /////////////////////////////////////////
3594 // LadderSegmentArb8 Volume
3595 /////////////////////////////////////////
3596   const Int_t kvertexnumber = 4;
3597   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
3598   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
3599                                                                                                   new TVector3*[kvertexnumber];
3600 //Shape Vertex Positioning
3601   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3602         laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0]);
3603         laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
3604                                                                                                                   i*fgkSSDFlexHeight[0]);
3605         laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
3606                                                                                    +                         fgkSSDFlexHeight[1]
3607                                                                                    +                      i*fgkSSDFlexHeight[0]);
3608         laddercablesegmentvertexposition[i][3] = 
3609                                                    new TVector3(laddercablesegmentvertexposition[i][1]->X(),
3610                                                                                 laddercablesegmentvertexposition[i][2]->Y());
3611   }
3612   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
3613                                                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
3614   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
3615                                         {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
3616
3617   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
3618                                         GetArbShape(laddercablesegmentvertexposition[i],
3619                                                                 laddercablesegmentwidth[i],
3620                                                                 fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
3621                                                                 laddercablesegmentarbshapename[i]);
3622   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
3623                                                   {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
3624
3625   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
3626                          laddercablesegmentarb[i] =
3627                                                    new TGeoVolume(laddercablesegmentarbname[i],
3628                                                                                   laddercablesegmentarbshape[i],
3629                                                                                   (i==0?fSSDAlTraceLadderCableMedium:
3630             fSSDKaptonLadderCableMedium)); 
3631                          laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
3632                                                                                                                    fColorPolyhamide);
3633 }
3634   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
3635   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
3636                                                                                                  90.,90,-90.);   
3637   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
3638                                                                                                   0.,90.,0.);    
3639   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
3640                                                    new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
3641                                                            0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
3642                                                          + fgkSSDFlexWidth[0],0.,0.,
3643                                                    new TGeoRotation((*laddercablesegmentarbrot[1])
3644                                                      *(*laddercablesegmentarbrot[0])));
3645   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
3646   laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
3647                                                                                    laddercablesegmentarbcombitrans);
3648   }  // End of static initialisations
3649 /////////////////////////////////////////
3650 // End Ladder Cable Volume
3651 // Note: this part depends explicitly on the length passed as an argument to the function
3652 /////////////////////////////////////////
3653   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
3654   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
3655                                 {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
3656   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
3657                                                   new TGeoBBox(ladderendcablesegmentbboxshapename[i],
3658                                                                            0.5*ssdendladdercablelength,
3659                                                                            0.5*fgkSSDLadderCableWidth,
3660                                                                            0.5*fgkSSDFlexHeight[i]);
3661   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
3662                                                   {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
3663   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
3664   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
3665                         ladderendcablesegmentbbox[i] =
3666                                                   new TGeoVolume(ladderendcablesegmentbboxname[i],
3667                                                                                  ladderendcablesegmentbboxshape[i],
3668                                                                                  (i==0?fSSDAlTraceLadderCableMedium:
3669             fSSDKaptonLadderCableMedium));
3670                         ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
3671                                                                                                                    fColorPolyhamide);
3672   }
3673   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
3674   ladderendcablesegmentbboxtrans[0] = 
3675                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
3676                                                                                            0.5*ssdendladdercablelength,
3677                                                                                            0.5*fgkSSDLadderCableWidth,
3678                                                                                            0.5*fgkSSDFlexHeight[0]);
3679   ladderendcablesegmentbboxtrans[1] = 
3680                                                    new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
3681                                                                                            0.5*ssdendladdercablelength,
3682                                                                                            0.5*fgkSSDLadderCableWidth,
3683                                                                                            fgkSSDFlexHeight[0]
3684                                                                                            +0.5*fgkSSDFlexHeight[1]);
3685   TGeoVolume* ladderendcablesegmentbboxassembly = 
3686                                                    new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
3687   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
3688                 ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
3689                                                                                             ladderendcablesegmentbboxtrans[i]);
3690 /////////////////////////////////////////
3691   TList* laddercablesegmentlist = new TList();
3692   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
3693   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
3694   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
3695   return laddercablesegmentlist;
3696 }
3697
3698 /////////////////////////////////////////////////////////////////////////////////
3699 TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
3700   /////////////////////////////////////////////////////////////
3701   // Method generating Ladder Cable of given length (n modules + end)
3702   // Called by GetLadderCableAssembly
3703   /////////////////////////////////////////////////////////////
3704   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
3705   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
3706   for(Int_t i=0; i<n; i++){
3707          TGeoTranslation* laddercabletrans = new TGeoTranslation(
3708                                                         i*(fgkCarbonFiberJunctionWidth),
3709                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3710                                                         i*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
3711     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
3712     if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
3713  
3714   }
3715   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
3716                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3717                                                              fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
3718                                                              (n-1)*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]));
3719   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
3720   return laddercable;
3721 }
3722 /////////////////////////////////////////////////////////////////////////////////
3723 TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
3724   ///////////////////////////////////////////////////////////////////
3725   // Main method generating Ladder Cable bundles containing n cables
3726   ///////////////////////////////////////////////////////////////////
3727   Double_t totalLength = ssdendladdercablelength+(n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0];
3728   Double_t cableOrig[3] = {0.5*totalLength,1.5*fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],0.5*n*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1])};
3729   TGeoBBox *laddercableshape = new TGeoBBox(0.5*totalLength,0.5*fgkSSDLadderCableWidth,0.5*n*(fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]),cableOrig);
3730   TGeoVolume* laddercable = new TGeoVolume("LadderCableMother", laddercableshape, fSSDAir);
3731   char laddercabletransname[100];
3732   for(Int_t i=0; i<n; i++){ 
3733         sprintf(laddercabletransname,"LadderCableTrans%i",i+1);
3734         laddercable->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
3735                              new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0,0));
3736   }
3737   return laddercable;
3738 }
3739 /////////////////////////////////////////////////////////////////////////////////
3740 TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
3741   /////////////////////////////////////////////////////////////
3742   // Method generating Ladder Cable List Assemblies  
3743   // containing two cables bundles, i.e. P+N readout for one endcap
3744   /////////////////////////////////////////////////////////////  
3745   const Int_t kladdercableassemblynumber = 2; 
3746   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
3747   TGeoVolume* ladderCable[kladdercableassemblynumber];
3748   char laddercableassemblyname[100];
3749   TList* laddercableassemblylist = new TList();
3750   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
3751         sprintf(laddercableassemblyname,"LadderCableAssembly%i",i+1);
3752         ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
3753         ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
3754                                          new TGeoCombiTrans((n-1)
3755                                          *       fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
3756                                              2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
3757                                                                                         0.,new TGeoRotation("",180,0.,0.)));
3758         laddercableassemblylist->Add(ladderCable[i]);
3759 }
3760   return laddercableassemblylist;
3761 }
3762 ///////////////////////////////////////////////////////////////////////////////
3763 void AliITSv11GeometrySSD::SetLadderSegment(){
3764   /////////////////////////////////////////////////////////////
3765   // Method Generating Ladder Segment Array
3766   /////////////////////////////////////////////////////////////
3767   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1"); 
3768   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2"); 
3769
3770   /* MvL: tried to create mother volume. Requires changes in all rotations, bc xtru is always along z-axis
3771   TGeoXtru *laddersegmentshape = new TGeoXtru(2);
3772   static const Int_t ntrianglevtx = 3;
3773   Double_t xtrianglevtx[ntrianglevtx]={-0.5*fgkCarbonFiberTriangleLength,fgkCarbonFiberTriangleLength, 0};
3774   Double_t ytrianglevtx[ntrianglevtx]={0, 0, fgkCarbonFiberTriangleLength * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad())};
3775   laddersegmentshape->DefinePolygon(ntrianglevtx,xtrianglevtx,ytrianglevtx);
3776   laddersegmentshape->DefineSection(0,0);
3777   laddersegmentshape->DefineSection(1,fgkCarbonFiberJunctionWidth);  // MVL
3778   fladdersegment[0] = new TGeoVolume("LadderSegment1",laddersegmentshape,fSSDAir);      
3779   fladdersegment[1] = new TGeoVolume("LadderSegment2",laddersegmentshape,fSSDAir);      
3780   */
3781
3782   if(!fCreateMaterials) CreateMaterials();
3783   if(!fTransformationMatrices) CreateTransformationMatrices();
3784   if(!fBasicObjects) CreateBasicObjects();
3785   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
3786   // Placing Carbon Fiber Support       
3787         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
3788                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3789                                                                                         fcarbonfibersupportmatrix[j]);  
3790                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3791                                                                                         fcarbonfibersupportmatrix[j]);
3792   }
3793   // Placing Carbon Fiber Junction
3794         for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++) {
3795         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
3796                                                                    fcarbonfiberjunctionmatrix[j]);
3797   }
3798   // Placing Carbon Fiber Lower Support
3799     for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++) {
3800                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
3801                                                            fcarbonfiberlowersupportrans[j]);    
3802     }
3803   // Placing SSD Sensor Support
3804     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
3805         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
3806                                                                      fssdsensorsupport[1][i],
3807                                                            j+1,fssdsensorsupportmatrix[j]);
3808   // Placing SSD Cooling Tube Support 
3809         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
3810                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3811                                                                    fcoolingtubesupportmatrix[j]);
3812   // Placing SSD Cooling Tube  
3813         fladdersegment[i]->AddNode(fcoolingtube,1,fcoolingtubematrix[0]);
3814         fladdersegment[i]->AddNode(fcoolingtube,2,fcoolingtubematrix[1]);
3815   // Placing SSD Hybrid
3816     switch(i){
3817         case 0: 
3818                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
3819                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3820                 break;
3821     case 1:
3822                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
3823                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
3824                 break;
3825         }
3826         // Placing Cooling Block System
3827       fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
3828         // Placing SSD Flex
3829       for(Int_t j=0; j<fgkflexnumber; j++){
3830         fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
3831         fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
3832       }
3833    }
3834 }
3835 ///////////////////////////////////////////////////////////////////////////////
3836 void AliITSv11GeometrySSD::SetEndLadderSegment(){
3837   /////////////////////////////////////////////////////////////
3838   // Method Generating End Ladder
3839   /////////////////////////////////////////////////////////////
3840   // End Ladder Carbon Fiber Junction 
3841   /////////////////////////////////////////////////////////////
3842   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
3843   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
3844   if(!fCreateMaterials) CreateMaterials();
3845   if(!fTransformationMatrices) CreateTransformationMatrices();
3846   if(!fBasicObjects) CreateBasicObjects();
3847   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
3848         for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
3849                 fendladdersegment[i]->AddNode(j==2 ? 
3850                                                         fendladdercarbonfiberjunction[i][1] : 
3851                                                         fendladdercarbonfiberjunction[i][0],
3852                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
3853   }
3854   /////////////////////////////////////////////////////////////
3855   // End Ladder Carbon Fiber Support 
3856   /////////////////////////////////////////////////////////////
3857   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
3858       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
3859                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
3860                   fendladdercarbonfibermatrix[i][j]);   
3861           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
3862                   fendladdercarbonfibermatrix[i][j]);   
3863       }
3864   /////////////////////////////////////////////////////////////
3865   // End Ladder Mounting Block
3866   /////////////////////////////////////////////////////////////
3867   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3868        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
3869                                      fendladdermountingblockcombitrans[i]);
3870   /////////////////////////////////////////////////////////////
3871   // End Ladder Mounting Block Clip
3872   /////////////////////////////////////////////////////////////
3873   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
3874         for(Int_t j=0; j<2; j++)
3875                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
3876                                               fendladdermountingblockclipmatrix[i][j]);
3877   /////////////////////////////////////////////////////////////
3878   // End Ladder Lower Supports
3879   /////////////////////////////////////////////////////////////
3880   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
3881                                 fendladderlowersupptrans[0]);
3882   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
3883                                 fendladderlowersupptrans[1]);
3884   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
3885                                 fendladderlowersupptrans[2]);
3886   /////////////////////////////////////////////////////////////
3887   // End Ladder Cooling Tube Support
3888   /////////////////////////////////////////////////////////////
3889   for(Int_t i=0; i<2; i++) 
3890         for(Int_t j=0; j<(i==0?4:2); j++)   
3891                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
3892                                               fendladdercoolingtubesupportmatrix[i][j]);
3893   /////////////////////////////////////////////////////////////
3894   // End Ladder Cooling Tube Support
3895   /////////////////////////////////////////////////////////////
3896   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]); 
3897   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);
3898   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[1][0]);
3899   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[1][1]); 
3900 }
3901 ///////////////////////////////////////////////////////////////////////////////
3902 void AliITSv11GeometrySSD::SetLadder(){
3903   /////////////////////////////////////////////////////////////
3904   // Method Generating Ladder of Layer 5 and 6
3905   /////////////////////////////////////////////////////////////  
3906   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
3907                                                                                                 fgkSSDLay6SensorsNumber};
3908   /////////////////////////////////////////////////////////////////////////////                                         
3909   /// Generating Ladder Mother Volume Containing Ladder 
3910   /////////////////////////////////////////////////////////////////////////////          
3911   TGeoXtru* laddershape[fgkladdernumber];       
3912   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
3913   const Int_t kmothervertexnumber = 8;  
3914   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
3915   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
3916   ///////////////////////
3917   // Setting the vertices 
3918   ///////////////////////
3919   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
3920                                                                 * (fgkSSDFlexHeight[0]+fgkSSDFlexHeight[1]);
3921   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
3922   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
3923   xmothervertex[0][1] = xmothervertex[0][0];
3924   ymothervertex[0][1] = 0.0;
3925   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
3926                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
3927   ymothervertex[0][2] = ymothervertex[0][1];
3928   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
3929   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
3930   xmothervertex[0][4] = -xmothervertex[0][3];
3931   ymothervertex[0][4] = ymothervertex[0][3];
3932   xmothervertex[0][5] = -xmothervertex[0][2];
3933   ymothervertex[0][5] = ymothervertex[0][2];
3934   xmothervertex[0][6] = -xmothervertex[0][1];
3935   ymothervertex[0][6] = ymothervertex[0][1];
3936   xmothervertex[0][7] = -xmothervertex[0][0];
3937   ymothervertex[0][7] = ymothervertex[0][0];
3938   for(Int_t i=0; i<kmothervertexnumber; i++){
3939         xmothervertex[1][i] = xmothervertex[0][i];
3940         ymothervertex[1][i] = ymothervertex[0][i];
3941   }
3942 ///////////////////////////////////////////////////////////////////////////
3943 // Disalignement Mother Volume corrections 25/08/08
3944 ///////////////////////////////////////////////////////////////////////////
3945   TGeoXtru* leftladdershape1[fgkladdernumber];  
3946   TGeoXtru* leftladdershape2[fgkladdernumber];  
3947   TGeoXtru* centersensorladdershape[fgkladdernumber];   
3948   TGeoXtru* rightladdershape1[fgkladdernumber]; 
3949   TGeoXtru* rightladdershape2[fgkladdernumber]; 
3950   for(Int_t i=0; i<fgkladdernumber; i++){
3951     leftladdershape1[i] = new TGeoXtru(2);
3952     leftladdershape2[i] = new TGeoXtru(2);
3953     centersensorladdershape[i] = new TGeoXtru(2);
3954     rightladdershape1[i] = new TGeoXtru(2);
3955     rightladdershape2[i] = new TGeoXtru(2);
3956   }
3957   //////////////////////////////////////
3958   // Setting the names for shapes  
3959   //////////////////////////////////////
3960   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
3961   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
3962   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
3963   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
3964   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
3965   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
3966   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
3967   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
3968   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
3969   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
3970   //////////////////////////////////////
3971   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
3972   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
3973   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
3974   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
3975   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
3976   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
3977   for(Int_t i=0; i<fgkladdernumber; i++) {
3978     for(Int_t j=0; j<kmothervertexnumber; j++){
3979       xcentersensorvertex[i][j] = xmothervertex[i][j];
3980       ycentersensorvertex[i][j] = ymothervertex[i][j];
3981       xend1laddervertex[i][j] = xmothervertex[i][j];
3982       yend1laddervertex[i][j] = ymothervertex[i][j];
3983       xend2laddervertex[i][j] = xmothervertex[i][j];
3984       yend2laddervertex[i][j] = ymothervertex[i][j];
3985     }
3986     // Add some space around sensors to accommodate misalignments
3987     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
3988     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
3989     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
3990     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
3991     
3992     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
3993     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
3994     
3995     // Center Ladder Piece
3996     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
3997                                               ycentersensorvertex[i]);
3998     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
3999                                                  + 1.45*fgkSSDMountingBlockWidth);
4000     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
4001                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4002                                                  - 2.4*fgkSSDMountingBlockWidth);
4003
4004     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
4005
4006     // Cuts off first corner (neg x)
4007     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
4008     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
4009     // Cuts off last part (pos x)
4010     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
4011     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
4012
4013     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
4014                                        yend1laddervertex[i]);
4015     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
4016     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4017                                          - fgkEndLadderMountingBlockPosition[0]);
4018     
4019     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
4020                                        yend2laddervertex[i]);
4021     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
4022                                          - fgkEndLadderMountingBlockPosition[0]); 
4023     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
4024                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
4025
4026     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
4027                                         yend1laddervertex[i]);
4028     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4029                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
4030                                         -2.4*fgkSSDMountingBlockWidth);
4031     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4032                                         + fgkEndLadderMountingBlockPosition[1]);
4033
4034     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
4035                                         yend2laddervertex[i]);
4036     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
4037                                            + fgkEndLadderMountingBlockPosition[1]);
4038     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
4039                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
4040   }
4041   TGeoCompositeShape* laddershapecontainer[2];
4042   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
4043                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
4044                                                    "+Lay5CenterSensorContainer"
4045                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
4046   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
4047                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
4048                                                    "+Lay6CenterSensorContainer"
4049                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
4050   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
4051   for(Int_t i=0; i<fgkladdernumber; i++){
4052     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
4053     fladder[i]->SetLineColor(4);
4054   }
4055 ///////////////////////////////////////////////////////////////////////////
4056  if(!fCreateMaterials) CreateMaterials();
4057  if(!fTransformationMatrices) CreateTransformationMatrices();
4058  if(!fBasicObjects) CreateBasicObjects();
4059  SetLadderSegment(); 
4060  SetEndLadderSegment();
4061   for(Int_t i=0; i<fgkladdernumber; i++){
4062         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
4063         //////////////////////////                                              
4064         /// Placing Ladder Segment
4065         //////////////////////////              
4066                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
4067                                                                      fladdersegment[i==0 ? 1 : 0],
4068                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
4069         //////////////////////////                                              
4070         /// Placing SSD Sensor
4071         //////////////////////////              
4072         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
4073                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
4074                                                         fssdsensormatrix[i][j]);
4075         }
4076         ///////////////////////////////                                         
4077         /// Placing End Ladder Segment
4078         ///////////////////////////////         
4079         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
4080         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
4081    }
4082 /////////////////////////////////////////////////////////////////////////////                                           
4083 /// Placing Ladder Cables
4084 /////////////////////////////////////////////////////////////////////////////           
4085   Int_t sidecablenumber[2][2];
4086   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
4087   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
4088   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
4089   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
4090   Double_t carbonfibertomoduleposition[3];
4091   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
4092   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
4093                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
4094          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
4095          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
4096          -            fgkSSDSensorCenterSupportThickness[0]);
4097   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
4098                                                                  +   0.5*fgkCoolingTubeSupportHeight
4099          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
4100   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
4101   Double_t ssdendladdercablelength[4];
4102   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
4103                                                          + fgkSSDSensorLength
4104                                                          - fgkSSDModuleStiffenerPosition[1]
4105                                                          - fgkSSDStiffenerWidth 
4106                                                          - fgkSSDFlexWidth[0]
4107                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4108   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
4109                                                          + fgkSSDModuleStiffenerPosition[1]
4110                                                          + fgkSSDStiffenerWidth
4111                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
4112   ssdendladdercablelength[2] = ssdendladdercablelength[1]
4113                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
4114                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
4115                                                          - kendladdercablecorrection;
4116   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
4117                                                          + carbonfibertomoduleposition[1]
4118                                                          - fgkSSDModuleStiffenerPosition[1]
4119                                                          - fgkSSDStiffenerWidth)
4120                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
4121   TList* laddercableassemblylist[4];
4122   const Int_t kendladdercablesnumber = 4;
4123   TGeoRotation *laddercablerot = new TGeoRotation();
4124   laddercablerot->SetAngles(90.,60.,-90.);
4125   for(Int_t i=0; i<fgkladdercablesnumber; i++)
4126         for(Int_t j=0; j<kendladdercablesnumber; j++){
4127                 laddercableassemblylist[j] = 
4128                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
4129                                                                    ssdendladdercablelength[j]);
4130                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
4131                                                                         j<2?1:2,fladdercablematrix[i][j]);
4132   }
4133 }
4134 ////////////////////////////////////////////////////////////////////////////////
4135 void AliITSv11GeometrySSD::SetLayer(){
4136 ////////////////////////////////////////////////////////////////////////////////
4137   // Creating Ladder of Layer 5 and Layer 6
4138   /////////////////////////////////////////////////////////////
4139   if(!fCreateMaterials) CreateMaterials();
4140   if(!fTransformationMatrices) CreateTransformationMatrices();
4141   if(!fBasicObjects) CreateBasicObjects();
4142   SetLadder(); // Generating the ladder of Layer5 and Layer6
4143   const Int_t kssdlayladdernumber[fgklayernumber] = 
4144                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4145   /////////////////////////////////////////////////////////////
4146   // Generating mother volumes for Layer5 and Layer6
4147   /////////////////////////////////////////////////////////////
4148   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
4149   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
4150   Int_t *ladderindex[fgklayernumber];
4151   Int_t index[fgklayernumber] = {8,9};
4152   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
4153   for(Int_t i=0; i<fgklayernumber; i++) 
4154         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4155                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
4156                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
4157                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
4158                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
4159         }
4160   /////////////////////////////////////////////////////////////
4161   // Deallocating memory
4162   /////////////////////////////////////////////////////////////
4163   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
4164 }
4165 ////////////////////////////////////////////////////////////////////////////////
4166 void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
4167   /////////////////////////////////////////////////////////////
4168   // Insert the layer 5 in the mother volume. 
4169   /////////////////////////////////////////////////////////////
4170   if (! moth) {
4171     AliError("Can't insert layer5, mother is null!\n");
4172     return;
4173   };
4174   if(!fSSDLayer5) SetLayer();
4175   fMotherVol = moth;
4176   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
4177                                                                                 + fgkLay5CenterITSPosition);
4178   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
4179  }
4180 ////////////////////////////////////////////////////////////////////////////////
4181 void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
4182   /////////////////////////////////////////////////////////////
4183   // Insert the layer 6 in the mother volume. 
4184   /////////////////////////////////////////////////////////////
4185   if (! moth) {
4186     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
4187     return;
4188   };
4189   if(!fSSDLayer6) SetLayer();
4190   fMotherVol = moth;
4191   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
4192                                                                                 + fgkLay6CenterITSPosition);
4193   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
4194  }
4195  ////////////////////////////////////////////////////////////////////////////////
4196  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
4197   /////////////////////////////////////////////////////////////
4198   // Method generating the Arc structure of Ladder Support 
4199   /////////////////////////////////////////////////////////////
4200   const Int_t kssdlayladdernumber[fgklayernumber] = 
4201                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4202   Double_t mountingsupportedge[fgklayernumber];
4203   Double_t mountingblockratio[fgklayernumber];
4204   Double_t theta[fgklayernumber];
4205   Double_t phi[fgklayernumber];
4206   Double_t psi0[fgklayernumber];
4207   Double_t deltapsi[fgklayernumber];
4208   TVector3* mountingsupportedgevector[fgklayernumber];
4209   for(Int_t i=0; i<fgklayernumber; i++){
4210         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4211     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4212                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4213                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4214                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4215                                                           / kssdlayladdernumber[i])));
4216     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
4217     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4218         mountingsupportedgevector[i] = new TVector3();
4219         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
4220         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
4221                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
4222                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
4223     psi0[i] = 0.5*TMath::Pi()-phi[i];   
4224     deltapsi[i] = (theta[i]+phi[i])/nedges;
4225   }
4226   TVector3** vertex[fgklayernumber];
4227   TList* vertexlist[fgklayernumber];
4228   Int_t indexedge[fgklayernumber] = {0,0};
4229   for(Int_t i=0; i<fgklayernumber; i++){
4230         vertex[i] = new TVector3*[nedges+1];
4231         vertexlist[i] = new TList();
4232   } 
4233   for(Int_t i=0; i<fgklayernumber; i++){
4234         for(Int_t j=0; j<nedges+1; j++){
4235                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
4236                                                                     fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]));
4237                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
4238                 vertexlist[i]->Add(vertex[i][j]);
4239         }
4240         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
4241   }
4242   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
4243   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
4244   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
4245   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
4246   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
4247   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
4248   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
4249   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
4250   for(Int_t i=0; i<fgklayernumber; i++){
4251     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4252     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
4253     xcentervertex[i] = new Double_t[indexedge[i]+3];
4254     ycentervertex[i] = new Double_t[indexedge[i]+3];
4255         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4256         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
4257         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
4258         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
4259         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
4260                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4261                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4262                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
4263                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4264                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
4265                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
4266                 if(j<indexedge[i]+1){
4267                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
4268                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
4269                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
4270                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
4271                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
4272                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
4273                 }
4274         }
4275         xsidevertex[i][1] = xsidevertex[i][0]; 
4276         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4277         xsidevertex[i][2] = xsidevertex[i][3]; 
4278         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4279         xcentervertex[i][1] = xcentervertex[i][0]; 
4280         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
4281         xcentervertex[i][2] = xcentervertex[i][3]; 
4282         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
4283         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
4284         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
4285         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
4286         ycenterlowervertex[i][0] = ysidevertex[i][0];
4287         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
4288         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
4289   }
4290   /////////////////////////////////////////////////////////////
4291   // Building the Arc Structure of Ladder Supports 
4292   /////////////////////////////////////////////////////////////
4293   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
4294   TGeoXtru* centermountingsupportshape[fgklayernumber];
4295   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
4296   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
4297   TGeoVolume* sidemountingblocksupport[fgklayernumber];
4298   TGeoVolume* centermountingblocksupport[fgklayernumber];
4299   TGeoVolume* sideladdersupportpiece[fgklayernumber];
4300   TGeoVolume* centerladdersupportpiece[fgklayernumber];
4301   char sidemountingblockname[100];
4302   char centermountingblockname[100];
4303   char sideladdersupportpiecename[100];
4304   char centerladdersupportpiecename[100];
4305   for(Int_t i=0; i<fgklayernumber; i++){ 
4306         sprintf(sidemountingblockname,"MountingBlockSupportSideLay%dArc",i+5);
4307         sprintf(centermountingblockname,"MountingBlockSupportCenterLay%dArc",i+5);
4308         sprintf(sideladdersupportpiecename,"SideLadderSupportPieceLay%d",i+5);
4309         sprintf(centerladdersupportpiecename,"CenterLadderSupportPieceLay%d",i+5);
4310         sidemountingblocksupportshape[i] = new TGeoXtru(2);
4311     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
4312                                                                                                 xsidevertex[i],ysidevertex[i]);
4313     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4314                                                                                                          -fgkMountingBlockSupportWidth[0]);
4315     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4316     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
4317                                                                           sidemountingblocksupportshape[i],
4318                                                                                   fSSDAlCoolBlockMedium);
4319         sidemountingblocksupport[i]->SetLineColor(9);
4320         centermountingsupportshape[i] = new TGeoXtru(2);
4321     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
4322                                                                                                 xcentervertex[i],ycentervertex[i]);
4323         centermountingsupportshape[i]->DefineSection(0,0.);
4324     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4325                                                                                                   -fgkMountingBlockSupportWidth[0]);
4326
4327     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
4328                                                                           centermountingsupportshape[i],
4329                                                                                   fSSDAlCoolBlockMedium);
4330         centermountingblocksupport[i]->SetLineColor(9);
4331         sideladdersupportpieceshape[i] = new TGeoXtru(2);
4332     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
4333                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
4334         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4335                                                                                                          -fgkMountingBlockSupportWidth[0]);
4336     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4337     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
4338                                                                           sideladdersupportpieceshape[i],
4339                                                                                   fSSDCarbonFiberMedium);
4340         sideladdersupportpiece[i]->SetLineColor(fColorAl);
4341         centerladdersupportpieceshape[i] = new TGeoXtru(2);
4342     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
4343                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
4344         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
4345     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
4346                                                                                                   -fgkMountingBlockSupportWidth[0]);
4347     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
4348                                                                           centerladdersupportpieceshape[i],
4349                                                                                   fSSDCarbonFiberMedium);
4350         centerladdersupportpiece[i]->SetLineColor(fColorAl);
4351   }
4352   /////////////////////////////////////////////////////////////
4353   // Building the Up Structure of Ladder Supports 
4354   /////////////////////////////////////////////////////////////
4355   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
4356   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
4357   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
4358   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
4359   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
4360   //////////////////////////////////////////////////////////
4361   // Setting the volume for TGeoXtru Mounting Block Piece  
4362   //////////////////////////////////////////////////////////
4363   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
4364   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
4365   TGeoVolume* mountingblockpiecedown[fgklayernumber];
4366   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
4367   TGeoVolume* mountingblockpieceup[fgklayernumber];
4368   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
4369   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
4370   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
4371   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
4372   char mountingblockpiecedownname[100];
4373   char mountingblockpieceupname[100];
4374   for(Int_t i=0; i<fgklayernumber; i++){
4375     ///////////////////////////
4376     // Mounting Block Down Vertex
4377     ///////////////////////////
4378         mountingblockpiecedownshape[i] = new TGeoXtru(2);
4379     sprintf(mountingblockpiecedownname,"MountingBlockPieceDownLay%d",i+5);
4380         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
4381         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4382                                               + fgkMountingBlockSupportDownHeight 
4383                                               - fgkSSDLadderVerticalDisalignment;
4384         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
4385         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4386                                                                                 + fgkSSDMountingBlockHeight[1]
4387                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4388                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4389         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
4390         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
4391         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
4392         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
4393         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4394         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
4395         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
4396         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
4397                                                                                 + fgkSSDMountingBlockHeight[2]
4398                                                                                 - fgkSSDMountingBlockHeight[0];
4399         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
4400         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
4401         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
4402         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
4403         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
4404                                                                                                          mountingblockpiecedownyvertex[i]);
4405         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
4406         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4407         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
4408                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
4409         mountingblockpiecedown[i]->SetLineColor(fColorG10);
4410
4411     ///////////////////////////
4412     // Mounting Block Up Vertex
4413     ///////////////////////////
4414         mountingblockpieceupshape[i] = new TGeoXtru(2);
4415         sprintf(mountingblockpieceupname,"MountingBlockPieceUpLay%d",i+5);
4416         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
4417         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
4418                                                                                 + fgkMountingBlockSupportUpHeight[i]
4419                                               - fgkSSDLadderVerticalDisalignment;
4420         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
4421         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
4422                                                                                 + fgkSSDMountingBlockHeight[1]
4423                                                                                 - 0.5*fgkCoolingTubeSupportHeight
4424                                                                                 - fgkSSDModuleCoolingBlockToSensor;
4425         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
4426         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
4427         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
4428         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
4429         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
4430         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
4431         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
4432         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
4433                                                                                 + fgkSSDMountingBlockHeight[2]
4434                                                                                 - fgkSSDMountingBlockHeight[0];
4435         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
4436         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
4437         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
4438         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
4439
4440         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
4441                                                                                                          mountingblockpieceupyvertex[i]);
4442         mountingblockpieceupshape[i]->DefineSection(0,0.0);
4443         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4444         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
4445                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
4446         mountingblockpieceup[i]->SetLineColor(fColorG10);
4447  }
4448   ///////////////////////////////////////////////////////////////////
4449   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
4450   ///////////////////////////////////////////////////////////////////
4451   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
4452   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
4453   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
4454   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
4455   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
4456   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
4457   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
4458   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
4459   char mountingblocksupportrapezoidowname[100];
4460   char mountingblocksupportrapezoidupname[100];
4461   Double_t scalefactor = 3./4.;
4462   for(Int_t i=0; i<fgklayernumber; i++){
4463   ////////////////////////////////////////////
4464   // Mounting Block Support Down Trapezoid Vertex 
4465   ////////////////////////////////////////////
4466         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
4467         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4468                                                                                                  - mountingsupportedge[i];
4469         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
4470         mountingblocksupportrapezoidownxvertex[i][1] = 
4471                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
4472         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
4473                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
4474                                                                                              - mountingblockpiecedownyvertex[i][0]);
4475         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4476         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
4477         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
4478         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
4479         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
4480         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
4481
4482         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
4483                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
4484         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4485                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4486         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4487         sprintf(mountingblocksupportrapezoidowname,"MountingBlockSuppTrapezoidDownLay%d",i+5);
4488         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
4489                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
4490         mountingblocksupportrapezoidown[i]->SetLineColor(9);
4491   ////////////////////////////////////////////
4492   // Mounting Block Support Up Trapezoid Vertex 
4493   ////////////////////////////////////////////
4494         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
4495         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4496                                                                                                  - mountingsupportedge[i];
4497         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
4498         mountingblocksupportrapezoidupxvertex[i][1] = 
4499                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
4500         mountingblocksupportrapezoidupyvertex[i][1] = 
4501                                                                                                mountingblockpieceupyvertex[i][0]
4502                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
4503                                                                                              - mountingblockpieceupyvertex[i][0]);
4504         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
4505         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
4506         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
4507         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
4508         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
4509         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
4510
4511         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
4512                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
4513         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
4514                                                                                                                         -fgkMountingBlockSupportWidth[0]);
4515         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4516         sprintf(mountingblocksupportrapezoidupname,"MountingBlockSuppTrapezoidUpLay%d",i+5);
4517         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
4518                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
4519         mountingblocksupportrapezoidup[i]->SetLineColor(9);
4520   }
4521   ///////////////////////////////////////////////////////////////////
4522   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
4523   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
4524   Double_t boxoriginup[fgklayernumber][2][3];
4525   Double_t boxorigindown[fgklayernumber][2][3];
4526   char mountingblocksupportboxdownname[100];
4527   char mountingblocksupportboxupname[100];
4528   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
4529   mountingblocksupportrot->SetAngles(90.,180.,-90);
4530   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
4531   globalrefladdersupportrot->SetAngles(0.,90.,0.);
4532   TGeoHMatrix* laddersupportmatrix[2];
4533   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
4534   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
4535   /////////////////////////////////////////////////////////////
4536   // Creating Mother Volume for Containment
4537   /////////////////////////////////////////////////////////////
4538   Double_t *xmothervertex[fgklayernumber];
4539   Double_t *ymothervertex[fgklayernumber];
4540   for(Int_t i=0; i<fgklayernumber; i++){
4541         xmothervertex[i] = new Double_t[8];
4542         ymothervertex[i] = new Double_t[8];
4543   }  
4544   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
4545   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
4546   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
4547   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
4548   char upmotheladdersupportname[100];
4549   char downmotheladdersupportname[100];
4550   for(Int_t i=0; i<fgklayernumber; i++){
4551         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
4552                                                     -  mountingsupportedge[i];
4553         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
4554         xmothervertex[i][1] = xmothervertex[i][0];
4555         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
4556                                                         + fgkMountingBlockSupportWidth[0];
4557         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
4558         ymothervertex[i][2] = ymothervertex[i][1];
4559         xmothervertex[i][3] = xmothervertex[i][2];
4560         ymothervertex[i][3] = -ymothervertex[i][0];
4561         xmothervertex[i][4] = -xmothervertex[i][0];
4562         ymothervertex[i][4] = ymothervertex[i][3];
4563         xmothervertex[i][5] = xmothervertex[i][4];
4564         ymothervertex[i][5] = -ymothervertex[i][1];
4565         xmothervertex[i][6] = -xmothervertex[i][2];
4566         ymothervertex[i][6] = ymothervertex[i][5];
4567         xmothervertex[i][7] = xmothervertex[i][6];
4568         ymothervertex[i][7] = ymothervertex[i][0];
4569
4570         sprintf(downmotheladdersupportname,"LadderSupportDownLay%d",i+5);
4571         sprintf(upmotheladdersupportname,"LadderSupportUpLay%d",i+5);
4572
4573         downmotherladdersupportshape[i] = new TGeoXtru(2);
4574         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4575         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4576         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4577                                                                    +                       fgkMountingBlockSupportDownHeight
4578                                                                    +                       fgkSSDMountingBlockHeight[1]
4579                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4580                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4581                                                        - fgkSSDLadderVerticalDisalignment);
4582         
4583 //                                                 - fgkSSDModuleVerticalDisalignment);
4584         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
4585
4586         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
4587                                                                           downmotherladdersupportshape[i],fSSDAir);
4588     upmotherladdersupportshape[i] = new TGeoXtru(2);
4589         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
4590         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
4591     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
4592                                                                    +                       fgkMountingBlockSupportUpHeight[i]
4593                                                                    +                       fgkSSDMountingBlockHeight[1]
4594                                                                    -                       0.5*fgkCoolingTubeSupportHeight
4595                                                                    -                       fgkSSDModuleCoolingBlockToSensor
4596                                                  - fgkSSDLadderVerticalDisalignment);
4597
4598      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
4599                                                                                           upmotherladdersupportshape[i],fSSDAir);
4600   }
4601   for(Int_t i=0; i<fgklayernumber; i++){
4602         /////////////////////////
4603         // Setting the box origin
4604         /////////////////////////
4605         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
4606         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
4607                                                    +  0.5*fgkMountingBlockSupportDownHeight
4608                                   - 0.5*fgkSSDLadderVerticalDisalignment;
4609         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
4610                                                    -  0.5*fgkMountingBlockSupportWidth[0];
4611   
4612         boxorigindown[i][1][0] = 0.0;
4613         boxorigindown[i][1][1] = boxorigindown[i][0][1];
4614         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4615                                                    -      fgkMountingBlockSupportWidth[0]);
4616                                                    
4617         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
4618         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
4619                                + 0.5*fgkMountingBlockSupportUpHeight[i]
4620                                - 0.5*fgkSSDLadderVerticalDisalignment;
4621         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
4622                                                  - 0.5*fgkMountingBlockSupportWidth[0];
4623   
4624         boxoriginup[i][1][0] = 0.0;
4625         boxoriginup[i][1][1] = boxoriginup[i][0][1];
4626         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
4627                                                  - fgkMountingBlockSupportWidth[0]);
4628   
4629         /////////////////////////
4630     // Setting the boxes    
4631         /////////////////////////
4632         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4633                                                                                  +  fgkSSDMountingBlockLength[0]),
4634                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4635                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4636                                                                                         boxorigindown[i][0]);
4637         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4638                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
4639                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4640                                                                                  -  fgkMountingBlockSupportWidth[0]),
4641                                                                                         boxorigindown[i][1]);
4642                                                                                         
4643         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
4644                                                                                  +  fgkSSDMountingBlockLength[0]),
4645                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4646                                                                                         0.5*fgkMountingBlockSupportWidth[0],
4647                                                                                         boxoriginup[i][0]);
4648
4649         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
4650                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
4651                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
4652                                                                      -  fgkMountingBlockSupportWidth[0]),
4653                                                                                         boxoriginup[i][1]);
4654         ///////////////////////////////////////
4655         // Adding the Volumes to Mother Volume    
4656         ///////////////////////////////////////
4657         for(Int_t j=0; j<2; j++){
4658                 sprintf(mountingblocksupportboxdownname,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
4659                 sprintf(mountingblocksupportboxupname,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
4660                 mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
4661                                                                                   mountingblocksupportboxdownshape[i][j],
4662                                                                                   fSSDCarbonFiberMedium);
4663                 mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
4664                                                                                   mountingblocksupportboxupshape[i][j],
4665                                                                                   fSSDCarbonFiberMedium);
4666                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
4667                 mountingblocksupportboxup[i][j]->SetLineColor(9);
4668                 for(Int_t k=0; k<2; k++){
4669                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
4670                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
4671                 }
4672         }
4673         for(Int_t k=0; k<2; k++){
4674                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4675                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4676                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4677                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4678                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
4679                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
4680                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
4681                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
4682                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4683                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
4684                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
4685                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
4686         }
4687   }
4688   TList* laddersupportlist = new TList();
4689   laddersupportlist->Add(downmotherladdersupport[0]); 
4690   laddersupportlist->Add(upmotherladdersupport[0]); 
4691   laddersupportlist->Add(downmotherladdersupport[1]); 
4692   laddersupportlist->Add(upmotherladdersupport[1]); 
4693   /////////////////////////////////////////////////////////////
4694   // Deallocating memory
4695   /////////////////////////////////////////////////////////////
4696   for(Int_t i=0; i<fgklayernumber; i++){
4697         for(Int_t j=0; j<nedges+1; j++)
4698                 delete vertex[i][j];
4699         delete mountingsupportedgevector[i];
4700         delete [] vertex[i];
4701         delete vertexlist[i];
4702         delete [] xsidevertex[i];
4703         delete [] ysidevertex[i];
4704         delete [] xcentervertex[i];
4705         delete [] ycentervertex[i];
4706         delete [] xsidelowervertex[i];
4707         delete [] ysidelowervertex[i];
4708         delete [] xcenterlowervertex[i];
4709         delete [] ycenterlowervertex[i];
4710         delete [] xmothervertex[i];
4711         delete [] ymothervertex[i];
4712   }
4713   delete [] xsidevertex;
4714   delete [] ysidevertex;
4715   delete [] xcentervertex;
4716   delete [] ycentervertex;
4717   delete [] xsidelowervertex;
4718   delete [] ysidelowervertex;
4719   delete [] xcenterlowervertex;
4720   delete [] ycenterlowervertex;
4721   delete globalrefladdersupportrot;
4722   delete mountingblocksupportrot;
4723   /////////////////////
4724   return laddersupportlist;     
4725 }
4726  ////////////////////////////////////////////////////////////////////////////////
4727 void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
4728 //////////////////////////////////////////
4729 // Method Generating Ladder Support Ring
4730 //////////////////////////////////////////
4731   if(!fCreateMaterials) CreateMaterials();
4732   if(!fTransformationMatrices) CreateTransformationMatrices();
4733   if(!fBasicObjects) CreateBasicObjects();
4734   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
4735   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
4736     const Int_t kssdlayladdernumber[fgklayernumber] = 
4737                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
4738   Double_t mountingsupportedge[fgklayernumber];
4739   Double_t mountingblockratio[fgklayernumber];
4740   Double_t theta[fgklayernumber];
4741   Double_t phi[fgklayernumber];
4742   for(Int_t i=0; i<fgklayernumber; i++){
4743         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
4744     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
4745                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
4746                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
4747                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
4748                                                           / kssdlayladdernumber[i])));
4749     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
4750                          / fgkMountingBlockSupportRadius[i]);
4751     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
4752   }
4753   TGeoRotation* globalrot = new TGeoRotation();
4754   globalrot->SetAngles(0.,-90.,0.); 
4755   TGeoRotation** laddersupportrot[fgklayernumber];
4756   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
4757   for(Int_t i=0; i<fgklayernumber; i++){                
4758         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
4759         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
4760         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
4761                 laddersupportrot[i][j] = new TGeoRotation();
4762                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
4763                 switch(i){
4764                         case 0: //Ladder of Layer5  
4765                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4766                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
4767                                                                             laddersupportmatrix[i][j]); 
4768                         break;
4769                         case 1: //Ladder of Layer6 
4770                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
4771                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
4772                                                                               laddersupportmatrix[i][j]); 
4773                         break;
4774                 }
4775     }
4776   }
4777   /////////////////////////////////////////////////////////////
4778   // Creating Lower Ladder Support 
4779   /////////////////////////////////////////////////////////////
4780   TVector3** ringsupportvertex[fgklayernumber];         
4781   Double_t angle = 360./nedges;
4782   for(Int_t i=0; i<fgklayernumber; i++){
4783     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
4784         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
4785                                                         *                          TMath::Cos(theta[i]));
4786         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
4787                                                         -                          mountingsupportedge[i],
4788                                                                                    ringsupportvertex[i][0]->Y());
4789         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
4790                                                                                    ringsupportvertex[i][1]->Y());                                                                               
4791     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
4792         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
4793            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
4794            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));   
4795            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
4796            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));   
4797         }
4798         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
4799     for(Int_t j=0; j<nedges+1; j++){
4800                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
4801                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*CosD(90.0-j*angle),
4802                                                  (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*SinD(90.0-j*angle));
4803         }
4804   }
4805   Double_t **xmothervertex = new Double_t*[fgklayernumber];
4806   Double_t **ymothervertex = new Double_t*[fgklayernumber];
4807   for(Int_t i=0; i<fgklayernumber; i++){
4808         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4809         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
4810         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
4811                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
4812                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
4813         }
4814   }
4815 ////////////////////////////////////////////////////////////////////////////////
4816 // Start Corrections 13/06/08
4817 ////////////////////////////////////////////////////////////////////////////////
4818   char lowerladderpconsupportname[100];
4819   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
4820   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
4821   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
4822   Double_t lowerladderpconradiusmax[fgklayernumber];
4823   Double_t lowerladderpconradiusmin[fgklayernumber];
4824   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4825   lowerladdersupportrot->SetAngles(90.,180.,-90);
4826   for(Int_t i=0; i<fgklayernumber; i++){
4827         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
4828                                                                 *                          TMath::Cos(theta[i]);
4829     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeight;
4830   } 
4831   for(Int_t i=0; i<fgklayernumber; i++){
4832 ///////////////////////////  Modified Version ?///////////////////
4833     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
4834         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
4835                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
4836                                                          lowerladderpconradiusmax[i]);
4837         sprintf(lowerladderpconsupportname,"LowerLadderPConSupportNameLay%d",i+5);
4838         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
4839     lowerladderpconsupport[i]->SetLineColor(fColorAl);
4840         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
4841         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
4842  }
4843 ////////////////////////////////////////////////////////////////////////////////
4844 // End Corrections 13/06/08
4845 ////////////////////////////////////////////////////////////////////////////////
4846   /*char lowerladdersupportname[30];
4847   TGeoXtru* lowerladdersupportshape[fgklayernumber];
4848   TGeoVolume* lowerladdersupport[fgklayernumber];
4849   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
4850   lowerladdersupportrot->SetAngles(90.,180.,-90);
4851   for(Int_t i=0; i<fgklayernumber; i++){
4852         lowerladdersupportshape[i] = new TGeoXtru(2);
4853         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
4854                                                                                           xmothervertex[i],ymothervertex[i]);
4855         lowerladdersupportshape[i]->DefineSection(0,0.);
4856     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
4857         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
4858     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
4859                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
4860         lowerladdersupport[i]->SetLineColor(fColorAl);
4861         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
4862         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
4863   }*/
4864   /////////////////////////////////////////////////////////////
4865   // Deallocating memory
4866   /////////////////////////////////////////////////////////////
4867   for(Int_t i=0; i<fgklayernumber; i++){
4868         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
4869                 delete ringsupportvertex[i][j];
4870         delete [] ringsupportvertex[i];
4871   }
4872   for(Int_t i=0; i<fgklayernumber; i++){
4873         delete [] xmothervertex[i];
4874         delete [] ymothervertex[i];
4875   }
4876   delete [] xmothervertex;
4877   delete [] ymothervertex; 
4878   delete globalrot;
4879   for(Int_t i=0; i<fgklayernumber; i++){
4880         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
4881                 delete laddersupportrot[i][j];
4882         delete [] laddersupportrot[i];
4883   }
4884  }  
4885  ////////////////////////////////////////////////////////////////////////////////
4886  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
4887   /////////////////////////////////////////////////////////////
4888   // Method generating Endcap CoverPlate
4889   /////////////////////////////////////////////////////////////
4890   // Holes Definition 
4891   ///////////////////
4892   Int_t nendcapcoverplateholedges = 30;
4893   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
4894   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
4895                                                           0.5*fgkEndCapCoverPlateThickness};
4896   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
4897                                                                                                               nendcapcoverplateholedges,holesection);
4898   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
4899                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
4900   endcapcoverplatesmallhole->SetLineColor(6);
4901   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
4902                                                                                                               nendcapcoverplateholedges,holesection);
4903   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
4904                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
4905   endcapcoverplatebighole->SetLineColor(6);
4906   //////////////////////////
4907   // Screw Piece Definition 
4908   //////////////////////////
4909   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
4910   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
4911                                                                                                       CosD(0.5*smallscrewangle),
4912                                                                                                       0.5*fgkEndCapCoverPlateThickness);
4913   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
4914                                                                                                 endcapsmallscrewpieceshape,
4915                                                                                                 fSSDCoolingTubePhynox);
4916   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
4917   ///////////////////
4918   // Box Definition 
4919   ///////////////////
4920   TGeoBBox* endcapcoverplateboxshape[4];
4921   TGeoVolume* endcapcoverplatebox[4];
4922   Double_t boxorigin[5][3];
4923   boxorigin[0][0] = 0.;
4924   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
4925   boxorigin[0][2] = 0.;
4926
4927   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
4928   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
4929   boxorigin[1][2] = 0.;
4930
4931   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
4932                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
4933   boxorigin[2][1] = boxorigin[1][1];
4934   boxorigin[2][2] = 0.;
4935
4936   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
4937                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
4938   boxorigin[3][1] = boxorigin[1][1];
4939   boxorigin[3][2] = 0.;
4940
4941   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4942                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
4943                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
4944                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
4945
4946   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
4947                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4948                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4949                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4950                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
4951
4952   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
4953                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4954                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4955                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4956                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
4957
4958   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
4959                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
4960                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
4961                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
4962                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
4963   
4964   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
4965                                                                            fSSDAlCoolBlockMedium);
4966   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
4967                                                                            fSSDAlCoolBlockMedium);
4968   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
4969                                                                            fSSDAlCoolBlockMedium);
4970   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
4971                                                                            fSSDAlCoolBlockMedium);
4972   endcapcoverplatebox[0]->SetLineColor(6);
4973   endcapcoverplatebox[1]->SetLineColor(6);
4974   endcapcoverplatebox[2]->SetLineColor(6);
4975   endcapcoverplatebox[3]->SetLineColor(6);
4976   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
4977   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
4978                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
4979                                                                                         0.5*fgkEndCapCoverPlateThickness,
4980                                                                                         endcapfillingboxorigin);
4981   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
4982                                                                            fSSDAlCoolBlockMedium);
4983   endcapfillingbox->SetLineColor(6);
4984   ////////////////////////////
4985   // Contour shape Definition 
4986   ////////////////////////////
4987   const Int_t kcontourvertexnumber = 10;
4988   Double_t xcontourvertex[kcontourvertexnumber];
4989   Double_t ycontourvertex[kcontourvertexnumber];
4990   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
4991   xcontourvertex[1] = xcontourvertex[0];
4992   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
4993   xcontourvertex[3] = xcontourvertex[2];
4994   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
4995   xcontourvertex[5] = xcontourvertex[4];
4996   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
4997   xcontourvertex[7] = xcontourvertex[6];
4998   xcontourvertex[8] = xcontourvertex[4];
4999   xcontourvertex[9] = xcontourvertex[8];
5000   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5001                                         - (kendcapcoverplatesmallholenumber[1]-1)
5002                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5003   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
5004                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5005   ycontourvertex[2] = ycontourvertex[1];
5006   ycontourvertex[3] = ycontourvertex[0];
5007   ycontourvertex[4] = ycontourvertex[3];
5008   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
5009   ycontourvertex[6] = ycontourvertex[5];
5010   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
5011                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5012                                         + fgkEndCapCoverPlateSmallHoleRadius;
5013   ycontourvertex[8] = ycontourvertex[7];
5014   ycontourvertex[9] = ycontourvertex[0];
5015
5016   Double_t xboxin, dxboxin, yboxin, dyboxin;
5017   Double_t xboxout, dxboxout, yboxout, dyboxout;
5018   Double_t coordmin, coordmax;
5019   coordmin = -fgkEndCapCoverPlateLength[0];
5020   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
5021   xboxout = 0.5*(coordmin+coordmax);
5022   dxboxout = 0.5*(coordmax-coordmin);
5023   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
5024                                         - (kendcapcoverplatesmallholenumber[1]-1)
5025                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
5026   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5027                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
5028   yboxout = 0.5*(coordmin+coordmax);
5029   dyboxout = 0.5*(coordmax-coordmin);
5030   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5031   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
5032   xboxin = 0.5*(coordmin+coordmax);
5033   dxboxin = 0.5*(coordmax-coordmin);
5034   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
5035   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
5036                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
5037                                         + fgkEndCapCoverPlateSmallHoleRadius;
5038   yboxin = 0.5*(coordmin+coordmax);
5039   dyboxin = 0.5*(coordmax-coordmin);
5040   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5041   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
5042                                                          xboxout, yboxout, 0.);
5043   trendCapCoverPlateContourboxout->RegisterYourself();
5044   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5045   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
5046                                                          xboxin, yboxin, 0.);
5047   trendCapCoverPlateContourboxin->RegisterYourself();
5048   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
5049         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
5050
5051   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
5052                                                                            fSSDAlCoolBlockMedium);
5053   contour->SetLineColor(6);
5054   /////////////////////////////
5055   // Hole Contour Shape Definition 
5056   ////////////////////////////
5057   coordmin = xcontourvertex[0];
5058   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5059   xboxout = 0.5*(coordmin+coordmax);
5060   dxboxout = 0.5*(coordmax-coordmin);
5061   coordmin = ycontourvertex[1];
5062   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
5063   yboxout = 0.5*(coordmin+coordmax);
5064   dyboxout = 0.5*(coordmax-coordmin);
5065   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
5066                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5067   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5068   xboxin = 0.5*(coordmin+coordmax);
5069   dxboxin = 0.5*(coordmax-coordmin);
5070   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
5071                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
5072   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
5073   yboxin = 0.5*(coordmin+coordmax);
5074   dyboxin = 0.5*(coordmax-coordmin);
5075   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5076   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
5077                                                          xboxout, yboxout, 0.);
5078   trendCapCoverPlateContourboxout1->RegisterYourself();
5079   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5080   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
5081                                                          xboxin, yboxin, 0.);
5082   trendCapCoverPlateContourboxin1->RegisterYourself();
5083   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
5084         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
5085
5086
5087   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5088   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
5089   xboxout = 0.5*(coordmin+coordmax);
5090   dxboxout = 0.5*(coordmax-coordmin);
5091   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5092                                                    - fgkEndCapCoverPlateWidth[0]);
5093   coordmax = ycontourvertex[0];
5094   yboxout = 0.5*(coordmin+coordmax);
5095   dyboxout = 0.5*(coordmax-coordmin);
5096   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
5097                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5098   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
5099   xboxin = 0.5*(coordmin+coordmax);
5100   dxboxin = 0.5*(coordmax-coordmin);
5101   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5102                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
5103                                                    - fgkEndCapCoverPlateWidth[0]
5104                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5105   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
5106   yboxin = 0.5*(coordmin+coordmax);
5107   dyboxin = 0.5*(coordmax-coordmin);
5108   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
5109   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
5110                                                          xboxout, yboxout, 0.);
5111   trendCapCoverPlateContourboxout2->RegisterYourself();
5112   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
5113   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
5114                                                          xboxin, yboxin, 0.);
5115   trendCapCoverPlateContourboxin2->RegisterYourself();
5116   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
5117         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
5118   
5119 //  const Int_t kholecontourvertexnumber = 10;
5120
5121   Double_t xholecontourvertex[2][kcontourvertexnumber];
5122   Double_t yholecontourvertex[2][kcontourvertexnumber];
5123   xholecontourvertex[0][0] = xcontourvertex[0];
5124   xholecontourvertex[0][1] = xholecontourvertex[0][0];
5125   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
5126   xholecontourvertex[0][3] = xholecontourvertex[0][2];
5127   xholecontourvertex[0][4] = xholecontourvertex[0][0]
5128                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5129                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5130   xholecontourvertex[0][5] = xholecontourvertex[0][4];
5131   xholecontourvertex[0][6] = xholecontourvertex[0][5]
5132                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5133   xholecontourvertex[0][7] = xholecontourvertex[0][6];
5134   xholecontourvertex[0][8] = xholecontourvertex[0][4];
5135   xholecontourvertex[0][9] = xholecontourvertex[0][8];
5136   
5137   yholecontourvertex[0][0] = ycontourvertex[1];
5138   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
5139   yholecontourvertex[0][2] = yholecontourvertex[0][1];
5140   yholecontourvertex[0][3] = yholecontourvertex[0][0];
5141   yholecontourvertex[0][4] = yholecontourvertex[0][3];
5142   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
5143                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5144   yholecontourvertex[0][6] = yholecontourvertex[0][5];
5145   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5146   yholecontourvertex[0][8] = yholecontourvertex[0][7];
5147   yholecontourvertex[0][9] = yholecontourvertex[0][0];
5148
5149   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
5150   xholecontourvertex[1][1] = xholecontourvertex[1][0];
5151   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
5152   xholecontourvertex[1][3] = xholecontourvertex[1][2];
5153   xholecontourvertex[1][4] = xholecontourvertex[1][0]
5154                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
5155                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5156   xholecontourvertex[1][5] = xholecontourvertex[1][4];
5157   xholecontourvertex[1][6] = xholecontourvertex[1][5]
5158                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
5159   xholecontourvertex[1][7] = xholecontourvertex[1][6];
5160   xholecontourvertex[1][8] = xholecontourvertex[1][4];
5161   xholecontourvertex[1][9] = xholecontourvertex[1][8];
5162   
5163   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
5164                                                    - fgkEndCapCoverPlateWidth[0]);
5165   yholecontourvertex[1][1] = ycontourvertex[0];
5166   yholecontourvertex[1][2] = yholecontourvertex[1][1];
5167   yholecontourvertex[1][3] = yholecontourvertex[1][0];
5168   yholecontourvertex[1][4] = yholecontourvertex[1][3];
5169   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
5170                                                    - fgkEndCapCoverPlateWidth[0]
5171                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
5172   yholecontourvertex[1][6] = yholecontourvertex[1][5];
5173   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
5174   yholecontourvertex[1][8] = yholecontourvertex[1][7];
5175   yholecontourvertex[1][9] = yholecontourvertex[1][0];
5176
5177   TGeoVolume* holecontour[2];
5178   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
5179                                                                   fSSDAlCoolBlockMedium);
5180   holecontour[0]->SetLineColor(6);
5181   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
5182                                                                   fSSDAlCoolBlockMedium);
5183   holecontour[1]->SetLineColor(6);
5184   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
5185                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
5186   TGeoTranslation*  bigholetrans[3];
5187   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
5188                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
5189   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
5190                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
5191                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
5192   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
5193                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
5194   /////////////////////////////////
5195   // Mother Volume Xtru Definition 
5196   /////////////////////////////////
5197   const Int_t kmothervertexnumber = 12;
5198   Double_t xmothervertex[kmothervertexnumber];  
5199   Double_t ymothervertex[kmothervertexnumber];  
5200   xmothervertex[0]  = xcontourvertex[0];
5201   xmothervertex[1]  = xmothervertex[0];
5202   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
5203   xmothervertex[3]  = xmothervertex[2];
5204   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
5205   xmothervertex[5]  = xmothervertex[4];
5206   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
5207   xmothervertex[7]  = xmothervertex[6];
5208   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
5209                                         + fgkEndCapCoverPlateLength[2]; 
5210   xmothervertex[9]  = xmothervertex[8];
5211   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
5212   xmothervertex[11] = xmothervertex[10];
5213   
5214   ymothervertex[0]  = ycontourvertex[0];
5215   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
5216   ymothervertex[2]  = ymothervertex[1];
5217   ymothervertex[3]  = ycontourvertex[1];
5218   ymothervertex[4]  = ymothervertex[3];
5219   ymothervertex[5]  = ymothervertex[1];
5220   ymothervertex[6]  = ymothervertex[5];
5221   ymothervertex[7]  = ymothervertex[0];
5222   ymothervertex[8]  = ymothervertex[7];
5223   ymothervertex[9]  = ymothervertex[8]
5224                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
5225   ymothervertex[10] = ymothervertex[9];
5226   ymothervertex[11] = ymothervertex[8];
5227   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
5228   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
5229   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
5230   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
5231   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
5232   ////////////////////////////////////////
5233   // Adding Nodes
5234   ////////////////////////////////////////
5235 //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
5236   TGeoTranslation*** endcapcoverplatesmallholetrans;
5237   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
5238   Double_t transx[4] = {0,
5239                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
5240                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
5241                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
5242                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
5243                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
5244   Int_t index = 0;
5245   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
5246         endcapcoverplatesmallholetrans[i] = 
5247                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
5248     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
5249                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
5250             endcapcoverplatesmallholetrans[i][j] = 
5251                 new TGeoTranslation(transx[i],
5252                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
5253             if(index!=10){ 
5254                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
5255                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5256                         mothercoverplate->AddNode(endcapsmallscrewpiece,
5257                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5258                 }
5259                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
5260                         mothercoverplate->AddNode(endcapcoverplatebox[0],
5261                                                                           index,endcapcoverplatesmallholetrans[i][j]);
5262     }
5263   }
5264   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
5265   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
5266   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
5267   mothercoverplate->AddNode(endcapfillingbox,1);
5268   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
5269   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
5270   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
5271   mothercoverplate->AddNode(holecontour[0],1);
5272   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
5273   mothercoverplate->AddNode(holecontour[1],1);  
5274   mothercoverplate->AddNode(contour,1);
5275   /////////////////////////////////
5276   return mothercoverplate;      
5277  }
5278  ////////////////////////////////////////////////////////////////////////////////
5279  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
5280   /////////////////////////////////////////////////////////////
5281   // Getting EndCap Cooling Tube 
5282   /////////////////////////////////////////////////////////////
5283   TGeoTorus* endcapcoolingtubetorushape[5];
5284   TGeoVolume* endcapcoolingtubetorus[5];
5285   TGeoTube* endcapcoolingtubeshape[4];
5286   TGeoVolume* endcapcoolingtube[4];
5287   char endcapcoolingtubetorusname[100];
5288   char endcapcoolingtubename[100];
5289   TGeoTorus* endcapcoolingwatertubetorushape[5];
5290   TGeoVolume* endcapcoolingwatertubetorus[5];
5291   TGeoTube* endcapcoolingwatertubeshape[4];
5292   TGeoVolume* endcapcoolingwatertube[4];
5293   char endcapcoolingwatertubetorusname[100];
5294   char endcapcoolingwatertubename[100];
5295   for(Int_t i=0; i<5; i++){
5296         sprintf(endcapcoolingtubetorusname,"EndCapCoolingTubeTorus%d",i+1);
5297         sprintf(endcapcoolingtubename,"EndCapCoolingTube%d",i+1);
5298         sprintf(endcapcoolingwatertubetorusname,"EndCapCoolingWaterTubeTorus%d",i+1);
5299         sprintf(endcapcoolingwatertubename,"EndCapCoolingWaterTube%d",i+1);
5300         if(i==3){
5301                 endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5302                                                                                 fgkEndCapCoolingTubeRadiusMin,
5303                                                                                 fgkEndCapCoolingTubeRadiusMax,
5304                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5305                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
5306                                                                                 0.,fgkEndCapCoolingTubeRadiusMin,
5307                                                                                 90.0,fgkEndCapCoolingTubeAngle[3]);
5308     }
5309         else{
5310                 endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5311                                                                           :fgkEndCapCoolingTubeAxialRadius[1],
5312                                                                            fgkEndCapCoolingTubeRadiusMin,
5313                                                                            fgkEndCapCoolingTubeRadiusMax,
5314                                                                     0.,fgkEndCapCoolingTubeAngle[i]);
5315                 endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
5316                                                                                :fgkEndCapCoolingTubeAxialRadius[1],
5317                                                                                  0.,fgkEndCapCoolingTubeRadiusMin,
5318                                                                          0.,fgkEndCapCoolingTubeAngle[i]);
5319         }
5320         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
5321                                                                                            endcapcoolingtubetorushape[i],
5322                                                                                            fSSDCoolingTubePhynox);
5323         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
5324                                                                                                         endcapcoolingwatertubetorushape[i],
5325                                                                                                         fSSDCoolingTubeWater);
5326     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
5327     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
5328     if(i<4){
5329                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
5330                                                                   fgkEndCapCoolingTubeRadiusMax,
5331                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5332                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
5333                                                           0.5*fgkEndCapCoolingTubeLength[i]);
5334         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
5335                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
5336         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
5337                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
5338                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
5339                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
5340         }
5341   }
5342   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
5343   /////////////////////////////////////////
5344   // Transformation for Volume Positioning 
5345   /////////////////////////////////////////
5346   TGeoCombiTrans* coolingtubecombitrans[6];
5347   TGeoRotation* coolingtuberot[8];
5348   TGeoTranslation* coolingtubetrans[6];
5349   TGeoHMatrix* coolingtubematrix[4];
5350   TGeoCombiTrans* torustubecombitrans[4];
5351   TGeoRotation* torustuberot[7];
5352   TGeoTranslation* torustubetrans[4];
5353   TGeoHMatrix* torustubematrix[5];
5354   TGeoCombiTrans* coolingwatertubecombitrans[6];
5355   TGeoRotation* coolingwatertuberot[8];
5356   TGeoTranslation* coolingwatertubetrans[6];
5357   TGeoHMatrix* coolingwatertubematrix[4];
5358   TGeoCombiTrans* toruswatertubecombitrans[4];
5359   TGeoRotation* toruswatertuberot[7];
5360   TGeoTranslation* toruswatertubetrans[4];
5361   TGeoHMatrix* toruswatertubematrix[5];
5362   for(Int_t i=0; i<8; i++){
5363     if(i<6){
5364          coolingtubetrans[i] = new TGeoTranslation();
5365          coolingwatertubetrans[i] = new TGeoTranslation();
5366     }
5367     if(i<8){
5368          coolingtuberot[i] = new TGeoRotation();
5369          coolingwatertuberot[i] = new TGeoRotation();
5370     }
5371     if(i<4){
5372          torustubetrans[i] = new TGeoTranslation();
5373          toruswatertubetrans[i] = new TGeoTranslation();
5374     }
5375     if(i<7){
5376          torustuberot[i] = new TGeoRotation();
5377          toruswatertuberot[i] = new TGeoRotation();
5378         }
5379   }
5380   /////////////////////////////////////////
5381   // Transformation for Inox Volume Positioning 
5382   /////////////////////////////////////////
5383   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5384                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
5385   coolingtuberot[0]->SetAngles(0.,90.,0.);
5386   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
5387                                                                                                 *coolingtuberot[0]);
5388                                                                                                 
5389   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
5390   coolingtuberot[1]->SetAngles(0.,90.,0.);
5391   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
5392                                                                                                 *coolingtuberot[1]);
5393
5394   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5395                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
5396                                                                           fgkEndCapCoolingTubeAxialRadius[0]
5397                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
5398                                                                           0.);
5399   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5400   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
5401                                                                                                 *coolingtuberot[2]);
5402
5403   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
5404                                            *                             (*coolingtubecombitrans[1]));
5405
5406   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5407                                                                          endcapcoolingtubeshape[1]->GetDz());
5408   torustuberot[0]->SetAngles(0.,90.,0.); 
5409   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
5410
5411   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
5412
5413   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5414                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
5415   coolingtuberot[3]->SetAngles(0.,90.,0.);
5416   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
5417                                                                                                 *coolingtuberot[3]);
5418   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5419   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
5420   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
5421   
5422   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5423                                                                         endcapcoolingtubeshape[2]->GetDz());
5424   torustuberot[1]->SetAngles(0.,90.,0.); 
5425   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
5426   torustuberot[2]->SetAngles(180.,0.,0.); 
5427   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
5428   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
5429
5430   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5431                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
5432   torustuberot[3]->SetAngles(0.,90.,0.); 
5433   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
5434   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5435   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
5436   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
5437
5438   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
5439                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
5440   coolingtuberot[5]->SetAngles(90.,90.,-90.);
5441   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
5442                                                                                                 *coolingtuberot[5]);
5443   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5444   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
5445   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
5446   
5447   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5448                                                                         endcapcoolingtubeshape[0]->GetDz());
5449   torustuberot[5]->SetAngles(0.,90.,0.); 
5450   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
5451   torustuberot[6]->SetAngles(-90.,0.,0.); 
5452   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
5453   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
5454   
5455   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5456                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
5457   coolingtuberot[6]->SetAngles(0.,90.,0.);
5458   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
5459                                                                                                 *coolingtuberot[6]);
5460   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5461   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
5462   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
5463     /////////////////////////////////////////
5464   // Transformation for Water Volume Positioning 
5465   /////////////////////////////////////////
5466   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
5467                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
5468   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
5469   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
5470                                                                                                      *coolingwatertuberot[0]);
5471
5472   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
5473   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
5474   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
5475                                                                                                      *coolingwatertuberot[1]);
5476
5477   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
5478                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
5479                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
5480                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
5481                                                                               0.);
5482   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
5483   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
5484                                                                                                     *coolingwatertuberot[2]);
5485
5486   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
5487                                            *                                 (*coolingwatertubecombitrans[1]));
5488                                            
5489   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5490                                                                          endcapcoolingwatertubeshape[1]->GetDz());
5491   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
5492   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
5493                                                                                                    *toruswatertuberot[0]);
5494
5495   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
5496                                                   *                                     (*toruswatertubecombitrans[0]));
5497
5498   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
5499                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
5500   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
5501   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
5502                                                                                                      *coolingwatertuberot[3]);
5503   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
5504   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
5505                                                         *                                 (*coolingwatertubecombitrans[3]));
5506   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
5507
5508   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
5509                                                                         endcapcoolingwatertubeshape[2]->GetDz());
5510   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
5511   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
5512                                                                                                    *toruswatertuberot[1]);
5513   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
5514   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
5515                                                   *                 (*toruswatertubecombitrans[1]));
5516   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
5517   
5518   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
5519                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
5520   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
5521   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
5522                                                                                                    *toruswatertuberot[3]);
5523   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
5524   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
5525                                                   *                                     (*toruswatertubecombitrans[2]));
5526   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
5527
5528   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
5529                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
5530   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
5531   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
5532                                                                                                      *coolingwatertuberot[5]);
5533   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
5534   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
5535                                                         *                                 (*coolingwatertubecombitrans[4]));
5536   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
5537   
5538   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
5539                                                                               endcapcoolingwatertubeshape[0]->GetDz());
5540   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
5541   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
5542                                                                                                    *toruswatertuberot[5]);
5543   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
5544   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
5545                                                   *                 (*toruswatertubecombitrans[3]));
5546   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
5547   
5548   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
5549                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
5550   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
5551   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
5552                                                                                                      *coolingwatertuberot[6]);
5553   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
5554   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
5555                                                         *                                 (*coolingwatertubecombitrans[5]));
5556   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
5557   /////////////////////////////////////////
5558   // Positioning Volumes
5559   /////////////////////////////////////////
5560   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
5561   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
5562   
5563   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
5564   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
5565
5566   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
5567   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
5568  
5569   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
5570   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
5571
5572   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
5573   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
5574
5575   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
5576   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
5577
5578   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
5579   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
5580
5581   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
5582   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
5583   
5584   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
5585   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
5586  
5587   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
5588   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
5589   /////////////////////////////////////////////////////////////
5590   // Deallocating memory
5591   /////////////////////////////////////////////////////////////
5592   for(Int_t i=0; i<8; i++){
5593     if(i<6){
5594          delete coolingtubetrans[i];
5595          delete coolingwatertubetrans[i];
5596          if(i!=0){
5597           delete coolingtubecombitrans[i];
5598           delete coolingwatertubecombitrans[i];
5599          }
5600         }
5601     if(i<8){
5602           delete coolingtuberot[i];
5603           delete coolingwatertuberot[i];
5604     }
5605     if(i<4){
5606                 delete torustubetrans[i];
5607                 delete toruswatertubetrans[i];
5608                 delete torustubecombitrans[i];
5609                 delete toruswatertubecombitrans[i];
5610         } 
5611     if(i<7){
5612          delete torustuberot[i];
5613          delete toruswatertuberot[i];
5614         }
5615   }
5616   /////////////////////////////////////////////////////////////
5617   return endcapcoolingtubemother;
5618  }
5619  ////////////////////////////////////////////////////////////////////////////////
5620  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
5621   /////////////////////////////////////////////////////////////
5622   // Getting EndCap Cover Side 
5623   /////////////////////////////////////////////////////////////
5624   const Int_t kendcapcoverholenumber[2] = {7,5}; 
5625   const Int_t kvertexnumber = 15; 
5626   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
5627   xvertex[0]  = 0.0;
5628   xvertex[1]  = xvertex[0];
5629   xvertex[2]  = fgkEndCapSideCoverLength[0];
5630   xvertex[3]  = fgkEndCapSideCoverLength[1];
5631   xvertex[4]  = xvertex[3];
5632   xvertex[5]  = fgkEndCapSideCoverLength[2];
5633   xvertex[6]  = xvertex[5];
5634   xvertex[7]  = xvertex[2];
5635   xvertex[8]  = xvertex[7];
5636   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
5637   xvertex[10] = xvertex[9];
5638   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
5639                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
5640                           * fgkEndCapSideCoverLength[4];
5641   xvertex[12] = xvertex[11];
5642   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
5643                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
5644                           * fgkEndCapSideCoverLength[4];
5645   xvertex[14] = xvertex[13];
5646   yvertex[0]  = 0.0;
5647   yvertex[1]  = fgkEndCapSideCoverWidth[0];
5648   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
5649   yvertex[3]  = yvertex[2];
5650   yvertex[4]  = fgkEndCapSideCoverWidth[1];
5651   yvertex[5]  = yvertex[4];
5652   yvertex[6]  = yvertex[0];
5653   yvertex[7]  = yvertex[6];
5654   yvertex[8]  = fgkEndCapSideCoverWidth[6];
5655   yvertex[9]  = yvertex[8];
5656   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
5657   yvertex[11] = yvertex[10];
5658   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
5659   yvertex[13] = yvertex[12];
5660   yvertex[14] = yvertex[6];
5661   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
5662   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
5663   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
5664   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5665   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5666   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
5667   endcapsidecovershapein->SetName("endcapsidecovershapein");
5668   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
5669   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
5670   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
5671
5672
5673   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
5674   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
5675                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
5676   endcapsidecover->SetLineColor(fColorPhynox);
5677   ////////////////////////////////////////////
5678   // Defininition of Mother Volume
5679   ////////////////////////////////////////////
5680   const Int_t kmothervertexnumber = 7;
5681   Double_t xmothervertex[kmothervertexnumber]; 
5682   Double_t ymothervertex[kmothervertexnumber]; 
5683   for(Int_t i=0; i<kmothervertexnumber; i++){
5684         xmothervertex[i] = xvertex[i];
5685         ymothervertex[i] = yvertex[i];
5686   }
5687   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
5688   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
5689   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
5690   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
5691   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
5692                                                                 endcapsidecovermothershape,fSSDAir);
5693   ////////////////////////////////////////////
5694   endcapsidecovermother->AddNode(endcapsidecover,1);
5695   TGeoBBox* endcapsidecoverboxshape[4];
5696   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
5697                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
5698                                                                0.5*fgkEndCapSideCoverLength[4],
5699                                                                    0.5*fgkEndCapSideCoverThickness); 
5700   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
5701                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
5702                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
5703                                                          -     fgkEndCapSideCoverLength[4]),
5704                                                                    0.5*fgkEndCapSideCoverThickness); 
5705   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
5706                                                                0.5*fgkEndCapSideCoverLength[4],
5707                                                                    0.5*fgkEndCapSideCoverThickness); 
5708   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
5709                                                                0.5*fgkEndCapSideCoverWidth[5],
5710                                                                    0.5*fgkEndCapSideCoverThickness); 
5711   TGeoVolume* endcapsidecoverbox[4];
5712   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
5713   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
5714   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
5715   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
5716   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
5717 //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5718   TGeoTranslation** endcapsidecoverboxtrans;
5719   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
5720   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
5721                                                          +                                         fgkEndCapSideCoverLength[0],
5722                                                                                                    endcapsidecoverboxshape[0]->GetDY()
5723                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
5724   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
5725                                                          +                     xvertex[11],
5726                                                                                                    endcapsidecoverboxshape[1]->GetDY()
5727                                                          +                     yvertex[12],0.);
5728   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
5729                                                          +                     xvertex[11],
5730                                                                                                    endcapsidecoverboxshape[2]->GetDY()
5731                                                          +                     yvertex[12]
5732                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
5733                                                          +                     fgkEndCapSideCoverWidth[5],0.);
5734   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
5735   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
5736   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
5737   for(Int_t i=0; i<2; i++)
5738         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
5739                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
5740                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
5741                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5742                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5743                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
5744                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
5745                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
5746         }
5747   for(Int_t i=0; i<2; i++)
5748         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
5749                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
5750                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
5751                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
5752                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
5753                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
5754                                                         +fgkEndCapSideCoverLength[4]),0.0);
5755                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
5756                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
5757                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
5758                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
5759         }
5760         return endcapsidecovermother;
5761  } 
5762  ////////////////////////////////////////////////////////////////////////////////
5763  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
5764  ////////////////////////////////////////////////////////////////////////////////
5765  // Method returning Interface Card A, Interface Card B, Supply Card 
5766  ////////////////////////////////////////////////////////////////////////////////
5767  /////////////////////
5768  // Supply Card
5769  /////////////////////
5770  // Electronic Board Back Al Plane
5771  const Int_t kelectboardbackvertexnumber = 8;
5772  Double_t xelectboardback[kelectboardbackvertexnumber];
5773  Double_t yelectboardback[kelectboardbackvertexnumber];
5774  xelectboardback[0] = 0.0;
5775  xelectboardback[1] = xelectboardback[0];
5776  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
5777  xelectboardback[3] = xelectboardback[2];
5778  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
5779  xelectboardback[5] = xelectboardback[4];
5780  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
5781  xelectboardback[7] = xelectboardback[6];
5782  
5783  yelectboardback[0] = 0.0;
5784  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
5785  yelectboardback[2] = yelectboardback[1];
5786  yelectboardback[3] = yelectboardback[0];
5787  yelectboardback[4] = yelectboardback[3];
5788  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
5789  yelectboardback[6] = yelectboardback[5];
5790  yelectboardback[7] = yelectboardback[4];
5791  TGeoXtru* electboardbackshape = new TGeoXtru(2);
5792  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
5793                                                                         xelectboardback,yelectboardback); 
5794  electboardbackshape->DefineSection(0,0.0);
5795  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
5796  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
5797                                                                                          electboardbackshape,fSSDSupportRingAl);
5798  electboardback->SetLineColor(fColorAl);
5799  // Electronic Board Kapton Layer
5800  const Int_t kelectlayervertexnumber = 8;
5801  Double_t xelectlayer[kelectlayervertexnumber];
5802  Double_t yelectlayer[kelectlayervertexnumber];
5803  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
5804  xelectlayer[1] = xelectlayer[0];
5805  xelectlayer[2] = fgkEndCapCardElectBoardLength;
5806  xelectlayer[3] = xelectlayer[2];
5807  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
5808      
5809  yelectlayer[0] = 0.0;
5810  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
5811  yelectlayer[2] = yelectlayer[1];
5812  yelectlayer[3] = yelectlayer[0];
5813  yelectlayer[4] = yelectlayer[3];
5814  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
5815  yelectlayer[6] = yelectlayer[5];
5816  yelectlayer[7] = yelectlayer[4];
5817  TGeoXtru* electlayershape = new TGeoXtru(2);
5818  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
5819  electlayershape->DefineSection(0,0.0);
5820  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
5821  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
5822                                                                                          electlayershape,fSSDKaptonFlexMedium);
5823  electlayer->SetLineColor(fColorKapton);
5824  // JMD Connector Female
5825  const Int_t kjmdconnectorvertexnumber = 6;
5826  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5827  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
5828  xjmdconnectorvertex[0] = 0.0; 
5829  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
5830  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
5831  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
5832  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
5833  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
5834
5835  yjmdconnectorvertex[0] = 0.0; 
5836  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
5837  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
5838  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
5839  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
5840  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
5841  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
5842  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
5843                                                                   yjmdconnectorvertex); 
5844  jmdconnectorshape->DefineSection(0,0.0);
5845  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
5846  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
5847                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
5848  jmdconnector->SetLineColor(fColorG10);
5849  // Top Cable Connector
5850  const Int_t kcableconnectorvertexnumber = 8;
5851  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
5852  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
5853  xconnectorvertex[0] = 0.0;
5854  xconnectorvertex[1] = xconnectorvertex[0];
5855  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
5856  xconnectorvertex[3] = xconnectorvertex[2];
5857  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
5858                                          - fgkEndCapCardCableConnectorLength[2];
5859  xconnectorvertex[5] = xconnectorvertex[4];
5860  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
5861  xconnectorvertex[7] = xconnectorvertex[6];
5862
5863  yconnectorvertex[0] = 0.0;
5864  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
5865  yconnectorvertex[2] = yconnectorvertex[1];
5866  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
5867  yconnectorvertex[4] = yconnectorvertex[3];
5868  yconnectorvertex[5] = yconnectorvertex[1];
5869  yconnectorvertex[6] = yconnectorvertex[5];
5870  yconnectorvertex[7] = yconnectorvertex[0];
5871  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
5872  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
5873                                                                     yconnectorvertex); 
5874  cableconnectorshape->DefineSection(0,0.0);
5875  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
5876  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
5877                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
5878  cableconnector->SetLineColor(fColorG10);
5879  // Strip Connection
5880  TGeoBBox* endcapstripconnectionshape = 
5881                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
5882                                                                                          0.5*fgkEndCapStripConnectionThickness,
5883                                                                                          0.5*fgkEndCapStripConnectionWidth);
5884  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
5885                                                                                                         endcapstripconnectionshape,
5886                                                                                                         fSSDSupportRingAl);
5887  endcapstripconnection->SetLineColor(fColorAl);
5888  // Interface Card B
5889  const Int_t kcardBvertexnumber = 12; 
5890  Double_t xcardBvertexnumber[kcardBvertexnumber];
5891  Double_t ycardBvertexnumber[kcardBvertexnumber];
5892
5893  xcardBvertexnumber[0]  = 0.0;
5894  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
5895  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
5896  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
5897  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
5898  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
5899  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
5900  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
5901  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
5902  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
5903  xcardBvertexnumber[10] = xcardBvertexnumber[7];
5904  xcardBvertexnumber[11] = xcardBvertexnumber[10];
5905  
5906  ycardBvertexnumber[0]  = 0.0;
5907  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
5908  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
5909  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
5910  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
5911  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
5912  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
5913  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
5914  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
5915  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
5916  ycardBvertexnumber[10] = ycardBvertexnumber[9];
5917  ycardBvertexnumber[11] = ycardBvertexnumber[0];
5918
5919  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
5920  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
5921  interfacecardBshape->DefineSection(0,0.);
5922  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
5923  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
5924                                                                                          fSSDMountingBlockMedium);
5925  interfacecardB->SetLineColor(46);
5926  // Interface Card B Electronic Board
5927  const Int_t kelectboardcardBvertexnumber = 14; 
5928  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
5929  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
5930
5931  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
5932  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
5933  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
5934  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
5935  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
5936  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
5937  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
5938  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
5939  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
5940  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
5941  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
5942  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
5943  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
5944  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
5945
5946  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
5947  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
5948  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
5949  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
5950  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
5951  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
5952  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
5953  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
5954  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
5955  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
5956  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
5957  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
5958  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
5959  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
5960
5961  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
5962  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
5963                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
5964  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
5965  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
5966                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
5967  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
5968                                                                                           fSSDSupportRingAl);
5969  electboardcardB->SetLineColor(fColorAl);
5970  // Generating Stiffener 2
5971  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
5972                                                                                            0.5*fgkEndCapStiffenerThickness,
5973                                                                                            0.5*fgkEndCapStiffenerLength);
5974  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
5975  endcapstiffener->SetLineColor(fColorAl);   
5976  // Generating Mother Interface Card B Container
5977  const Int_t kinterfacecardBmothervertexnumber = 10;
5978  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
5979  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
5980
5981  xinterfacecardBmothervertex[0] = 0.0;
5982  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
5983  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
5984                                                                 + fgkEndCapInterfaceCardBThickness;
5985  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
5986  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
5987                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
5988  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
5989  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
5990  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
5991  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
5992                                                                 + fgkEndCapCardJMDConnectorLength[0];
5993  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
5994
5995  yinterfacecardBmothervertex[0] = 0.0;
5996  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
5997                                                                 + fgkEndCapInterfaceCardBWidth[1]
5998                                                                 + fgkEndCapInterfaceCardBWidth[2];
5999  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
6000  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
6001  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
6002  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
6003  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
6004  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
6005                                                                 + fgkEndCapCardJMDConnectorWidth[0]
6006                                                                 + fgkEndCapCardJMDConnectorWidth[1];
6007  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
6008  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
6009  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
6010  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
6011                                                                                   xinterfacecardBmothervertex,
6012                                                                                   yinterfacecardBmothervertex);
6013  interfacecardBmothershape->DefineSection(0,-1.e-15);
6014  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
6015  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
6016                                                                                                    interfacecardBmothershape,fSSDAir);
6017  electboardcardB->SetLineColor(fColorAl);
6018  // Positioning Volumes Mother Interface Card B Container 
6019  TGeoRotation* interfacecardBrot = new TGeoRotation();
6020  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
6021  interfacecardBrot->SetAngles(90.,-90.,-90.);
6022  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
6023  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
6024  TGeoRotation* electboardcardBrot = new TGeoRotation();
6025  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
6026  electboardcardBrot->SetAngles(90.,90.,-90.);
6027  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
6028  TGeoCombiTrans* electboardcardBcombitrans = 
6029                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
6030  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
6031  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
6032  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
6033  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
6034  TGeoTranslation* jmdconnectorcardBtrans[3];
6035  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
6036  for(Int_t i=0; i<3; i++){
6037    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
6038                                                          + fgkEndCapCardJMDConnectorLength[0], 
6039                                                            fgkEndCapCardElectBoardLayerWidth[1],
6040                                                            0.5*fgkEndCapCardJMDConnectorThickness
6041                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
6042                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
6043                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
6044    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
6045                                                                                                            *jmdconnectorcardBrot);
6046    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
6047  }
6048  // Mother Supply Card Container 
6049  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
6050  // Interface Card Container
6051  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
6052  // Placing Volumes in Mother Supply Card Container
6053  // JMD Connector Positioning
6054  TGeoTranslation* jmdconnectortrans[2];
6055  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
6056  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
6057                                                                                         fgkEndCapCardElectBoardBackLength[0]
6058                                           -                                             fgkEndCapCardJMDConnectorThickness
6059                                           -                                             fgkEndCapCardJMDConnectorToLayer);
6060  TGeoRotation* jmdconnectorot = new TGeoRotation();
6061  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
6062                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
6063                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
6064                                                                           fgkEndCapCardElectBoardLayerWidth[1],
6065                                                                       fgkEndCapCardJMDConnectorThickness
6066                                                                  +    fgkEndCapCardJMDConnectorToLayer);
6067  jmdconnectorot->SetAngles(90.,180.,-90);
6068  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
6069                                                                                 * jmdconnectorot);
6070  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
6071  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
6072  // Top Cable Connector Placing
6073  TGeoRotation* cableconnectorot[2];
6074  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
6075  TGeoTranslation* cableconnectortrans[3];
6076  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
6077  cableconnectorot[0]->SetAngles(90.,0.,0.); 
6078  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
6079  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
6080  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
6081                                                                                                                            *cableconnectorot[0]);
6082  TGeoHMatrix* cableconnectormatrix[2];
6083  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
6084                                                         new TGeoHMatrix((*cableconnectorot[1])
6085                                                                                    *(*cableconnectorcombitrans));
6086  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6087                                            -                               fgkEndCapCardCableConnectorThickness,
6088                                                                                 fgkEndCapCardCableConnectorLength[0]
6089                                            +                            fgkEndCapCardCableConnectorToLayer);
6090  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
6091                                            -                2.*fgkEndCapCardCableConnectorThickness
6092                                            -                            fgkEndCapCardCableConnectorDistance,
6093                                                                                 fgkEndCapCardCableConnectorLength[0]
6094                                            +                            fgkEndCapCardCableConnectorToLayer);
6095  for(Int_t i=0; i<2; i++){
6096         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
6097     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
6098  }
6099  TGeoRotation* electboardbackrot = new TGeoRotation(); 
6100  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
6101  electboardbackrot->SetAngles(90.,-90.,-90.);
6102  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
6103                                                         +                fgkEndCapCardJMDConnectorLength[0]
6104                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
6105  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
6106                                                                                                                            *electboardbackrot);
6107  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
6108  // Electronic Board Kapton Layer Positioning
6109  TGeoRotation* electlayerrot = new TGeoRotation();
6110  TGeoTranslation* electlayertrans[2];
6111  TGeoCombiTrans* electlayercombitrans[2];
6112  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
6113  electlayerrot->SetAngles(90.,-90.,-90.);
6114  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6115                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
6116  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
6117                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
6118                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
6119  for(Int_t i=0; i<2; i++){
6120         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
6121         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
6122  }
6123  // Placing Volumes in Mother Interface Card Container
6124  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
6125  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
6126  for(Int_t i=0; i<2; i++){
6127         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
6128  }
6129  /////////////////////////////////////////////////////////////
6130  // Generation of Card Interface Container
6131  /////////////////////////////////////////////////////////////
6132  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6133                                                   - fgkEndCapCardJMDConnectorLength[0]
6134                                                   - fgkEndCapInterfaceCardBThickness
6135                                                   - 9.*fgkEndCapStripConnectionThickness
6136                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
6137  const Int_t kcardinterfacecontainervertexnumber = 14;
6138  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6139  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
6140  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
6141                                                                    - 7.0*fgkEndCapStripConnectionThickness;
6142  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
6143  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
6144                                                                    + fgkEndCapStripConnectionThickness
6145                                                                    - fgkEndCapCardElectBoardLayerThickness
6146                                                                    - fgkEndCapCardCableConnectorWidth[0];
6147  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
6148  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
6149  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
6150  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
6151                                                                    + 2.0*fgkEndCapStripConnectionThickness;
6152  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
6153  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
6154                                                                    + fgkEndCapInterfaceCardBThickness;
6155  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
6156  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
6157                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
6158  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
6159  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
6160                                    - fgkEndCapInterfaceElectBoardCardBThickness
6161                                                                    + fgkEndCapCardJMDConnectorLength[0]
6162                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
6163  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
6164
6165  ycardinterfacecontainervertex[0]  = 0.;
6166  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
6167                                                                    + fgkEndCapCardJMDConnectorWidth[0]
6168                                                                    + fgkEndCapCardJMDConnectorWidth[1];
6169  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
6170  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
6171                                                                    - fgkEndCapStripConnectionWidth;
6172  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
6173  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
6174  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
6175  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
6176                                                                    + fgkEndCapInterfaceCardBWidth[1]
6177                                                                    + fgkEndCapInterfaceCardBWidth[2];
6178  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
6179  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
6180  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
6181  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
6182  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
6183  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
6184  
6185  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
6186  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
6187                                                                                   xcardinterfacecontainervertex,
6188                                                                                   ycardinterfacecontainervertex);
6189  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
6190                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6191  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
6192                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
6193  TGeoVolume** cardinterfacecontainer;
6194  cardinterfacecontainer = new TGeoVolume*[4];
6195  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
6196                                                                                         interfacecardmothershape,fSSDAir); 
6197  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
6198                                                                                         interfacecardmothershape,fSSDAir); 
6199  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
6200                                                                                         interfacecardmothershape,fSSDAir); 
6201  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
6202                                                                                         interfacecardmothershape,fSSDAir); 
6203  /////////////////////////////////
6204  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
6205  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
6206  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
6207  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
6208  /////////////////////////////////
6209  TGeoRotation* endcapstripconnectionrot[2];
6210  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
6211  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
6212  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
6213  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
6214                                                                         *                                 (*endcapstripconnectionrot[0]));
6215  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
6216  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
6217                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
6218                                                                                          fgkEndCapCardElectBoardBackWidth[0]
6219                                                                                         -endcapstripconnectionshape->GetDZ(),
6220                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
6221  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
6222  TGeoTranslation* cardinterfacetrans[9];
6223  TGeoHMatrix* cardinterfacematrix[9]; 
6224  for(Int_t i=0; i<7; i++){ 
6225         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
6226                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
6227                                                                                                 0.0,0.0);  
6228         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6229                                                    *                             (*endcapstripconnectionmatrix));
6230  }
6231  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
6232                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6233                                                                                                 0.0,0.0);  
6234  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
6235                                                 *                                 (*endcapstripconnectionmatrix));
6236  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
6237                                                   +                                             fgkEndCapCardElectBoardBackThickness),
6238                                                                                                 0.0,0.0);  
6239  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
6240                                                 *                                 (*endcapstripconnectionmatrix));
6241
6242  for(Int_t i=0; i<4; i++){
6243         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
6244                                                                            cardinterfacematrix[7]);                             
6245         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
6246                                                                            cardinterfacematrix[8]);                             
6247  }
6248  TGeoTranslation* mothersupplycardtrans = 
6249                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
6250                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
6251                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
6252  TGeoHMatrix* mothersupplycardmatrix[7];
6253  Int_t index[4] = {1,1,1,1};
6254  for(Int_t i=0; i<7; i++){
6255         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
6256                                                         *                                 (*mothersupplycardtrans));
6257         for(Int_t j=0; j<4; j++){
6258                 switch(j){
6259                         case 0: //Layer5 EndCap Left Side  
6260                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6261                                                                                                    cardinterfacematrix[i]);                             
6262                                 if(i!=0){
6263                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6264                                                                                                            mothersupplycardmatrix[i]);                  
6265                                         index[j]++;
6266
6267                                 }
6268                         break;
6269                         case 1: //Layer5 EndCap Rigth Side  
6270                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6271                                                                                                    cardinterfacematrix[i]);                     
6272                                 if(i>0&&i<6){
6273                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6274                                                                                                            mothersupplycardmatrix[i]);                  
6275                                         index[j]++;
6276                                 }
6277                         break;
6278                         case 2: //Layer6 EndCap Left Side  
6279                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6280                                                                                                    cardinterfacematrix[i]);                             
6281                                 if(i!=6){
6282                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6283                                                                                                            mothersupplycardmatrix[i]);                  
6284                                         index[j]++;
6285                                 }
6286                         break;
6287                         case 3: //Layer6 EndCap Right Side  
6288                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
6289                                                                                                    cardinterfacematrix[i]);                             
6290                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
6291                                                                                                    mothersupplycardmatrix[i]);                  
6292                                 index[j]++;
6293                         break;
6294                 }
6295         }
6296  }
6297  // Positioning Interface 
6298  TGeoTranslation* motherinterfacecardtrans = 
6299                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
6300                                                          +0.5*fgkEndCapCardElectBoardBackThickness
6301                                                          -fgkEndCapCardElectBoardLayerThickness
6302                                                          +fgkEndCapStripConnectionThickness,0.,0.);
6303  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
6304                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
6305  // Positioning Interface Card B 
6306  TGeoTranslation* interfacecardBmothertrans = 
6307                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
6308                                                                                 + 2.*fgkEndCapStripConnectionThickness
6309                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
6310                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
6311                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
6312  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
6313                                                                                                                          interfacecardBmothertrans);
6314  // Positioning Stiffener 
6315  TGeoTranslation* endcapstiffenertrans = 
6316                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
6317                                                                            +    2.0*fgkEndCapStripConnectionThickness
6318                                                                            +    fgkEndCapInterfaceCardBThickness
6319                                                                            +    fgkEndCapCardJMDConnectorLength[0]
6320                                                                            +    stiffenertransx
6321                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
6322                                                                                         endcapstiffenershape->GetDZ()
6323                                                                            -    0.5*(fgkEndCapStiffenerLength
6324                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
6325  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
6326  /////////////////////////////////////////////////////////////
6327  // Deallocating memory
6328  /////////////////////////////////////////////////////////////
6329  delete interfacecardBrot;
6330  delete interfacecardBtrans;
6331  delete electboardcardBtrans;
6332  delete electboardcardBrot; 
6333  delete jmdconnectorcardBrot;
6334  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
6335  delete jmdconnectorot;
6336  delete jmdconnectortrans[1];
6337  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
6338  delete cableconnectorcombitrans;
6339  delete electboardbacktrans;
6340  delete electboardbackrot;
6341  delete electlayerrot;
6342  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
6343  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
6344  delete mothersupplycardtrans;
6345  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
6346  /////////////////////////////////////////////////////////////
6347  return cardinterfacecontainer;
6348  }
6349  ////////////////////////////////////////////////////////////////////////////////
6350  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
6351   /////////////////////////////////////////////////////////////
6352   // Method returning EndCap Mother Volume
6353   /////////////////////////////////////////////////////////////
6354   const Int_t kendcapcoverplatesmallholenumber = 9;
6355   Double_t endcapmotherorigin[3];
6356   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
6357                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
6358                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
6359   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
6360                                           -                      fgkEndCapCoverPlateWidth[2]
6361                                           -       (kendcapcoverplatesmallholenumber-1)
6362                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
6363                                           +  0.5*(fgkEndCapSideCoverLength[2]
6364                                           +               fgkEndCapCoverPlateWidth[1]
6365                                           -       fgkEndCapCoverPlateWidth[0])
6366                                           -      (fgkEndCapCoverPlateWidth[1]
6367                                           -       fgkEndCapCoverPlateWidth[0]);
6368   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
6369                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
6370                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
6371                                                 +      fgkEndCapSideCoverWidth[1]
6372                                                 +      fgkEndCapSideCoverThickness
6373                                                 +      fgkEndCapKaptonFoilThickness);
6374   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
6375                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
6376                                                           +              2.0* fgkEndCapSideCoverThickness),
6377                                                                          0.5* (fgkEndCapSideCoverLength[2]
6378                                                           +                    fgkEndCapCoverPlateWidth[1]
6379                                                           -                                        fgkEndCapCoverPlateWidth[0]),
6380                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
6381                                                       +                                    fgkEndCapSideCoverWidth[1]
6382                                                           +                                       fgkEndCapSideCoverThickness
6383                                                       +                                   fgkEndCapKaptonFoilThickness),
6384                                                                                          endcapmotherorigin);
6385   TGeoVolume** endcapassembly;  
6386   endcapassembly = new TGeoVolume*[4];
6387   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
6388                                                                                         endcapmothershape,fSSDAir); 
6389   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
6390                                                                                         endcapmothershape,fSSDAir); 
6391   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
6392                                                                                         endcapmothershape,fSSDAir); 
6393   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
6394                                                                                         endcapmothershape,fSSDAir); 
6395  /////////////////////////////////
6396  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
6397  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
6398  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
6399  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
6400  /////////////////////////////////
6401   /////////////////////////////////////////////////////
6402   // Placing Endcap Cover Plate
6403   /////////////////////////////////////////////////////
6404   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
6405   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
6406   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
6407   TGeoCombiTrans* endcapcoverplatecombitrans = 
6408                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
6409                                                                                          endcapcoverplaterot);
6410   TGeoTranslation* endcapcoverplatetrans = 
6411                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
6412   TGeoHMatrix* endcapcoverplatematrix = 
6413                                                   new TGeoHMatrix((*endcapcoverplatetrans)
6414                                                                           *       (*endcapcoverplatecombitrans));
6415   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
6416   /////////////////////////////////////////////////////
6417   // Placing Endcap Side Cover
6418   /////////////////////////////////////////////////////
6419   TGeoVolume* endcapsidecover = GetEndCapSideCover();
6420   TGeoRotation* endcapsidecoverot[2];
6421   TGeoCombiTrans* endcapsidecovercombitrans[3];
6422   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
6423   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
6424   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
6425                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
6426                                                                                         - fgkEndCapCoverPlateWidth[2]
6427                                                                                     - (kendcapcoverplatesmallholenumber-1)
6428                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
6429                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
6430                                                                                         + fgkEndCapSideCoverLength[2],
6431                                                                                           0.5*(fgkEndCapSideCoverThickness
6432                                                                                         + fgkEndCapCoverPlateThickness)
6433                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
6434                                                                                           endcapsidecoverot[0]);
6435   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
6436   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
6437                                                                                                         0.5*fgkEndCapCoverPlateThickness
6438                                                                                                         -fgkEndCapSideCoverWidth[1],
6439                                                                                                         endcapsidecoverot[1]);
6440   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
6441                                                                                                         +fgkEndCapCoverPlateLength[3]
6442                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
6443                                                                                                         +fgkEndCapSideCoverThickness,0.0,
6444                                                                                                         0.5*fgkEndCapCoverPlateThickness
6445                                                                                                         -fgkEndCapSideCoverWidth[1],
6446                                                                                                         endcapsidecoverot[1]);
6447   TGeoHMatrix* endcapsidecovermatrix[2];
6448   for(Int_t i=0; i<2; i++){
6449    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
6450                                                         *                                 (*endcapsidecovercombitrans[0]));
6451         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
6452                                                                                                                 endcapsidecovermatrix[i]);
6453   }
6454   /////////////////////////////////////////////////////
6455   // Placing Endcap Cooling Tube
6456   /////////////////////////////////////////////////////
6457   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
6458   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
6459   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
6460   TGeoCombiTrans* endcapccolingtubecombitrans 
6461                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
6462                                                 + fgkEndCapCoolingTubeAxialRadius[1])
6463                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
6464                                                 - fgkEndCapCoolingTubeToCoverSide,
6465                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
6466                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
6467   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
6468                                                                                                           endcapccolingtubecombitrans);
6469   /////////////////////////////////////////////////////
6470   // Placing Screws 
6471   /////////////////////////////////////////////////////
6472   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
6473                                                                            fgkEndCapCoverPlateScrewRadiusMin};
6474   Int_t screwcoverplatedgesnumber[2] = {20,20};
6475   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
6476                                                                                 fgkEndCapCoverPlateThickness
6477                                                                          +  fgkEndCapCoolingTubeRadiusMax};
6478   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
6479                                                                                                  screwcoverplatedgesnumber,
6480                                                                                                  screwcoverplatesection);
6481   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
6482                                                                                            screwcoverplateshape,
6483                                                                                            fSSDCoolingTubePhynox); 
6484   screwcoverplate->SetLineColor(12);
6485   Double_t transx[4] = {0,
6486                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
6487                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
6488                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
6489                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
6490                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
6491   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
6492 //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
6493   TGeoTranslation*** endcapcoverplatescrewtrans;
6494   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
6495   Int_t index = 0;
6496   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
6497         endcapcoverplatescrewtrans[i] = 
6498                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
6499     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
6500                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
6501         if(index==1||index==9||index==28||index==36){
6502                         endcapcoverplatescrewtrans[i][j] = 
6503                                 new TGeoTranslation(transx[i],
6504                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6505                                                                         fgkEndCapSideCoverThickness);
6506                 }
6507                 else{
6508                         endcapcoverplatescrewtrans[i][j] = 
6509                                 new TGeoTranslation(transx[i],
6510                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
6511                                                                         0.);
6512                 }
6513             if(index!=19) 
6514                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
6515                                                                                           endcapcoverplatescrewtrans[i][j]);
6516         }
6517   }
6518   /////////////////////////////////////////////////////
6519   // Placing Cover Plate Clips 
6520   /////////////////////////////////////////////////////
6521   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
6522                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
6523                                                                                                          0.5*fgkEndCapSideCoverThickness);
6524   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
6525                                                                                                         endcapcoverplateclipshape,
6526                                                                                                         fSSDCoolingTubePhynox);
6527   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
6528                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
6529                                                                                                          0.5*fgkEndCapSideCoverThickness);
6530   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
6531                                                                                                         endcapcoverplatedownclipshape,
6532                                                                                                         fSSDCoolingTubePhynox);
6533   TGeoTranslation* endcapcoverplatecliptrans[4];
6534   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6535                                                            -                     fgkEndCapCoverPlateLength[0]
6536                                                            -                     fgkEndCapSideCoverThickness,
6537                                                                                                          0.0,
6538                                                                                                  0.5*(fgkEndCapSideCoverThickness
6539                                                            +                                              fgkEndCapCoverPlateThickness));
6540   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6541                                                            -                     fgkEndCapCoverPlateLength[0]
6542                                                            -                     fgkEndCapSideCoverThickness,
6543                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6544                                                            *                                     fgkEndCapSideCoverWidth[5],
6545                                                                                                  0.5*(fgkEndCapSideCoverThickness
6546                                                            +                                              fgkEndCapCoverPlateThickness));
6547   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6548                                                            -                     fgkEndCapCoverPlateLength[0]
6549                                                            +                                     fgkEndCapCoverPlateLength[1]
6550                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6551                                                            -                                     fgkEndCapCoverPlateClipLength
6552                                                            +                                 fgkEndCapSideCoverThickness,
6553                                                                                                          0.0,
6554                                                                                                  0.5*(fgkEndCapSideCoverThickness
6555                                                            +                                              fgkEndCapCoverPlateThickness));
6556   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
6557                                                            -                     fgkEndCapCoverPlateLength[0]
6558                                                            +                                     fgkEndCapCoverPlateLength[1]
6559                                                            +                              2.*fgkEndCapCoverPlateLength[0]
6560                                                            -                                     fgkEndCapCoverPlateClipLength
6561                                                            +                                 fgkEndCapSideCoverThickness,
6562                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
6563                                                            *                                     fgkEndCapSideCoverWidth[5],
6564                                                                                                  0.5*(fgkEndCapSideCoverThickness
6565                                                            +                                              fgkEndCapCoverPlateThickness));
6566   endcapcoverplateclip->SetLineColor(fColorPhynox);
6567   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
6568   for(Int_t i=0; i<4; i++) 
6569         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
6570                                                                                                    endcapcoverplatecliptrans[i]);  
6571   TGeoTranslation* endcapcoverplatedowncliptrans[4];
6572   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6573                                                                    -                     fgkEndCapCoverPlateLength[0]
6574                                                                    -                     fgkEndCapSideCoverThickness,
6575                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6576                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6577                                                                                                         0.5*(fgkEndCapSideCoverThickness
6578                                                                +                                         fgkEndCapCoverPlateThickness)
6579                                                                    -                     fgkEndCapSideCoverWidth[1]
6580                                                                    -                                     fgkEndCapSideCoverThickness);
6581   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6582                                                                    -                     fgkEndCapCoverPlateLength[0]
6583                                                                    -                     fgkEndCapSideCoverThickness,
6584                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6585                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6586                                                                    +                            fgkEndCapSideCoverLength[2]
6587                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
6588                                                                                                         0.5*(fgkEndCapSideCoverThickness
6589                                                                +                                         fgkEndCapCoverPlateThickness)
6590                                                                    -                     fgkEndCapSideCoverWidth[1]
6591                                                                    -                                     fgkEndCapSideCoverThickness);
6592   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6593                                                                    -                     fgkEndCapCoverPlateLength[0]
6594                                                                    +                     fgkEndCapSideCoverThickness
6595                                                                    +                     fgkEndCapCoverPlateLength[1]
6596                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6597                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6598                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6599                                                                    -                                 fgkEndCapCoverPlateClipWidth),
6600                                                                                                         0.5*(fgkEndCapSideCoverThickness
6601                                                                +                                         fgkEndCapCoverPlateThickness)
6602                                                                    -                     fgkEndCapSideCoverWidth[1]
6603                                                                    -                                     fgkEndCapSideCoverThickness);
6604   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
6605                                                                    -                     fgkEndCapCoverPlateLength[0]
6606                                                                    +                     fgkEndCapSideCoverThickness
6607                                                                    +                     fgkEndCapCoverPlateLength[1]
6608                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
6609                                                                    -                     fgkEndCapCoverPlateDownClipLength,
6610                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
6611                                                                    -                                 fgkEndCapCoverPlateClipWidth)
6612                                                                    +                                 fgkEndCapSideCoverLength[2]
6613                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
6614                                                                                                         0.5*(fgkEndCapSideCoverThickness
6615                                                                +                                         fgkEndCapCoverPlateThickness)
6616                                                                    -                     fgkEndCapSideCoverWidth[1]
6617                                                                    -                                     fgkEndCapSideCoverThickness);
6618   for(Int_t i=0; i<4; i++)
6619         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
6620                                                                                                    endcapcoverplatedowncliptrans[i]);
6621   /////////////////////////////////////////////////////
6622   // Placing Kapton Foil
6623   /////////////////////////////////////////////////////
6624   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
6625                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
6626                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
6627   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
6628                                                                                                 endcapkaptonfoilshape,
6629                                                                                                 fSSDKaptonFlexMedium);
6630   endcapkaptonfoil->SetLineColor(8);
6631   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6632                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
6633                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
6634                                                                                                                            0.5*fgkEndCapCoverPlateThickness
6635                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
6636                                                                              -                     fgkEndCapSideCoverWidth[1]
6637                                                                                  -                     fgkEndCapSideCoverThickness);
6638   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
6639   /////////////////////////////////////////////////////////////
6640   // Placing Electronic Tubes
6641   /////////////////////////////////////////////////////////////
6642   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
6643                                                                              - fgkEndCapInterfaceCardBThickness
6644                                                                              - 9.*fgkEndCapStripConnectionThickness
6645                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
6646                                                                                fgkEndCapKaptonFoilWidth
6647                                                                              - fgkEndCapInterfaceCardBThickness
6648                                                                              - 9.*fgkEndCapStripConnectionThickness
6649                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
6650                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
6651   TGeoVolume* endcapeffectivecables[2];
6652   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6653                                                                                          fgkEndCapEffectiveCableRadiusMax,
6654                                                                                          endcapeffectivecableswidth[0],
6655                                                                                          10,"EndCapEffectiveCables1"); 
6656   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
6657                                                                                          fgkEndCapEffectiveCableRadiusMax,
6658                                                                                          endcapeffectivecableswidth[1],
6659                                                                                          25,"EndCapEffectiveCables2"); 
6660   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
6661   TGeoTranslation* endcapeffectivecablestrans[2];
6662   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6663                                           -                                                        0.5*endcapeffectivecableswidth[0]
6664                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6665                                           -                                                               fgkEndCapCoverPlateWidth[2]
6666                                           -                                             (kendcapcoverplatesmallholenumber-1)
6667                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6668                                           +                                             fgkEndCapSideCoverLength[2],
6669                                           -                     0.5*fgkEndCapCoverPlateThickness
6670                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6671                                           -                                              fgkEndCapInterfaceCardBWidth[0]
6672                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
6673   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
6674                                           -                                                        0.5*endcapeffectivecableswidth[1]
6675                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
6676                                           -                                                               fgkEndCapCoverPlateWidth[2]
6677                                           -                                             (kendcapcoverplatesmallholenumber-1)
6678                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6679                                           +                                         fgkEndCapSideCoverLength[2],
6680                                           -                     0.5*fgkEndCapCoverPlateThickness
6681                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
6682                                           -                                              fgkEndCapInterfaceCardBWidth[0])
6683                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
6684   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
6685   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
6686   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
6687                                                                                                                    *endcapeffectivecablesrot);
6688   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
6689                                                                                                                    *endcapeffectivecablesrot);
6690 //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
6691 //                                                                                                        endcapeffectivecablescombitrans[0]);
6692   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
6693                                                                                                           endcapeffectivecablescombitrans[1]);
6694   /////////////////////////////////////////////////////////////
6695   // Placing End Cap Cards
6696   /////////////////////////////////////////////////////////////
6697   TGeoVolume** endcapcards = GetEndCapCards();
6698   TGeoRotation* endcapcardsrot[2];
6699   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
6700   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
6701   TGeoTranslation* endcapcardstrans[2]; 
6702   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
6703                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
6704   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
6705   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
6706   TGeoHMatrix* endcapcardsmatrix[2];
6707   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
6708   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
6709                                                   - fgkEndCapCardJMDConnectorLength[0]
6710                                                   - fgkEndCapInterfaceCardBThickness
6711                                                   - 9.*fgkEndCapStripConnectionThickness
6712                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
6713   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
6714                                           -                                             fgkEndCapCoverPlateLength[0]
6715                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
6716                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
6717                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
6718                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
6719                                           -                                                               fgkEndCapInterfaceCardBThickness
6720                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
6721                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
6722                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
6723                                           -                                                               fgkEndCapCoverPlateWidth[2]
6724                                           -                                             (kendcapcoverplatesmallholenumber-1)
6725                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
6726                                           +                     fgkEndCapKaptonFoilWidth,
6727                                                                                           0.5*fgkEndCapCoverPlateThickness
6728                                           -                                                     fgkEndCapSideCoverWidth[1]);
6729   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
6730   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
6731    /////////////////////////////////////////////////////////////
6732   // Deallocating memory
6733   /////////////////////////////////////////////////////////////
6734   delete endcapcoverplaterot;
6735   delete endcapcoverplatecombitrans;
6736   delete endcapcoverplatetrans;
6737   for(Int_t i=0; i<3; i++){
6738    delete endcapsidecovercombitrans[i];
6739    if(i<2) delete endcapsidecoverot[i]; 
6740   }
6741   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
6742   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
6743   delete endcapcardsmatrix[0];
6744   return endcapassembly;
6745  } 
6746  ////////////////////////////////////////////////////////////////////////////////
6747  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
6748                                                                                                                         Double_t radiusmax, 
6749                                                                                                                         Double_t width, 
6750                                                                                                                         Int_t ncables,
6751                                                                                                                         const char* volname){
6752   /////////////////////////////////////////////////////////////
6753   // Generating EndCap High Voltage Tubes 
6754   /////////////////////////////////////////////////////////////
6755   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
6756   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
6757
6758   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
6759   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
6760                                                                                                    effectiveouteradius,0.5*width);
6761   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
6762                                                                                                 effectiveinnertubeshape,
6763                                                                                                 fSSDStiffenerConnectorMedium);
6764   effectiveinnertube->SetLineColor(41);
6765   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
6766                                                                                                 effectiveoutertubeshape,
6767                                                                                                 fSSDKaptonChipCableMedium);
6768   effectiveoutertube->SetLineColor(39);
6769   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
6770   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
6771   effectivemothertube->AddNode(effectiveinnertube,1);
6772   effectivemothertube->AddNode(effectiveoutertube,1);
6773   return effectivemothertube;
6774  } 
6775  ////////////////////////////////////////////////////////////////////////////////
6776  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
6777   /////////////////////////////////////////////////////////////
6778   // Generating EndCap Support Layer 5 and Layer 6 
6779   /////////////////////////////////////////////////////////////
6780   const Int_t knedges = 5;
6781   ///////////////////////////////////////////////
6782   // Setting the vertices for TGeoXtru Up Volume
6783   ///////////////////////////////////////////////
6784   const Int_t klayernumber = 2;
6785   Double_t xupvertex[klayernumber][knedges+3];
6786   Double_t yupvertex[klayernumber][knedges+3];
6787   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
6788   Double_t middledgeangle[klayernumber] = {0.0,0.0};
6789   Double_t middlepsi[klayernumber] = {0.0,0.0};
6790   for(Int_t i=0; i<klayernumber; i++){
6791         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
6792         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
6793         xupvertex[i][2] = -xupvertex[i][1];
6794         xupvertex[i][3] = -xupvertex[i][0];
6795
6796         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
6797         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
6798         yupvertex[i][2] =  yupvertex[i][1];
6799         yupvertex[i][3] =  yupvertex[i][0];
6800         
6801     middledgeangle[i] = upedgeangle[i]/knedges;
6802     middlepsi[i] = 90.0-0.5*upedgeangle[i];
6803     for(Int_t j=1; j<knedges; j++){
6804                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
6805                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
6806         }
6807   }
6808   ////////////////////////////////////
6809   // Generating Up TGeoXtru
6810   ////////////////////////////////////
6811   TGeoXtru* upendcapsupportshape[klayernumber];
6812   TGeoVolume* upendcapsupport[klayernumber]; 
6813   char upendcapsupportname[100]; 
6814   for(Int_t i=0; i<klayernumber; i++){
6815    upendcapsupportshape[i] = new TGeoXtru(2);
6816    sprintf(upendcapsupportname,"UpEndCapSupportPieceLayer%i",i+5);
6817    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
6818    upendcapsupportshape[i]->DefineSection(0,0.);
6819    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6820    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
6821                                                                         fSSDSupportRingAl);
6822    upendcapsupport[i]->SetLineColor(5);
6823   }
6824   ///////////////////////////////////////////////
6825   // Setting the vertices for TGeoXtru Down Volume
6826   ///////////////////////////////////////////////
6827   Double_t xdownvertex[klayernumber][2*(knedges+1)];
6828   Double_t ydownvertex[klayernumber][2*(knedges+1)];
6829   for(Int_t i=0; i<klayernumber; i++){
6830         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
6831         xdownvertex[i][1] =  xupvertex[i][0];
6832         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
6833         ydownvertex[i][1] =  yupvertex[i][0];
6834         for(Int_t j=0; j<knedges; j++){
6835                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
6836                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
6837         } 
6838         for(Int_t j=0; j<knedges; j++){
6839                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6840                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
6841                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
6842                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
6843         }
6844   }
6845   ////////////////////////////////////
6846   // Generating Down TGeoXtru
6847   ////////////////////////////////////  
6848   TGeoXtru* downendcapsupportshape[klayernumber];
6849   TGeoVolume* downendcapsupport[klayernumber]; 
6850   char downendcapsupportname[100]; 
6851   for(Int_t i=0; i<klayernumber; i++){
6852         downendcapsupportshape[i] = new TGeoXtru(2);
6853     sprintf(downendcapsupportname,"DownEndCapSupportPieceLayer%i",i+5);
6854         downendcapsupportshape[i] = new TGeoXtru(2);
6855         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
6856     if(i==0){
6857                 downendcapsupportshape[i]->DefineSection(0,0.);
6858                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
6859     }
6860         else{
6861                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
6862                                                                  -                 fgkEndCapSupportLowWidth[i]);
6863                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
6864         }
6865     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
6866                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
6867         downendcapsupport[i]->SetLineColor(5);
6868   }
6869   ///////////////////////////////////////////////
6870   // Setting TGeoPgon Volume
6871   ///////////////////////////////////////////////
6872   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6873                                                                                                    fgkSSDLay6LadderNumber};
6874   TGeoPgon* endcapsupportmothershape[klayernumber];
6875   TGeoVolume** endcapsupportmother;
6876   endcapsupportmother = new TGeoVolume*[klayernumber];
6877   char endcapsupportmothername[100];
6878   for(Int_t i=0; i<klayernumber; i++){
6879         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6880     sprintf(endcapsupportmothername,"EndCapSupportMotherLayer%i",i+5);
6881         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);     
6882     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
6883                                                                                           ydownvertex[i][0],yupvertex[i][1]);
6884     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
6885                                                                                         fSSDAir);       
6886   }
6887   ////////////////////////////////////
6888   TGeoRotation** endcapsupportrot[klayernumber];
6889   for(Int_t i=0; i<2; i++){
6890         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
6891         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6892            endcapsupportrot[i][j] = new TGeoRotation();
6893            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
6894        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
6895        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
6896         }
6897   }
6898   return endcapsupportmother;
6899  } 
6900  ////////////////////////////////////////////////////////////////////////////////
6901  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
6902   /////////////////////////////////////////////////////////////
6903   // Setting End Cap Support Layer 5 and 6. 
6904   /////////////////////////////////////////////////////////////
6905   const Int_t kendcapcoverplatesmallholenumber = 9;
6906   const Int_t klayernumber = 2;
6907   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
6908                                                                                                    fgkSSDLay6LadderNumber};
6909   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
6910                                                                                 360.0/kssdlayladdernumber[1]};
6911   TGeoVolume** endcapsupport = EndCapSupport();
6912   TGeoVolume** endcapassembly = GetEndCapAssembly();
6913   TGeoPgon* endcapsupportshape[klayernumber];
6914   Double_t* radiusmin[klayernumber];
6915   Double_t* radiusmax[klayernumber];
6916   for(Int_t i=0; i<klayernumber; i++){
6917     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
6918         radiusmin[i] = endcapsupportshape[i]->GetRmin();
6919         radiusmax[i] = endcapsupportshape[i]->GetRmax();
6920   }  
6921   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
6922   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
6923                                                                           endcapassemblyshape->GetDY(),
6924                                                                           endcapassemblyshape->GetDZ()};
6925   ///////////////////////////////////////////////
6926   // Setting TGeoPgon Volume for Mother Container
6927   ///////////////////////////////////////////////
6928   TGeoPgon* endcapsupportsystemshape[klayernumber];
6929   char endcapsupportsystemothername[100];
6930   for(Int_t i=0; i<klayernumber; i++){
6931         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
6932     sprintf(endcapsupportsystemothername,"EndCapSupportSystemLayer%i",i+5);
6933         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
6934                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
6935                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6936                                                                                            +2.*endcapassemblycenter[2])
6937                                                                                            /CosD(0.5*upedgeangle[i]));  
6938     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
6939                                                                                                  -(fgkEndCapCoverPlateWidth[1]
6940                                                                                              - fgkEndCapCoverPlateWidth[0]),
6941                                                                                            *radiusmin[i],
6942                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
6943                                                                                            +2.*endcapassemblycenter[2])
6944                                                                                            /CosD(0.5*upedgeangle[i]));
6945   }
6946   fgkEndCapSupportSystem = new TGeoVolume*[4];
6947   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
6948                                                                           endcapsupportsystemshape[0],fSSDAir); 
6949   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
6950                                                                           endcapsupportsystemshape[0],fSSDAir); 
6951   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
6952                                                                           endcapsupportsystemshape[1],fSSDAir); 
6953   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
6954                                                                           endcapsupportsystemshape[1],fSSDAir); 
6955   ///////////////////////////////////////////////
6956   TGeoTranslation* endcapassemblytrans[klayernumber];
6957   for(Int_t i=0; i<klayernumber; i++)
6958         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
6959                                                                            -  fgkEndCapSideCoverThickness
6960                                                                            +  endcapassemblycenter[0],
6961                                                                            -  0.5*fgkEndCapCoverPlateThickness
6962                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
6963                                                                            +  2.0*endcapassemblycenter[2]
6964                                                                            +  0.5*fgkEndCapSupportLength[i]
6965                                                                            /  TanD(0.5*upedgeangle[i]),
6966                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
6967                                                                            -  fgkEndCapCoverPlateWidth[2]
6968                                                                            - (kendcapcoverplatesmallholenumber-1)
6969                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
6970   TGeoRotation** endcapassemblyrot[klayernumber];
6971   TGeoHMatrix** endcapassemblymatrix[klayernumber];
6972   for(Int_t i=0; i<klayernumber; i++){
6973    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
6974    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
6975    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
6976    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);      
6977    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);   
6978    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
6979    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
6980    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
6981         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
6982         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
6983    }
6984   }
6985   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
6986                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
6987   for(Int_t i=0; i<2*klayernumber; i++){
6988         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
6989                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
6990                                                                                                                                            endcapassemblymatrix[1][j+2]);
6991         }
6992         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
6993   }
6994    /////////////////////////////////////////////////////////////
6995   // Deallocating memory
6996   /////////////////////////////////////////////////////////////
6997   for(Int_t i=0; i<klayernumber; i++){
6998         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
6999                 delete endcapassemblyrot[i][j];
7000         }
7001         delete [] endcapassemblyrot[i];
7002         delete endcapassemblymatrix[i][0];
7003         delete endcapassemblymatrix[i][1];
7004   }
7005   /////////////////////////////////////////////////////////////
7006   }
7007   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
7008   /////////////////////////////////////////////////////////////
7009   // Setting End Cap Support + End Cap Assembly of Layer 5. 
7010   /////////////////////////////////////////////////////////////
7011   if (! moth) {
7012     AliError("Can't insert end cap support of layer5, mother is null!\n");
7013     return;
7014   };
7015   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7016   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7017   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7018                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
7019                                                                            +            fgkEndCapSupportCenterLay5Position
7020                                                                            -            fgkEndCapSideCoverLength[2]);
7021   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7022                                                                                                 fgkEndCapSideCoverLength[2]
7023                                                                            -        fgkEndCapSupportCenterLay5Position
7024                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
7025   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7026   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7027   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7028         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7029   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
7030   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
7031    /////////////////////////////////////////////////////////////
7032   // Deallocating memory
7033   /////////////////////////////////////////////////////////////
7034   delete endcapsupportsystemrot;
7035   delete endcapsupportsystemITSCentertrans[1];
7036  }
7037   /////////////////////////////////////////////////////////////
7038   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
7039   /////////////////////////////////////////////////////////////
7040   // Setting End Cap Support + End Cap Assembly of Layer 6. 
7041   /////////////////////////////////////////////////////////////
7042   if (! moth) {
7043     AliError("Can't insert end cap support of layer6, mother is null!\n");
7044     return;
7045   };
7046   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
7047   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
7048   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
7049                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
7050                                                                            +            fgkEndCapSupportCenterLay6Position
7051                                                                            -            fgkEndCapSideCoverLength[2]);
7052   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
7053                                                                                                 fgkEndCapSideCoverLength[2]
7054                                                                            -        fgkEndCapSupportCenterLay6Position
7055                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
7056   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
7057   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
7058   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
7059         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
7060   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
7061   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
7062    /////////////////////////////////////////////////////////////
7063   // Deallocating memory
7064   /////////////////////////////////////////////////////////////
7065   delete endcapsupportsystemrot;
7066   delete endcapsupportsystemITSCentertrans[1];
7067  }
7068  ////////////////////////////////////////////////////////////////////////////////
7069  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
7070   /////////////////////////////////////////////////////////////
7071   // Setting Ladder Support of Layer 5. 
7072   /////////////////////////////////////////////////////////////
7073   if (! moth) {
7074     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
7075     return;
7076   };
7077   if(!fLay5LadderSupportRing) SetLadderSupport(100);
7078   fMotherVol = moth;
7079   TGeoTranslation* centerITSRingSupportLay5trans[2];
7080   for(Int_t i=0; i<2; i++){
7081         centerITSRingSupportLay5trans[i] = 
7082                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
7083     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
7084   }
7085  }
7086  ////////////////////////////////////////////////////////////////////////////////
7087  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
7088   /////////////////////////////////////////////////////////////
7089   // Setting Ladder Support of Layer 6. 
7090   /////////////////////////////////////////////////////////////
7091   if (! moth) {
7092     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
7093     return;
7094   };
7095   if(!fLay6LadderSupportRing) SetLadderSupport(100);
7096   fMotherVol = moth;
7097   TGeoTranslation* centerITSRingSupportLay6trans[2];
7098   for(Int_t i=0; i<2; i++){
7099         centerITSRingSupportLay6trans[i] = 
7100                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
7101     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
7102   }
7103  }
7104  ////////////////////////////////////////////////////////////////////////////////
7105  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
7106   /////////////////////////////////////////////////////////////
7107   // Setting Ladder Support of Layer 6. 
7108   /////////////////////////////////////////////////////////////
7109   if (! moth) {
7110     AliError("Can't insert SSD Cone, mother is null!\n");
7111     return;
7112   };
7113   if(!fSSDCone) SetSSDCone();
7114   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
7115                                                                 +                                         fgkSSDCentralAL3SupportLength);
7116     moth->AddNode(fSSDCone,1,ssdconetrans);
7117 }
7118  ////////////////////////////////////////////////////////////////////////////////
7119  void AliITSv11GeometrySSD::SetSSDCone(){
7120   /////////////////////////////////////////////////////////////
7121   // Method generating SSDCone 
7122   /////////////////////////////////////////////////////////////
7123   if(!fCreateMaterials) CreateMaterials();
7124   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
7125   Double_t ssdpconesectionradiusmax[16];
7126   Double_t ssdpconesectionradiusmin[16];
7127   Double_t ssdpconezsection[16];
7128   TGeoPcon* ssdpconelittleholeshape[8];
7129   TGeoVolume* ssdpconelittlehole[8];
7130   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
7131   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
7132   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7133                                                       / SinD(fgkSSDPConeAngle)
7134                                                           + ssdpconesectionradiusmin[0];
7135   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
7136                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7137                                                           / SinD(fgkSSDPConeAngle);
7138   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
7139   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
7140                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
7141   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
7142   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
7143                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7144   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
7145   ssdpconelittlehole[0]->SetLineColor(4);
7146   /////////////////////////////////////////////////////////////
7147   ssdpconezsection[2] = ssdpconezsection[1];  
7148   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
7149   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
7150   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
7151                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7152                                                           / SinD(fgkSSDPConeAngle);
7153   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
7154                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
7155   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
7156                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
7157   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
7158                                                                    * TMath::RadToDeg();
7159   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
7160                                                                                                           60.-ssdpconelittleholeangle,2);    
7161   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
7162                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7163   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
7164   ssdpconelittlehole[1]->SetLineColor(4);
7165   TGeoRotation* ssdconelittleholerot[6];
7166   for(Int_t i=0; i<6; i++){
7167         ssdconelittleholerot[i] = new TGeoRotation();
7168     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
7169   }
7170   /////////////////////////////////////////////////////////////
7171   ssdpconezsection[4] = ssdpconezsection[3];  
7172   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
7173   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
7174   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
7175                                                           * CosD(fgkSSDPConeAngle)
7176                                                           / SinD(fgkSSDPConeAngle);
7177   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
7178   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
7179                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
7180   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
7181   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
7182                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7183   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
7184   ssdpconelittlehole[2]->SetLineColor(4);
7185   ///////////////////////////////////////////////////
7186   ssdpconezsection[6] = ssdpconezsection[5];  
7187   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
7188   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
7189   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
7190                                                           -ssdpconezsection[0]
7191                                                           * CosD(fgkSSDPConeAngle)
7192                                                           / SinD(fgkSSDPConeAngle);
7193   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
7194   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
7195                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
7196   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
7197                                                                    * TMath::RadToDeg();
7198   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
7199                                                                                                           45.-ssdpconemiddleholeangle,2);    
7200   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
7201                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7202   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
7203   ssdpconelittlehole[3]->SetLineColor(4);
7204   TGeoRotation* ssdconemiddleholerot[8];
7205   for(Int_t i=0; i<8; i++){
7206         ssdconemiddleholerot[i] = new TGeoRotation();
7207     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
7208   }
7209   /////////////////////////////////////////////////////////////
7210   ssdpconezsection[8] = ssdpconezsection[7];  
7211   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
7212   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
7213   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
7214                                                           * CosD(fgkSSDPConeAngle)
7215                                                           / SinD(fgkSSDPConeAngle);
7216   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
7217   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
7218                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
7219   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
7220   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
7221                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7222   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
7223   ssdpconelittlehole[4]->SetLineColor(4);
7224   /////////////////////////////////////////////////////////////
7225   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
7226   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
7227                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
7228                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
7229                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
7230                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
7231   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
7232   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
7233                                                                                  * TMath::RadToDeg();
7234   ssdpconezsection[10] = ssdpconezsection[9];
7235   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
7236   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
7237   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
7238                                                           * CosD(fgkSSDPConeAngle)
7239                                                           / SinD(fgkSSDPConeAngle);
7240   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
7241   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
7242                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
7243   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
7244                                                                                         ssdpconetrapezoidsectionangle,2);    
7245   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
7246                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7247   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
7248   ssdpconelittlehole[5]->SetLineColor(4);
7249   TGeoRotation* ssdconeupradiusrot[8];
7250   for(Int_t i=0; i<8; i++){
7251         ssdconeupradiusrot[i] = new TGeoRotation();
7252     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
7253   }
7254   /////////////////////////////////////////////////////////////
7255   ssdpconezsection[12] = ssdpconezsection[11];
7256   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
7257   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
7258   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
7259   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
7260   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
7261   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
7262   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
7263                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7264   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
7265   ssdpconelittlehole[6]->SetLineColor(4);
7266   /////////////////////////////////////////////////////////////
7267   ssdpconezsection[14] = 0.0;
7268   ssdpconezsection[15] = ssdpconezsection[0];
7269   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
7270   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
7271   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
7272   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
7273   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
7274   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
7275                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
7276   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
7277   ssdpconelittlehole[7]->SetLineColor(4);
7278   /////////////////////////////////////////////////////////////
7279   TGeoTube* ssdtubeconeshape[2];
7280   TGeoVolume* ssdtubecone[2];
7281   TGeoTranslation* ssdtubeconetrans[2];
7282   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
7283                                                                            fgkSSDPConeExternalRadius,
7284                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
7285   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
7286                                                                            0.5*ssdpconezsection[0]); 
7287   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
7288   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
7289   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
7290                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
7291                                           + ssdpconezsection[13]);
7292   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
7293   ssdtubecone[0]->SetLineColor(4);
7294   ssdtubecone[1]->SetLineColor(4);
7295   /////////////////////////////////////////////////////////////
7296   // Mother Volume Container
7297   /////////////////////////////////////////////////////////////
7298   Double_t ssdconemotherradiusmin[8];
7299   Double_t ssdconemotherradiusmax[8];
7300   Double_t ssdconemothersection[8]; 
7301   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
7302   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
7303   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
7304   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
7305   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
7306   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
7307   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
7308   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
7309   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
7310   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
7311   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
7312   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
7313   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
7314   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
7315   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
7316   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
7317   ssdconemothersection[0] = 0.0;
7318   ssdconemothersection[1] = ssdpconezsection[0];
7319   ssdconemothersection[2] = ssdpconezsection[0];
7320   ssdconemothersection[3] = ssdpconezsection[11];
7321   ssdconemothersection[4] = ssdpconezsection[11];
7322   ssdconemothersection[5] = ssdpconezsection[13];
7323   ssdconemothersection[6] = ssdpconezsection[13];
7324   ssdconemothersection[7] = fgkSSDPConeLength;
7325   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
7326   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
7327                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
7328   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
7329   /////////////////////////////////////////////////////////////
7330   //Placing the Volumes into Mother 
7331   /////////////////////////////////////////////////////////////
7332   ssdconemother->AddNode(ssdpconelittlehole[0],1);
7333   for(Int_t i=0; i<6; i++){
7334         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
7335   }
7336   ssdconemother->AddNode(ssdpconelittlehole[2],1);
7337   for(Int_t i=0; i<8; i++){
7338     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
7339   }
7340   ssdconemother->AddNode(ssdpconelittlehole[4],1);
7341   for(Int_t i=0; i<8; i++){
7342     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
7343   }
7344   ssdconemother->AddNode(ssdpconelittlehole[6],1);
7345   ssdconemother->AddNode(ssdpconelittlehole[7],1);
7346   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
7347   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
7348   /////////////////////////////////////////////////////////////
7349   // ITS General Support
7350   /////////////////////////////////////////////////////////////
7351   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7352                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
7353   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
7354   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
7355                                                                              - fgkSSDCentralAL3SupportLength);
7356   ssdcentralsupport->SetLineColor(4);
7357   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
7358   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
7359                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
7360   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
7361   TGeoTranslation* ssdcentralal3supportrans[3]; 
7362   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
7363   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7364                                                           - 1.25*fgkSSDCentralAL3SupportLength);
7365   ssdcentralal3support->SetLineColor(4);
7366   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
7367   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
7368   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
7369   Double_t ssdpconcentralradiusmin[2];
7370   Double_t ssdpconcentralradiusmax[2];
7371   Double_t ssdpconcentralsection[2];
7372   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
7373   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
7374   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
7375   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
7376   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
7377   ssdpconcentralsection[1] = 0.;
7378   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
7379                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
7380   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
7381   ssdpconcentralal3->SetLineColor(4);
7382   fSSDCone->AddNode(ssdpconcentralal3,1);
7383   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
7384   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
7385   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7386                                                                 -2.*fgkSSDCentralAL3SupportLength);
7387   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
7388                                                                                                                      *ssdcentralal3supportrot);
7389   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
7390   TGeoRotation* ssdconemotherot = new TGeoRotation();
7391   ssdconemotherot->SetAngles(90.,180.,-90.);
7392   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
7393                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
7394   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
7395   fSSDCone->AddNode(ssdconemother,1);
7396   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
7397   /////////////////////////////////////////////////////////////
7398   // Deallocating memory
7399   /////////////////////////////////////////////////////////////
7400   delete ssdcentralal3supportrot;
7401   delete ssdcentralal3supportrans[2];
7402   delete ssdconemotherot;
7403   delete ssdconemothertrans;
7404   /////////////////////////////////////////////////////////////
7405  }
7406  ////////////////////////////////////////////////////////////////////////////////
7407  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
7408   /////////////////////////////////////////////////////////////
7409   // Setting SSD Cables
7410   /////////////////////////////////////////////////////////////
7411   if (! moth) {
7412     AliError("Can't insert SSD Cables, mother is null!\n");
7413     return;
7414   };
7415   TGeoVolume* ssdcables = SetSSDCables();
7416   moth->AddNode(ssdcables,1);
7417 }
7418  ////////////////////////////////////////////////////////////////////////////////
7419  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
7420   /////////////////////////////////////////////////////////////
7421   // Method generating SSDCables
7422   /////////////////////////////////////////////////////////////
7423   // SSD Layer 5 Cables
7424   //////////////////////////////////////////////////////////////////////////////////////////////////
7425   TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
7426   Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
7427   Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
7428   Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
7429   //////////////////////////////////////////////////////////////////////////////////////////////////
7430   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+fgkSSDCablesLay5TubeRadiusMin;  
7431   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
7432                                                                             -  fgkSSDLowerPConeRadius)
7433                                                                             * TanD(fgkSSDPConeAngle);
7434   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
7435                                                                               + fgkEndCapSupportCenterLay5Position
7436                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
7437   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
7438                                                                            - ssdcableslay5startconedistance; 
7439   ssdcablelay5rightsidelength *= ssdcablesfactor;
7440   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+fgkSSDCablesLay5RightSideHeight; 
7441   TGeoTube* ssdcablelay5rightubeshape = new TGeoTube(ssdcableslay5rigthsideradiusmin,
7442                                                                                                 ssdcableslay5rightsideradiusmax,
7443                                                                                                 0.5*ssdcablelay5rightsidelength); 
7444   TGeoVolume* ssdcablelay5righttube = new TGeoVolume("SSDCableLay5RightSideTube",
7445                                                                                                          ssdcablelay5rightubeshape,
7446                                                                                                          fSSDCopper);
7447   ssdcablelay5righttube->SetLineColor(9);
7448   TGeoTranslation* ssdcablelay5rightrans = 
7449                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
7450                                                                                  +              fgkEndCapSupportCenterLay5Position
7451                                                                                  +      0.5*ssdcablelay5rightsidelength);
7452   ////////////////////////////////////
7453   //  Double_t cablescapacity[20];
7454   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
7455   ////////////////////////////////////
7456   ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
7457   ////////////////////////////////////
7458   // TGeoPCone Volumes
7459   ///////////////////////////////////
7460   TGeoPcon* ssdcableslay5pconshape[3];
7461   TGeoVolume* ssdcableslay5pcon[3]; 
7462   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
7463   Double_t ssdcableslay5pconzsection[6];
7464   Double_t ssdcableslay5pconrmin[6];
7465   Double_t ssdcableslay5pconrmax[6];
7466   ssdcableslay5pconrmin[0] = ssdcablelay5rightubeshape->GetRmin();
7467   ssdcableslay5pconrmax[0] = ssdcablelay5rightubeshape->GetRmax();
7468   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
7469   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+fgkSSDCablesLay5RightSideHeight;
7470   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
7471                                                            + fgkEndCapSupportCenterLay5Position
7472                                                            + 2.*ssdcablelay5rightubeshape->GetDz();
7473   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
7474                                                            + fgkSSDCentralAL3SupportLength
7475                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
7476                                                            * TanD(fgkSSDPConeAngle);      
7477   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
7478                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
7479   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
7480                                                            ssdcableslay5pconshape[0],fSSDCopper);
7481   ssdcableslay5pcon[0]->SetLineColor(9);
7482   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
7483 ////////////////////////////////////
7484 //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
7485 ////////////////////////////////////
7486   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
7487   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
7488                                                            + fgkSSDCentralAL3SupportLength
7489                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
7490                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
7491   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
7492                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
7493                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
7494   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7495                                                                                    ssdcableangle,2);   
7496   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
7497   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1];
7498   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
7499                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
7500   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
7501   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3]+fgkSSDCablesLay5RightSideHeight;
7502   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
7503                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
7504   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
7505   ssdcableslay5pcon[1]->SetLineColor(9);
7506   ////////////////////////////////////
7507   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7508                                                                                    ssdcableangle,2);   
7509   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
7510   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
7511   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
7512   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
7513   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
7514   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
7515                                                            * TanD(fgkSSDPConeAngle)
7516                                                            + 0.5*fgkSSDCentralSupportLength
7517                                                            + fgkSSDCentralAL3SupportLength;
7518   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
7519   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
7520                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
7521   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
7522   ssdcableslay5pcon[2]->SetLineColor(9);
7523 ////////////////////////////////////
7524   TGeoRotation* ssdcableslay5pconrot[4];        
7525   for(Int_t i=0; i<4; i++){
7526    ssdcableslay5pconrot[i] = new TGeoRotation();
7527    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
7528    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
7529    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);          
7530   }
7531   ////////////////////////////////////
7532   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
7533   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
7534   ////////////////////////////////////
7535   // Positioning Left SSD Cables Part
7536   ////////////////////////////////////
7537   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7538                                                                                                         - 0.5*ssdcablelay5rightsidelength
7539                                                                                                         - fgkEndCapSupportCenterLay5Position
7540                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
7541   ssdcablesmother->AddNode(ssdcablelay5righttube,2,ssdcablesLay5RightTubeToLeftrans);  
7542   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
7543   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
7544   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
7545   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
7546   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
7547         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
7548         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7549     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);   
7550   }
7551   ////////////////////////////////////
7552   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
7553   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
7554   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
7555   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
7556   /////////////////////////////////////////////////////////////
7557   // Water Tubes Layer 5
7558   /////////////////////////
7559   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
7560                                                                                      ssdcableslay5rightsideradiusmax
7561                                                                                + fgkSSDCablesLay5RightSideWaterHeight,
7562                                                                                      0.5*ssdcablelay5rightsidelength); 
7563   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
7564                                                                                                          ssdcablelay5rightubewatershape,
7565                                                                                                          fSSDCoolingTubeWater);
7566   ssdcablelay5rightwatertube->SetLineColor(7);
7567   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
7568   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
7569   ////////////////////////////////////
7570   // TGeoPCone Water Volumes Layer 
7571   ///////////////////////////////////
7572   TGeoPcon* ssdcableslay5pconwatershape[3];
7573   TGeoVolume* ssdcableslay5pconwater[3]; 
7574   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
7575   Double_t ssdcableslay5pconwaterzsection[6];
7576   Double_t ssdcableslay5pcwateronrmin[6];
7577   Double_t ssdcableslay5pconwaterrmax[6];
7578   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
7579   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
7580                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7581   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
7582   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
7583                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7584   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
7585   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
7586   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
7587                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
7588   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
7589                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
7590   ssdcableslay5pconwater[0]->SetLineColor(7);
7591   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
7592   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
7593 ////////////////////////////////////
7594   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
7595   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
7596   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7597                                                                                                 ssdcableangle,2);   
7598   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
7599   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
7600                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7601   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
7602   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
7603                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7604   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
7605                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
7606   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
7607                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
7608   ssdcableslay5pconwater[1]->SetLineColor(7);
7609 ////////////////////////////////////
7610   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7611                                                                                                 ssdcableangle,2);   
7612   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
7613   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
7614                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7615   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
7616   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
7617                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7618   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
7619   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
7620   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
7621                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
7622   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
7623                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
7624   ssdcableslay5pconwater[2]->SetLineColor(7);
7625 ////////////////////////////////////
7626   TGeoRotation* ssdcableslay5pconwaterot[4];    
7627   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
7628   for(Int_t i=0; i<4; i++){
7629    ssdcableslay5pconwaterot[i] = new TGeoRotation();
7630    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7631    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
7632         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
7633         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
7634         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7635         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
7636         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
7637   }
7638   /////////////////////////
7639   // SSD Layer 6 Cables
7640   /////////////////////////
7641   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+fgkSSDCablesLay6TubeRadiusMin;  
7642   Double_t ssdcablelay6rightsidelength = 2.*ssdcablelay5rightsidelength;
7643   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+fgkSSDCablesLay6RightSideHeight; 
7644   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
7645                                                                                                 ssdcableslay6rightsideradiusmax,
7646                                                                                                 0.5*ssdcablelay6rightsidelength); 
7647   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
7648                                                                                                          ssdcablelay6rightubeshape,
7649                                                                                                          fSSDCopper);
7650   ssdcablelay6righttube->SetLineColor(9);
7651   TGeoTranslation* ssdcablelay6rightrans = 
7652                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
7653                                                                                  +              fgkEndCapSupportCenterLay6Position
7654                                                                                  +      0.5*ssdcablelay6rightsidelength);
7655   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
7656                                                                                                         - 0.5*ssdcablelay6rightsidelength
7657                                                                                                         - fgkEndCapSupportCenterLay6Position
7658                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
7659   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
7660   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
7661   ////////////////////////////////////
7662   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
7663   ////////////////////////////////////
7664   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7665                                                                                    ssdcableangle,2);   
7666   TGeoVolume* ssdcableslay6pcon;
7667   Double_t ssdcableslay6pconrmin[2];
7668   Double_t ssdcableslay6pconrmax[2];
7669   Double_t ssdcableslay6pconzsection[2];
7670   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
7671   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
7672   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
7673   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
7674   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7675                                                            + fgkEndCapSupportCenterLay6Position
7676                                                            + ssdcablelay6rightsidelength;
7677   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
7678   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
7679                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
7680   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
7681                                                            ssdcableslay6pconshape,fSSDCopper);
7682   ssdcableslay6pcon->SetLineColor(9);
7683   for(Int_t i=0; i<4; i++){
7684    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
7685    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7686   }
7687   ////////////////////////////////////
7688   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
7689   /////////////////////////
7690   // Water Tubes Layer 6
7691   /////////////////////////
7692   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
7693                                                                                                                   ssdcableslay6rightsideradiusmax
7694                                                                                    +                      fgkSSDCablesLay5RightSideWaterHeight,
7695                                                                                                                   0.5*ssdcablelay6rightsidelength); 
7696   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
7697                                                                                                          ssdcablelay6righwatertubeshape,
7698                                                                                                          fSSDCoolingTubeWater);
7699   ssdcablelay6rightwatertube->SetLineColor(7);
7700   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
7701   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
7702   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,
7703                                                                                    ssdcableangle,2);   
7704   TGeoVolume* ssdcableslay6waterpcon;
7705   Double_t ssdcableslay6waterpconrmin[2];
7706   Double_t ssdcableslay6waterpconrmax[2];
7707   Double_t ssdcableslay6waterpconzsection[2];
7708   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
7709   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
7710                                                             + fgkSSDCablesLay5RightSideWaterHeight;
7711   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
7712   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
7713   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7714                                                            + fgkEndCapSupportCenterLay6Position
7715                                                            + ssdcablelay6rightsidelength;
7716   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7717   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
7718                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
7719   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
7720                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
7721   ssdcableslay6waterpcon->SetLineColor(7);
7722   TGeoRotation* ssdcableslay6pconwaterot[4];    
7723   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
7724   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
7725   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
7726   for(Int_t i=0; i<4; i++){
7727    ssdcableslay6pconwaterot[i] = new TGeoRotation();
7728    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
7729    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
7730                                                                                  * (*ssdcableslay6pconwaterot[i]));   
7731    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
7732    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
7733   }
7734   ////////////////////////////////////////
7735   // From ITS Ring to Patch Panel3-RB26
7736   ////////////////////////////////////////
7737   Double_t ssdcablepatchpanel3BB26radiusmin[2];
7738   Double_t ssdcablepatchpanel3BB26radiusmax[2];
7739   Double_t ssdcablepatchpanel3RB26zsection[2];
7740   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*fgkSSDPatchPanelHeight+2.8;
7741   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
7742                                                                           + fgkSSDCablesLay5RightSideHeight
7743                                                                           + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7744   ssdcablepatchpanel3BB26radiusmin[1] = fgkSSDPatchPanel2RB26Radius;
7745   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
7746                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7747                                                                           + 0.*fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7748   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
7749                                                                                  + fgkSSDCentralAL3SupportLength
7750                                                                                  + fgkSSDPConeZLength[0];
7751   ssdcablepatchpanel3RB26zsection[1] = fgkSSDPatchPanel2RB26ITSDistance;  
7752   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
7753                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7754                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7755   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
7756                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
7757   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
7758                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
7759   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
7760   TGeoRotation* ssdcablepatchpanel3B26rot[3];
7761   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
7762   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
7763   ssdcablepatchpanel3B26rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB26Angle[0]
7764                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7765   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
7766   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB26Angle[0]
7767                                                                   +                       fgkSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
7768   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
7769   ////////////////////////////////////
7770   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
7771   ////////////////////////////////////////
7772   //  ITS Ring Cables RB26 Part
7773   ////////////////////////////////////////
7774   Double_t ssdcableitsring3BB26pconzsection[2];
7775   Double_t ssdcableitsring3BB26pconrmin[2];
7776   Double_t ssdcableitsring3BB26pconrmax[2];
7777   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
7778                                                                           + fgkSSDCentralAL3SupportLength
7779                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
7780   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
7781   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7782   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0]
7783                                                                   + fgkSSDCablesLay5RightSideHeight
7784                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7785   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
7786   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
7787   TGeoPcon* ssdcableitsring3BB26pconshape[4];
7788   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB26Angle[0]
7789                                                                    -              0.5*ssdcableangle,ssdcableangle
7790                                                                    +                            (fgkSSDCablesPatchPanel2RB26Angle[0]
7791                                                                    -                             fgkSSDCableAngle),2);
7792   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7793                                                                    -              0.5*ssdcableangle,ssdcableangle
7794                                                                    +                      3.0*fgkSSDCableAngle
7795                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7796   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-fgkSSDCablesPatchPanel2RB26Angle[0]
7797                                                                    -              0.5*ssdcableangle,ssdcableangle
7798                                                                    -                      fgkSSDCableAngle
7799                                                                    +                      fgkSSDCablesPatchPanel2RB26Angle[0],2);
7800   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+fgkSSDCablesPatchPanel2RB26Angle[1]
7801                                                                    -              0.5*ssdcableangle,ssdcableangle
7802                                                                    +                      3.0*fgkSSDCableAngle
7803                                                                    -                      fgkSSDCablesPatchPanel2RB26Angle[1],2);
7804   for(Int_t i=0;i<4;i++)
7805         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
7806                                                          ssdcableitsring3BB26pconrmin[j],
7807                                                          ssdcableitsring3BB26pconrmax[j]); 
7808   TGeoVolume* ssdcableitsring3BB26pcon[4];
7809   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
7810                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
7811   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
7812                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
7813   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
7814                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
7815   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
7816                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
7817   for(Int_t i=0;i<4;i++){
7818         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
7819         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
7820 }
7821   ////////////////////////////////////
7822   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
7823   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
7824   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
7825   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
7826   ////////////////////////////////////////
7827   // From ITS Ring to Patch Panel2-RB24
7828   ////////////////////////////////////////
7829   Double_t ssdcablepatchpanel3BB24radiusmin[2];
7830   Double_t ssdcablepatchpanel3BB24radiusmax[2];
7831   Double_t ssdcablepatchpanel3RB24zsection[2];
7832   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
7833   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
7834   ssdcablepatchpanel3BB24radiusmin[1] = fgkSSDPatchPanel2RB24Radius;
7835   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
7836                                                                           + 0.*fgkSSDCablesLay5RightSideHeight
7837                                                                           + 0.*fgkSSDCablesLay6RightSideHeight
7838                                                                           + 0.5*fgkSSDPatchPanelHeight;
7839   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
7840                                                                          -  fgkSSDCentralAL3SupportLength
7841                                                                          -  fgkSSDPConeZLength[0];
7842   ssdcablepatchpanel3RB24zsection[1] = -fgkSSDPatchPanel2RB24ITSDistance;  
7843   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
7844                                                                 new TGeoPcon(90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7845                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
7846   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
7847                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
7848   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
7849                                                                                                 ssdcablepatchpanel3RB24pconshape,
7850                                                                                                 fSSDCopper);
7851   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
7852   TGeoRotation* ssdcablepatchpanel3B24rot[3];
7853   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
7854   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
7855   ssdcablepatchpanel3B24rot[1]->SetAngles(fgkSSDCablesPatchPanel2RB24Angle[0]
7856                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7857   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
7858   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+fgkSSDCablesPatchPanel2RB24Angle[0]
7859                                                                   +                       fgkSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
7860   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
7861   ////////////////////////////////////
7862   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
7863   ////////////////////////////////////////
7864   //  ITS Ring Cables RB24 Part
7865   ////////////////////////////////////////
7866   Double_t ssdcableitsring3BB24pconzsection[2];
7867   Double_t ssdcableitsring3BB24pconrmin[2];
7868   Double_t ssdcableitsring3BB24pconrmax[2];
7869   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
7870   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
7871   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*fgkSSDPatchPanelHeight;
7872   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0]
7873                                                                   + fgkSSDCablesLay5RightSideHeight
7874                                                                   + fgkSSDCablesLay6RightSideHeight+0.5*fgkSSDPatchPanelHeight;
7875   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
7876   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
7877   TGeoPcon* ssdcableitsring3BB24pconshape[4];
7878   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7879                                                                    +                            (90.0-fgkSSDCablesPatchPanel2RB24Angle[1]
7880                                                                    -                             fgkSSDCableAngle),2);
7881   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+fgkSSDCableAngle-0.5*ssdcableangle,
7882                                                                      ssdcableangle-fgkSSDCableAngle
7883                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7884   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle
7885                                                                    -                      fgkSSDCableAngle
7886                                                                    +                      90.0-fgkSSDCablesPatchPanel2RB24Angle[1],2);
7887   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+fgkSSDCableAngle-0.5*ssdcableangle,
7888                                                                                                   ssdcableangle-fgkSSDCableAngle
7889                                                                    +                      fgkSSDCablesPatchPanel2RB24Angle[0],2);
7890   for(Int_t i=0;i<4;i++)
7891         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
7892                                                          ssdcableitsring3BB24pconrmin[j],
7893                                                          ssdcableitsring3BB24pconrmax[j]); 
7894   TGeoVolume* ssdcableitsring3BB24pcon[4];
7895   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
7896                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
7897   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
7898                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
7899   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
7900                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
7901   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
7902                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
7903   for(Int_t i=0;i<4;i++){
7904         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
7905         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
7906 }
7907   ////////////////////////////////////
7908   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
7909   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
7910   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
7911   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
7912   ////////////////////////////////////
7913   // Volumes for Material Budget 
7914   ////////////////////////////////////
7915   TGeoTube* ssdcablelay6materialbudgetubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax
7916                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight,
7917                                                                                                          ssdcableslay6rightsideradiusmax
7918                                                                                            +     fgkSSDCablesLay5RightSideWaterHeight
7919                                                                                            +     fgkSSDCableMaterialBudgetHeight,0.5*ssdcablelay6rightsidelength); 
7920   TGeoVolume* ssdcablelay6materialbudgetube = new TGeoVolume("SSDCableLay6MaterialBudgetTube",
7921                                                                                                          ssdcablelay6materialbudgetubeshape,
7922                                                                                                          fSSDCopper);
7923   ssdcablelay6materialbudgetube->SetLineColor(9);
7924   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,1,ssdcablelay6rightrans);
7925   ssdcablesmother->AddNode(ssdcablelay6materialbudgetube,2,ssdcablesLay6RightTubeToLeftrans);
7926
7927   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
7928                                         new TGeoPcon(90.0-fgkSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
7929   TGeoVolume* ssdcablelay6materialbudgetpcon;
7930   Double_t ssdcablelay6materialbudgetpconrmin[2];
7931   Double_t ssdcablelay6materialbudgetpconrmax[2];
7932   Double_t ssdcablelay6materialbudgetpconzsection[2];
7933   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
7934                                                                                 + fgkSSDCablesLay5RightSideWaterHeight;
7935   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
7936                                                                                 + fgkSSDCableMaterialBudgetHeight;
7937   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
7938   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
7939   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
7940                                                                                         + fgkEndCapSupportCenterLay6Position
7941                                                                                         + ssdcablelay6rightsidelength;
7942   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
7943   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
7944                                                   ssdcablelay6materialbudgetpconzsection[i],
7945                                                   ssdcablelay6materialbudgetpconrmin[i],
7946                                                   ssdcablelay6materialbudgetpconrmax[i]); 
7947   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
7948                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
7949   ssdcablelay6materialbudgetpcon->SetLineColor(9);
7950   for(Int_t i=0; i<4; i++){
7951    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
7952    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
7953   }
7954 ////////////////////////////////////
7955  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
7956   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
7957   Double_t ssdcablesvolume = 0.0;
7958   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
7959   std::cout << ssdcablesvolume << std::endl;*/
7960   return ssdcablesmother;
7961  }
7962  ////////////////////////////////////////////////////////////////////////////////
7963 TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3* vertexpos[], Double_t* width, 
7964                                             Double_t height, const char* shapename, Int_t isign) const{
7965   /////////////////////////////////////////////////////////////
7966   // Method generating an Arb shape 
7967   /////////////////////////////////////////////////////////////
7968   const Int_t kvertexnumber = 8;
7969   const Int_t ktransvectnumber = 2;
7970   TVector3 vertex[kvertexnumber];
7971   TVector3 transvector[2];
7972   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
7973   /////////////////////////////////////////////////////////////
7974   //Setting the vertices for TGeoArb8
7975   /////////////////////////////////////////////////////////////
7976   vertex[0] = *vertexpos[0];
7977   vertex[1] = *vertexpos[1];
7978   vertex[2] = vertex[1]; 
7979   vertex[3] = vertex[0]; 
7980   vertex[4] = *vertexpos[2];
7981   vertex[5] = *vertexpos[3];
7982   vertex[6] = vertex[5];
7983   vertex[7] = vertex[4];
7984
7985   // NB: order of points is clockwise
7986   if (isign < 0) {
7987     vertex[2] -= transvector[0];
7988     vertex[3] -= transvector[0];
7989     vertex[6] -= transvector[1];
7990     vertex[7] -= transvector[1];
7991   }
7992   else {
7993     vertex[0] += transvector[0];
7994     vertex[1] += transvector[0];
7995     vertex[4] += transvector[1];
7996     vertex[5] += transvector[1];
7997   }
7998
7999   /////////////////////////////////////////////////////////////
8000   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
8001   for(Int_t i = 0; i<kvertexnumber;i++) {
8002     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
8003   }
8004
8005   return arbshape;
8006
8007 ///////////////////////////////////////////////////////////////////////////////
8008 TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
8009                                                                 Double_t rmax, Int_t nedges, Double_t height){
8010   /////////////////////////////////////////////////////////////
8011   // Method generating Arc shape 
8012   /////////////////////////////////////////////////////////////
8013         const Int_t kvertexnumber = 2*nedges+2;
8014         TGeoXtru* arcshape = new TGeoXtru(2);   
8015         TVector3** vertexposition[2];
8016         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
8017         Double_t angle = 0.;
8018     for(Int_t i=0; i<nedges+1; i++){ 
8019                 angle = 90.+0.5*phi-i*(phi/nedges);
8020                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle));
8021                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle));
8022         }
8023         Double_t *xvertexpoints = new Double_t[kvertexnumber];
8024         Double_t *yvertexpoints = new Double_t[kvertexnumber];
8025         for(Int_t i=0; i<kvertexnumber; i++){ 
8026                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
8027                                   yvertexpoints[i] = vertexposition[0][i]->Y(); 
8028                 }
8029                 else if(i>=1&&i<nedges+2)
8030                 {
8031                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
8032                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
8033                 }
8034         else
8035                 {
8036                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
8037                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
8038                 }
8039     }
8040   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
8041   arcshape->DefineSection(0,-0.5*height);
8042   arcshape->DefineSection(1,0.5*height);
8043   /////////////////////////////////////////////////////////////
8044   // Deallocating memory
8045   /////////////////////////////////////////////////////////////
8046   for(Int_t i=0; i<2; i++){
8047         for(Int_t j=0; j<nedges+1; j++)
8048                 delete vertexposition[i][j];
8049         delete [] vertexposition[i];
8050   }
8051   delete [] xvertexpoints;
8052   delete [] yvertexpoints;
8053   /////////////////////////////////////////////////////////////
8054         return arcshape;
8055 }
8056 ////////////////////////////////////////////////////////////////////////////////
8057 TGeoShape* AliITSv11GeometrySSD::GetScrewShape(Double_t* radius,Int_t* edgesnumber,Double_t* section) const {
8058   ///////////////////////////////////////////////////////////////////////
8059   // Method Generating the Screw Shape  
8060   // radius[0]: outer radius
8061   // radius[1]: inner radius
8062   // edgesnumber[0]: outer number of edges
8063   // edgesnumber[1]: inner number of edges
8064   // section[0]: lower section position
8065   // section[1]: higher section position
8066   ///////////////////////////////////////////////////////////////////////
8067   Double_t outradius = radius[0];
8068   Double_t inradius = radius[1];
8069   Int_t outvertexnumber = edgesnumber[0];
8070   Int_t invertexnumber = edgesnumber[1];
8071   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8072   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
8073   for(Int_t i=0; i<outvertexnumber; i++){
8074         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
8075         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
8076   }
8077   for(Int_t i=0; i<invertexnumber; i++){
8078         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
8079         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
8080   }
8081   TGeoXtru* screwshapeout = new TGeoXtru(2);
8082   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
8083   screwshapeout->DefineSection(0,section[0]);
8084   screwshapeout->DefineSection(1,section[1]);
8085   TGeoXtru* screwshapein = new TGeoXtru(2);
8086   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
8087   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
8088   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
8089   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
8090   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
8091   
8092   delete [] xscrewvertex;
8093   delete [] yscrewvertex;
8094   return screwshape;
8095 }
8096 ////////////////////////////////////////////////////////////////////////////////
8097 TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, Double_t *section) const {
8098   ///////////////////////////////////////////////////////////////////////
8099   // Method Generating the Hole Shape  
8100   // radius of the Hole
8101   // nedges: number of edges to approximate the circle
8102   ///////////////////////////////////////////////////////////////////////
8103   Double_t* xholevertex = new Double_t[nedges];
8104   Double_t* yholevertex = new Double_t[nedges];
8105   Double_t z  = 0.5*(section[0]+section[1]);
8106   Double_t dz = 0.5*(section[1]-section[0]);
8107   TGeoTranslation *tr = 0;
8108   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
8109      tr = new TGeoTranslation(0.,0.,z);
8110      tr->RegisterYourself();
8111   }   
8112   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
8113   for(Int_t i=0; i<nedges; i++){
8114         xholevertex[i] = radius*CosD(i*360./nedges);
8115         yholevertex[i] = radius*SinD(i*360./nedges);
8116   }
8117   TGeoXtru* holeshapeout = new TGeoXtru(2);
8118   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
8119   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
8120   holeshapeout->DefineSection(1,section[1]+0.01);
8121   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
8122   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
8123   
8124   delete [] xholevertex;
8125   delete [] yholevertex;
8126   return holeshape;
8127 }
8128 ////////////////////////////////////////////////////////////////////////////////
8129 TVector3* AliITSv11GeometrySSD::GetReflection(TVector3* vector,Double_t* param) const{
8130   /////////////////////////////////////////////////////////////
8131   // Given an axis specified by param, it gives the reflection of the point
8132   // respect to the axis
8133   /////////////////////////////////////////////////////////////
8134   TVector3* n = new TVector3(param[0],param[1],param[2]);
8135   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
8136   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
8137   /////////////////////////////////////////////////////////////
8138   // Deallocating memory
8139   /////////////////////////////////////////////////////////////
8140   delete n;
8141   /////////////////////////////////////////////////////////////
8142   return reflectedvector;
8143 }
8144 ////////////////////////////////////////////////////////////////////////////////
8145 TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(TGeoHMatrix* ct,
8146                                                        Double_t dx,
8147                                                        Double_t dy,
8148                                                        Double_t dz) const{
8149   /////////////////////////////////////////////////////////////
8150   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
8151   /////////////////////////////////////////////////////////////
8152   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
8153   const Double_t *vect = hmatrix->GetTranslation();
8154   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
8155   hmatrix->SetTranslation(newvect);
8156   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
8157   delete hmatrix;
8158   return matrix;
8159 }
8160 ////////////////////////////////////////////////////////////////////////////////
8161 TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
8162   /////////////////////////////////////////////////////////////
8163   // Method returning the Medium type 
8164   /////////////////////////////////////////////////////////////
8165   char ch[100];
8166   sprintf(ch, "ITS_%s",mediumName);
8167   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
8168   if (! medium)
8169     AliError(Form("medium %s not found !\n", mediumName));
8170   return medium;
8171 }
8172 ////////////////////////////////////////////////////////////////////////////////
8173 void AliITSv11GeometrySSD::CreateMaterials(){
8174 ///////////////////////////////////
8175 // This part has to be modified
8176 ///////////////////////////////////
8177   ///////////////////////////////////
8178   // Silicon for Sensor
8179   /////////////////////////////////// 
8180   fSSDSensorMedium = GetMedium("SI$");
8181   ///////////////////////////////////
8182   // Silicon Mixture for Sensor
8183   /////////////////////////////////// 
8184   fSSDChipMedium = GetMedium("SPD SI CHIP$");
8185   fSSDChipGlueMedium = GetMedium("EPOXY$");
8186   ///////////////////////////////////
8187   // Stiffener Components Materials
8188   /////////////////////////////////// 
8189   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
8190   ///////////////////////////  
8191   // Stiffener Connectors 
8192   ///////////////////////////  
8193   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
8194   ////////////////////////////////  
8195   // Stiffener 0603-1812 Capacitor
8196   ////////////////////////////////  
8197   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8198   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
8199   ///////////////////////////  
8200   // Stiffener Hybrid Wire 
8201   ///////////////////////////  
8202   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
8203   ///////////////////////////  
8204   // Al for Cooling Block
8205   ///////////////////////////  
8206   fSSDAlCoolBlockMedium = GetMedium("AL$");
8207   //////////////////////////////////////////////////////  
8208   // Kapton and Al for Chip Cable Flex and Ladder Cables
8209   //////////////////////////////////////////////////////  
8210   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8211   fSSDAlTraceChipCableMedium = GetMedium("AL$");
8212   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
8213   fSSDAlTraceFlexMedium = GetMedium("AL$");
8214   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
8215   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
8216   /////////////////////////////////////////////////////////////////  
8217   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
8218   //////////////////////////////////////////////////////////////////  
8219   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
8220   /////////////////////////////////////////////////////////////////  
8221   // G10 for Detector Leg, TubeHolder
8222   //////////////////////////////////////////////////////////////////  
8223   fSSDTubeHolderMedium = GetMedium("G10FR4$");
8224   fSSDSensorSupportMedium = GetMedium("G10FR4$");
8225   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8226   fSSDMountingBlockMedium = GetMedium("G10FR4$");
8227   /////////////////////////////////////////////////////////////////  
8228   // Water and Phynox for Cooling Tube
8229   //////////////////////////////////////////////////////////////////  
8230   fSSDCoolingTubeWater = GetMedium("WATER$");
8231   fSSDCoolingTubePhynox = GetMedium("INOX$");
8232   /////////////////////////////////////////////////////////////////////
8233   // Material for Support Rings
8234   /////////////////////////////////////////////////////////////////////
8235   fSSDSupportRingAl = GetMedium("AL$");
8236   fSSDRohaCellCone = GetMedium("ROHACELL$");
8237   /////////////////////////////////////////////////////////////////////
8238   fSSDAir = GetMedium("SDD AIR$");
8239   fSSDCopper = GetMedium("COPPER$");
8240   fCreateMaterials = kTRUE;
8241 }
8242 /////////////////////////////////////////////////////////////////////