fixed the tainted variables
[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::fgSSDsensitiveVolName5 = "ITSssdSensitivL5";
46 const char* AliITSv11GeometrySSD::fgSSDsensitiveVolName6 = "ITSssdSensitivL6";
47 /////////////////////////////////////////////////////////////////////////////////
48 //Parameters for SSD Geometry
49 /////////////////////////////////////////////////////////////////////////////////
50 // Variable for Vertical Disalignement of Modules
51 /////////////////////////////////////////////////////////////////////////////////
52 const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
53 const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
54 const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
55 // For ladders:
56 const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.520*fgkmm;
57 /////////////////////////////////////////////////////////////////////////////////
58 // Layer5 (lengths are in mm and angles in degrees)
59 /////////////////////////////////////////////////////////////////////////////////
60 const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
61 const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
62 const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
63 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
64 const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
65 const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
66 /////////////////////////////////////////////////////////////////////////////////
67 // Layer6 (lengths are in mm and angles in degrees)
68 /////////////////////////////////////////////////////////////////////////////////
69 const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
70 const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
71 const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
72 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
73 const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
74 const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
75 /////////////////////////////////////////////////////////////////////////////////
76 // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
77 /////////////////////////////////////////////////////////////////////////////////
78 const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
79 const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
80 const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
81 const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
82 const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
83 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
84 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
85 const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
86 /////////////////////////////////////////////////////////////////////////////////
87 // Stiffener (lengths are in mm and angles in degrees)
88 /////////////////////////////////////////////////////////////////////////////////
89 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
90 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
91 const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   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 = 625.0*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 }
617 /////////////////////////////////////////////////////////////////////////////////
618 AliITSv11GeometrySSD::AliITSv11GeometrySSD(const AliITSv11GeometrySSD &s):
619   AliITSv11Geometry(s.GetDebug()),
620   fSSDChipMedium(s.fSSDChipMedium),
621   fSSDChipGlueMedium(s.fSSDChipGlueMedium),
622   fSSDStiffenerMedium(s.fSSDStiffenerMedium),
623   fSSDStiffenerConnectorMedium(s.fSSDStiffenerConnectorMedium),
624   fSSDStiffener0603CapacitorMedium(s.fSSDStiffener0603CapacitorMedium),
625   fSSDStiffener1812CapacitorMedium(s.fSSDStiffener1812CapacitorMedium),
626   fSSDStiffenerCapacitorCapMedium(s.fSSDStiffenerCapacitorCapMedium),
627   fSSDStiffenerHybridWireMedium(s.fSSDStiffenerHybridWireMedium),
628   fSSDKaptonFlexMedium(s.fSSDKaptonFlexMedium),
629   fSSDAlTraceFlexMedium(s.fSSDAlTraceFlexMedium),
630   fSSDAlTraceLadderCableMedium(s.fSSDAlTraceLadderCableMedium),
631   fSSDKaptonLadderCableMedium(s.fSSDKaptonLadderCableMedium),
632   fSSDKaptonChipCableMedium(s.fSSDKaptonChipCableMedium),
633   fSSDAlTraceChipCableMedium(s.fSSDAlTraceChipCableMedium),
634   fSSDAlCoolBlockMedium(s.fSSDAlCoolBlockMedium),
635   fSSDSensorMedium(s.fSSDSensorMedium),
636   fSSDSensorSupportMedium(s.fSSDSensorSupportMedium),
637   fSSDCarbonFiberMedium(s.fSSDCarbonFiberMedium),
638   fSSDTubeHolderMedium(s.fSSDTubeHolderMedium),
639   fSSDCoolingTubeWater(s.fSSDCoolingTubeWater),
640   fSSDCoolingTubePhynox(s.fSSDCoolingTubePhynox),
641   fSSDSupportRingAl(s.fSSDSupportRingAl),
642   fSSDMountingBlockMedium(s.fSSDMountingBlockMedium),
643   fSSDRohaCellCone(s.fSSDRohaCellCone),
644   fSSDAir(s.fSSDAir),
645   fSSDCopper(s.fSSDCopper),  
646   fSSDSn(s.fSSDSn),
647   fCreateMaterials(s.fCreateMaterials),
648   fTransformationMatrices(s.fTransformationMatrices),
649   fBasicObjects(s.fBasicObjects),
650   fcarbonfiberjunction(s.fcarbonfiberjunction),
651   fcoolingtubesupport(s.fcoolingtubesupport),
652   fhybridmatrix(s.fhybridmatrix),
653   fssdcoolingblocksystem(s.fssdcoolingblocksystem),
654   fcoolingblocksystematrix(s.fcoolingblocksystematrix),
655   fssdstiffenerflex(s.fssdstiffenerflex),
656   fssdendflex(s.fssdendflex),
657   fcoolingtube(s.fcoolingtube),
658   fendladdercoolingtubesupportmatrix(s.fendladdercoolingtubesupportmatrix),
659   fendladdermountingblock(s.fendladdermountingblock),
660   fendladdermountingblockclip(s.fendladdermountingblockclip),
661   fSSDSensor5(s.fSSDSensor5),
662   fSSDSensor6(s.fSSDSensor6),
663   fSSDLayer5(s.fSSDLayer5),     
664   fSSDLayer6(s.fSSDLayer6),
665   fMotherVol(s.fMotherVol),
666   fLay5LadderSupportRing(s.fLay5LadderSupportRing),
667   fLay6LadderSupportRing(s.fLay6LadderSupportRing),
668   fgkEndCapSupportSystem(s.fgkEndCapSupportSystem),
669   fSSDCone(s.fSSDCone),
670   fColorCarbonFiber(s.fColorCarbonFiber),
671   fColorRyton(s.fColorRyton),
672   fColorPhynox(s.fColorPhynox),
673   fColorSilicon(s.fColorSilicon),
674   fColorAl(s.fColorAl),
675   fColorNiSn(s.fColorNiSn),
676   fColorKapton(s.fColorKapton),
677   fColorPolyhamide(s.fColorPolyhamide),
678   fColorStiffener(s.fColorStiffener),
679   fColorEpoxy(s.fColorEpoxy),
680   fColorWater(s.fColorWater),
681   fColorG10(s.fColorG10)
682 {
683   ////////////////////////
684   // Copy Constructor
685   ////////////////////////
686 }
687 /////////////////////////////////////////////////////////////////////////////////
688 AliITSv11GeometrySSD& AliITSv11GeometrySSD::
689 operator=(const AliITSv11GeometrySSD &s){
690   ////////////////////////
691   // Assignment operator
692   ////////////////////////
693   this->~AliITSv11GeometrySSD();
694   new(this) AliITSv11GeometrySSD(s); 
695   return *this;
696 /*      
697   if(&s == this) return *this;
698   fMotherVol = s.fMotherVol;
699   return *this;
700  */
701 }
702 ///////////////////////////////////////////////////////////////////////////////
703 void AliITSv11GeometrySSD::CreateTransformationMatrices(){
704   ///////////////////////////////////////////////////////////////////////  
705   // Method generating the trasformation matrix for the whole SSD Geometry   
706   ///////////////////////////////////////////////////////////////////////  
707   // Setting some variables for Carbon Fiber Supportmatrix creation
708   //////////////////////////////////////////////////////////////////////
709   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
710                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
711   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
712                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
713                                                                  +      fgkCarbonFiberSupportWidth);
714   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
715                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
716   TGeoRotation* carbonfiberot[3];
717   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
718   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
719   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
720   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
721   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
722                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
723                                                   -  fgkCarbonFiberTriangleLength
724                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
725   ///////////////////////////////////////////
726   //Setting Local Translations and Rotations: 
727   ///////////////////////////////////////////
728   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
729   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
730                                                                          0.5*carbonfibersupportheight,NULL);    
731   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
732                                                                          2.*symmetryplaneposition+transvector[1],
733                                                                          transvector[2], carbonfiberot[2]);
734   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
735   /////////////////////////////////////////////////////////////
736   // Carbon Fiber Support Transformations
737   /////////////////////////////////////////////////////////////
738   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
739   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
740                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
741                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
742                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
743   }             
744   /////////////////////////////////////////////////////////////
745   // Carbon Fiber Junction Transformation
746   /////////////////////////////////////////////////////////////
747   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
748   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
749   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
750   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
751   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
752         localcarbonfiberjunctionmatrix[i] = 
753                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
754         localcarbonfiberjunctionrot[i] = 
755                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
756         localcarbonfiberjunctiontrans[i] = 
757                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
758   }
759   ///////////////////////
760   // Setting Translations
761   ///////////////////////
762   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
763   localcarbonfiberjunctiontrans[1][0] = 
764                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
765   localcarbonfiberjunctiontrans[2][0] = 
766                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
767                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
768                                  fgkCarbonFiberTriangleLength
769                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
770   localcarbonfiberjunctiontrans[0][1] = 
771                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
772   localcarbonfiberjunctiontrans[1][1] = 
773                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
774   localcarbonfiberjunctiontrans[2][1] = 
775                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
776   ////////////////////
777   // Setting Rotations
778   ////////////////////
779   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
780                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
781                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
782   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
783         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
784   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
785   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
786   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
787   ////////////////////////////////////////
788   // Setting Carbon Fiber Junction matrix 
789   ////////////////////////////////////////
790   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
791                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
792                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
793                         localcarbonfiberjunctionmatrix[i][j] = 
794                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
795                                                            *localcarbonfiberjunctionrot[i][j]);
796                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
797          }
798   }
799   /////////////////////////////////////////////////////////////
800   // Carbon Fiber Lower Support Transformations
801   /////////////////////////////////////////////////////////////
802   TGeoTranslation* localcarbonfiberlowersupportrans[2];
803   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
804                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
805                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
806                                                                          0.0);
807   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
808                                                                          fgkCarbonFiberJunctionWidth
809                                                                 -    fgkCarbonFiberLowerSupportWidth
810                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
811                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
812                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
813    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
814    fcarbonfiberlowersupportrans[0] = 
815                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
816    fcarbonfiberlowersupportrans[1] = 
817                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
818   /////////////////////////////////////////////////////////////
819   // SSD Sensor Support Transformations
820   /////////////////////////////////////////////////////////////
821   const Int_t kssdsensorsupportmatrixnumber = 3;
822   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
823   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
824   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
825   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
826         localssdsensorsupportmatrix[i] = 
827                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
828         localssdsensorsupportrot[i] = 
829                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
830         localssdsensorsupportrans[i] = 
831                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
832   }
833   ///////////////////////
834   // Setting Translations
835   ///////////////////////
836   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
837                                                                           0.5*fgkSSDSensorSideSupportWidth,
838                                                                           0.0);
839   localssdsensorsupportrans[1][0] = 
840                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
841   localssdsensorsupportrans[2][0] = 
842                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
843   localssdsensorsupportrans[0][1] = 
844                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
845                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
846                                                                                 0.0);
847   localssdsensorsupportrans[1][1] = 
848                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
849                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
850                                                                     -   fgkSSDModuleSensorSupportDistance,
851                                                                                 0.0);
852   localssdsensorsupportrans[2][1] = 
853                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
854                                                                         -    fgkSSDSensorCenterSupportPosition,
855                                                                                  0.5*fgkSSDSensorCenterSupportWidth
856                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
857                                                                                  fgkSSDSensorCenterSupportThickness[0]);
858   localssdsensorsupportrans[0][2] = 
859                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
860                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
861                                                                                  fgkCarbonFiberJunctionWidth
862                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
863                                                                         +    fgkSSDSensorCenterSupportLength
864                                                                         -    fgkSSDSensorCenterSupportThickness[0])
865                                                                         -    fgkSSDSensorCenterSupportPosition,
866                                                                              0.0);
867   localssdsensorsupportrans[1][2] = 
868                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
869   localssdsensorsupportrans[2][2] = 
870                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
871   ////////////////////
872   // Setting Rotations
873   ////////////////////
874   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
875                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
876                         localssdsensorsupportrot[i][j] = new TGeoRotation();
877   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
878         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
879         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
880   }
881   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
882   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
883   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
884   ////////////////////////////////////////
885   // SSD Sensor Support matrix 
886   ////////////////////////////////////////
887   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
888                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
889                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
890                         localssdsensorsupportmatrix[i][j] = 
891                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
892                                                            *localssdsensorsupportrot[i][j]);
893                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
894          }
895   }
896   /////////////////////////////////////////////////////////////
897   // SSD Cooling Tube Support Transformations
898   /////////////////////////////////////////////////////////////
899   const Int_t kcoolingtubesupportmatrixnumber = 2;
900   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
901   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
902   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
903   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
904                                                                                                         /fgkCoolingTubeSupportRmax);
905   localcoolingtubesupportrans[0] = 
906                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
907                                                 +  2.*(fgkCoolingTubeSupportLength
908                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
909                                                 +  fgkCarbonFiberTriangleLength
910                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
911   localcoolingtubesupportrans[1] = 
912                         new TGeoTranslation(fgkCarbonFiberJunctionLength
913                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
914                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
915                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
916                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
917                     -  0.5*(fgkCarbonFiberLowerSupportWidth
918                                         +          fgkSSDSensorCenterSupportLength
919                     -      fgkSSDSensorCenterSupportThickness[0])
920                                         +  0.5*fgkSSDSensorLength,
921                                         -  0.5*fgkCoolingTubeSupportHeight);  
922   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
923   localcoolingtubesupportrot[i] = new TGeoRotation();
924   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
925   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
926   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
927         localcoolingtubesupportmatrix[i] = 
928                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
929                                                    *localcoolingtubesupportrot[i]);
930   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
931   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
932                                                                 (*localcoolingtubesupportmatrix[0]));
933   /////////////////////////////////////////////////////////////
934   // End Ladder SSD Cooling Tube Support Transformations
935   /////////////////////////////////////////////////////////////
936   TGeoTranslation** localendladdercooltubetrans[2];
937   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
938   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
939   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
940   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
941                                                                                         -          (fgkCoolingTubeSupportLength
942                                                                                         -               fgkCoolingTubeSupportRmax),
943                                                                                                         fgkEndLadderMountingBlockPosition[0]
944                                                                                         -               fgkendladdercoolingsupportdistance[0]
945                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
946                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
947   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
948                                                                                         -          (fgkCoolingTubeSupportLength
949                                                                                         -               fgkCoolingTubeSupportRmax),
950                                                                                                         fgkEndLadderMountingBlockPosition[0]
951                                                                                         +               fgkendladdercoolingsupportdistance[1]
952                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
953                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
954   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
955                                                                                         -       fgkCoolingTubeSupportRmax)
956                                                                                         +               fgkCarbonFiberTriangleLength
957                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
958                                                                                                 0.0,
959                                                                                                 0.0);
960   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
961                                                                                                         fgkendladdercoolingsupportdistance[0]
962                                                                                         +               fgkendladdercoolingsupportdistance[1],
963                                                                                                         0.0);
964   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
965   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
966                                                                                         +               fgkCarbonFiberJunctionLength
967                                                                                         -               fgkCoolingTubeSupportLength,
968                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
969                                                                                         -       0.5*fgkCoolingTubeSupportWidth
970                                                                                                    -fgkendladdercoolingsupportdistance[2],
971                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
972   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
973                                                                                         +               fgkCoolingTubeSupportLength
974                                                                                         -               fgkCoolingTubeSupportRmax
975                                                                                         -               fgkCarbonFiberJunctionLength,
976                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
977                                                                                         -       0.5*fgkCoolingTubeSupportWidth
978                                                                                         -               fgkendladdercoolingsupportdistance[2],
979                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
980   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
981   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
982   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
983   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
984   (*localcoolingtubesupportrot[1]));
985   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
986   (*localcoolingtubesupportrot[1]));
987   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
988   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
989   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
990   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
991   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
992
993   fendladdercoolingtubesupportmatrix[1][0] =    
994                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
995                                                                                    *(*localcoolingtubesupportrot[1]));
996   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
997   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
998   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
999   /////////////////////////////////////////////////////////////
1000   // SSD Cooling Tube Transformations
1001   /////////////////////////////////////////////////////////////
1002   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
1003   localcoolingtuberot->SetAngles(0.,90.,0.);
1004   TGeoTranslation* localcoolingtubetrans[2];
1005   TVector3* localcoolingtubevect[2];
1006
1007   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
1008                                                   -fgkCarbonFiberTriangleLength),
1009                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
1010                                             - fgkCarbonFiberLowerSupportWidth 
1011                                             - fgkLowerSupportToSensorZ ,
1012                                                   -  0.5*fgkCoolingTubeSupportHeight);  
1013   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
1014                                               localcoolingtubevect[0]->Y(),
1015                                               localcoolingtubevect[0]->Z());
1016   for(Int_t j=0; j<2; j++){
1017     localcoolingtubetrans[j] = 
1018         new TGeoTranslation(localcoolingtubevect[j]->X(),
1019                             localcoolingtubevect[j]->Y(),
1020                             localcoolingtubevect[j]->Z());
1021      fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
1022                                              *(*localcoolingtuberot));
1023   }
1024   /////////////////////////////////////////////////////////////
1025   // SSD End Ladder Cooling Tube Transformations
1026   /////////////////////////////////////////////////////////////
1027   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
1028   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
1029   TGeoTranslation** localendlladdercoolingtubetrans[2];
1030   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
1031   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
1032   for(Int_t i=0; i<2; i++)      
1033         for(Int_t j=0; j<2; j++)        
1034                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
1035
1036   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
1037   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1038                                                                         -        fgkCoolingTubeSupportRmax)
1039                                                                         +        fgkCarbonFiberJunctionLength,
1040                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1041                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1042   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
1043                                                                         -        fgkCoolingTubeSupportRmax)
1044                                                                         -        fgkCarbonFiberJunctionLength
1045                                                                         +    fgkCarbonFiberTriangleLength,
1046                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
1047                                                                         - 0.5*fgkCoolingTubeSupportHeight);
1048
1049   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
1050                                                           -   fgkCoolingTubeSupportRmax)
1051                                                         +       fgkCarbonFiberJunctionLength,
1052                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1053                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1054   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
1055                                                   -      fgkCoolingTubeSupportRmax)
1056                                                   -      fgkCarbonFiberJunctionLength
1057                                                   +    fgkCarbonFiberTriangleLength,
1058                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
1059                                                   -             0.5*fgkCoolingTubeSupportHeight);        
1060   for(Int_t i=0; i<2; i++)
1061         for(Int_t j=0; j<2; j++){
1062                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
1063                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]); 
1064         }
1065   /////////////////////////////////////////////////////////////
1066   // SSD Hybrid Components Transformations
1067   /////////////////////////////////////////////////////////////
1068   const Int_t khybridmatrixnumber = 3;
1069   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
1070   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
1071                                             0.5*fgkSSDStiffenerWidth,
1072                                             0.5*fgkSSDStiffenerHeight);
1073   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
1074                                             fgkSSDModuleStiffenerPosition[1],0.0);
1075
1076   localhybridtrans[2] = new TGeoTranslation(
1077                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1078                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1079                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1080                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1081                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
1082                       -       fgkSSDSensorCenterSupportThickness[0]),
1083                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
1084                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
1085                                           -       fgkSSDModuleVerticalDisalignment)); 
1086   fhybridmatrix = new TGeoHMatrix();
1087   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
1088   /////////////////////////////////////////////////////////////
1089   // SSD Cooling Block Transformations
1090   /////////////////////////////////////////////////////////////
1091   TGeoTranslation localcoolingblocktrans (fcoolingtubematrix[0]->GetTranslation()[0] 
1092                                           - 0.5*fgkSSDCoolingBlockLength,
1093                                           fhybridmatrix->GetTranslation()[1]-0.5*fgkSSDStiffenerWidth,
1094                                           fhybridmatrix->GetTranslation()[2]+0.5*fgkSSDStiffenerHeight+
1095                                           0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
1096   fcoolingblocksystematrix = new TGeoHMatrix(localcoolingblocktrans);
1097   /////////////////////////////////////////////////////////////
1098   // SSD Stiffener Flex Transformations
1099   /////////////////////////////////////////////////////////////
1100   const Int_t klocalflexmatrixnumber = 4;
1101   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
1102   for(Int_t i=0; i<fgkflexnumber; i++)    
1103       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
1104   for(Int_t i=0; i<fgkflexnumber; i++)
1105       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
1106             localflexmatrix[i][j] = new TGeoCombiTrans();
1107   Double_t ssdstiffenerseparation = fgkSSDSensorLength
1108                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
1109                                                                   -    fgkSSDStiffenerWidth;
1110   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
1111                                         +0.5*fgkSSDStiffenerLength,
1112                                          0.5*fgkSSDStiffenerWidth,
1113                                         -0.5*fgkSSDStiffenerHeight
1114                                         -0.5*fgkSSDFlexHeight[0]);
1115   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
1116                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
1117                                         -0.5*fgkSSDStiffenerWidth,
1118                                         -0.5*fgkSSDStiffenerHeight
1119                                         -0.5*fgkSSDFlexHeight[0]);
1120   TGeoRotation* localflexrot = new TGeoRotation();
1121   localflexrot->SetAngles(180.,0.,0.);    
1122   localflexmatrix[1][0]->SetRotation(localflexrot);
1123   for(Int_t i=0; i<fgkflexnumber; i++)
1124       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
1125             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
1126   for(Int_t i=0; i<fgkflexnumber; i++){
1127       fstiffenerflexmatrix[i] = new TGeoHMatrix();
1128       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
1129             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
1130   }
1131   /////////////////////////////////////////////////////////////
1132   // SSD End Flex Transformations
1133   /////////////////////////////////////////////////////////////
1134   TGeoRotation* localendflexrot = new TGeoRotation();
1135   localendflexrot->SetAngles(0.0,90.0,0.0);
1136   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
1137   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
1138                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
1139   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1140                             * TMath::DegToRad()*ssdflexradiusmax
1141                                                                - fgkSSDFlexLength[2]-TMath::Pi()
1142                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1143                                                                                    - 0.1*fgkSSDFlexFullLength;
1144   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
1145                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
1146                             +      fgkSSDFlexLength[2];
1147   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
1148                               0.5*fgkSSDFlexWidth[0],
1149                               2.*fgkSSDStiffenerHeight
1150                             + 0.5*fgkSSDFlexHeight[0]);      
1151   localendflexmatrix->SetRotation(localendflexrot);
1152   for(Int_t i=0; i<fgkflexnumber; i++) 
1153       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
1154   /////////////////////////////////////////////////////////////
1155   // End Ladder Carbon Fiber Junction
1156   /////////////////////////////////////////////////////////////
1157   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
1158   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
1159   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
1160   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1161       localendladdercarbonfiberjunctionmatrix[i] 
1162             = new TGeoCombiTrans*[fgkendladdercabonfiberjunctionmatrixnumber];
1163       localendladdercarbonfiberjunctionrot[i] 
1164             = new TGeoRotation*[fgkendladdercabonfiberjunctionmatrixnumber];
1165       localendladdercarbonfiberjunctiontrans[i] 
1166             = new TGeoTranslation*[fgkendladdercabonfiberjunctionmatrixnumber];
1167       fendladdercarbonfiberjunctionmatrix[i]
1168             = new TGeoHMatrix*[fgkendladdercabonfiberjunctionmatrixnumber];
1169   }
1170   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1171       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1172             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
1173             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
1174       }
1175   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
1176       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++)
1177           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
1178   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1179       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
1180                               0.0,0.0);
1181       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
1182                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
1183                 *                     SinD(fgkCarbonFiberTriangleAngle),
1184                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
1185   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
1186   }
1187   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
1188   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
1189   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
1190   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1191       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
1192       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
1193       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
1194       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
1195             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
1196       localendladdercarbonfiberjunctionglobalmatrix[i] = 
1197             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
1198                                *localendladdercarbonfiberjunctionglobalrot[i]);
1199   }
1200   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
1201       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1202             localendladdercarbonfiberjunctionmatrix[i][j] = 
1203                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
1204                                      *localendladdercarbonfiberjunctionrot[i][j]);
1205            fendladdercarbonfiberjunctionmatrix[i][j] =
1206             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
1207             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
1208       }  
1209   /////////////////////////////////////////////////////////////
1210   // End Ladder Carbon Fiber Support
1211   /////////////////////////////////////////////////////////////
1212   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
1213   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
1214       localendladdercarbonfibertrans[i] = new TGeoTranslation();
1215       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
1216             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
1217       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
1218   }
1219   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1220       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
1221             fendladdercarbonfibermatrix[i][j] = 
1222             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
1223             *(*fcarbonfibersupportmatrix[j]));
1224   /////////////////////////////////////////////////////////////
1225   // End Ladder SSD Mounting Block
1226   /////////////////////////////////////////////////////////////
1227   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1228       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
1229   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1230       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
1231                                 +        fgkSSDMountingBlockLength[1])
1232                                 +  0.5*fgkCarbonFiberTriangleLength,
1233                                 fgkEndLadderMountingBlockPosition[i],
1234                                 -  fgkSSDMountingBlockHeight[1]
1235                                 +  0.5*fgkSSDMountingBlockHeight[0]);
1236   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
1237   endladdermountingblockrot->SetAngles(0.,90.,0.);
1238   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1239         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
1240   /////////////////////////////////////////////////////////////
1241   // End Ladder SSD Mounting Block Clip Matrix 
1242   /////////////////////////////////////////////////////////////
1243   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
1244         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
1245   
1246   TGeoRotation* localendladdercliprot = new TGeoRotation();
1247   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
1248   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
1249                                                                                   -     fgkSSDMountingBlockLength[1])
1250                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
1251   localendladdercliprot->SetAngles(90.,180.,-90.);
1252   TGeoCombiTrans* localendladderclipcombitrans = 
1253                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
1254   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
1255         for(Int_t j=0; j<2; j++){
1256                 fendladdermountingblockclipmatrix[i][j] = 
1257                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
1258                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
1259         }
1260   /////////////////////////////////////////////////////////////
1261   // End Ladder Carbon Fiber Lower Support
1262   /////////////////////////////////////////////////////////////
1263   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
1264       fendladderlowersupptrans[i] = 
1265             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
1266                         +  0.5*fgkSSDMountingBlockWidth),
1267                         -  0.5*fgkCarbonFiberLowerSupportHeight);
1268   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
1269                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
1270                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
1271                                                                          0.0);
1272   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
1273  /////////////////////////////////////////////////////////////
1274   // Matrix for positioning Ladder into mother volume
1275   /////////////////////////////////////////////////////////////
1276   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
1277   for(Int_t i=0; i<fgkladdernumber; i++) 
1278         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
1279   TGeoRotation* localladdermotherrot = new TGeoRotation();
1280   localladdermotherrot->SetAngles(0.,90.,0.);  
1281   TGeoTranslation* localladdermothertrans[fgkladdernumber];
1282   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
1283   for(Int_t i=0; i<fgkladdernumber; i++){
1284         localladdermothertrans[i] = new TGeoTranslation(0.,
1285                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
1286                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
1287                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
1288                                                           * fgkCarbonFiberJunctionWidth,0.);
1289         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
1290                                                                                                                 *localladdermotherrot);
1291         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
1292         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
1293   }
1294   /////////////////////////////////////////////////////////////
1295   // Ladder Cables Matrices
1296   /////////////////////////////////////////////////////////////
1297   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
1298                                              + fgkSSDFlexHeight[1];  
1299   Double_t ssdladdercabletransx[3];
1300   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1301                                                   *   SinD(2.*fgkSSDFlexAngle)
1302                                                   *       CosD(2.*fgkSSDFlexAngle);
1303   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
1304                                                   -     ssdladdercabletransx[0]
1305                                                   /     SinD(2.*fgkSSDFlexAngle))
1306                                                   *     CosD(fgkSSDFlexAngle);                                          
1307   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
1308                                                   *       TMath::DegToRad()*ssdflexradiusmax
1309                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
1310                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
1311                                                   -       fgkSSDLadderCableWidth)
1312                                                   *       CosD(2.*fgkSSDFlexAngle);
1313   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
1314                                                   *     TanD(2.*fgkSSDFlexAngle),
1315                                                         ssdladdercabletransx[1]
1316                                                   *     TanD(fgkSSDFlexAngle),
1317                                                         ssdladdercabletransx[2]
1318                                                   *     TanD(2.*fgkSSDFlexAngle)};      
1319   TGeoRotation* localladdercablerot[3]; 
1320   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
1321   localladdercablerot[0]->SetAngles(90.,0.,0.);
1322   localladdercablerot[1]->SetAngles(90.,60.,-90.);
1323   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
1324                                                  *                        (*localladdercablerot[0]));
1325   //TGeoRotation* localladdercablerot = new TGeoRotation();     
1326   //localladdercablerot->SetAngles(90.,0.,0.);
1327   ////////////////////////////////////////////
1328   // LocalLadderCableCombiTransMatrix
1329   ////////////////////////////////////////////
1330   const Int_t klocalladdersidecablesnumber = 2;
1331   const Int_t klocalladdercombitransnumber = 5;
1332   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
1333   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
1334          localladdercablecombitransmatrix[i] = 
1335                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
1336   ///////////////////////////////////////////
1337   // Left Side Ladder Cables Transformations
1338   ///////////////////////////////////////////
1339   localladdercablecombitransmatrix[0][0]  =
1340                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
1341                                                 0.,0.,NULL);
1342   localladdercablecombitransmatrix[0][1] = 
1343         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
1344                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
1345                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
1346                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
1347                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
1348                                            + fgkSSDSensorCenterSupportLength
1349                                            - fgkSSDSensorCenterSupportThickness[0]),
1350                                            - (fgkSSDModuleCoolingBlockToSensor
1351                                            + 0.5*fgkCoolingTubeSupportHeight
1352                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
1353                                            - fgkSSDChipHeight),NULL);
1354   localladdercablecombitransmatrix[0][2] = 
1355                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
1356                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
1357   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
1358                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
1359                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1360                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
1361                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
1362                                                                                                 new TGeoRotation("",180.,0.,0.));
1363   localladdercablecombitransmatrix[0][4] = 
1364                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
1365                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
1366                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
1367                                                           0.,
1368                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
1369                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
1370                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
1371                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
1372   ///////////////////////////////////////////
1373   // Rigth Side Ladder Cables Transformations
1374   ///////////////////////////////////////////
1375   TGeoCombiTrans* localladdercablessdmodulematrix = 
1376         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
1377                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
1378                                                                          fgkSSDStiffenerWidth,
1379                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
1380   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
1381    localladdercablecombitransmatrix[1][i] = 
1382                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
1383                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
1384   ///////////////////////////////////////////
1385   // Setting LadderCableHMatrix
1386   ///////////////////////////////////////////
1387   Int_t beamaxistrans[2][3];
1388   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
1389   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
1390   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
1391   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
1392   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
1393   beamaxistrans[1][2] = beamaxistrans[1][0];
1394   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
1395   TGeoRotation* laddercablerot = new TGeoRotation();
1396   TGeoTranslation* laddercabletrans = new TGeoTranslation();
1397   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
1398   Double_t* laddercabletransvector;     
1399   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
1400         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
1401         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
1402   }
1403   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1404         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
1405                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
1406                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
1407                         localladdercablehmatrix[i][j]->MultiplyLeft(
1408                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
1409         }
1410                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
1411                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
1412                 laddercabletrans->SetTranslation(laddercabletransvector[0],
1413                                                                          laddercabletransvector[1]
1414                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
1415                                         *                                fgkCarbonFiberJunctionWidth,
1416                                                                          laddercabletransvector[2]);
1417                 laddercablecombitrans->SetRotation(*laddercablerot);
1418                 laddercablecombitrans->SetTranslation(*laddercabletrans);       
1419                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
1420         }
1421     fladdercablematrix[i][2] = 
1422                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
1423                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
1424         fladdercablematrix[i][3] = 
1425                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
1426                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
1427   }
1428   for(Int_t i=0; i<fgkladdercablesnumber; i++)
1429     for(Int_t j=0; j<klocalladdercombitransnumber-1; j++) 
1430       fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1431   
1432   ///////////////////////////////////////////
1433   // Setting Ladder HMatrix
1434   ///////////////////////////////////////////
1435   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
1436                                                                                                 fgkSSDLay6SensorsNumber};
1437   for(Int_t i=0; i<fgkladdernumber; i++){
1438         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1439         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1440                 fladdermatrix[i][j] = new TGeoHMatrix();
1441                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1442                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
1443                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
1444         }
1445   }
1446   ///////////////////////////////////////////
1447   // Setting SSD Sensor Matrix 
1448   ///////////////////////////////////////////
1449   TGeoCombiTrans* localssdsensorcombitrans[2];
1450   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
1451   localssdsensorrot->SetAngles(0.,90.,0.);      
1452   TGeoTranslation* localssdsensortrans[2];
1453   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
1454   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1455                                          fgkCarbonFiberJunctionWidth 
1456                                          - fgkCarbonFiberLowerSupportWidth 
1457                                          - fgkLowerSupportToSensorZ,
1458                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1459                                           -             fgkSSDModuleCoolingBlockToSensor
1460                                           +    (fgkSSDSensorSideSupportHeight[1]
1461                                           -             fgkSSDSensorSideSupportHeight[0]));
1462   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
1463                                          fgkCarbonFiberJunctionWidth 
1464                                          - fgkCarbonFiberLowerSupportWidth 
1465                                          - fgkLowerSupportToSensorZ,
1466                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
1467                                                         -fgkSSDModuleCoolingBlockToSensor);
1468
1469   for(Int_t i=0; i<2; i++) 
1470         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
1471                                                                                                          *localssdsensorrot);   
1472     for(Int_t i=0; i<fgkladdernumber; i++){
1473         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
1474         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
1475                 switch(i){
1476                         case 0: //Ladder of Layer5  
1477                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1478                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
1479                                                                                                 *localssdsensorcombitrans[1])));
1480                         break;
1481                         case 1: //Ladder of Layer6 
1482                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
1483                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
1484                                                                                                 *localssdsensorcombitrans[0])));
1485                 break;
1486                 }
1487           }
1488   }     
1489   //////////////////////////
1490   // Setting SSD End Ladder  
1491   //////////////////////////
1492   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
1493   for(Int_t i=0; i<2; i++){
1494         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
1495         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1496         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
1497         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1498         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
1499         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
1500         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
1501         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
1502    }
1503   /////////////////////////////////////////////////////
1504   // Setting the CombiTransformation to pass ITS center 
1505   /////////////////////////////////////////////////////
1506   Double_t itscentertransz[fgklayernumber];
1507   itscentertransz[0] = fgkSSDLay5LadderLength
1508                                          - fgkLay5CenterITSPosition;
1509   itscentertransz[1] = fgkSSDLay6LadderLength
1510                                          - fgkLay6CenterITSPosition;
1511   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
1512                                                    + 0.5*fgkCoolingTubeSupportHeight;
1513   TGeoRotation* itscenterrot[3];
1514   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
1515   itscenterrot[0]->SetAngles(90.,180.,-90.);
1516   itscenterrot[1]->SetAngles(0.,90.,0.);
1517   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
1518   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
1519   for(Int_t i=0; i<fgklayernumber; i++) 
1520         itscentercombitrans[i] = new TGeoCombiTrans(0.,
1521                                                          itssensortransy,
1522                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
1523                                                    - itscentertransz[i],itscenterrot[2]);
1524   TGeoRotation** locallayerrot[fgklayernumber];
1525   TGeoTranslation** locallayertrans[fgklayernumber];    
1526   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
1527   TGeoTranslation* localbeamaxistrans[fgklayernumber];
1528   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
1529                                          - fgkLay5CenterITSPosition);
1530   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
1531                                          - fgkLay6CenterITSPosition);
1532   const Int_t kssdlayladdernumber[fgklayernumber] = 
1533                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
1534   for(Int_t i=0; i<fgklayernumber; i++){
1535     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
1536     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
1537         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
1538         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
1539   }
1540   Double_t layerladderangleposition[fgklayernumber] = 
1541                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
1542   Double_t layerradius = 0.;
1543   for(Int_t i=0; i<fgklayernumber; i++){        
1544         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1545                 switch(i){
1546                         case 0: //Ladder of Layer5  
1547                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
1548                         break;
1549                         case 1: //Ladder of Layer6 
1550                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
1551                 break;
1552                 }
1553                 locallayerrot[i][j] = new TGeoRotation();
1554                 locallayertrans[i][j] = new TGeoTranslation();
1555                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
1556                 locallayertrans[i][j]->SetTranslation(layerradius 
1557                                                           *     CosD(90.0+j*layerladderangleposition[i]),
1558                                                             layerradius 
1559                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
1560                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
1561                                                                          *locallayerrot[i][j]);
1562                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
1563                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
1564                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
1565         }
1566   }
1567   /////////////////////////////////////////////////////////////
1568   // Deallocating memory
1569   /////////////////////////////////////////////////////////////
1570   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
1571         delete carbonfiberot[i];
1572         delete localcarbonfibersupportmatrix[i];
1573   }
1574   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
1575      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
1576        delete localcarbonfiberjunctionmatrix[i][j];
1577            delete localcarbonfiberjunctionrot[i][j];
1578            delete localcarbonfiberjunctiontrans[i][j];
1579            }
1580        delete [] localcarbonfiberjunctionmatrix[i];
1581        delete [] localcarbonfiberjunctionrot[i];
1582        delete [] localcarbonfiberjunctiontrans[i];
1583   }
1584   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
1585            delete localcarbonfiberlowersupportrans[i];
1586   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
1587      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
1588        delete localssdsensorsupportmatrix[i][j];
1589            delete localssdsensorsupportrot[i][j];
1590            delete localssdsensorsupportrans[i][j];
1591            }
1592        delete [] localssdsensorsupportmatrix[i];
1593        delete [] localssdsensorsupportrot[i];
1594        delete [] localssdsensorsupportrans[i];
1595   }
1596   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
1597         delete localcoolingtubesupportmatrix[i];
1598         delete localcoolingtubesupportrot[i];
1599         delete localcoolingtubesupportrans[i];
1600   }
1601   for(Int_t j=0; j<2; j++){
1602     delete localcoolingtubevect[j];
1603     delete localcoolingtubetrans[j];
1604   }
1605  delete endladdermountingblockrot;
1606  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
1607  for(Int_t i=0; i<fgkflexnumber; i++){
1608       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
1609             delete localflexmatrix[i][j];
1610       delete [] localflexmatrix[i];
1611  }
1612  delete localendlladdercoolingtuberot;
1613  for(Int_t i=0; i<2; i++){
1614         for(Int_t j=0; j<2; j++)
1615           delete localendlladdercoolingtubetrans[i][j];
1616         delete [] localendlladdercoolingtubetrans[i];
1617   }
1618
1619  delete localflexrot;
1620  delete localendflexrot;
1621  delete localendflexmatrix;
1622  for(Int_t i=0; i<fgkladdernumber; i++){ 
1623         delete localladdermothertrans[i];
1624         delete localladdermothercombitrans[i];
1625   }
1626  delete localladdermotherrot;
1627  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
1628       for(Int_t j=0; j<fgkendladdercabonfiberjunctionmatrixnumber; j++){
1629             delete localendladdercarbonfiberjunctionmatrix[i][j];
1630             delete localendladdercarbonfiberjunctionrot[i][j];
1631             delete localendladdercarbonfiberjunctiontrans[i][j];
1632       }
1633       delete [] localendladdercarbonfiberjunctionmatrix[i];
1634       delete [] localendladdercarbonfiberjunctionrot[i];
1635       delete [] localendladdercarbonfiberjunctiontrans[i];
1636       delete localendladdercarbonfiberjunctionglobalrot[i];
1637       delete localendladdercarbonfiberjunctionglobaltrans[i];
1638       delete localendladdercarbonfiberjunctionglobalmatrix[i];
1639  }
1640   for(Int_t i=0; i<2; i++){
1641         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
1642         delete [] localendladdercooltubetrans[i];
1643   }
1644   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
1645       delete localendladdercarbonfibertrans[i];
1646   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
1647   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
1648         for(Int_t j=0; j<klocalladdercombitransnumber; j++)
1649                 delete localladdercablecombitransmatrix[i][j];
1650                 delete []localladdercablecombitransmatrix[i];
1651   }
1652   delete localendladdercliprot;
1653   delete localendladdercliptrans;
1654   for(Int_t i=0; i<fgkladdercablesnumber; i++){
1655         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
1656                 delete localladdercablehmatrix[i][j];
1657         delete []localladdercablehmatrix[i];
1658   }
1659   delete laddercablerot;
1660   delete laddercabletrans;
1661   delete laddercablecombitrans;
1662   delete localladdercablessdmodulematrix;
1663   delete localssdsensorrot;     
1664   for(Int_t i=0; i<2; i++){
1665         delete localssdsensortrans[i];
1666         delete localssdsensorcombitrans[i];
1667   }
1668   for(Int_t i=0; i<fgklayernumber; i++){
1669         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
1670                 delete locallayerrot[i][j];
1671                 delete locallayertrans[i][j];
1672                 delete locallayercombitrans[i][j];
1673     }
1674         delete [] locallayerrot[i];
1675         delete [] locallayertrans[i];
1676         delete [] locallayercombitrans[i];
1677         delete localbeamaxistrans[i];
1678   }
1679   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
1680   for(Int_t i=0; i<fgkladdernumber; i++){
1681         for(Int_t j=0; j<fgkladdernumber; j++)
1682                 delete ladderglobalmatrix[i][j];
1683         delete [] ladderglobalmatrix[i];
1684   }
1685   /////////////////////////////////////////////////////////////
1686   fTransformationMatrices = kTRUE;      
1687 }
1688 ///////////////////////////////////////////////////////////////////////////////
1689 void AliITSv11GeometrySSD::CreateBasicObjects(){
1690   /////////////////////////////////////////////////////////////  
1691   // Method generating the Objects of SSD Geometry    
1692   /////////////////////////////////////////////////////////////
1693   // SSD Sensor
1694   ///////////////////////////////////
1695   SetSSDSensor();
1696   /////////////////////////////////////////////////////////////  
1697   // Carbon Fiber Support    
1698   /////////////////////////////////////////////////////////////  
1699   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
1700   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
1701       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
1702   /////////////////////////////////////////////////////////////
1703   // Carbon Fiber Junction 
1704   /////////////////////////////////////////////////////////////
1705   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
1706   /////////////////////////////////////////////////////////////
1707   // Carbon Fiber Lower Support
1708   /////////////////////////////////////////////////////////////
1709   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
1710   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
1711         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
1712   /////////////////////////////
1713   // SSD Sensor Support
1714   /////////////////////////////
1715   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
1716                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
1717   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
1718                                                                          fgkSSDSensorSideSupportThickness[1]};
1719   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
1720         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
1721                                                                                            fgkSSDSensorSideSupportHeight[i],
1722                                                                                            fgkSSDSensorSideSupportWidth,
1723                                                                                            sidesupporthickness);  
1724         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
1725                                                                                            fgkSSDSensorCenterSupportHeight[i],
1726                                                                                            fgkSSDSensorCenterSupportWidth,
1727                                                                                            sidesupporthickness);
1728   }
1729   /////////////////////////////////////////////////////////////
1730   // SSD Cooling Tube Support
1731   /////////////////////////////////////////////////////////////
1732   Int_t edgesnumber = 3;
1733   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
1734   /////////////////////////////////////////////////////////////
1735   // SSD Hybrid
1736   /////////////////////////////////////////////////////////////
1737   TList* ssdhybridcomponentslist = GetSSDHybridParts();
1738   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
1739         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
1740   /////////////////////////////////////////////////////////////
1741   // SSD Cooling Block System
1742   /////////////////////////////////////////////////////////////
1743   fssdcoolingblocksystem = GetCoolingBlockSystem();
1744    /////////////////////////////////////////////////////////////
1745   // SSD Cooling Tube
1746   /////////////////////////////////////////////////////////////
1747   CreateCoolingTubes();
1748   /////////////////////////////////////////////////////////////
1749   // SSD Flex  
1750   /////////////////////////////////////////////////////////////
1751   fssdstiffenerflex = GetSSDStiffenerFlex();
1752   fssdendflex = GetSSDEndFlex();
1753   ///////////////////////////////////
1754   // End Ladder Carbon Fiber Junction
1755   ///////////////////////////////////
1756   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
1757                                                    fendladdercarbonfiberjunction[i] = 
1758                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
1759   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
1760     fendladdercarbonfiberjunction[i][0] = 
1761                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
1762     fendladdercarbonfiberjunction[i][1] = 
1763                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
1764   }
1765   ///////////////////////////////////
1766   // End Ladder Mounting Block
1767   ///////////////////////////////////
1768   fendladdermountingblock = GetSSDMountingBlock();
1769   ///////////////////////////////////
1770   // End Ladder Mounting Block
1771   ///////////////////////////////////
1772   fendladdermountingblockclip = GetMountingBlockClip();
1773   ///////////////////////////////////
1774   // Ladder Support 
1775   ///////////////////////////////////
1776   TList* laddersupportlist = GetMountingBlockSupport(20);
1777   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
1778   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
1779   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
1780   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
1781   /////////////////////////////////////////////////////////////
1782   // Deallocating memory
1783   /////////////////////////////////////////////////////////////
1784   delete carbonfibersupportlist;
1785   delete carbonfiberlowersupportlist;
1786   delete ssdhybridcomponentslist;
1787   delete laddersupportlist;
1788   /////////////////////////////////////////////////////////////
1789   fBasicObjects = kTRUE;
1790 }
1791 /////////////////////////////////////////////////////////////////////////////////
1792 void AliITSv11GeometrySSD::SetSSDSensor(){
1793   ////////////////////////////////////////////////////////////////
1794   // Method generating SSD Sensors: it sets the private variables
1795   // fSSDSensor5, fSSDSensor6  
1796   ////////////////////////////////////////////////////////////////
1797   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
1798   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
1799   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
1800                                                 0.5*ssdsensitivewidth,
1801                                                 0.5*fgkSSDSensorHeight,
1802                                                 0.5*ssdsensitivelength);
1803   TGeoVolume* ssdsensorsensitiveLay5 = 
1804         new TGeoVolume(fgSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
1805   TGeoVolume* ssdsensorsensitiveLay6 = 
1806         new TGeoVolume(fgSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
1807   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
1808   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
1809   TGeoBBox* ssdsensorinsensitiveshape[2];
1810   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
1811                                                 0.5*fgkSSDSensorInsensitiveWidth,
1812                                                 0.5*fgkSSDSensorHeight,
1813                                                 0.5*fgkSSDSensorLength);
1814   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
1815                                                 0.5*ssdsensitivewidth,
1816                                                 0.5*fgkSSDSensorHeight,
1817                                                 0.5*fgkSSDSensorInsensitiveWidth);
1818   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
1819                                              "SSDSensorInsensitive2"};
1820   TGeoVolume* ssdsensorinsensitive[2];
1821   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
1822       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
1823                      fSSDSensorMedium);
1824       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
1825   }
1826   /////////////////////////////////////////////////////////////
1827   // Virtual Volume containing SSD Sensor  
1828   /////////////////////////////////////////////////////////////
1829   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
1830                                                                                              0.5*fgkSSDSensorWidth,
1831                                                                                              0.5*fgkSSDSensorHeight,
1832                                                                                              0.5*fgkSSDSensorLength);
1833   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
1834                                                                                  fSSDAir);      
1835   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
1836                                                                                  fSSDAir);      
1837   /////////////////////////////////////////////////////////////
1838   for(Int_t i=0; i<4; i++){ 
1839             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1840             ssdsensorinsensitive[1],i<2?1:2,
1841                         new TGeoTranslation(
1842                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1843       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1844                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1845       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1846             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
1847             ssdsensorinsensitive[1],i<2?1:2,
1848                         new TGeoTranslation(
1849                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
1850       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                  
1851                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
1852       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
1853   }
1854     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
1855     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
1856 }
1857 ///////////////////////////////////////////////////////////////////////////////
1858 TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
1859   /////////////////////////////////////////////////////////////  
1860   // Method generating the Carbon Fiber Support   
1861   /////////////////////////////////////////////////////////////  
1862   const Int_t kvertexnumber = 4;
1863   const Int_t kshapesnumber = 2;
1864   TVector3** vertexposition[kshapesnumber];
1865   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
1866   Double_t carbonfibersupportxaxisEdgeproj = 
1867                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1868         *       TMath::DegToRad());
1869   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
1870                                  /                         fgkCarbonFiberSupportXAxisLength);
1871   /////////////////////
1872   //Vertex Positioning
1873   ////////////////////
1874   vertexposition[0][0] = new TVector3();
1875   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
1876                                                                           fgkCarbonFiberSupportYAxisLength);
1877   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
1878                                                                           carbonfibersupportxaxisEdgeproj
1879                                            *                      TMath::Tan(theta));
1880   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
1881                                            -                      carbonfibersupportxaxisEdgeproj,
1882                                                                           fgkCarbonFiberSupportYAxisLength
1883                                            -                      vertexposition[0][2]->Y());
1884   ////////////////////////////////////////////////////
1885   //Setting the parameters for Isometry Transformation
1886   ////////////////////////////////////////////////////
1887   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
1888                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
1889                                                                  +      fgkCarbonFiberSupportWidth);
1890   Double_t* param = new Double_t[4]; 
1891   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
1892   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
1893     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
1894                  (GetReflection(vertexposition[0][j],param))->Y());
1895   const char* carbonfibersupportshapename[kshapesnumber] = 
1896                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
1897   const char* carbonfibersupportname[kshapesnumber] = 
1898                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
1899   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
1900   TGeoVolume* carbonfibersupport[kshapesnumber];
1901   TList* carbonfibersupportlist = new TList();
1902   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
1903   Double_t carbonfibersupportheight = 
1904           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1905           *TMath::DegToRad());
1906   for(Int_t i = 0; i< kshapesnumber; i++){
1907    carbonfibersupportshape[i] = 
1908                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
1909                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
1910    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
1911                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
1912    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
1913    carbonfibersupportlist->Add(carbonfibersupport[i]);  
1914    }
1915   /////////////////////////////////////////////////////////////
1916   // Deallocating memory
1917   /////////////////////////////////////////////////////////////
1918   for(Int_t i=0; i< kshapesnumber; i++){
1919      for(Int_t j=0; j< kvertexnumber; j++)
1920            delete vertexposition[i][j];
1921        delete [] vertexposition[i];
1922   }
1923   delete [] param;
1924   /////////////////////////////////////////////////////////////
1925    return carbonfibersupportlist;
1926 }
1927 /////////////////////////////////////////////////////////////////////////////////
1928 TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
1929   /////////////////////////////////////////////////////////////
1930   // Method generating SSD Carbon Fiber Junction
1931   /////////////////////////////////////////////////////////////
1932   const Int_t kvertexnumber = 6;
1933   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
1934   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
1935                                             *  TMath::DegToRad()),-1.,0.,0.};
1936   TVector3* vertex[kvertexnumber];
1937   vertex[0] = new TVector3();
1938   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
1939                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
1940                         *                         TMath::DegToRad()),
1941                                                   fgkCarbonFiberJunctionEdge[0]
1942                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
1943                         *                         TMath::DegToRad()));
1944   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength,
1945                                                    fgkCarbonFiberJunctionEdge[1]);
1946   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength); 
1947   vertex[1] = GetReflection(vertex[5],reflectionparam); 
1948   vertex[2] = GetReflection(vertex[4],reflectionparam); 
1949   Double_t xvertexpoints[6], yvertexpoints[6];
1950   for(Int_t i=0; i<kvertexnumber; i++) 
1951           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
1952   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
1953   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
1954   carbonfiberjunctionshape->DefineSection(1,0.5*width);
1955   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
1956                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
1957   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
1958   /////////////////////////////////////////////////////////////
1959   // Deallocating memory
1960   /////////////////////////////////////////////////////////////
1961   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
1962   ///////////////////////////////////////////////////////////// 
1963   return carbonfiberjunction;
1964 }
1965 ////////////////////////////////////////////////////////////////////////////////
1966 TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
1967   /////////////////////////////////////////////////////////////
1968   // Method generating the Carbon Fiber Lower Support   
1969   /////////////////////////////////////////////////////////////  
1970   const Int_t kvertexnumber = 4;
1971   const Int_t kshapesnumber = 2;
1972   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
1973                                                                 fgkCarbonFiberLowerSupportWidth};
1974   TVector3** vertexposition[kshapesnumber];
1975   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
1976                                                  new TVector3*[kvertexnumber];
1977   //First Shape Vertex Positioning
1978   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght);
1979   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
1980                                            -            fgkCarbonFiberLowerSupportLowerLenght);
1981   vertexposition[0][2] = new TVector3();
1982   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength);
1983   //Second Shape Vertex Positioning
1984   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
1985                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
1986                                  /                              fgkCarbonFiberTriangleLength);
1987   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
1988                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
1989                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1990   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
1991                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
1992                                  +                              fgkCarbonFiberLowerSupportVolumePosition[0]);
1993   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0]);
1994   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
1995                                                                 fgkCarbonFiberLowerSupportVolumePosition[1]);
1996   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
1997                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
1998   const char* carbonfiberlowersupportname[kshapesnumber] = 
1999                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
2000   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
2001   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
2002   TList* carbonfiberlowersupportlist = new TList();
2003   for(Int_t i = 0; i< kshapesnumber; i++){ 
2004         carbonfiberlowersupportshape[i] = 
2005                                                                 GetArbShape(vertexposition[i],width,
2006                                                                                         fgkCarbonFiberLowerSupportHeight,
2007                                                                                         carbonfiberlowersupportshapename[i]);
2008     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
2009                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
2010         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
2011     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
2012   }
2013   /////////////////////////////////////////////////////////////
2014   // Deallocating memory
2015   /////////////////////////////////////////////////////////////
2016   for(Int_t i=0; i< kshapesnumber; i++){
2017      for(Int_t j=0; j< kvertexnumber; j++)
2018            delete vertexposition[i][j];
2019        delete [] vertexposition[i];
2020   }
2021   /////////////////////////////////////////////////////////////
2022   return carbonfiberlowersupportlist;
2023 }
2024 ///////////////////////////////////////////////////////////////////////////////
2025 TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
2026                                                                  Double_t width, Double_t* thickness)const{
2027   /////////////////////////////////////////////////////////////
2028   // Method generating the Sensor Support   
2029   /////////////////////////////////////////////////////////////  
2030         const Int_t kvertexnumber = 6;
2031         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
2032     TVector3* vertexposition[kvertexnumber];
2033         vertexposition[0] = new TVector3();     
2034         vertexposition[1] = new TVector3(0.0,length);   
2035         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y());  
2036         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0]);  
2037         vertexposition[4] = new TVector3(height,vertexposition[3]->Y());        
2038         vertexposition[5] = new TVector3(vertexposition[4]->X());       
2039         Double_t xvertexpoints[6], yvertexpoints[6];
2040         for(Int_t i=0; i<kvertexnumber; i++) 
2041                 xvertexpoints[i] = vertexposition[i]->X(), 
2042                 yvertexpoints[i] = vertexposition[i]->Y();
2043     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
2044     ssdsensorsupportshape->DefineSection(0,-0.5*width);
2045     ssdsensorsupportshape->DefineSection(1,0.5*width);
2046     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
2047                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
2048   /////////////////////////////////////////////////////////////
2049   // Deallocating memory
2050   /////////////////////////////////////////////////////////////
2051         for (Int_t i=0; i<kvertexnumber; i++)
2052                 delete vertexposition[i];
2053   /////////////////////////////////////////////////////////////
2054     return ssdsensorsupport;
2055 }
2056 ////////////////////////////////////////////////////////////////////////////////
2057 TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
2058   /////////////////////////////////////////////////////////////
2059   // Method generating the Cooling Tube Support
2060   /////////////////////////////////////////////////////////////
2061   if(nedges%2!=0) nedges--;     
2062   const Int_t kvertexnumber = nedges+5;
2063   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
2064                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
2065   Double_t angle = 90.+phi;
2066   Double_t psi = 90.-phi;
2067   ///////////////////////////////////////
2068   // Vertex Positioning for TGeoXTru
2069   ///////////////////////////////////////
2070   TVector3** vertexposition = new TVector3*[kvertexnumber];
2071
2072   Double_t Router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
2073   vertexposition[0] = new TVector3(Router*CosD(angle),
2074                                                                    Router*SinD(angle));
2075   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
2076                                                                    fgkCoolingTubeSupportRmax*SinD(angle));
2077   vertexposition[2] = new TVector3(vertexposition[1]->X(),
2078                                                                    fgkCoolingTubeSupportRmax);
2079   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
2080                                                                    fgkCoolingTubeSupportRmax);
2081   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
2082                                                                     vertexposition[1]->Y());
2083
2084   for(Int_t i=0; i<nedges; i++)
2085         vertexposition[i+5] = 
2086                 new TVector3(Router*CosD(psi+i*(2.*phi/nedges)),
2087                              Router*SinD(psi+i*(2.*phi/nedges)));
2088   ///////////////////////////////////////////////////////////////////////
2089   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
2090   ///////////////////////////////////////////////////////////////////////
2091   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
2092   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
2093   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
2094   for(Int_t i=0; i<kvertexnumber; i++){
2095         xvertexpoints[i] = vertexposition[i]->X();
2096         yvertexpoints[i] = vertexposition[i]->Y();
2097   } 
2098   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
2099                                                                                         yvertexpoints);
2100   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2101   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2102   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
2103                                                                           coolingtubesupportarcshape,
2104                                                                                   fSSDTubeHolderMedium);
2105   coolingtubesupportarc->SetLineColor(fColorG10);
2106   //////////////////////////////////////////////////////////////////////////
2107   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
2108   //////////////////////////////////////////////////////////////////////////
2109   TGeoTubeSeg* coolingtubesupportsegshape = 
2110                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
2111                                                                                         fgkCoolingTubeSupportRmax,
2112                                                                                         0.5*fgkCoolingTubeSupportWidth,
2113                                                                                         phi,360-phi);
2114   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
2115                                                                                         coolingtubesupportsegshape,
2116                                                                                         fSSDTubeHolderMedium);
2117   coolingtubesupportseg->SetLineColor(fColorG10);
2118   //////////////////////////////////////////////////////////////////////////
2119   // TGeoBBox Volume definition for Cooling Tube Support Box Part
2120   //////////////////////////////////////////////////////////////////////////
2121   Double_t* boxorigin = new Double_t[3];
2122   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
2123   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
2124   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
2125                                                                                  0.5*fgkCoolingTubeSupportHeight,
2126                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
2127   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
2128                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
2129   coolingtubesupportbox->SetLineColor(fColorG10);
2130   //////////////////////////////////////////////////////////////////////////
2131   // Cooling Tube for Cooling Tube Support 
2132   //////////////////////////////////////////////////////////////////////////
2133   TGeoXtru* coolingtubearcshape[2];
2134   coolingtubearcshape[0] = new TGeoXtru(2);     
2135   Double_t* xvert = new Double_t[nedges+2];
2136   Double_t* yvert = new Double_t[nedges+2];
2137   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
2138   ////////////////////////////////////////
2139   // Positioning the vertices for TGeoXTru
2140   ////////////////////////////////////////
2141   xvert[0] = 0., yvert[0] = 0.;
2142   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
2143   for(Int_t i=0; i< nedges; i++)
2144                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
2145                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
2146   ////////////////////////////////////////
2147   // Defining TGeoXTru PolyGone
2148   ////////////////////////////////////////
2149   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
2150   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2151   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2152   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
2153                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
2154   TGeoVolume* coolingtubearc[2];
2155   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
2156                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
2157   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
2158                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
2159   coolingtubearc[0]->SetLineColor(fColorWater);
2160   coolingtubearc[1]->SetLineColor(fColorPhynox);
2161   ////////////////////////////////////////////
2162   // Defining TGeoTubeSeg Part of Cooling Tube
2163   ////////////////////////////////////////////
2164   TGeoTubeSeg* coolingtubesegshape[2];
2165   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
2166                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2167   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
2168                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
2169   TGeoVolume* coolingtubeseg[2];
2170   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
2171                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
2172   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
2173                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
2174   coolingtubeseg[0]->SetLineColor(fColorPhynox);
2175   coolingtubeseg[1]->SetLineColor(fColorWater);
2176   /////////////////////////////////////////////////////////////
2177   // Virtual Volume containing Cooling Tube Support  
2178   /////////////////////////////////////////////////////////////
2179   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
2180   const Int_t kvirtualvertexnumber = 8;
2181   TVector3* virtualvertex[kvirtualvertexnumber];
2182    ////////////////////////////////////////
2183   // Positioning the vertices for TGeoXTru
2184   ////////////////////////////////////////
2185   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax); 
2186   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y());
2187   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y());
2188   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight);
2189   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y());
2190   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y());
2191   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y());
2192   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y());
2193   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
2194   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2195         xmothervertex[i] = virtualvertex[i]->X(),
2196         ymothervertex[i] = virtualvertex[i]->Y();
2197   ////////////////////////////////////////
2198   // Defining TGeoXTru PolyGone
2199   ////////////////////////////////////////
2200   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
2201                                                                                                                                          ymothervertex);
2202   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
2203   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
2204   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
2205     virtualCoolingTubeSupportShape,fSSDAir); */
2206   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
2207
2208   ////////////////////////////////////////
2209   // Positioning Volumes in Virtual Volume
2210   ////////////////////////////////////////
2211   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
2212   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
2213   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
2214   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
2215   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
2216   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
2217   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
2218   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
2219   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
2220   /////////////////////////////////////////////////////////////
2221   // Deallocating memory
2222   /////////////////////////////////////////////////////////////
2223   delete [] vertexposition;
2224   delete [] xvertexpoints;
2225   delete [] yvertexpoints;
2226   delete [] xvert;
2227   delete [] yvert;
2228   for(Int_t i=0; i< kvirtualvertexnumber; i++)
2229         delete virtualvertex[i];
2230   /////////////////////////////////////////////////////////////
2231         return virtualcoolingtubesupport;
2232 }
2233 /////////////////////////////////////////////////////////////////////////////////
2234 TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
2235   /////////////////////////////////////////////////////////////
2236   // Method generating List containing SSD Hybrid Components   
2237   /////////////////////////////////////////////////////////////
2238   TList* ssdhybridlist = new TList();
2239   const Int_t kssdstiffenernumber = 2;
2240   Double_t ssdstiffenerseparation = fgkSSDSensorLength
2241                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
2242                                                                   -    fgkSSDStiffenerWidth;
2243   Double_t ssdchipcablesradius[kssdstiffenernumber];
2244   for(Int_t i=0; i<kssdstiffenernumber; i++)
2245           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
2246                                -  fgkSSDChipCablesHeight[0]
2247                                -  fgkSSDChipCablesHeight[1]);
2248   /////////////////////////////////////////////////////////////
2249   // Mother Volumes Containers 
2250   /////////////////////////////////////////////////////////////
2251   const Int_t kmothernumber = 2;
2252   const Int_t kmothervertexnumber = 8;
2253   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
2254   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
2255
2256   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
2257   TGeoVolume* ssdhybridmother[kmothernumber][2];
2258
2259   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
2260   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
2261   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
2262
2263   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
2264   for(Int_t i=0; i<kmothernumber; i++){
2265     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
2266     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
2267     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
2268     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
2269       -fgkSSDChipCablesHeight[i+2];
2270     
2271     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
2272     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
2273     xmothervertex[i][3] = xmothervertex[i][2];
2274     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1];
2275
2276     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
2277     ymothervertex[i][4] = ymothervertex[i][3];
2278     xmothervertex[i][5] = xmothervertex[i][4];
2279     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i];
2280
2281     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
2282     ymothervertex[i][6] = ymothervertex[i][5];
2283     
2284     xmothervertex[i][7] = xmothervertex[i][6];
2285     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
2286     TGeoXtru *shape = new TGeoXtru(2);
2287     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
2288     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
2289     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
2290     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
2291     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
2292     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
2293    }   
2294   /////////////////////////////////////////////////////////////
2295   // SSD Stiffener   
2296   /////////////////////////////////////////////////////////////
2297   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
2298                                              0.5*fgkSSDStiffenerLength,
2299                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
2300                                              0.5*fgkSSDStiffenerHeight);
2301   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
2302                                             fSSDStiffenerMedium);  
2303   ssdstiffener->SetLineColor(fColorStiffener); 
2304
2305 ////////////////////////////
2306 // Capacitor 0603-2200 nF
2307 ///////////////////////////
2308   const Int_t knapacitor0603number = 5;
2309   TGeoBBox* capacitor0603mothershape =  new TGeoBBox("Capacitor0603MotherShape",
2310                                                0.5*fgkSSDCapacitor0603Length + fgkSSDCapacitor0603CapLength,
2311                                                0.5*fgkSSDCapacitor0603Width,
2312                                                0.5*fgkSSDCapacitor0603Height);
2313   TGeoVolume* capacitor0603mother = new TGeoVolume("Capacitor0603Mother",capacitor0603mothershape,
2314                                              fSSDAir); 
2315
2316   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
2317                                                0.5*fgkSSDCapacitor0603Length,
2318                                                0.5*fgkSSDCapacitor0603Width,
2319                                                0.5*fgkSSDCapacitor0603Height);
2320   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
2321                                              fSSDStiffener0603CapacitorMedium); 
2322   capacitor0603->SetLineColor(fColorAl);
2323   TGeoTranslation *cap0603trans = new TGeoTranslation(0.,0.,0.);
2324   capacitor0603mother->AddNode(capacitor0603,1,cap0603trans);
2325
2326   TGeoBBox* capacitor0603capshape =  new TGeoBBox("Capacitor0603CapShape",
2327                                                0.5*fgkSSDCapacitor0603CapLength,
2328                                                0.5*fgkSSDCapacitor0603Width,
2329                                                0.5*fgkSSDCapacitor0603Height);
2330   TGeoVolume* capacitor0603cap = new TGeoVolume("Capacitor0603Cap",capacitor0603capshape,
2331                                              fSSDStiffenerCapacitorCapMedium); 
2332   capacitor0603cap->SetLineColor(fColorNiSn);
2333   TGeoTranslation *cap0603captrans1 = new TGeoTranslation(- capacitor0603shape->GetDX() - capacitor0603capshape->GetDX(),0.,0.);
2334   capacitor0603mother->AddNode(capacitor0603cap,1,cap0603captrans1);
2335   TGeoTranslation *cap0603captrans2 = new TGeoTranslation(capacitor0603shape->GetDX() + capacitor0603capshape->GetDX(),0.,0.);
2336   capacitor0603mother->AddNode(capacitor0603cap,2,cap0603captrans2);
2337
2338
2339   TGeoVolume* ssdchip = GetSSDChip();
2340
2341   const Int_t knedges = 5;
2342   TGeoVolume *ssdchipcables[2];
2343
2344   for(Int_t i=0; i<kmothernumber; i++){
2345     for(Int_t j=0; j<kssdstiffenernumber; j++){
2346       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
2347       for(Int_t k=1; k<knapacitor0603number+1; k++){
2348         ssdhybridmother[i][j]->AddNode(capacitor0603mother,k,
2349                                        new TGeoCombiTrans("",
2350                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
2351                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
2352                                                           (k-3.)/6*fgkSSDStiffenerLength,
2353                                                           hybridmotherrotInv));
2354       }
2355     }
2356     
2357     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
2358     for(Int_t k=0; k<fgkSSDChipNumber; k++){
2359       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
2360                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
2361                                                             - fgkSSDChipCablesHeight[i+2],
2362                                                             (k+0.5-fgkSSDChipNumber/2)*
2363                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
2364       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
2365                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
2366                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
2367                                                      hybridmotherrotInv);
2368       for(Int_t j=0; j<kssdstiffenernumber; j++){
2369         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
2370         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
2371       }
2372     }  
2373     // Final placement by assembly
2374     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
2375     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
2376     ssdhybridlist->Add(ssdhybridassembly[i]);
2377   }    
2378   /////////////////////////////////////////////////////////////
2379   // Mother Volume Containing Capacitor Part 
2380   /////////////////////////////////////////////////////////////
2381   const Int_t kcapacitormothernumber = 8;
2382   Double_t xcapacitorvertex[kcapacitormothernumber];
2383   Double_t ycapacitorvertex[kcapacitormothernumber];  
2384   ///////////////////////
2385   // Setting the vertices 
2386   ///////////////////////
2387   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
2388   xcapacitorvertex[1] = xcapacitorvertex[0];   
2389   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
2390   xcapacitorvertex[3] = xcapacitorvertex[2];   
2391   xcapacitorvertex[4] = xcapacitorvertex[0];   
2392   xcapacitorvertex[5] = xcapacitorvertex[0];   
2393   xcapacitorvertex[6] = -xcapacitorvertex[0];   
2394   xcapacitorvertex[7] = xcapacitorvertex[6];   
2395   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
2396   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
2397   ycapacitorvertex[2] = ycapacitorvertex[1];   
2398   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
2399   ycapacitorvertex[4] = ycapacitorvertex[3];   
2400   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
2401   ycapacitorvertex[6] = ycapacitorvertex[5];   
2402   ycapacitorvertex[7] = ycapacitorvertex[0];   
2403   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
2404   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
2405                                               ycapacitorvertex);
2406   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
2407   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
2408 //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
2409 //                                          fSSDAir);
2410   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
2411 ////////////////////////////
2412 // Connector 
2413 ///////////////////////////
2414   const Int_t kssdconnectorlayernumber = 3;
2415   TGeoBBox* ssdconnectorshape[kssdconnectorlayernumber];
2416   Double_t ssdConnectorThickness[kssdconnectorlayernumber]={fgkSSDConnectorAlHeight,fgkSSDConnectorNiHeight,fgkSSDConnectorSnHeight};
2417   /*
2418   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
2419   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
2420                                    +  fgkSSDConnectorAlHeight};  
2421   */
2422   Double_t ssdconnectororigin[3] = {0,0,0.5*fgkSSDStiffenerHeight};
2423   const char* ssdconnectorname[kssdconnectorlayernumber] = {"SSDConnectorAl","SSDConnectorNi","SSDConnectorSn"};
2424   TGeoMedium *ssdConnectorMedium[kssdconnectorlayernumber]={fSSDAlTraceFlexMedium,fSSDStiffenerConnectorMedium,fSSDSn};
2425   TGeoVolume* ssdconnector[kssdconnectorlayernumber];
2426   for(Int_t i=0; i<kssdconnectorlayernumber; i++){
2427     ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2428       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
2429                                           0.5*fgkSSDConnectorWidth,
2430                                           0.5*ssdConnectorThickness[i],
2431                                           ssdconnectororigin);
2432       ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
2433       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
2434                                        ssdConnectorMedium[i]);      
2435       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorNiSn);
2436   }
2437   const Int_t kssdconnectornumber = 4;
2438   TGeoTranslation* ssdconnectortrans[kssdconnectornumber];
2439   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
2440                        +  fgkSSDConnectorPosition[0]
2441                        -  fgkSSDConnectorSeparation
2442                        -  1.5*fgkSSDConnectorLength,
2443                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2444                        -  fgkSSDConnectorPosition[1]
2445                        -  ssdconnectorshape[0]->GetDY(),0.0);   
2446   ssdconnectortrans[1] = new TGeoTranslation(
2447                        -  ssdstiffenershape->GetDX()
2448                        +  fgkSSDConnectorPosition[0]
2449                        -  0.5*fgkSSDConnectorLength,
2450                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
2451                        -  fgkSSDConnectorPosition[1]
2452                        -  ssdconnectorshape[0]->GetDY(),0.0);
2453   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2454                        -  fgkSSDConnectorPosition[0]
2455                        +  fgkSSDConnectorSeparation
2456                        +  1.5*fgkSSDConnectorLength,
2457                           -(ssdstiffenershape->GetDY()
2458                        -  fgkSSDConnectorPosition[1]
2459                        -  ssdconnectorshape[0]->GetDY()),0.0);  
2460   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
2461                        -  fgkSSDConnectorPosition[0]
2462                        +  0.5*fgkSSDConnectorLength,
2463                           -(ssdstiffenershape->GetDY()
2464                        -  fgkSSDConnectorPosition[1]
2465                        -  ssdconnectorshape[0]->GetDY()),0.0);
2466   for(Int_t i=0; i<kssdconnectornumber; i++) {
2467     Int_t nlay = kssdconnectorlayernumber - 1;
2468     if (i == 1 || i == 2)
2469       nlay++;
2470     for(Int_t j=0; j<nlay; j++)
2471       ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
2472   }
2473 ////////////////////////////
2474 // Capacitor 1812-330 nF
2475 /////////////////////////// 
2476 //  Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
2477   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
2478                                                                                          0.5*fgkSSDCapacitor1812Length,
2479                                                                                          0.5*fgkSSDCapacitor1812Width,
2480                                                0.5*fgkSSDCapacitor1812Height);
2481   //            ssdcapacitor1812origin);
2482   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
2483                                              fSSDStiffener1812CapacitorMedium); 
2484   capacitor1812->SetLineColor(fColorAl);
2485   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
2486                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2487                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2488   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
2489
2490   TGeoBBox* capacitor1812capshape =  new TGeoBBox("Capacitor1812CapShape",
2491     0.5*fgkSSDCapacitor1812CapLength, 0.5*fgkSSDCapacitor1812Width,
2492     0.5*fgkSSDCapacitor1812Height);
2493   TGeoVolume* capacitor1812cap = new TGeoVolume("Capacitor1812Cap",capacitor1812capshape,
2494                                              fSSDStiffenerCapacitorCapMedium);
2495   capacitor1812cap->SetLineColor(fColorNiSn);
2496   TGeoTranslation* capacitor1812captrans1 = new TGeoTranslation(
2497         - capacitor1812shape->GetDX() - capacitor1812capshape->GetDX(),
2498         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2499         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2500         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2501   ssdhybridcapacitormother->AddNode(capacitor1812cap,1,capacitor1812captrans1);
2502   TGeoTranslation* capacitor1812captrans2 = new TGeoTranslation(
2503         capacitor1812shape->GetDX() + capacitor1812capshape->GetDX(),
2504         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
2505         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
2506         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
2507   ssdhybridcapacitormother->AddNode(capacitor1812cap,2,capacitor1812captrans2);
2508
2509 ////////////////////////////
2510 //Hybrid Wire
2511 ////////////////////////////
2512   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
2513                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
2514                                  - fgkSSDConnectorSeparation;
2515   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
2516                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
2517   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
2518
2519   Double_t wireangle = TMath::ATan(wirex/wirey);
2520   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
2521                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
2522   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
2523                                              fSSDStiffenerHybridWireMedium); 
2524   hybridwire->SetLineColor(fColorPhynox);
2525   TGeoCombiTrans* hybridwirecombitrans[2];
2526   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
2527                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
2528                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
2529                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
2530                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
2531                                    ssdstiffenershape->GetDZ()
2532                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight+fgkSSDConnectorSnHeight,
2533                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
2534   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
2535                             0.0,
2536                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
2537                             0.0,        
2538                             new TGeoRotation("HybridWireRot2",
2539                           - wireangle*TMath::RadToDeg(),0.,0.));
2540   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
2541   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
2542   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
2543   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
2544   ssdhybridlist->Add(ssdhybridcapacitormother);
2545   /////////////////////////////////////////////////////////////
2546   // Deallocating memory
2547   /////////////////////////////////////////////////////////////
2548   delete hybridwirecombitrans[0];
2549   delete hybridwirecombitrans[1];
2550   return ssdhybridlist;
2551   /////////////////////////////////////////////////////////////
2552 }
2553 ///////////////////////////////////////////////////////////////////////////////
2554 TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
2555   /////////////////////////////////////////////////////////////
2556   // SSD Cooling Block System
2557   /////////////////////////////////////////////////////////////
2558   // SSD Cooling Block and Cooling Tube Transformations
2559   /////////////////////////////////////////////////////////////
2560   TGeoRotation* localcoolingblockrot = new TGeoRotation();
2561   localcoolingblockrot->SetAngles(0.,90.,0.);
2562   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
2563   TVector3* coolingblocktransvector;
2564   coolingblocktransvector = new TVector3(fgkCoolingTubeSeparation,
2565                                                                   fgkSSDSensorLength
2566                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
2567                                                                 - fgkSSDCoolingBlockWidth);
2568   const Int_t kcoolingblocktransnumber = 2;
2569   const Int_t kcoolingblocknumber = 4;
2570   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
2571   TGeoRotation* localcoolingtuberot = new TGeoRotation();
2572   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
2573   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
2574     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
2575       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X(),//+2*coolingtubedistance,
2576                                              j*coolingblocktransvector->Y(),
2577                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
2578                                                     + fgkCoolingTubeRmax));
2579       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
2580     }
2581   }
2582   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
2583   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
2584   /////////////////////////////////////////////////////////////
2585   // Adding Cooling block to mother volume
2586   /////////////////////////////////////////////////////////////
2587   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
2588     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
2589   }
2590   /////////////////////////////////////////////////////////////
2591   // Deallocating memory
2592   /////////////////////////////////////////////////////////////
2593   delete coolingblocktransvector;
2594   delete localcoolingblockrot;
2595
2596   return coolingsystemother;
2597 }
2598 /////////////////////////////////////////////////////////////////////////////////
2599 TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
2600   /////////////////////////////////////////////////////////////
2601   // SSD Flex
2602   /////////////////////////////////////////////////////////////
2603   const Int_t kssdflexlayernumber = 2;
2604   TGeoXtru* ssdflexshape[kssdflexlayernumber];
2605   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
2606   const Int_t&