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