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