Introduction of the new SSD geometry in simulation (AliITSv11Hybrid) and suppression...
[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
17 //*************************************************************************
18 // SSD geometry, based on ROOT geometrical modeler
19 //
20 // Enrico Cattaruzza                                    ecattar@ts.infn.it
21 //*************************************************************************
22 #include "TMath.h"
23 #include "TGeoVolume.h"
24 #include "TGeoMatrix.h"
25 #include <TGeoManager.h>
26 #include "TVector3.h"
27 #include "TGeoArb8.h"
28 #include "TList.h"
29 #include "TGeoMatrix.h"
30 #include "TGeoCompositeShape.h"
31 #include "TGeoTube.h"
32 #include "TGeoBBox.h"
33 #include "TGeoXtru.h"
34 #include "AliITSv11GeometrySSD.h"
35 /////////////////////////////////////////////////////////////////////////////////
36 // Names of the Sensitive Volumes of Layer 5 and Layer 6
37 /////////////////////////////////////////////////////////////////////////////////
38 const char* AliITSv11GeometrySSD::fgSDDsensitiveVolName5 = "ITSsddSensitivL5";
39 const char* AliITSv11GeometrySSD::fgSDDsensitiveVolName6 = "ITSsddSensitivL6";
40 /////////////////////////////////////////////////////////////////////////////////
41 //Parameters for SSD Geometry
42 /////////////////////////////////////////////////////////////////////////////////
43 // Layer5 (lengths are in mm and angles in degrees)
44 /////////////////////////////////////////////////////////////////////////////////
45 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
46 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
47 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
48 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
49 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
50 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
51 /////////////////////////////////////////////////////////////////////////////////
52 // Layer6 (lengths are in mm and angles in degrees)
53 /////////////////////////////////////////////////////////////////////////////////
54 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
55 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
56 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
57 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
58 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
59 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
60 /////////////////////////////////////////////////////////////////////////////////
61 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
62 /////////////////////////////////////////////////////////////////////////////////
63 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
64 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
65 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
66 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
67 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
68 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
69 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
70 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
71 /////////////////////////////////////////////////////////////////////////////////
72 // Stiffener (lengths are in mm and angles in degrees)
73 /////////////////////////////////////////////////////////////////////////////////
74 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
75 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
76 //const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   3.315;
77 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.315*fgkmm;
78 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
79 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
84 const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   0.700*fgkmm; // multiplied by 0.5  
85 const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
86 const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
87 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = 
88                                                                                                            {44.32*fgkmm, 0.33*fgkmm};
89 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
92 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       = 
93                                                                                                           0.25*fgkSSDStiffenerHeight;
94 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
95 const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
96 /////////////////////////////////////////////////////////////////////////////////
97 // Cooling Block (lengths are in mm and angles in degrees)
98 /////////////////////////////////////////////////////////////////////////////////
99 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
100 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
101 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
102                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
103 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
104                                                                                                           {1.000*fgkmm, 0.120*fgkmm};
105 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
106                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
107 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
108                                                                                                                                          1.500*fgkmm;
109 const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
110                                                                                                                                          0.300*fgkmm;
111 /////////////////////////////////////////////////////////////////////////////////
112 // SSD Sensor (lengths are in mm and angles in degrees)
113 /////////////////////////////////////////////////////////////////////////////////
114 const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
115                                                                                                                  "SSDSensorSensitiveVol";
116 const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
117 const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
118 const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
119 const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
120                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
121 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
122 const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
123 /////////////////////////////////////////////////////////////////////////////////
124 // Flex (lengths are in mm and angles in degrees)
125 /////////////////////////////////////////////////////////////////////////////////
126 const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
127 const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
128                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
129                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
130                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
131                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
132                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
133 const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
134                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
135 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
136                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
137 const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
138 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
139 const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
140 const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
141                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
142 const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
143                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
144 /////////////////////////////////////////////////////////////////////////////////
145 // SSD Ladder Cable (lengths are in mm and angles in degrees)
146 /////////////////////////////////////////////////////////////////////////////////
147 const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
148 /////////////////////////////////////////////////////////////////////////////////
149 // SSD Module (lengths are in mm and angles in degrees)
150 /////////////////////////////////////////////////////////////////////////////////
151 const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
152                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
153 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
154                                                                                                                                         45.600*fgkmm;
155 const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
156                                                                                                                                          5.075*fgkmm;
157 /////////////////////////////////////////////////////////////////////////////////
158 // Sensor Support (lengths are in mm and angles in degrees)
159 /////////////////////////////////////////////////////////////////////////////////
160 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
161                                                                                                                                          5.800*fgkmm;
162 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
163                                                                                                                                          2.000*fgkmm;
164 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
165                                                                                                      { 4.620*fgkmm, 5.180*fgkmm};
166 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
167                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
168 const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
169                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
170                                                             +  fgkSSDSensorSideSupportThickness[0])
171                                                                 -  fgkSSDSensorSideSupportLength;
172 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
173                                                                                                                                     5.250*fgkmm;
174 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
175                                                                                                                                         1.680*fgkmm;
176 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
177                                                                   = {fgkSSDSensorSideSupportHeight[0]
178                                                                   +  fgkSSDSensorSideSupportThickness[0],
179                                                                          fgkSSDSensorSideSupportHeight[1]
180                                                                   +  fgkSSDSensorSideSupportThickness[1]};
181 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
182                                                                   =  {fgkSSDSensorSideSupportThickness[0],
183                                                                           fgkSSDSensorSideSupportThickness[1]};
184 const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
185                                                                                                                                    19.000*fgkmm;
186 /////////////////////////////////////////////////////////////////////////////////
187 // Chip Cables (lengths are in mm and angles in degrees)
188 /////////////////////////////////////////////////////////////////////////////////
189 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
190                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
191 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
192                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
193                                                                   -  (fgkSSDSensorSideSupportHeight[1]
194                                                                   -   fgkSSDSensorSideSupportHeight[0])
195                                                                   -   fgkSSDCoolingBlockHoleCenter
196                                                                   -   fgkSSDStiffenerHeight
197                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
198                                                                           fgkSSDModuleCoolingBlockToSensor
199                                                                   -   fgkSSDCoolingBlockHoleCenter
200                                                                   -       fgkSSDStiffenerHeight
201                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
202 const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
203                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
204 /////////////////////////////////////////////////////////////////////////////////
205 // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
206 /////////////////////////////////////////////////////////////////////////////////
207 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
208                                                                                                                                         3.820*fgkmm;
209 //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
210 //                                                                                                                                         3.780;
211 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
212                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
213 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
214                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
215 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
216                                                                                                                                 { 30.00, 90.00};
217 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
218                                                                                                                                          1.78*fgkmm;
219 /////////////////////////////////////////////////////////////////////////////////
220 //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
221 /////////////////////////////////////////////////////////////////////////////////
222 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
223                                                                    = fgkSSDModuleSensorSupportDistance
224                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
225 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
226 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
227                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
228 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
229                                                                                                                                         1.630*fgkmm;
230 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
231 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
232                                                                         = fgkCarbonFiberTriangleLength
233                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
234                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
235                                                                         * TMath::DegToRad());
236 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
237                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
238                                                                         - fgkCarbonFiberSupportWidth)
239                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
240                                                                         - fgkCarbonFiberSupportWidth;
241 /////////////////////////////////////////////////////////////////////////////////
242 // Carbon Fiber Lower Support Parameters (lengths are in mm)
243 /////////////////////////////////////////////////////////////////////////////////
244 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
245                                                                                                                                           =  0.950*fgkmm;
246 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
247                                                                                                                                           =  1.600*fgkmm;
248 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
249                                                                                                                                           =  0.830*fgkmm;
250 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
251                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
252 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
253                                                                         = fgkCarbonFiberJunctionWidth
254                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
255                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
256 const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
257                                                                         = {fgkCarbonFiberLowerSupportWidth
258                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
259                                                                            fgkCarbonFiberLowerSupportWidth
260                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
261                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
262 /////////////////////////////////////////////////////////////////////////////////
263 // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
264 /////////////////////////////////////////////////////////////////////////////////
265 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
266                                                            {0.5 * (fgkSSDLay5LadderLength
267                                                                         -  fgkSSDLay5SensorsNumber
268                                                                         *  fgkCarbonFiberJunctionWidth
269                                                                         -  fgkCarbonFiberLowerSupportWidth),
270                                                                 0.5 * (fgkSSDLay5LadderLength
271                                                                         -  fgkSSDLay5SensorsNumber
272                                                                         *  fgkCarbonFiberJunctionWidth
273                                                                         +  fgkCarbonFiberLowerSupportWidth)};
274 const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
275                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
276                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
277 const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
278                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
279                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
280 /////////////////////////////////////////////////////////////////////////////////
281 // Cooling Tube Support (lengths are in mm and angles in degrees)
282 /////////////////////////////////////////////////////////////////////////////////
283 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
284 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
285                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
286 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
287 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
288 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
289 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
290                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
291 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
292                                                                                                                                           11.70*fgkmm;
293 /////////////////////////////////////////////////////////////////////////////////
294 // Cooling Tube (lengths are in mm and angles in degrees)
295 /////////////////////////////////////////////////////////////////////////////////
296 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
297 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  0.96*fgkmm;
298 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
299                                                                                                         fgkCarbonFiberJunctionWidth;
300 const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
301                                                                          fgkSSDModuleSensorSupportDistance
302                                                                   +      fgkSSDCoolingBlockLength;
303 //const Double_t AliITSv11GeometrySSD_ct::fgkCoolingTubeLength               =  39.1;
304 /////////////////////////////////////////////////////////////////////////////////
305 // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
306 /////////////////////////////////////////////////////////////////////////////////
307 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
308                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
309 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
310                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
311 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
312                                                                                                                                           20.0*fgkmm;
313 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
314                                                                                                                                                     40.0;
315 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
316                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
317 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
318                                                                                                                                           2.5*fgkmm;
319 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
320                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
321 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
322                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
323 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
324                                                                                                                                           1.0*fgkmm;
325 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
326                                                                                                                                           6.0*fgkmm;
327 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeigth      =  
328                                                                                                                                           4.0*fgkmm;
329 const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
330                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
331 /////////////////////////////////////////////////////////////////////////////////
332 ClassImp(AliITSv11GeometrySSD)
333 /////////////////////////////////////////////////////////////////////////////////
334 AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
335   AliITSv11Geometry(),
336   fSSDChipMedium(),
337   fSSDChipGlueMedium(),
338   fSSDStiffenerMedium(),
339   fSSDStiffenerConnectorMedium(),
340   fSSDStiffener0603CapacitorMedium(),
341   fSSDStiffener1812CapacitorMedium(),
342   fSSDStiffenerHybridWireMedium(),
343   fSSDKaptonFlexMedium(),
344   fSSDAlTraceFlexMedium(),
345   fSSDAlTraceLadderCableMedium(),
346   fSSDKaptonLadderCableMedium(),
347   fSSDKaptonChipCableMedium(),
348   fSSDAlTraceChipCableMedium(),
349   fSSDAlCoolBlockMedium(),
350   fSSDSensorMedium(),
351   fSSDSensorSupportMedium(),
352   fSSDCarbonFiberMedium(),
353   fSSDTubeHolderMedium(),
354   fSSDCoolingTubeWater(),
355   fSSDCoolingTubePhynox(),
356   fSSDMountingBlockMedium(),
357   fSSDAir(),
358   fCreateMaterials(kFALSE),
359   fTransformationMatrices(kFALSE),
360   fBasicObjects(kFALSE),
361   fcarbonfiberjunction(),
362   fcoolingtubesupport(),
363   fhybridmatrix(),
364   fssdcoolingblocksystem(),
365   fcoolingblocksystematrix(),
366   fssdstiffenerflex(),
367   fssdendflex(),
368   fendladdermountingblock(),
369   fSSDSensor5(),
370   fSSDSensor6(),
371   fSSDLayer5(), 
372   fSSDLayer6(),
373   fMotherVol(),
374   fColorCarbonFiber(4),
375   fColorRyton(5),
376   fColorPhynox(14),
377   fColorSilicon(3),
378   fColorAl(38),
379   fColorKapton(6),
380   fColorPolyhamide(5),
381   fColorStiffener(9),
382   fColorEpoxy(30),
383   fColorWater(7),
384   fColorG10(41)
385 {
386   ////////////////////////
387   // Standard constructor
388   ////////////////////////
389 }
390 /////////////////////////////////////////////////////////////////////////////////
391 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
392   AliITSv11Geometry(s.GetDebug()),
393   fSSDChipMedium(s.fSSDChipMedium),
394   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
395   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
396   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
397   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
398   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
399   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
400   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
401   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
402   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
403   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
404   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
405   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
406   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
407   fSSDSensorMedium(s.fSSDSensorMedium),
408   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
409   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
410   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
411   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
412   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
413   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
414   fSSDAir(s.fSSDAir),
415   fCreateMaterials(s.fCreateMaterials),
416   fTransformationMatrices(s.fTransformationMatrices),
417   fBasicObjects(s.fBasicObjects),
418   fcarbonfiberjunction(s.fcarbonfiberjunction),
419   fcoolingtubesupport(s.fcoolingtubesupport),
420   fhybridmatrix(s.fhybridmatrix),
421   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
422   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
423   fssdstiffenerflex(s.fssdstiffenerflex),
424   fssdendflex(s.fssdendflex),
425   fendladdermountingblock(s.fendladdermountingblock),
426   fSSDSensor5(s.fSSDSensor5),
427   fSSDSensor6(s.fSSDSensor6),
428   fSSDLayer5(s.fSSDLayer5),     
429   fSSDLayer6(s.fSSDLayer6),
430   fMotherVol(s.fMotherVol),
431   fColorCarbonFiber(s.fColorCarbonFiber),
432   fColorRyton(s.fColorRyton),
433   fColorPhynox(s.fColorPhynox),
434   fColorSilicon(s.fColorSilicon),
435   fColorAl(s.fColorAl),
436   fColorKapton(s.fColorKapton),
437   fColorPolyhamide(s.fColorPolyhamide),
438   fColorStiffener(s.fColorStiffener),
439   fColorEpoxy(s.fColorEpoxy),
440   fColorWater(s.fColorWater),
441   fColorG10(s.fColorG10)
442 {
443   ////////////////////////
444   // Copy Constructor
445   ////////////////////////
446 }
447 /////////////////////////////////////////////////////////////////////////////////
448 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
449 operator=(const AliITSv11GeometrySSD &s){
450   ////////////////////////
451   // Assignment operator
452   ////////////////////////
453   this->~AliITSv11GeometrySSD();
454   new(this) AliITSv11GeometrySSD(s); 
455   return *this;
456 /*      
457   if(&s == this) return *this;
458   fMotherVol = s.fMotherVol;
459   return *this;
460  */
461 }
462 ///////////////////////////////////////////////////////////////////////////////
463 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
464   ///////////////////////////////////////////////////////////////////////  
465   // Method generating the trasformation matrix for the whole SSD Geometry   
466   ///////////////////////////////////////////////////////////////////////  
467   // Setting some variables for Carbon Fiber Supportmatrix creation
468   //////////////////////////////////////////////////////////////////////
469   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
470                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
471   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
472                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
473                                                                  +      fgkCarbonFiberSupportWidth);
474   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
475                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
476   TGeoRotation* carbonfiberot[3];
477   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
478   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
479   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
480   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
481   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
482                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
483                                                   -  fgkCarbonFiberTriangleLength
484                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
485   ///////////////////////////////////////////
486   //Setting Local Translations and Rotations: 
487   ///////////////////////////////////////////
488   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
489   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
490                                                                          0.5*carbonfibersupportheight,NULL);    
491   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
492                                                                          2.*symmetryplaneposition+transvector[1],
493                                                                          transvector[2], carbonfiberot[2]);
494   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
495   /////////////////////////////////////////////////////////////
496   // Carbon Fiber Support Transformations
497   /////////////////////////////////////////////////////////////
498   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
499   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
500                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
501                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
502                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
503   }             
504   /////////////////////////////////////////////////////////////
505   // Carbon Fiber Junction Transformation
506   /////////////////////////////////////////////////////////////
507   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
508   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
509   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
510   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
511   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
512         localcarbonfiberjunctionmatrix[i] = 
513                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
514         localcarbonfiberjunctionrot[i] = 
515                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
516         localcarbonfiberjunctiontrans[i] = 
517                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
518   }
519   ///////////////////////
520   // Setting Translations
521   ///////////////////////
522   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
523   localcarbonfiberjunctiontrans[1][0] = 
524                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
525   localcarbonfiberjunctiontrans[2][0] = 
526                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
527                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
528                                  fgkCarbonFiberTriangleLength
529                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
530   localcarbonfiberjunctiontrans[0][1] = 
531                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
532   localcarbonfiberjunctiontrans[1][1] = 
533                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
534   localcarbonfiberjunctiontrans[2][1] = 
535                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
536   ////////////////////
537   // Setting Rotations
538   ////////////////////
539   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
540                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
541                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
542   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
543         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
544   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
545   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
546   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
547   ////////////////////////////////////////
548   // Setting Carbon Fiber Junction matrix 
549   ////////////////////////////////////////
550   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
551                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
552                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
553                         localcarbonfiberjunctionmatrix[i][j] = 
554                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
555                                                            *localcarbonfiberjunctionrot[i][j]);
556                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
557          }
558   }
559   /////////////////////////////////////////////////////////////
560   // Carbon Fiber Lower Support Transformations
561   /////////////////////////////////////////////////////////////
562   TGeoTranslation* localcarbonfiberlowersupportrans[2];
563   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
564                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
565                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
566                                                                          0.0);
567   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
568                                                                          fgkCarbonFiberJunctionWidth
569                                                                 -    fgkCarbonFiberLowerSupportWidth
570                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
571                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
572                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
573    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
574    fcarbonfiberlowersupportrans[0] = 
575                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
576    fcarbonfiberlowersupportrans[1] = 
577                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
578   /////////////////////////////////////////////////////////////
579   // SSD Sensor Support Transformations
580   /////////////////////////////////////////////////////////////
581   const Int_t kssdsensorsupportmatrixnumber = 3;
582   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
583   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
584   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
585   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
586         localssdsensorsupportmatrix[i] = 
587                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
588         localssdsensorsupportrot[i] = 
589                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
590         localssdsensorsupportrans[i] = 
591                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
592   }
593   ///////////////////////
594   // Setting Translations
595   ///////////////////////
596   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
597                                                                           0.5*fgkSSDSensorSideSupportWidth,
598                                                                           0.0);
599   localssdsensorsupportrans[1][0] = 
600                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
601   localssdsensorsupportrans[2][0] = 
602                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
603   localssdsensorsupportrans[0][1] = 
604                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
605                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
606                                                                                 0.0);
607   localssdsensorsupportrans[1][1] = 
608                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
609                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
610                                                                     -   fgkSSDModuleSensorSupportDistance,
611                                                                                 0.0);
612   localssdsensorsupportrans[2][1] = 
613                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
614                                                                         -    fgkSSDSensorCenterSupportPosition,
615                                                                                  0.5*fgkSSDSensorCenterSupportWidth
616                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
617                                                                                  fgkSSDSensorCenterSupportThickness[0]);
618   localssdsensorsupportrans[0][2] = 
619                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
620                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
621                                                                                  fgkCarbonFiberJunctionWidth
622                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
623                                                                         +    fgkSSDSensorCenterSupportLength
624                                                                         -    fgkSSDSensorCenterSupportThickness[0])
625                                                                         -    fgkSSDSensorCenterSupportPosition,
626                                                                              0.0);
627   localssdsensorsupportrans[1][2] = 
628                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
629   localssdsensorsupportrans[2][2] = 
630                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
631   ////////////////////
632   // Setting Rotations
633   ////////////////////
634   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
635                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
636                         localssdsensorsupportrot[i][j] = new TGeoRotation();
637   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
638         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
639         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
640   }
641   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
642   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
643   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
644   ////////////////////////////////////////
645   // SSD Sensor Support matrix 
646   ////////////////////////////////////////
647   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
648                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
649                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
650                         localssdsensorsupportmatrix[i][j] = 
651                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
652                                                            *localssdsensorsupportrot[i][j]);
653                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
654          }
655   }
656   /////////////////////////////////////////////////////////////
657   // SSD Cooling Tube Support Transformations
658   /////////////////////////////////////////////////////////////
659   const Int_t kcoolingtubesupportmatrixnumber = 2;
660   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
661   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
662   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
663   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
664                                                                                                         /fgkCoolingTubeSupportRmax);
665   localcoolingtubesupportrans[0] = 
666                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
667                                                 +  2.*(fgkCoolingTubeSupportLength
668                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
669                                                 +  fgkCarbonFiberTriangleLength
670                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
671   localcoolingtubesupportrans[1] = 
672                         new TGeoTranslation(fgkCarbonFiberJunctionLength
673                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
674                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
675                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
676                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
677                     -  0.5*(fgkCarbonFiberLowerSupportWidth
678                                         +          fgkSSDSensorCenterSupportLength
679                     -      fgkSSDSensorCenterSupportThickness[0])
680                                         +  0.5*fgkSSDSensorLength,
681                                         -  0.5*fgkCoolingTubeSupportHeight);  
682   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
683   localcoolingtubesupportrot[i] = new TGeoRotation();
684   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
685   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
686   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
687         localcoolingtubesupportmatrix[i] = 
688                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
689                                                    *localcoolingtubesupportrot[i]);
690   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
691   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
692                                                                 (*localcoolingtubesupportmatrix[0]));
693   /////////////////////////////////////////////////////////////
694   // SSD Cooling Tube Transformations
695   /////////////////////////////////////////////////////////////
696   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
697   localcoolingtuberot->SetAngles(0.,90.,0.);
698   TGeoTranslation** localcoolingtubetrans[4];
699   TVector3** localcoolingtubevect[4];
700   for(Int_t i=0; i<4; i++){
701         localcoolingtubevect[i] = new TVector3*[2];
702         localcoolingtubetrans[i] = new TGeoTranslation*[2];
703         fcoolingtubematrix[i] = new TGeoHMatrix*[2];
704   }
705   localcoolingtubevect[0][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
706                                                   -fgkCarbonFiberTriangleLength),
707                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
708                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
709                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
710                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
711                                                   +      fgkSSDSensorCenterSupportLength
712                                                   -      fgkSSDSensorCenterSupportThickness[0])+
713                                                          0.5*fgkSSDSensorLength-0.25*(fgkSSDSensorLength
714                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
715                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
716                                                   -  0.5*fgkCoolingTubeSupportWidth,
717                                                   -  0.5*fgkCoolingTubeSupportHeight);  
718   localcoolingtubevect[0][1] = new TVector3(localcoolingtubevect[0][0]->X(),
719                                                         localcoolingtubevect[0][0]->Y()+0.5*(fgkSSDSensorLength
720                                                   -  2.0*fgkSSDModuleStiffenerPosition[1]
721                                                   -      2.0*fgkSSDCoolingBlockWidth-fgkCoolingTubeSupportWidth)
722                                                   +  fgkCoolingTubeSupportWidth,
723                                                   localcoolingtubevect[0][0]->Z());     
724   localcoolingtubevect[1][0] = new TVector3(-localcoolingtubevect[0][0]->X()
725                                                          +                               fgkCarbonFiberTriangleLength,
726                                                                                          localcoolingtubevect[0][0]->Y(),
727                                                                                          localcoolingtubevect[0][0]->Z());
728   localcoolingtubevect[1][1] = new TVector3(-localcoolingtubevect[0][1]->X()
729                                                          +                               fgkCarbonFiberTriangleLength,
730                                                                                          localcoolingtubevect[0][1]->Y(),
731                                                                                          localcoolingtubevect[0][1]->Z());
732   localcoolingtubevect[2][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
733                                                   -     fgkCarbonFiberTriangleLength),
734                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
735                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
736                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
737                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
738                                                   +      fgkSSDSensorCenterSupportLength
739                                                   -      fgkSSDSensorCenterSupportThickness[0])
740                                                   +  fgkSSDModuleStiffenerPosition[1]
741                                                   -  0.5*(fgkSSDModuleStiffenerPosition[1]-fgkSSDSensorOverlap),
742                                                   -  0.5*fgkCoolingTubeSupportHeight);  
743   localcoolingtubevect[2][1] = new TVector3(-localcoolingtubevect[2][0]->X()
744                                                          +                               fgkCarbonFiberTriangleLength,
745                                                                                          localcoolingtubevect[2][0]->Y(),
746                                                                                          localcoolingtubevect[2][0]->Z());      
747   localcoolingtubevect[3][0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
748                                                   -     fgkCarbonFiberTriangleLength),
749                                                   - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
750                                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
751                                                   +      0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
752                                                   -      0.5*(fgkCarbonFiberLowerSupportWidth
753                                                   +      fgkSSDSensorCenterSupportLength
754                                                   -      fgkSSDSensorCenterSupportThickness[0])
755                                                   +      fgkSSDSensorLength
756                                                   -      0.5*fgkSSDModuleStiffenerPosition[1],
757                                                   -  0.5*fgkCoolingTubeSupportHeight);  
758   localcoolingtubevect[3][1] = new TVector3(-localcoolingtubevect[3][0]->X()
759                                                   + fgkCarbonFiberTriangleLength,
760                                                         localcoolingtubevect[3][0]->Y(),
761                                                   - 0.5*fgkCoolingTubeSupportHeight);   
762   for(Int_t i=0; i<4; i++) 
763         for(Int_t j=0; j<2; j++){
764                 localcoolingtubetrans[i][j] = 
765                         new TGeoTranslation(localcoolingtubevect[i][j]->X(),
766                                                                 localcoolingtubevect[i][j]->Y(),
767                                                                 localcoolingtubevect[i][j]->Z());
768                 fcoolingtubematrix[i][j] = new TGeoHMatrix((*localcoolingtubetrans[i][j])
769                                                           *                                     (*localcoolingtuberot));
770         }
771   /////////////////////////////////////////////////////////////
772   // SSD Hybrid Components Transformations
773   /////////////////////////////////////////////////////////////
774   const Int_t khybridmatrixnumber = 3;
775   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
776   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
777                                             0.5*fgkSSDStiffenerWidth,
778                                             0.5*fgkSSDStiffenerHeight);
779   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
780                                             fgkSSDModuleStiffenerPosition[1],0.0);
781
782   localhybridtrans[2] = new TGeoTranslation(
783                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
784                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
785                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
786                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
787                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
788                       -       fgkSSDSensorCenterSupportThickness[0]),
789                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
790                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight)); 
791   fhybridmatrix = new TGeoHMatrix();
792   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
793   /////////////////////////////////////////////////////////////
794   // SSD Cooling Block Transformations
795   /////////////////////////////////////////////////////////////
796   const Int_t kcoolingblockmatrixnumber = 4;    
797   TGeoTranslation* localcoolingblocktrans[kcoolingblockmatrixnumber];
798   localcoolingblocktrans[0] = new TGeoTranslation(-2.*(fgkCoolingTubeSupportRmax
799                             -  fgkCoolingTubeSupportRmin),0.0,
800                                0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
801   localcoolingblocktrans[1] = new TGeoTranslation(0.5*fgkSSDStiffenerLength
802                             -  0.5*fgkSSDModuleSensorSupportDistance-fgkSSDCoolingBlockLength,
803                                0.0,fgkSSDStiffenerHeight);
804   localcoolingblocktrans[2] = new TGeoTranslation(*localhybridtrans[1]);
805   localcoolingblocktrans[3] = new TGeoTranslation(*localhybridtrans[2]);
806   fcoolingblocksystematrix = new TGeoHMatrix();
807   for(Int_t i=0; i<kcoolingblockmatrixnumber; i++)
808       fcoolingblocksystematrix->MultiplyLeft(localcoolingblocktrans[i]);
809   /////////////////////////////////////////////////////////////
810   // SSD Stiffener Flex Transformations
811   /////////////////////////////////////////////////////////////
812   const Int_t klocalflexmatrixnumber = 4;
813   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
814   for(Int_t i=0; i<fgkflexnumber; i++)    
815       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
816   for(Int_t i=0; i<fgkflexnumber; i++)
817       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
818             localflexmatrix[i][j] = new TGeoCombiTrans();
819   Double_t ssdstiffenerseparation = fgkSSDSensorLength
820                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
821                                                                   -    fgkSSDStiffenerWidth;
822   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
823                                         +0.5*fgkSSDStiffenerLength,
824                                          0.5*fgkSSDStiffenerWidth,
825                                         -0.5*fgkSSDStiffenerHeight
826                                         -0.5*fgkSSDFlexHeight[0]);
827   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
828                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
829                                         -0.5*fgkSSDStiffenerWidth,
830                                         -0.5*fgkSSDStiffenerHeight
831                                         -0.5*fgkSSDFlexHeight[0]);
832   TGeoRotation* localflexrot = new TGeoRotation();
833   localflexrot->SetAngles(180.,0.,0.);    
834   localflexmatrix[1][0]->SetRotation(localflexrot);
835   for(Int_t i=0; i<fgkflexnumber; i++)
836       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
837             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
838   for(Int_t i=0; i<fgkflexnumber; i++){
839       fstiffenerflexmatrix[i] = new TGeoHMatrix();
840       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
841             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
842   }
843   /////////////////////////////////////////////////////////////
844   // SSD End Flex Transformations
845   /////////////////////////////////////////////////////////////
846   TGeoRotation* localendflexrot = new TGeoRotation();
847   localendflexrot->SetAngles(0.0,90.0,0.0);
848   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
849   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
850                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
851   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
852                             * TMath::DegToRad()*ssdflexradiusmax
853                                                                - fgkSSDFlexLength[2]-TMath::Pi()
854                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
855   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
856                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
857                             +      fgkSSDFlexLength[2];
858   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
859                               0.5*fgkSSDFlexWidth[0],
860                               2.*fgkSSDStiffenerHeight
861                             + 0.5*fgkSSDFlexHeight[0]);      
862   localendflexmatrix->SetRotation(localendflexrot);
863   for(Int_t i=0; i<fgkflexnumber; i++) 
864       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
865   /////////////////////////////////////////////////////////////
866   // End Ladder Carbon Fiber Junction
867   /////////////////////////////////////////////////////////////
868   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
869   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
870   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
871   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
872       localendladdercarbonfiberjunctionmatrix[i] 
873             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
874       localendladdercarbonfiberjunctionrot[i] 
875             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
876       localendladdercarbonfiberjunctiontrans[i] 
877             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
878       fendladdercarbonfiberjunctionmatrix[i]
879             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
880   }
881   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
882       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
883             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
884             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
885       }
886   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
887       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
888           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
889   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
890       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
891                               0.0,0.0);
892       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
893                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
894                 *                     SinD(fgkCarbonFiberTriangleAngle),
895                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
896   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
897   }
898   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
899   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
900   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
901   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
902       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
903       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
904       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
905       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
906             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
907       localendladdercarbonfiberjunctionglobalmatrix[i] = 
908             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
909                                *localendladdercarbonfiberjunctionglobalrot[i]);
910   }
911   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
912       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
913             localendladdercarbonfiberjunctionmatrix[i][j] = 
914                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
915                                      *localendladdercarbonfiberjunctionrot[i][j]);
916            fendladdercarbonfiberjunctionmatrix[i][j] =
917             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
918             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
919       }  
920   /////////////////////////////////////////////////////////////
921   // End Ladder Carbon Fiber Support
922   /////////////////////////////////////////////////////////////
923   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
924   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
925       localendladdercarbonfibertrans[i] = new TGeoTranslation();
926       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
927             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
928       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
929   }
930   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
931       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
932             fendladdercarbonfibermatrix[i][j] = 
933             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
934             *(*fcarbonfibersupportmatrix[j]));
935   /////////////////////////////////////////////////////////////
936   // End Ladder SSD Mounting Block
937   /////////////////////////////////////////////////////////////
938   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
939       fendladdermountingblocktrans[i] = 
940             new TGeoTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
941                                 +        fgkSSDMountingBlockLength[1])
942                                 +  0.5*fgkCarbonFiberTriangleLength,
943                                 fgkEndLadderMountingBlockPosition[i],
944                                 -  fgkSSDMountingBlockHeight[1]
945                                 +  0.5*fgkSSDMountingBlockHeight[0]);
946   /////////////////////////////////////////////////////////////
947   // End Ladder Carbon Fiber Lower Support
948   /////////////////////////////////////////////////////////////
949   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
950       fendladderlowersupptrans[i] = 
951             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
952                         +  0.5*fgkSSDMountingBlockWidth),
953                         -  0.5*fgkCarbonFiberLowerSupportHeight);
954   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
955                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
956                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
957                                                                          0.0);
958   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
959  /////////////////////////////////////////////////////////////
960   // Matrix for positioning Ladder into mother volume
961   /////////////////////////////////////////////////////////////
962   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
963   for(Int_t i=0; i<fgkladdernumber; i++) 
964         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
965   TGeoRotation* localladdermotherrot = new TGeoRotation();
966   localladdermotherrot->SetAngles(0.,90.,0.);  
967   TGeoTranslation* localladdermothertrans[fgkladdernumber];
968   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
969   for(Int_t i=0; i<fgkladdernumber; i++){
970         localladdermothertrans[i] = new TGeoTranslation(0.,
971                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
972                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
973                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
974                                                           * fgkCarbonFiberJunctionWidth,0.);
975         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
976                                                                                                                 *localladdermotherrot);
977         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
978         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
979   }
980   /////////////////////////////////////////////////////////////
981   // Ladder Cables Matrices
982   /////////////////////////////////////////////////////////////
983   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
984                                              + fgkSSDFlexHeight[1];  
985   Double_t ssdladdercabletransx[3];
986   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
987                                                   *   SinD(2.*fgkSSDFlexAngle)
988                                                   *       CosD(2.*fgkSSDFlexAngle);
989   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
990                                                   -     ssdladdercabletransx[0]
991                                                   /     SinD(2.*fgkSSDFlexAngle))
992                                                   *     CosD(fgkSSDFlexAngle);                                          
993   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
994                                                   *       TMath::DegToRad()*ssdflexradiusmax
995                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
996                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
997                                                   -       fgkSSDLadderCableWidth)
998                                                   *       CosD(2.*fgkSSDFlexAngle);
999   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1000                                                   *     TanD(2.*fgkSSDFlexAngle),
1001                                                         ssdladdercabletransx[1]
1002                                                   *     TanD(fgkSSDFlexAngle),
1003                                                         ssdladdercabletransx[2]
1004                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1005   TGeoRotation* localladdercablerot[3]; 
1006   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1007   localladdercablerot[0]->SetAngles(90.,0.,0.);
1008   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1009   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1010                                                  *                        (*localladdercablerot[0]));
1011   ////////////////////////////////////////////
1012   // LocalLadderCableCombiTransMatrix
1013   ////////////////////////////////////////////
1014   const Int_t klocalladdersidecablesnumber = 2;
1015   const Int_t klocalladdercombitransnumber = 5;
1016   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1017   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1018          localladdercablecombitransmatrix[i] = 
1019                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1020   ///////////////////////////////////////////
1021   // Left Side Ladder Cables Transformations
1022   ///////////////////////////////////////////
1023   localladdercablecombitransmatrix[0][0]  =
1024                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1025                                                 0.,0.,NULL);
1026   localladdercablecombitransmatrix[0][1] = 
1027         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1028                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1029                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1030                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1031                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1032                                            + fgkSSDSensorCenterSupportLength
1033                                            - fgkSSDSensorCenterSupportThickness[0]),
1034                                            - (fgkSSDModuleCoolingBlockToSensor
1035                                            + 0.5*fgkCoolingTubeSupportHeight
1036                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1037                                            - fgkSSDChipHeight),NULL);
1038   localladdercablecombitransmatrix[0][2] = 
1039                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1040                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1041   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1042                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1043                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1044                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1045                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1046                                                                                                 new TGeoRotation("",180.,0.,0.));
1047   localladdercablecombitransmatrix[0][4] = 
1048                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1049                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1050                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1051                                                           0.,
1052                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1053                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1054                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1055                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1056   ///////////////////////////////////////////
1057   // Rigth Side Ladder Cables Transformations
1058   ///////////////////////////////////////////
1059   TGeoCombiTrans* localladdercablessdmodulematrix = 
1060         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1061                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1062                                                                          fgkSSDStiffenerWidth,
1063                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1064   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1065    localladdercablecombitransmatrix[1][i] = 
1066                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1067                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1068   ///////////////////////////////////////////
1069   // Setting LadderCableHMatrix
1070   ///////////////////////////////////////////
1071   Int_t beamaxistrans[2][3];
1072   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1073   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1074   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1075   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1076   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1077   beamaxistrans[1][2] = beamaxistrans[1][0];
1078   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1079   TGeoRotation* laddercablerot = new TGeoRotation();
1080   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1081   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1082   Double_t* laddercabletransvector;     
1083   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1084         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1085         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1086   }
1087   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1088         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1089                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1090                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1091                         localladdercablehmatrix[i][j]->MultiplyLeft(
1092                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1093         }
1094                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1095                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1096                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1097                                                                          laddercabletransvector[1]
1098                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1099                                         *                                fgkCarbonFiberJunctionWidth,
1100                                                                          laddercabletransvector[2]);
1101                 laddercablecombitrans->SetRotation(*laddercablerot);
1102                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1103                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1104         }
1105     fladdercablematrix[i][2] = 
1106                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1107                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1108         fladdercablematrix[i][3] = 
1109                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1110                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1111   }
1112   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1113         for(Int_t j=0; j<klocalladdercombitransnumber-1; j++)
1114                 fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1115   ///////////////////////////////////////////
1116   // Setting Ladder HMatrix
1117   ///////////////////////////////////////////
1118   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1119                                                                                                 fgkSSDLay6SensorsNumber};
1120   for(Int_t i=0; i<fgkladdernumber; i++){
1121         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1122         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1123                 fladdermatrix[i][j] = new TGeoHMatrix();
1124                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1125                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1126                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1127         }
1128   }
1129   ///////////////////////////////////////////
1130   // Setting SSD Sensor Matrix 
1131   ///////////////////////////////////////////
1132   TGeoCombiTrans* localssdsensorcombitrans[2];
1133   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1134   localssdsensorrot->SetAngles(0.,90.,0.);      
1135   TGeoTranslation* localssdsensortrans[2];
1136   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1137   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1138                                           -             (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1139                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1140                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1141                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1142                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1143                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1144                                           -             fgkSSDModuleCoolingBlockToSensor+(fgkSSDSensorSideSupportHeight[1]
1145                                           -             fgkSSDSensorSideSupportHeight[0]));
1146   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1147                                           -        (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1148                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1149                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1150                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1151                       -       fgkSSDSensorCenterSupportThickness[0])+0.5*fgkSSDSensorLength,
1152                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1153                                                         -fgkSSDModuleCoolingBlockToSensor);
1154   for(Int_t i=0; i<2; i++) 
1155         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1156                                                                                                          *localssdsensorrot);   
1157     for(Int_t i=0; i<fgkladdernumber; i++){
1158         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1159         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1160                 switch(i){
1161                         case 0: //Ladder of Layer5  
1162                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1163                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1164                                                                                                 *localssdsensorcombitrans[1])));
1165                         break;
1166                         case 1: //Ladder of Layer6 
1167                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1168                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1169                                                                                                 *localssdsensorcombitrans[0])));
1170                 break;
1171                 }
1172           }
1173   }     
1174   //////////////////////////
1175   // Setting SSD End Ladder  
1176   //////////////////////////
1177   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1178   for(Int_t i=0; i<2; i++){
1179         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1180         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1181         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1182         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1183         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1184         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1185         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1186         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1187    }
1188   /////////////////////////////////////////////////////
1189   // Setting the CombiTransformation to pass ITS center 
1190   /////////////////////////////////////////////////////
1191   Double_t itscentertransz[fgklayernumber];
1192   itscentertransz[0] = fgkSSDLay5LadderLength
1193                                          - fgkLay5CenterITSPosition;
1194   itscentertransz[1] = fgkSSDLay6LadderLength
1195                                          - fgkLay6CenterITSPosition;
1196   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1197                                                    + 0.5*fgkCoolingTubeSupportHeight;
1198   TGeoRotation* itscenterrot[3];
1199   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1200   itscenterrot[0]->SetAngles(90.,180.,-90.);
1201   itscenterrot[1]->SetAngles(0.,90.,0.);
1202   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1203   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1204   for(Int_t i=0; i<fgklayernumber; i++) 
1205         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1206                                                          itssensortransy,
1207                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1208                                                    - itscentertransz[i],itscenterrot[2]);
1209   TGeoRotation** locallayerrot[fgklayernumber];
1210   TGeoTranslation** locallayertrans[fgklayernumber];    
1211   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1212   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1213   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1214                                          - fgkLay5CenterITSPosition);
1215   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1216                                          - fgkLay6CenterITSPosition);
1217   const Int_t kssdlayladdernumber[fgklayernumber] = 
1218                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1219   for(Int_t i=0; i<fgklayernumber; i++){
1220     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1221     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1222         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1223         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1224   }
1225   Double_t layerladderangleposition[fgklayernumber] = 
1226                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1227   Double_t layerradius = 0.;
1228   for(Int_t i=0; i<fgklayernumber; i++){        
1229         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1230                 switch(i){
1231                         case 0: //Ladder of Layer5  
1232                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1233                         break;
1234                         case 1: //Ladder of Layer6 
1235                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1236                 break;
1237                 }
1238                 locallayerrot[i][j] = new TGeoRotation();
1239                 locallayertrans[i][j] = new TGeoTranslation();
1240                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1241                 locallayertrans[i][j]->SetTranslation(layerradius 
1242                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1243                                                             layerradius 
1244                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1245                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1246                                                                          *locallayerrot[i][j]);
1247                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1248                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1249                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1250         }
1251   }
1252   /////////////////////////////////////////////////////////////
1253   // Deallocating memory
1254   /////////////////////////////////////////////////////////////
1255   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1256         delete carbonfiberot[i];
1257         delete localcarbonfibersupportmatrix[i];
1258   }
1259   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1260      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1261        delete localcarbonfiberjunctionmatrix[i][j];
1262            delete localcarbonfiberjunctionrot[i][j];
1263            delete localcarbonfiberjunctiontrans[i][j];
1264            }
1265        delete [] localcarbonfiberjunctionmatrix[i];
1266        delete [] localcarbonfiberjunctionrot[i];
1267        delete [] localcarbonfiberjunctiontrans[i];
1268   }
1269   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1270            delete localcarbonfiberlowersupportrans[i];
1271   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1272      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1273        delete localssdsensorsupportmatrix[i][j];
1274            delete localssdsensorsupportrot[i][j];
1275            delete localssdsensorsupportrans[i][j];
1276            }
1277        delete [] localssdsensorsupportmatrix[i];
1278        delete [] localssdsensorsupportrot[i];
1279        delete [] localssdsensorsupportrans[i];
1280   }
1281   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1282         delete localcoolingtubesupportmatrix[i];
1283         delete localcoolingtubesupportrot[i];
1284         delete localcoolingtubesupportrans[i];
1285   }
1286   for(Int_t i=0; i<4; i++){
1287         for(Int_t j=0; j<2; j++){
1288                 delete localcoolingtubevect[i][j];
1289                 delete localcoolingtubetrans[i][j];
1290         }
1291         delete [] localcoolingtubevect[i];
1292         delete [] localcoolingtubetrans[i];
1293   }
1294  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1295  for(Int_t i=0; i<kcoolingblockmatrixnumber; i++) delete localcoolingblocktrans[i];
1296  for(Int_t i=0; i<fgkflexnumber; i++){
1297       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1298             delete localflexmatrix[i][j];
1299       delete [] localflexmatrix[i];
1300  }
1301  delete localflexrot;
1302  delete localendflexrot;
1303  delete localendflexmatrix;
1304  for(Int_t i=0; i<fgkladdernumber; i++){ 
1305         delete localladdermothertrans[i];
1306         delete localladdermothercombitrans[i];
1307   }
1308  delete localladdermotherrot;
1309  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1310       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1311             delete localendladdercarbonfiberjunctionmatrix[i][j];
1312             delete localendladdercarbonfiberjunctionrot[i][j];
1313             delete localendladdercarbonfiberjunctiontrans[i][j];
1314       }
1315       delete [] localendladdercarbonfiberjunctionmatrix[i];
1316       delete [] localendladdercarbonfiberjunctionrot[i];
1317       delete [] localendladdercarbonfiberjunctiontrans[i];
1318       delete localendladdercarbonfiberjunctionglobalrot[i];
1319       delete localendladdercarbonfiberjunctionglobaltrans[i];
1320       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1321  }
1322  for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1323       delete localendladdercarbonfibertrans[i];
1324   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1325   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1326         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1327                 delete localladdercablecombitransmatrix[i][j];
1328                 delete []localladdercablecombitransmatrix[i];
1329   }
1330   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1331         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1332                 delete localladdercablehmatrix[i][j];
1333         delete []localladdercablehmatrix[i];
1334   }
1335   delete laddercablerot;
1336   delete laddercabletrans;
1337   delete laddercablecombitrans;
1338   delete localladdercablessdmodulematrix;
1339   delete localssdsensorrot;     
1340   for(Int_t i=0; i<2; i++){
1341         delete localssdsensortrans[i];
1342         delete localssdsensorcombitrans[i];
1343   }
1344   for(Int_t i=0; i<fgklayernumber; i++){
1345         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1346                 delete locallayerrot[i][j];
1347                 delete locallayertrans[i][j];
1348                 delete locallayercombitrans[i][j];
1349     }
1350         delete [] locallayerrot[i];
1351         delete [] locallayertrans[i];
1352         delete [] locallayercombitrans[i];
1353         delete localbeamaxistrans[i];
1354   }
1355   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1356   for(Int_t i=0; i<fgkladdernumber; i++){
1357         for(Int_t j=0; j<fgkladdernumber; j++)
1358                 delete ladderglobalmatrix[i][j];
1359         delete [] ladderglobalmatrix[i];
1360   }
1361   /////////////////////////////////////////////////////////////
1362   fTransformationMatrices = kTRUE;      
1363 }
1364 ///////////////////////////////////////////////////////////////////////////////
1365 void AliITSv11GeometrySSD::CreateBasicObjects(){
1366   /////////////////////////////////////////////////////////////  
1367   // Method generating the Objects of SSD Geometry    
1368   /////////////////////////////////////////////////////////////
1369   // SSD Sensor
1370   ///////////////////////////////////
1371   SetSSDSensor();
1372   /////////////////////////////////////////////////////////////  
1373   // Carbon Fiber Support    
1374   /////////////////////////////////////////////////////////////  
1375   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1376   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1377       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1378   /////////////////////////////////////////////////////////////
1379   // Carbon Fiber Junction 
1380   /////////////////////////////////////////////////////////////
1381   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth);
1382   /////////////////////////////////////////////////////////////
1383   // Carbon Fiber Lower Support
1384   /////////////////////////////////////////////////////////////
1385   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1386   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1387         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1388   /////////////////////////////
1389   // SSD Sensor Support
1390   /////////////////////////////
1391   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1392                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1393   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1394                                                                          fgkSSDSensorSideSupportThickness[1]};
1395   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1396         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1397                                                                                            fgkSSDSensorSideSupportHeight[i],
1398                                                                                            fgkSSDSensorSideSupportWidth,
1399                                                                                            sidesupporthickness);  
1400         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1401                                                                                            fgkSSDSensorCenterSupportHeight[i],
1402                                                                                            fgkSSDSensorCenterSupportWidth,
1403                                                                                            sidesupporthickness);
1404   }
1405   /////////////////////////////////////////////////////////////
1406   // SSD Cooling Tube Support
1407   /////////////////////////////////////////////////////////////
1408   Int_t edgesnumber = 16;
1409   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1410   /////////////////////////////////////////////////////////////
1411   // SSD Hybrid
1412   /////////////////////////////////////////////////////////////
1413   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1414   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1415         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1416   /////////////////////////////////////////////////////////////
1417   // SSD Cooling Block System
1418   /////////////////////////////////////////////////////////////
1419   fssdcoolingblocksystem = GetCoolingBlockSystem();
1420    /////////////////////////////////////////////////////////////
1421   // SSD Cooling Tube
1422   /////////////////////////////////////////////////////////////
1423   TList* coolingtubelist = GetCoolingTubeList();        
1424   for(Int_t i=0; i<fgkcoolingtubenumber; i++)   
1425         fcoolingtube[i] = (TGeoVolume*)coolingtubelist->At(i);
1426   /////////////////////////////////////////////////////////////
1427   // SSD Flex  
1428   /////////////////////////////////////////////////////////////
1429   fssdstiffenerflex = GetSSDStiffenerFlex();
1430   fssdendflex = GetSSDEndFlex();
1431   ///////////////////////////////////
1432   // End Ladder Carbon Fiber Junction
1433   ///////////////////////////////////
1434   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1435                                                    fendladdercarbonfiberjunction[i] = 
1436                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1437   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1438     fendladdercarbonfiberjunction[i][0] = 
1439                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]);
1440     fendladdercarbonfiberjunction[i][1] = 
1441                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]);
1442   }
1443   ///////////////////////////////////
1444   // End Ladder Mounting Block
1445   ///////////////////////////////////
1446   fendladdermountingblock = GetSSDMountingBlock();
1447   /////////////////////////////////////////////////////////////
1448   // Deallocating memory
1449   /////////////////////////////////////////////////////////////
1450   delete carbonfibersupportlist;
1451   delete carbonfiberlowersupportlist;
1452   delete ssdhybridcomponentslist;
1453   /////////////////////////////////////////////////////////////
1454   fBasicObjects = kTRUE;
1455 }
1456 /////////////////////////////////////////////////////////////////////////////////
1457 void AliITSv11GeometrySSD::SetSSDSensor(){
1458   ////////////////////////////////////////////////////////////////
1459   // Method generating SSD Sensors: it sets the private variables
1460   // fSSDSensor5, fSSDSensor6  
1461   ////////////////////////////////////////////////////////////////
1462   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1463   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1464   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1465                                                 0.5*ssdsensitivewidth,
1466                                                 0.5*fgkSSDSensorHeight,
1467                                                 0.5*ssdsensitivelength);
1468   TGeoVolume* ssdsensorsensitiveLay5 = 
1469         new TGeoVolume(fgSDDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1470   TGeoVolume* ssdsensorsensitiveLay6 = 
1471         new TGeoVolume(fgSDDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1472   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1473   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1474   TGeoBBox* ssdsensorinsensitiveshape[2];
1475   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1476                                                 0.5*fgkSSDSensorInsensitiveWidth,
1477                                                 0.5*fgkSSDSensorHeight,
1478                                                 0.5*fgkSSDSensorLength);
1479   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1480                                                 0.5*ssdsensitivewidth,
1481                                                 0.5*fgkSSDSensorHeight,
1482                                                 0.5*fgkSSDSensorInsensitiveWidth);
1483   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1484                                              "SSDSensorInsensitive2"};
1485   TGeoVolume* ssdsensorinsensitive[2];
1486   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1487       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1488                      fSSDSensorMedium);
1489       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1490   }
1491   /////////////////////////////////////////////////////////////
1492   // Virtual Volume containing SSD Sensor  
1493   /////////////////////////////////////////////////////////////
1494   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1495                                                                                              0.5*fgkSSDSensorWidth,
1496                                                                                              0.5*fgkSSDSensorHeight,
1497                                                                                              0.5*fgkSSDSensorLength);
1498   fSSDSensor5 = new TGeoVolume("ITSsddSensor5",virtualSSDSensorShape,
1499                                                                                  fSSDAir);      
1500   fSSDSensor6 = new TGeoVolume("ITSsddSensor6",virtualSSDSensorShape,
1501                                                                                  fSSDAir);      
1502   /////////////////////////////////////////////////////////////
1503   for(Int_t i=0; i<4; i++){ 
1504             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1505             ssdsensorinsensitive[1],i<2?1:2,
1506                         new TGeoTranslation(
1507                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1508       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1509                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1510       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1511             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1512             ssdsensorinsensitive[1],i<2?1:2,
1513                         new TGeoTranslation(
1514                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1515       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1516                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1517       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1518   }
1519     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1520     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1521 }
1522 ///////////////////////////////////////////////////////////////////////////////
1523 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1524   /////////////////////////////////////////////////////////////  
1525   // Method generating the Carbon Fiber Support   
1526   /////////////////////////////////////////////////////////////  
1527   const Int_t kvertexnumber = 4;
1528   const Int_t kshapesnumber = 2;
1529   TVector3** vertexposition[kshapesnumber];
1530   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1531   Double_t carbonfibersupportxaxisEdgeproj = 
1532                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1533         *       TMath::DegToRad());
1534   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1535                                  /                         fgkCarbonFiberSupportXAxisLength);
1536   /////////////////////
1537   //Vertex Positioning
1538   ////////////////////
1539   vertexposition[0][0] = new TVector3();
1540   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1541                                                                           fgkCarbonFiberSupportYAxisLength);
1542   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1543                                                                           carbonfibersupportxaxisEdgeproj
1544                                            *                      TMath::Tan(theta));
1545   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1546                                            -                      carbonfibersupportxaxisEdgeproj,
1547                                                                           fgkCarbonFiberSupportYAxisLength
1548                                            -                      vertexposition[0][2]->Y());
1549   ////////////////////////////////////////////////////
1550   //Setting the parameters for Isometry Transformation
1551   ////////////////////////////////////////////////////
1552   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1553                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1554                                                                  +      fgkCarbonFiberSupportWidth);
1555   Double_t* param = new Double_t[4]; 
1556   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1557   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1558                                   new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1559                                                           (GetReflection(vertexposition[0][j],param))->Y());
1560   char* carbonfibersupportshapename[kshapesnumber] = 
1561                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1562   char* carbonfibersupportname[kshapesnumber] = 
1563                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1564   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1565   TGeoVolume* carbonfibersupport[kshapesnumber];
1566   TList* carbonfibersupportlist = new TList();
1567   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1568   Double_t carbonfibersupportheight = 
1569           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1570           *TMath::DegToRad());
1571   for(Int_t i = 0; i< kshapesnumber; i++){
1572    carbonfibersupportshape[i] = 
1573                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1574                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1575    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1576                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1577    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1578    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1579    }
1580   /////////////////////////////////////////////////////////////
1581   // Deallocating memory
1582   /////////////////////////////////////////////////////////////
1583   for(Int_t i=0; i< kshapesnumber; i++){
1584      for(Int_t j=0; j< kvertexnumber; j++)
1585            delete vertexposition[i][j];
1586        delete [] vertexposition[i];
1587   }
1588   delete [] param;
1589   /////////////////////////////////////////////////////////////
1590    return carbonfibersupportlist;
1591 }
1592 /////////////////////////////////////////////////////////////////////////////////
1593 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1594   /////////////////////////////////////////////////////////////
1595   // Method generating SSD Carbon Fiber Junction
1596   /////////////////////////////////////////////////////////////
1597   const Int_t kvertexnumber = 6;
1598   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
1599   Double_t reflectionparam[3] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1600                                                           *  TMath::DegToRad()),-1.,0.};
1601   TVector3* vertex[kvertexnumber];
1602   vertex[0] = new TVector3();
1603   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
1604                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1605                         *                         TMath::DegToRad()),
1606                                                   fgkCarbonFiberJunctionEdge[0]
1607                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
1608                         *                         TMath::DegToRad()));
1609   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
1610                                                    fgkCarbonFiberJunctionEdge[1]);
1611   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
1612   vertex[1] = GetReflection(vertex[5],reflectionparam); 
1613   vertex[2] = GetReflection(vertex[4],reflectionparam); 
1614   Double_t xvertexpoints[6], yvertexpoints[6];
1615   for(Int_t i=0; i<kvertexnumber; i++) 
1616           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
1617   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
1618   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
1619   carbonfiberjunctionshape->DefineSection(1,0.5*width);
1620   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
1621                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
1622   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
1623   /////////////////////////////////////////////////////////////
1624   // Deallocating memory
1625   /////////////////////////////////////////////////////////////
1626   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
1627   ///////////////////////////////////////////////////////////// 
1628   return carbonfiberjunction;
1629 }
1630 ////////////////////////////////////////////////////////////////////////////////
1631 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
1632   /////////////////////////////////////////////////////////////
1633   // Method generating the Carbon Fiber Lower Support   
1634   /////////////////////////////////////////////////////////////  
1635   const Int_t kvertexnumber = 4;
1636   const Int_t kshapesnumber = 2;
1637   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
1638                                                                 fgkCarbonFiberLowerSupportWidth};
1639   TVector3** vertexposition[kshapesnumber];
1640   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
1641                                                  new TVector3*[kvertexnumber];
1642   //First Shape Vertex Positioning
1643   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
1644   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
1645                                            -            fgkCarbonFiberLowerSupportLowerLenght);
1646   vertexposition[0][2] = new TVector3();
1647   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
1648   //Second Shape Vertex Positioning
1649   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
1650                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
1651                                  /                              fgkCarbonFiberTriangleLength);
1652   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
1653                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
1654                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1655   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
1656                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
1657                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1658   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
1659   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
1660                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
1661   char* carbonfiberlowersupportshapename[kshapesnumber] = 
1662                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
1663   char* carbonfiberlowersupportname[kshapesnumber] = 
1664                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
1665   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
1666   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
1667   TList* carbonfiberlowersupportlist = new TList();
1668   for(Int_t i = 0; i< kshapesnumber; i++){ 
1669         carbonfiberlowersupportshape[i] = 
1670                                                                 GetArbShape(vertexposition[i],width,
1671                                                                                         fgkCarbonFiberLowerSupportHeight,
1672                                                                                         carbonfiberlowersupportshapename[i]);
1673     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
1674                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
1675         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
1676     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
1677   }
1678   /////////////////////////////////////////////////////////////
1679   // Deallocating memory
1680   /////////////////////////////////////////////////////////////
1681   for(Int_t i=0; i< kshapesnumber; i++){
1682      for(Int_t j=0; j< kvertexnumber; j++)
1683            delete vertexposition[i][j];
1684        delete [] vertexposition[i];
1685   }
1686   /////////////////////////////////////////////////////////////
1687   return carbonfiberlowersupportlist;
1688 }
1689 ///////////////////////////////////////////////////////////////////////////////
1690 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
1691                                                                  Double_t width, Double_t* thickness)const{
1692   /////////////////////////////////////////////////////////////
1693   // Method generating the Sensor Support   
1694   /////////////////////////////////////////////////////////////  
1695         const Int_t kvertexnumber = 6;
1696         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
1697     TVector3* vertexposition[kvertexnumber];
1698         vertexposition[0] = new TVector3();     
1699         vertexposition[1] = new TVector3(0.0,length);   
1700         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
1701         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
1702         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
1703         vertexposition[5] = new TVector3(vertexposition[4]->X());       
1704         Double_t xvertexpoints[6], yvertexpoints[6];
1705         for(Int_t i=0; i<kvertexnumber; i++) 
1706                 xvertexpoints[i] = vertexposition[i]->X(), 
1707                 yvertexpoints[i] = vertexposition[i]->Y();
1708     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
1709     ssdsensorsupportshape->DefineSection(0,-0.5*width);
1710     ssdsensorsupportshape->DefineSection(1,0.5*width);
1711     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
1712                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
1713   /////////////////////////////////////////////////////////////
1714   // Deallocating memory
1715   /////////////////////////////////////////////////////////////
1716         for (Int_t i=0; i<kvertexnumber; i++)
1717                 delete vertexposition[i];
1718   /////////////////////////////////////////////////////////////
1719     return ssdsensorsupport;
1720 }
1721 ////////////////////////////////////////////////////////////////////////////////
1722 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
1723   /////////////////////////////////////////////////////////////
1724   // Method generating the Cooling Tube Support
1725   /////////////////////////////////////////////////////////////
1726   if(nedges%2!=0) nedges--;     
1727   const Int_t kvertexnumber = nedges+5;
1728   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
1729                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
1730   Double_t angle = 90.+phi;
1731   Double_t psi = 90.-phi;
1732   ///////////////////////////////////////
1733   // Vertex Positioning for TGeoXTru
1734   ///////////////////////////////////////
1735   TVector3** vertexposition = new TVector3*[kvertexnumber];
1736   vertexposition[0] = new TVector3(fgkCoolingTubeSupportRmin*CosD(angle),
1737                                                                    fgkCoolingTubeSupportRmin*SinD(angle));
1738   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
1739                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
1740   vertexposition[2] = new TVector3(vertexposition[1]->X(),
1741                                                                    fgkCoolingTubeSupportRmax);
1742   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
1743                                                                    fgkCoolingTubeSupportRmax);
1744   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
1745                                                                     vertexposition[1]->Y());
1746   for(Int_t i=0; i<nedges; i++)
1747         vertexposition[i+5] = 
1748                 new TVector3(fgkCoolingTubeSupportRmin*CosD(psi+i*(2.*phi/nedges)),
1749                                          fgkCoolingTubeSupportRmin*SinD(psi+i*(2.*phi/nedges)));
1750   ///////////////////////////////////////////////////////////////////////
1751   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
1752   ///////////////////////////////////////////////////////////////////////
1753   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
1754   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
1755   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
1756   for(Int_t i=0; i<kvertexnumber; i++){
1757         xvertexpoints[i] = vertexposition[i]->X();
1758         yvertexpoints[i] = vertexposition[i]->Y();
1759   } 
1760   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
1761                                                                                         yvertexpoints);
1762   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
1763   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
1764   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
1765                                                                           coolingtubesupportarcshape,
1766                                                                                   fSSDTubeHolderMedium);
1767   coolingtubesupportarc->SetLineColor(fColorG10);
1768   //////////////////////////////////////////////////////////////////////////
1769   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
1770   //////////////////////////////////////////////////////////////////////////
1771   TGeoTubeSeg* coolingtubesupportsegshape = 
1772                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
1773                                                                                         fgkCoolingTubeSupportRmax,
1774                                                                                         0.5*fgkCoolingTubeSupportWidth,
1775                                                                                         phi,360-phi);
1776   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
1777                                                                                         coolingtubesupportsegshape,
1778                                                                                         fSSDTubeHolderMedium);
1779   coolingtubesupportseg->SetLineColor(fColorG10);
1780   //////////////////////////////////////////////////////////////////////////
1781   // TGeoBBox Volume definition for Cooling Tube Support Box Part
1782   //////////////////////////////////////////////////////////////////////////
1783   Double_t* boxorigin = new Double_t[3];
1784   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
1785   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
1786   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
1787                                                                                  0.5*fgkCoolingTubeSupportHeight,
1788                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
1789   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
1790                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
1791   coolingtubesupportbox->SetLineColor(fColorG10);
1792   //////////////////////////////////////////////////////////////////////////
1793   // Cooling Tube for Cooling Tube Support 
1794   //////////////////////////////////////////////////////////////////////////
1795   TGeoXtru* coolingtubearcshape[2];
1796   coolingtubearcshape[0] = new TGeoXtru(2);     
1797   Double_t* xvert = new Double_t[nedges+2];
1798   Double_t* yvert = new Double_t[nedges+2];
1799   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
1800   ////////////////////////////////////////
1801   // Positioning the vertices for TGeoXTru
1802   ////////////////////////////////////////
1803   xvert[0] = 0., yvert[0] = 0.;
1804   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
1805   for(Int_t i=0; i< nedges; i++)
1806                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
1807                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
1808   ////////////////////////////////////////
1809   // Defining TGeoXTru PolyGone
1810   ////////////////////////////////////////
1811   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
1812   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
1813   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
1814   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
1815                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
1816   TGeoVolume* coolingtubearc[2];
1817   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
1818                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
1819   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
1820                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
1821   coolingtubearc[0]->SetLineColor(fColorWater);
1822   coolingtubearc[1]->SetLineColor(fColorPhynox);
1823   ////////////////////////////////////////////
1824   // Defining TGeoTubeSeg Part of Cooling Tube
1825   ////////////////////////////////////////////
1826   TGeoTubeSeg* coolingtubesegshape[2];
1827   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
1828                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
1829   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
1830                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
1831   TGeoVolume* coolingtubeseg[2];
1832   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
1833                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
1834   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
1835                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
1836   coolingtubeseg[0]->SetLineColor(fColorPhynox);
1837   coolingtubeseg[1]->SetLineColor(fColorWater);
1838   /////////////////////////////////////////////////////////////
1839   // Virtual Volume containing Cooling Tube Support  
1840   /////////////////////////////////////////////////////////////
1841   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
1842   const Int_t kvirtualvertexnumber = 8;
1843   TVector3* virtualvertex[kvirtualvertexnumber];
1844    ////////////////////////////////////////
1845   // Positioning the vertices for TGeoXTru
1846   ////////////////////////////////////////
1847   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
1848   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
1849   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
1850   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
1851   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
1852   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
1853   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
1854   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
1855   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
1856   for(Int_t i=0; i< kvirtualvertexnumber; i++)
1857         xmothervertex[i] = virtualvertex[i]->X(),
1858         ymothervertex[i] = virtualvertex[i]->Y();
1859   ////////////////////////////////////////
1860   // Defining TGeoXTru PolyGone
1861   ////////////////////////////////////////
1862   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
1863                                                                                                                                          ymothervertex);
1864   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
1865   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
1866   TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
1867                                                                  virtualCoolingTubeSupportShape,fSSDAir);
1868   ////////////////////////////////////////
1869   // Positioning Volumes in Virtual Volume
1870   ////////////////////////////////////////
1871   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
1872   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
1873   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
1874   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
1875   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
1876   virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
1877   virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
1878   virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
1879   virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
1880   /////////////////////////////////////////////////////////////
1881   // Deallocating memory
1882   /////////////////////////////////////////////////////////////
1883   delete [] vertexposition;
1884   delete xvertexpoints;
1885   delete yvertexpoints;
1886   delete xvert;
1887   delete yvert;
1888   for(Int_t i=0; i< kvirtualvertexnumber; i++)
1889         delete virtualvertex[i];
1890   /////////////////////////////////////////////////////////////
1891         return virtualcoolingtubesupport;
1892 }
1893 /////////////////////////////////////////////////////////////////////////////////
1894 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
1895   /////////////////////////////////////////////////////////////
1896   // Method generating List containing SSD Hybrid Components   
1897   /////////////////////////////////////////////////////////////
1898   TList* ssdhybridlist = new TList();
1899   const Int_t kssdstiffenernumber = 2;
1900   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1901                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1902                                                                   -    fgkSSDStiffenerWidth;
1903   Double_t ssdchipcablesradius[kssdstiffenernumber];
1904   for(Int_t i=0; i<kssdstiffenernumber; i++)
1905           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
1906                                -  fgkSSDChipCablesHeight[0]
1907                                -  fgkSSDChipCablesHeight[1]);
1908   /////////////////////////////////////////////////////////////
1909   // Mother Volumes Containers 
1910   /////////////////////////////////////////////////////////////
1911   const Int_t kmothernumber = 2;
1912   const Int_t kmothervertexnumber = 12;
1913   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
1914   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
1915   ///////////////////////
1916   // Setting the vertices 
1917   ///////////////////////
1918   xmothervertex[0][0]  = -0.5*fgkSSDStiffenerLength;
1919   xmothervertex[0][1]  = xmothervertex[0][0]; 
1920   xmothervertex[0][2]  = fgkSSDFlexLength[0]-0.5*fgkSSDStiffenerLength;
1921   xmothervertex[0][3]  = xmothervertex[0][2];
1922   xmothervertex[0][4]  = xmothervertex[0][0];
1923   xmothervertex[0][5]  = xmothervertex[0][4];
1924   xmothervertex[0][6]  = -xmothervertex[0][0];
1925   xmothervertex[0][7]  = xmothervertex[0][6];
1926   xmothervertex[0][8]  = -xmothervertex[0][2];
1927   xmothervertex[0][9]  = xmothervertex[0][8];
1928   xmothervertex[0][10] = xmothervertex[0][7];
1929   xmothervertex[0][11] = xmothervertex[0][10];
1930   for(Int_t i=0; i<kmothervertexnumber; i++) xmothervertex[1][i] = xmothervertex[0][i];
1931   for(Int_t i = 0; i<kmothernumber; i++){
1932       ymothervertex[i][0]  = -(fgkSSDChipWidth-(0.5*fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist)
1933                            + ssdchipcablesradius[i]+fgkSSDChipCablesWidth[1]+fgkSSDChipCablesWidth[2]);
1934       ymothervertex[i][1]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexWidth[0];
1935       ymothervertex[i][2]  = ymothervertex[i][1];
1936       ymothervertex[i][3]  = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth;
1937       ymothervertex[i][4]  = ymothervertex[i][3];
1938       ymothervertex[i][5]  = ymothervertex[i][4]+0.5*fgkSSDStiffenerWidth-ymothervertex[i][0];
1939       ymothervertex[i][6]  = ymothervertex[i][5];
1940       ymothervertex[i][7]  = 0.5*fgkSSDStiffenerWidth+fgkSSDFlexWidth[0];
1941       ymothervertex[i][8]  = ymothervertex[i][7];
1942       ymothervertex[i][9]  = 0.5*fgkSSDStiffenerWidth;
1943       ymothervertex[i][10] = ymothervertex[i][9];
1944       ymothervertex[i][11] = ymothervertex[i][0];
1945   }
1946   TGeoXtru* ssdhybridmothershape[kmothernumber];
1947   TGeoVolume* ssdhybridmother[kmothernumber];
1948   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
1949   for(Int_t i=0; i<kmothernumber; i++){
1950       ssdhybridmothershape[i] = new TGeoXtru(2);
1951       ssdhybridmothershape[i]->DefinePolygon(kmothervertexnumber,xmothervertex[i],
1952                                           ymothervertex[i]);
1953       ssdhybridmothershape[i]->DefineSection(0,-0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
1954                                                -fgkSSDChipCablesHeight[i+2]);
1955       ssdhybridmothershape[i]->DefineSection(1, 0.5*fgkSSDStiffenerHeight);
1956       ssdhybridmother[i] = new TGeoVolume(ssdhybridmothername[i],ssdhybridmothershape[i],
1957                                           fSSDAir);
1958    }   
1959   /////////////////////////////////////////////////////////////
1960   // SSD Stiffener   
1961   /////////////////////////////////////////////////////////////
1962   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
1963                                              0.5*fgkSSDStiffenerLength,
1964                                              0.5*fgkSSDStiffenerWidth,
1965                                              0.5*fgkSSDStiffenerHeight);
1966   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
1967                                             fSSDStiffenerMedium);  
1968   ssdstiffener->SetLineColor(fColorStiffener); 
1969   TGeoTranslation* ssdstiffenertrans[kssdstiffenernumber];
1970   for(Int_t i=0; i<kssdstiffenernumber; i++) 
1971       ssdstiffenertrans[i] = new TGeoTranslation(0.,i*ssdstiffenerseparation,0.);
1972   /////////////////////////////////////////////////////////////
1973   // SSD Chip System    
1974   /////////////////////////////////////////////////////////////
1975   TList* ssdchipsystemlist = GetSSDChipSystem(); 
1976   Double_t ssdchipseparation = fgkSSDSensorLength
1977                              - 2.*fgkSSDModuleStiffenerPosition[1]
1978                              - 2.*(fgkSSDStiffenerWidth-fgkSSDStiffenerToChipDist
1979                              - 0.5*fgkSSDChipWidth);
1980   Double_t ssdchipsystemlength = (fgkSSDChipNumber-1)*(fgkSSDChipLength 
1981                                +  fgkSSDChipSeparationLength)+fgkSSDChipCablesLength[1];
1982   TGeoTranslation* ssdchipsystemtrans = new TGeoTranslation(0.5*fgkSSDChipCablesLength[1]
1983                                       - 0.5*ssdchipsystemlength,
1984                                         0.5*(ssdstiffenerseparation-ssdchipseparation),
1985                                       - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight));  
1986 ////////////////////////////
1987 // Capacitor 0603-2200 nF
1988 ///////////////////////////
1989   const Int_t knapacitor0603number = 5;
1990   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
1991                                                                                          0.5*fgkSSDCapacitor0603Length,
1992                                                                                          0.5*fgkSSDCapacitor0603Width,
1993                                                                                          0.5*fgkSSDCapacitor0603Height);
1994   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
1995                                              fSSDStiffener0603CapacitorMedium); 
1996   capacitor0603->SetLineColor(fColorAl);
1997   for(Int_t i=0; i<kmothernumber; i++){
1998       for(Int_t j=0; j<kssdstiffenernumber; j++){
1999             ssdhybridmother[i]->AddNode(ssdstiffener,j+1,ssdstiffenertrans[j]);
2000             for(Int_t k=1; k<knapacitor0603number+1; k++){
2001                   ssdhybridmother[i]->AddNode(capacitor0603,knapacitor0603number*j+k,
2002                         new TGeoTranslation((k-3.)/6*fgkSSDStiffenerLength,
2003                                              j*ssdstiffenerseparation
2004                         +                    0.5*((j==0? 1:-1)*fgkSSDStiffenerWidth
2005                         +                    (j==0? -1:+1)*fgkSSDCapacitor0603Width),
2006                         -                    0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height)));
2007             }
2008       } 
2009       ssdhybridmother[i]->AddNode((TGeoVolume*)ssdchipsystemlist->At(i),i+1,ssdchipsystemtrans);
2010       ssdhybridlist->Add(ssdhybridmother[i]);
2011   }    
2012 /////////////////////////////////////////////////////////////
2013 // Mother Volume Containing Capacitor Part 
2014 /////////////////////////////////////////////////////////////
2015   const Int_t kcapacitormothernumber = 8;
2016   Double_t xcapacitorvertex[kcapacitormothernumber];
2017   Double_t ycapacitorvertex[kcapacitormothernumber];  
2018   ///////////////////////
2019   // Setting the vertices 
2020   ///////////////////////
2021   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2022   xcapacitorvertex[1] = xcapacitorvertex[0];   
2023   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2024   xcapacitorvertex[3] = xcapacitorvertex[2];   
2025   xcapacitorvertex[4] = xcapacitorvertex[0];   
2026   xcapacitorvertex[5] = xcapacitorvertex[0];   
2027   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2028   xcapacitorvertex[7] = xcapacitorvertex[6];   
2029   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2030   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2031   ycapacitorvertex[2] = ycapacitorvertex[1];   
2032   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2033   ycapacitorvertex[4] = ycapacitorvertex[3];   
2034   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2035   ycapacitorvertex[6] = ycapacitorvertex[5];   
2036   ycapacitorvertex[7] = ycapacitorvertex[0];   
2037   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2038   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2039                                               ycapacitorvertex);
2040   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2041   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2042   TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2043                                           fSSDAir);
2044 ////////////////////////////
2045 // Connector 
2046 ///////////////////////////
2047   const Int_t kssdconnectornumber = 2;
2048   TGeoBBox* ssdconnectorshape[kssdconnectornumber];
2049   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2050   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2051                                    +  fgkSSDConnectorAlHeight};  
2052   const char* ssdconnectorname[kssdconnectornumber] = {"SSDConnectorAl","SSDConnectorNi"};
2053   TGeoVolume* ssdconnector[kssdconnectornumber];
2054   for(Int_t i=0; i<kssdconnectornumber; i++){
2055       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2056                                           0.5*fgkSSDConnectorWidth,
2057                                           0.5*((1-i)*fgkSSDConnectorAlHeight
2058                            +              i*fgkSSDConnectorNiHeight),
2059                              i==0? ssdAlconnectororigin : ssdNiconnectororigin);
2060       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2061                                        i==0 ? fSSDAlTraceFlexMedium 
2062                                             : fSSDStiffenerConnectorMedium);      
2063       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorPhynox);
2064   }
2065   TGeoTranslation* ssdconnectortrans[2*kssdconnectornumber];
2066   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2067                        +  fgkSSDConnectorPosition[0]
2068                        -  fgkSSDConnectorSeparation
2069                        -  1.5*fgkSSDConnectorLength,
2070                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2071                        -  fgkSSDConnectorPosition[1]
2072                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2073   ssdconnectortrans[1] = new TGeoTranslation(
2074                        -  ssdstiffenershape->GetDX()
2075                        +  fgkSSDConnectorPosition[0]
2076                        -  0.5*fgkSSDConnectorLength,
2077                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2078                        -  fgkSSDConnectorPosition[1]
2079                        -  ssdconnectorshape[0]->GetDY(),0.0);
2080   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2081                        -  fgkSSDConnectorPosition[0]
2082                        +  fgkSSDConnectorSeparation
2083                        +  1.5*fgkSSDConnectorLength,
2084                           -(ssdstiffenershape->GetDY()
2085                        -  fgkSSDConnectorPosition[1]
2086                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2087   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2088                        -  fgkSSDConnectorPosition[0]
2089                        +  0.5*fgkSSDConnectorLength,
2090                           -(ssdstiffenershape->GetDY()
2091                        -  fgkSSDConnectorPosition[1]
2092                        -  ssdconnectorshape[0]->GetDY()),0.0);
2093   for(Int_t i=0; i<2*kssdconnectornumber; i++)
2094       for(Int_t j=0; j<kssdconnectornumber; j++)
2095             ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2096 ////////////////////////////
2097 // Capacitor 1812-330 nF
2098 /////////////////////////// 
2099   Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2100   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2101                                                                                          0.5*fgkSSDCapacitor1812Length,
2102                                                                                          0.5*fgkSSDCapacitor1812Width,
2103                                                                                          0.5*fgkSSDCapacitor1812Height,
2104             ssdcapacitor1812origin);
2105   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2106                                              fSSDStiffener1812CapacitorMedium); 
2107   capacitor1812->SetLineColor(fColorAl);
2108   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2109                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2110                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.0);
2111   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2112 ////////////////////////////
2113 //Hybrid Wire
2114 ////////////////////////////
2115   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2116                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2117                                  - fgkSSDConnectorSeparation;
2118   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2119                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2120   Double_t ssdwireradius = TMath::Sqrt(TMath::Power(wirex,2.)
2121                                          + TMath::Power(wirey,2));
2122   Double_t wireangle = TMath::ATan(wirex/wirey);
2123   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2124                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2125   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2126                                              fSSDStiffenerHybridWireMedium); 
2127   hybridwire->SetLineColor(fColorPhynox);
2128   TGeoCombiTrans* hybridwirecombitrans[2];
2129   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2130                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2131                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2132                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2133                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2134                                    ssdstiffenershape->GetDZ()
2135                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight,
2136                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2137   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2138                             0.0,
2139                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2140                             0.0,        
2141                             new TGeoRotation("HybridWireRot2",
2142                           - wireangle*TMath::RadToDeg(),0.,0.));
2143   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2144   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2145   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2146   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2147   ssdhybridlist->Add(ssdhybridcapacitormother);
2148   /////////////////////////////////////////////////////////////
2149   // Deallocating memory
2150   /////////////////////////////////////////////////////////////
2151   delete hybridwirecombitrans[0];
2152   delete hybridwirecombitrans[1];
2153   delete ssdchipsystemlist;
2154   return ssdhybridlist;
2155   /////////////////////////////////////////////////////////////
2156 }
2157 ///////////////////////////////////////////////////////////////////////////////
2158 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2159   /////////////////////////////////////////////////////////////
2160   // SSD Cooling Block System
2161   /////////////////////////////////////////////////////////////
2162   // SSD Cooling Block and Cooling Tube Transformations
2163   /////////////////////////////////////////////////////////////
2164   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2165   localcoolingblockrot->SetAngles(0.,90.,0.);
2166   TGeoCombiTrans* localcoolingblockmatrix = 
2167         new TGeoCombiTrans(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2168   TGeoTranslation* localcoolingblocktrans;  
2169   TVector3* coolingblocktransvector;
2170   coolingblocktransvector = new TVector3(fgkSSDModuleSensorSupportDistance
2171                                                                 + fgkSSDCoolingBlockLength,
2172                                                                   fgkSSDSensorLength
2173                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2174                                                                 - fgkSSDCoolingBlockWidth);
2175   const Int_t kcoolingblocktransnumber = 2;
2176   const Int_t kcoolingblocknumber = 4;
2177   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2178   TGeoHMatrix* coolingtubematrix[kcoolingblocknumber];
2179   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2180   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2181   TGeoTranslation* localcoolingtubetrans = new TGeoTranslation();
2182   localcoolingtubetrans->SetTranslation(0.5*fgkSSDCoolingBlockLength,
2183                                                                                 0.5*fgkSSDCoolingBlockWidth,
2184                                                                                         fgkSSDCoolingBlockHoleCenter);
2185   TGeoCombiTrans* localcoolingtubematrix = new TGeoCombiTrans(*localcoolingtubetrans,
2186                                                                                                                           *localcoolingtuberot);
2187   Double_t coolingtubedistance = fgkCoolingTubeSupportRmax-fgkCoolingTubeSupportRmin;
2188   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2189           for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2190                 localcoolingblocktrans= 
2191                      new TGeoTranslation(i*coolingblocktransvector->X()+2*coolingtubedistance,
2192                                                                  j*coolingblocktransvector->Y(),
2193                                                                  - 0.5*(fgkSSDCoolingBlockHoleCenter
2194                                                              + fgkCoolingTubeRmax));
2195                 coolingblockmatrix[2*i+j] = new TGeoHMatrix((*localcoolingblocktrans)
2196                                                                  *(*localcoolingblockmatrix));
2197                 coolingtubematrix[2*i+j] = new TGeoHMatrix((*localcoolingblocktrans)
2198                                                                  *(*localcoolingtubematrix));
2199         }
2200   }
2201   /////////////////////////////////////////////////////////////
2202   // Virtual Volume containing CoolingBlock System   
2203   /////////////////////////////////////////////////////////////
2204   TGeoXtru* coolingsystemothershape = new TGeoXtru(2);
2205   const Int_t kmothervertexnumber = 16;  
2206   Double_t xmothervertex[kmothervertexnumber];
2207   Double_t ymothervertex[kmothervertexnumber];
2208   ///////////////////////
2209   // Setting the vertices 
2210   ///////////////////////fgkCoolingTubeSupportRmax
2211   xmothervertex[0] = 0.0,ymothervertex[0] = 0.0;
2212   xmothervertex[1] = xmothervertex[0], ymothervertex[1] = coolingblocktransvector->Y()
2213                                    + fgkSSDCoolingBlockWidth;
2214   xmothervertex[2] = coolingblocktransvector->X()
2215                                    + fgkSSDCoolingBlockLength
2216                                    + 4*coolingtubedistance;
2217   ymothervertex[2] = ymothervertex[1];
2218   xmothervertex[3] = xmothervertex[2], ymothervertex[3] = ymothervertex[0];
2219   xmothervertex[4] = xmothervertex[3]-2.*coolingtubedistance-fgkSSDCoolingBlockLength;
2220   ymothervertex[4] = ymothervertex[0];
2221   xmothervertex[5] = xmothervertex[4], ymothervertex[5] = fgkSSDCoolingBlockWidth;
2222   xmothervertex[6] = xmothervertex[3]-coolingtubedistance; 
2223   ymothervertex[6] = ymothervertex[5]; 
2224   xmothervertex[7] = xmothervertex[6], ymothervertex[7] = ymothervertex[2]
2225                                    - fgkSSDCoolingBlockWidth; 
2226   xmothervertex[8] = xmothervertex[5], ymothervertex[8] = ymothervertex[7];
2227   xmothervertex[9] = xmothervertex[8], ymothervertex[9] = ymothervertex[2]
2228                                    - coolingtubedistance;
2229   xmothervertex[10] = fgkSSDCoolingBlockLength+2.*coolingtubedistance;
2230   ymothervertex[10] = ymothervertex[9];
2231   xmothervertex[11] = xmothervertex[10], ymothervertex[11] = ymothervertex[8];
2232   xmothervertex[12] = coolingtubedistance, ymothervertex[12] = ymothervertex[11];
2233   xmothervertex[13] = xmothervertex[12], ymothervertex[13] = fgkSSDCoolingBlockWidth;
2234   xmothervertex[14] = 2.*coolingtubedistance+fgkSSDCoolingBlockLength;
2235   ymothervertex[14] = ymothervertex[13];
2236   xmothervertex[15] = xmothervertex[14], ymothervertex[15] = ymothervertex[0];
2237   //////////////////////////////////////////////////////////
2238   coolingsystemothershape->DefinePolygon(kmothervertexnumber,
2239                                                                         xmothervertex,ymothervertex);
2240   coolingsystemothershape->DefineSection(0,-0.5*(fgkSSDCoolingBlockHoleCenter
2241                                                                                            + fgkCoolingTubeRmax));
2242   coolingsystemothershape->DefineSection(1, 0.5*(fgkSSDCoolingBlockHoleCenter
2243                                                                                            + fgkCoolingTubeRmax));
2244   TGeoVolume* coolingsystemother = new TGeoVolume("CoolingBlockSystem",
2245                                                           coolingsystemothershape,fSSDAir);
2246   /////////////////////////////////////////////////////////////
2247   // SSD Cooling Tube Part 
2248   /////////////////////////////////////////////////////////////
2249   TGeoTube* coolingtubeshape[fgkcoolingtubenumber];
2250   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2251                                                                                  0.5*fgkSSDCoolingBlockWidth); 
2252   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
2253                                                                          0.5*fgkSSDCoolingBlockWidth);
2254   TGeoVolume* coolingtube[fgkcoolingtubenumber];
2255   coolingtube[0] = new TGeoVolume("OuterCoolingTube",coolingtubeshape[0],
2256                                                                         fSSDCoolingTubePhynox);
2257   coolingtube[1] = new TGeoVolume("InnerCoolingTube",coolingtubeshape[1],
2258                                                                         fSSDCoolingTubeWater);
2259   coolingtube[0]->SetLineColor(fColorPhynox);
2260   coolingtube[1]->SetLineColor(fColorWater);
2261   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2262   /////////////////////////////////////////////////////////////
2263   // Adding Cooling block to mother volume
2264   /////////////////////////////////////////////////////////////
2265    for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2266         coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2267         coolingsystemother->AddNode(coolingtube[0],i+1,coolingtubematrix[i]);
2268         coolingsystemother->AddNode(coolingtube[1],i+1,coolingtubematrix[i]);
2269   }
2270   /////////////////////////////////////////////////////////////
2271   // Deallocating memory
2272   /////////////////////////////////////////////////////////////
2273         delete coolingblocktransvector;
2274     delete localcoolingblocktrans;
2275         delete localcoolingblockrot;
2276         delete localcoolingblockmatrix;
2277         delete localcoolingtubetrans;
2278         delete localcoolingtuberot;
2279   /////////////////////////////////////////////////////////////
2280   // Checking overlaps  
2281   /////////////////////////////////////////////////////////////
2282         //coolingsystemother->CheckOverlaps(0.01);
2283   /////////////////////////////////////////////////////////////
2284         return coolingsystemother;
2285 }
2286 /////////////////////////////////////////////////////////////////////////////////
2287 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2288   /////////////////////////////////////////////////////////////
2289   // SSD Flex
2290   /////////////////////////////////////////////////////////////
2291   const Int_t kssdflexlayernumber = 2;
2292   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2293   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2294   const Int_t kmothervertexnumber = 17; 
2295   Double_t xmothervertex[kmothervertexnumber];
2296   Double_t ymothervertex[kmothervertexnumber];
2297   /////////////////////////////////////////////
2298   // Auxiliary variables for vertex positioning
2299   /////////////////////////////////////////////
2300   const Int_t kssdflexboxnumber = 5;
2301   Double_t ssdflexboxlength[kssdflexboxnumber];
2302   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
2303                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
2304                                           *     fgkSSDChipSeparationLength
2305                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
2306                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
2307   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
2308   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
2309                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
2310   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
2311   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
2312                                           -     ssdflexboxlength[1];
2313   Double_t ssdflexboxwidth[kssdflexboxnumber];
2314   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
2315   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
2316   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
2317   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
2318   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
2319   ///////////////////////
2320   // Setting the vertices 
2321   ///////////////////////
2322   xmothervertex[0]  = 0.0;
2323   xmothervertex[1]  = xmothervertex[0];
2324   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
2325   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
2326                                         + ssdflexboxlength[4];
2327   xmothervertex[4]  = xmothervertex[3];
2328   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
2329   xmothervertex[6]  = xmothervertex[5];
2330   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
2331   xmothervertex[8]  = xmothervertex[7];
2332   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
2333   xmothervertex[10] = xmothervertex[9]; 
2334   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
2335   xmothervertex[12] = xmothervertex[11];
2336   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
2337   xmothervertex[14] = xmothervertex[13];
2338   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
2339   xmothervertex[16] = xmothervertex[15];
2340   ymothervertex[0]  = 0.0;
2341   ymothervertex[1]  = fgkSSDFlexWidth[1];
2342   ymothervertex[2]  = fgkSSDFlexWidth[0];
2343   ymothervertex[3]  = ymothervertex[2];
2344   ymothervertex[4]  = ymothervertex[0];
2345   ymothervertex[5]  = ymothervertex[4];
2346   ymothervertex[6]  = ssdflexboxwidth[2];
2347   ymothervertex[7]  = ymothervertex[6];
2348   ymothervertex[8]  = ymothervertex[0];
2349   ymothervertex[9]  = ymothervertex[8];
2350   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
2351   ymothervertex[11] = ymothervertex[10];
2352   ymothervertex[12] = ymothervertex[0];
2353   ymothervertex[13] = ymothervertex[12];
2354   ymothervertex[14] = ymothervertex[7];
2355   ymothervertex[15] = ymothervertex[14];
2356   ymothervertex[16] = ymothervertex[0];
2357   /////////////////////////////////////////////////////////////
2358   // First Mother Volume containing SSDFlex
2359   /////////////////////////////////////////////////////////////
2360   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
2361   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
2362                                                                     ymothervertex);
2363   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
2364   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
2365   TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
2366                                                                                          fSSDAir);
2367   /////////////////////////////////////////////////////////////
2368   // SSDFlex Layer Shapes
2369   /////////////////////////////////////////////////////////////
2370   for(Int_t i=0; i<kssdflexlayernumber; i++){
2371         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
2372                                                                    ymothervertex);
2373     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
2374         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
2375   }
2376   /////////////////////////////////////
2377   // Setting Layers into Mother Volume
2378   /////////////////////////////////////
2379   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
2380   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
2381                                                                                                  fSSDKaptonFlexMedium};
2382   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
2383                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
2384   TGeoVolume* ssdflex[2*kssdflexlayernumber];
2385   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
2386   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
2387         ssdflex[i] = new TGeoVolume(ssdflexname[i],
2388                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
2389                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
2390         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
2391     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
2392                                          +                                         fgkSSDFlexHeight[1])); 
2393     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
2394   }
2395   //ssdflexmother->CheckOverlaps(0.01);
2396   return ssdflexmother;
2397 }
2398 /////////////////////////////////////////////////////////////////////////////////
2399 TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
2400   /////////////////////////////////////////////////////////////
2401   // Method generating SSD End Flex   
2402   /////////////////////////////////////////
2403   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
2404                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
2405   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
2406                                                 * TMath::DegToRad()*ssdflexradiusmax
2407                                                 - fgkSSDFlexLength[2]-TMath::Pi()
2408                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0];
2409   const Int_t knedges = 20;  
2410   const Int_t karcnumber = 2;
2411   TVector3* vertexposition[karcnumber*(knedges+1)];
2412   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
2413   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
2414   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
2415   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
2416                                                                                  - 90.0*TMath::DegToRad()};
2417   TVector3* referencetrans[karcnumber];
2418   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
2419                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
2420                                                                    radius[0]);
2421   referencetrans[1] = new TVector3(referencetrans[0]->X()
2422                                         +              fgkSSDFlexLength[2],
2423      -              fgkSSDStiffenerHeight);
2424 for(Int_t i=0; i<karcnumber; i++){
2425         for(Int_t j=0; j<knedges+1; j++){
2426                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
2427                                                                                                radius[i]*SinD(angle[i]));
2428                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
2429         }       
2430   }
2431   ///////////////////////
2432   // Setting the vertices 
2433   ///////////////////////
2434   const Int_t kendflexlayernumber = 4;
2435   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
2436   TVector3** vertex[kendflexlayernumber];
2437   for(Int_t i=0; i<kendflexlayernumber; i++) 
2438                                         vertex[i] = new TVector3*[kendflexvertexnumber];
2439   TVector3* transvector[kendflexlayernumber+1];
2440   TVector3* deltatransvector = new TVector3();  
2441   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3(); 
2442   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
2443                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
2444   for(Int_t i=1; i<kendflexlayernumber+1; i++){         
2445         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2446                                         *                 CosD(fgkSSDFlexAngle),
2447                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2448                                         *         SinD(fgkSSDFlexAngle),0.0);   
2449         *transvector[i] = *transvector[i-1]+*deltatransvector;
2450   }
2451   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
2452   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
2453   for(Int_t i=0; i<karcnumber; i++){
2454         for(Int_t j=1; j<kendflexlayernumber+1; j++){
2455                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
2456                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
2457                                               /radius[i];
2458         }
2459   }
2460   for(Int_t i=0; i<kendflexlayernumber; i++){
2461         vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y());
2462         vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y());
2463         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
2464                 if(j<(knedges+1)){
2465                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
2466                                                                                   vertexposition[j]->Y()*ratioradius[0][i+1]);
2467                         vertex[i][j+2]->RotateZ(referenceangle[0]);
2468                         *vertex[i][j+2] += *referencetrans[0];
2469                         vertex[i][4*(knedges+1)-j+1] = 
2470                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
2471                                                                                   vertexposition[j]->Y()*ratioradius[0][i]);
2472                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
2473                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
2474                 }
2475                 else{
2476                 
2477                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
2478                                                                                   vertexposition[j]->Y()*ratioradius[1][i+1]);
2479                         vertex[i][j+2]->RotateZ(referenceangle[1]);
2480                         *vertex[i][j+2] += *referencetrans[1];
2481                         vertex[i][4*(knedges+1)-j+1] = 
2482                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
2483                                                                                   vertexposition[j]->Y()*ratioradius[1][i]);
2484                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
2485                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
2486            }
2487         }
2488   }
2489   /////////////////////////////////////////////////////////////
2490   // First Mother Volume containing SSDEndFlex
2491   /////////////////////////////////////////////////////////////
2492   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
2493   Double_t xmothervertex[kendflexvertexnumber];
2494   Double_t ymothervertex[kendflexvertexnumber];
2495   xmothervertex[0] = vertex[0][0]->X(); 
2496   ymothervertex[0] = vertex[0][0]->Y();
2497   for(Int_t i=1; i<kendflexvertexnumber; i++){
2498         if(i<2*(knedges+1)+2){
2499                 xmothervertex[i] = vertex[3][i]->X();
2500                 ymothervertex[i] = vertex[3][i]->Y();
2501         }
2502         else{
2503                 xmothervertex[i] = vertex[0][i]->X();
2504                 ymothervertex[i] = vertex[0][i]->Y();
2505         }
2506   }
2507   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
2508                                                                            xmothervertex,ymothervertex);
2509   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2510   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2511   TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
2512                                                                  ssdendflexmothershape,fSSDAir);        
2513   //////////////////////////////////////
2514   // End Flex TGeoXtru Layer Definition 
2515   //////////////////////////////////////
2516   TGeoXtru* ssdendflexshape[kendflexlayernumber];
2517   TGeoVolume* ssdendflex[kendflexlayernumber];
2518   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
2519   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
2520   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
2521   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
2522   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
2523                                                                                                         fSSDKaptonFlexMedium};
2524   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
2525                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
2526   for(Int_t i=0; i<kendflexlayernumber; i++){
2527         for(Int_t j=0; j<4*(knedges+1)+2; j++){
2528                 xvertex[i][j] = vertex[i][j]->X();
2529                 yvertex[i][j] = vertex[i][j]->Y();
2530         }
2531   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
2532   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
2533   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
2534   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
2535                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
2536   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
2537   ssdendflexmother->AddNode(ssdendflex[i],1);
2538   }
2539   /////////////////////////////////////////////////////////////
2540   // Deallocating memory
2541   /////////////////////////////////////////////////////////////
2542   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
2543   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
2544   for(Int_t i=0; i<kendflexlayernumber; i++){
2545         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
2546         delete [] vertex[i];
2547   }
2548   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];   
2549   delete deltatransvector;
2550   /////////////////////////////////////////////////////////////
2551   //ssdendflexmother->CheckOverlaps(0.01);
2552   return ssdendflexmother;
2553 }
2554 ////////////////////////////////////////////////////////////////////////////////
2555 TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
2556   /////////////////////////////////////////////////////////////
2557   // Method generating the Mounting Block   
2558   /////////////////////////////////////////////////////////////  
2559   // Mounting Block Boxes Shapes
2560   ///////////////////////////////////////
2561   const Int_t kmountingblockboxnumber = 3;
2562   TGeoBBox* mountingblockboxshape[kmountingblockboxnumber];
2563   mountingblockboxshape[0] = new TGeoBBox("MountingBlockBoxShape0",
2564                                                         0.25*(fgkSSDMountingBlockLength[0]
2565                                                 -       fgkSSDMountingBlockLength[1]),
2566                                                         0.5*fgkSSDMountingBlockWidth,
2567                                                         0.5*fgkSSDMountingBlockHeight[0]);
2568   mountingblockboxshape[1] = new TGeoBBox("MountingBlockBoxShape1",
2569                                                         0.25*(fgkSSDMountingBlockLength[1]
2570                                                 -       fgkSSDMountingBlockLength[2]),
2571                                                         0.5*fgkSSDMountingBlockWidth,
2572                                                         0.5*(fgkSSDMountingBlockHeight[1]
2573                                                 -       fgkSSDMountingBlockHeight[3]));
2574   mountingblockboxshape[2] = new TGeoBBox("MountingBlockBoxShape2",
2575                                                         0.5*fgkSSDMountingBlockLength[2],
2576                                                         0.5*fgkSSDMountingBlockWidth,
2577                                                         0.5*(fgkSSDMountingBlockHeight[2]
2578                                                 -       fgkSSDMountingBlockHeight[3]));
2579   TGeoTranslation* mountingblockboxtrans[kmountingblockboxnumber+2];
2580   mountingblockboxtrans[0] = new TGeoTranslation("MountingBlockBoxTrans0",0.,0.,0.);
2581   mountingblockboxtrans[1] = new TGeoTranslation("MountingBlockBoxTrans1",
2582                                                         mountingblockboxshape[0]->GetDX()
2583                                                 +       mountingblockboxshape[1]->GetDX(),
2584                                                         0.0,
2585                                                         mountingblockboxshape[1]->GetDZ()
2586                                                 -       mountingblockboxshape[0]->GetDZ()
2587                                                 +       fgkSSDMountingBlockHeight[3]);
2588   mountingblockboxtrans[2] = new TGeoTranslation("MountingBlockBoxTrans2",
2589                                                         mountingblockboxshape[0]->GetDX()
2590                                                 +       2.*mountingblockboxshape[1]->GetDX()
2591                                                 +       mountingblockboxshape[2]->GetDX(),
2592                                                         0.0,
2593                                                         mountingblockboxshape[2]->GetDZ()
2594                                                 -       mountingblockboxshape[0]->GetDZ()
2595                                                 +       fgkSSDMountingBlockHeight[3]);
2596   mountingblockboxtrans[3] = new TGeoTranslation("MountingBlockBoxTrans3",
2597                                                         mountingblockboxshape[0]->GetDX()
2598                                                 +       mountingblockboxshape[1]->GetDX()
2599                                                 +       2.*(mountingblockboxshape[1]->GetDX()
2600                                                 +       mountingblockboxshape[2]->GetDX()),
2601                                                         0.0,
2602                                                         mountingblockboxshape[1]->GetDZ()
2603                                                 -       mountingblockboxshape[0]->GetDZ()
2604                                                 +       fgkSSDMountingBlockHeight[3]);
2605   mountingblockboxtrans[4] = new TGeoTranslation("MountingBlockBoxTrans4",
2606                                                         2.*(mountingblockboxshape[0]->GetDX()
2607                                                 +       2.*mountingblockboxshape[1]->GetDX()
2608                                                 +   mountingblockboxshape[2]->GetDX()),
2609                                                         0.0,
2610                                                         0.0);
2611   for(Int_t i=0; i<kmountingblockboxnumber+2; i++) 
2612                                                                         mountingblockboxtrans[i]->RegisterYourself();
2613   ///////////////////////////////////////
2614   // Mounting Block Trapezoid Hole Shapes
2615   ///////////////////////////////////////
2616   const Int_t kholetrapezoidvertexnumber = 4;
2617   TVector3* holetrapezoidvertex[kholetrapezoidvertexnumber];
2618   holetrapezoidvertex[0] = new TVector3();
2619   holetrapezoidvertex[1] = new TVector3(fgkSSDMountingBlockHoleTrapezoidHeight);
2620   holetrapezoidvertex[2] = new TVector3(*holetrapezoidvertex[0]);
2621   holetrapezoidvertex[3] = new TVector3(*holetrapezoidvertex[1]);
2622   Double_t holetrapezoidwidth[2] = {fgkSSDMountingBlockHoleTrapezoidUpBasis
2623                                                 +       2.*mountingblockboxshape[1]->GetDX()
2624                                                 *       TMath::Tan(fgkSSDMountingBlockHoleTrapezoidAngle
2625                                                 *       TMath::DegToRad()),
2626                                                         fgkSSDMountingBlockHoleTrapezoidUpBasis}; 
2627   GetArbShape(holetrapezoidvertex,
2628                                                         holetrapezoidwidth,