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