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