81f180e35db2f3392245b0c12af42794711a54d8
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySDD.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
17 //*************************************************************************
18 //
19 // SDD geometry, based on ROOT geometrical modeler
20 //
21 //
22 // This geometry has no dependence with aliroot, you can run it with root
23 // only, provided that the AliITSv11GeomCable classes are also compiled
24 //
25 // Ludovic Gaudichet                                   gaudichet@to.infn.it
26 //*************************************************************************
27
28
29 // $Id$
30
31
32 // General Root includes
33 #include <TMath.h>
34
35 // Root Geometry includes
36 #include <TGeoManager.h>
37 #include <TGeoVolume.h>
38 #include <TGeoCone.h>
39 #include <TGeoTube.h>
40 #include <TGeoTrd1.h>
41 #include <TGeoArb8.h>
42 #include <TGeoCompositeShape.h>
43 #include <TGeoMatrix.h>
44 #include <TGeoNode.h>
45 #include <TGeoPcon.h>
46 #include <TGeoTorus.h>
47
48 #include "AliITSgeom.h"
49 #include "AliITSgeomSDD.h"
50 #include "AliITSv11GeometrySDD.h"
51 #include "AliITSv11GeomCableFlat.h"
52 #include "AliITSv11GeomCableRound.h"
53
54 const char*    AliITSv11GeometrySDD::fgSDDsensitiveVolName3 = "ITSsddSensitivL3";
55 const char*    AliITSv11GeometrySDD::fgSDDsensitiveVolName4 = "ITSsddSensitivL4";
56 const Double_t AliITSv11GeometrySDD::fgkSegmentLength     = 37.2*2*fgkmm;
57 const Double_t AliITSv11GeometrySDD::fgkLadderWidth       = 50.0*fgkmm;
58 const Double_t AliITSv11GeometrySDD::fgkLadderHeight      = 30.0*fgkmm;
59 const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDW    =  3.5*fgkmm;
60 const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDH    =  3.*fgkmm;
61
62 const Double_t AliITSv11GeometrySDD::fgkLadderBeamRadius  =  0.6*fgkmm;
63 const Double_t AliITSv11GeometrySDD::fgkLadderLa          =  3.*fgkmm;
64 const Double_t AliITSv11GeometrySDD::fgkLadderHa          =  0.721979*fgkmm;
65 const Double_t AliITSv11GeometrySDD::fgkLadderLb          =  3.7*fgkmm;
66 const Double_t AliITSv11GeometrySDD::fgkLadderHb          =  0.890428*fgkmm;
67 const Double_t AliITSv11GeometrySDD::fgkLadderl           =  0.25*fgkmm;
68
69 const Double_t AliITSv11GeometrySDD::fgkBottomBeamAngle   = 56.5;
70 const Double_t AliITSv11GeometrySDD::fgkBeamSidePhi       = 65;
71
72 const Double_t AliITSv11GeometrySDD::fgkLadWaferSep       = 2*fgkmm;
73 const Double_t AliITSv11GeometrySDD::fgkPinSuppWidth      = 2.5*fgkmm;
74 const Double_t AliITSv11GeometrySDD::fgkPinSuppHeight     = 2.*fgkmm;
75 const Double_t AliITSv11GeometrySDD::fgkPinSuppRmax       = 2.5/2.*fgkmm;
76 const Double_t AliITSv11GeometrySDD::fgkPinR              = 1.5/2.*fgkmm;
77 const Double_t AliITSv11GeometrySDD::fgkPinSuppLength     = 5.*fgkmm;
78 const Double_t AliITSv11GeometrySDD::fgkPinSuppThickness  = 0.5*fgkmm;
79 const Double_t AliITSv11GeometrySDD::fgkPinSuppConeAngle  = 4;
80 const Double_t AliITSv11GeometrySDD::fgkPinDXminOnSensor  = (39./2.)*fgkmm;
81 const Double_t AliITSv11GeometrySDD::fgkPinPinDDXOnSensor = 3*fgkmm;
82 const Double_t AliITSv11GeometrySDD::fgkPinDYOnSensor     = (52.5/2.)*fgkmm;
83
84 // parameters from ALR-0752/3
85 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppHeight    =  3.2*fgkmm;  
86 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppMaxLength = 14*fgkmm;
87 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppWidthExt  =  0.4*fgkmm;
88 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppWidthIn   =  0.65*fgkmm;
89 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppHoleDiam  =  2*fgkmm;
90 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppFulWidth  =  5.15*fgkmm;
91 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppTongW     =  0.8*fgkmm; 
92 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppAngle     = 22.5;
93 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppSlitL     =  4.9*fgkmm;
94 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppAxeDist   =  3.05*fgkmm;
95 const Double_t AliITSv11GeometrySDD::fgkCoolPipeInnerDiam     =  1.84*fgkmm;
96 const Double_t AliITSv11GeometrySDD::fgkCoolPipeOuterDiam     =  2.*fgkmm;
97
98 const Double_t AliITSv11GeometrySDD::fgkBTBthick           =  0.25 *fgkmm;
99 const Double_t AliITSv11GeometrySDD::fgkBTBlength          = 55. *fgkmm;
100 const Double_t AliITSv11GeometrySDD::fgkBTBwidth           = 18*fgkmm;
101 const Double_t AliITSv11GeometrySDD::fgkBTBaxisAtoBottom   =  4*fgkmm;
102 const Double_t AliITSv11GeometrySDD::fgkBTBaxisAtoBase     =  1.2*fgkmm;
103 const Double_t AliITSv11GeometrySDD::fgkRadiusAminBTB      =  1. *fgkmm;
104 const Double_t AliITSv11GeometrySDD::fgkRadiusBminBTB      =  0.53 *fgkmm;
105 const Double_t AliITSv11GeometrySDD::fgkBTBHoleLength      = 15 *fgkmm;
106 const Double_t AliITSv11GeometrySDD::fgkBTBHolewidth       =  6 *fgkmm;
107 const Double_t AliITSv11GeometrySDD::fgkBTBHoleRefX        = 10 *fgkmm;
108 const Double_t AliITSv11GeometrySDD::fgkBTBHoleRefY        =  6.5 *fgkmm;
109
110 const Double_t AliITSv11GeometrySDD::fgkLay3Rmin           = 129.*fgkmm;
111 const Double_t AliITSv11GeometrySDD::fgkLay3Rmax           = 200.*fgkmm;
112 const Double_t AliITSv11GeometrySDD::fgkLay3Length         = (524.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
113 const Double_t AliITSv11GeometrySDD::fgkLay3LadderLength   = 524.*fgkmm;
114 const Double_t AliITSv11GeometrySDD::fgkLay3DetShortRadius = 146.0*fgkmm;
115 const Double_t AliITSv11GeometrySDD::fgkLay3DetLongRadius  = 152.0*fgkmm;
116 const Double_t AliITSv11GeometrySDD::fgkLay3LaddTopCornerEnd = 15.6*fgkmm;
117 const Int_t    AliITSv11GeometrySDD::fgkLay3Ndet           =  6;
118 const Int_t    AliITSv11GeometrySDD::fgkLay3Nladd          = 14;
119 const Double_t AliITSv11GeometrySDD::fgkLay3CoolPipeSuppH  =  7.5*fgkmm;
120
121 const Double_t AliITSv11GeometrySDD::fgkLay4Rmin           = 220.*fgkmm;
122 const Double_t AliITSv11GeometrySDD::fgkLay4Rmax           = 286.*fgkmm;
123 const Double_t AliITSv11GeometrySDD::fgkLay4Length         = (671.+0.)*fgkmm;    // ladder+supporting rings (length of the virtual tube)
124 const Double_t AliITSv11GeometrySDD::fgkLay4LadderLength   = 671.*fgkmm;
125 const Double_t AliITSv11GeometrySDD::fgkLay4DetShortRadius = 235.0*fgkmm;
126 const Double_t AliITSv11GeometrySDD::fgkLay4DetLongRadius  = 240.5*fgkmm;
127 const Double_t AliITSv11GeometrySDD::fgkLay4LaddTopCornerEnd = 15.6*fgkmm;
128 const Int_t    AliITSv11GeometrySDD::fgkLay4Ndet           = 8;
129 const Int_t    AliITSv11GeometrySDD::fgkLay4Nladd          = 22;
130 const Double_t AliITSv11GeometrySDD::fgkLay4CoolPipeSuppH  = 7.5*fgkmm;
131
132 const Double_t AliITSv11GeometrySDD::fgkEndLaddCardsShortRadiusLay3 = fgkLay3DetShortRadius;
133 const Double_t AliITSv11GeometrySDD::fgkEndLaddCardsShortRadiusLay4 = fgkLay4DetShortRadius;
134 const Double_t AliITSv11GeometrySDD::fgkDistEndLaddCardsLadd = 0.*fgkmm;
135
136 //hybrid 
137 const Double_t AliITSv11GeometrySDD::fgkHybridAngle       = 46;           // approx !!!
138 // Origine taken at the hybrid corner :
139 const Double_t AliITSv11GeometrySDD::fgkHybridLength      = 65*fgkmm;
140 const Double_t AliITSv11GeometrySDD::fgkHybridWidth       = 41*fgkmm;
141 const Double_t AliITSv11GeometrySDD::fgkHybRndHoleRad     = 1.05*fgkmm;
142 const Double_t AliITSv11GeometrySDD::fgkHybRndHoleZ       = 2.5*fgkmm;
143 const Double_t AliITSv11GeometrySDD::fgkHybRndHoleX       = fgkHybridWidth-23.599*fgkmm;
144
145 const Double_t AliITSv11GeometrySDD::fgkHybFLlowHoleDZ    =   9.698*fgkmm; 
146 const Double_t AliITSv11GeometrySDD::fgkHybFLlowHolePasDX =  10.754*fgkmm; 
147 const Double_t AliITSv11GeometrySDD::fgkHybFLlowHoleAmbDX =   9.122*fgkmm;
148   // center of ships to the border
149 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ4    = fgkHybridLength-(4.654      )*fgkmm-fgkHybFLlowHoleDZ/2;
150 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ3    = fgkHybridLength-(4.654+15.  )*fgkmm-fgkHybFLlowHoleDZ/2;
151 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ2    = fgkHybridLength-(4.654+15.*2)*fgkmm-fgkHybFLlowHoleDZ/2;
152 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ1    = fgkHybridLength-(4.654+15.*3)*fgkmm-fgkHybFLlowHoleDZ/2;
153 const Double_t AliITSv11GeometrySDD::fgkHybFLlowPasX      = fgkHybridWidth-32.775*fgkmm;       
154 const Double_t AliITSv11GeometrySDD::fgkHybFLlowAmbX      = fgkHybridWidth-20.791*fgkmm;
155 const Double_t AliITSv11GeometrySDD::fgkHybChipsDZ        =  9.221*fgkmm; 
156 const Double_t AliITSv11GeometrySDD::fgkHybPascalDX       = 10.245*fgkmm; 
157 const Double_t AliITSv11GeometrySDD::fgkHybAmbraDX        =  8.51*fgkmm; 
158 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperWidth   = 15.012*fgkmm;
159 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperLength  = 59.878*fgkmm;
160 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperAlDZ    = 11.183*fgkmm;
161 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperAldx    =  2.307*fgkmm;
162
163 const Double_t AliITSv11GeometrySDD::fgkmu = 1*fgkmicron; // 1*fgkmicron; // can be increase for checking thin objects
164 const Double_t AliITSv11GeometrySDD::fgkHybridThBridgeThick =  0.25*fgkmm;               // ???
165 const Double_t AliITSv11GeometrySDD::fgkHybAlThick         =  30*fgkmu;
166 const Double_t AliITSv11GeometrySDD::fgkHybUpThick         =  20*fgkmu;
167 const Double_t AliITSv11GeometrySDD::fgkHybGlueScrnThick   =  50*fgkmu;           // ??? ?????
168 const Double_t AliITSv11GeometrySDD::fgkHybGlueLowThick    =  90*fgkmu;
169 const Double_t AliITSv11GeometrySDD::fgkHybGlueUpThick     =  90*fgkmu;           // sur ?????
170 const Double_t AliITSv11GeometrySDD::fgkHybAlCCThick       =  12*fgkmu;
171 const Double_t AliITSv11GeometrySDD::fgkHybUpCCThick       =  12*fgkmu;
172 const Double_t AliITSv11GeometrySDD::fgkHybChipThick       = 150*fgkmu;
173 const Double_t AliITSv11GeometrySDD::fgkHybGlueAgThick     =  50*fgkmu;          // ??? ????
174 const Double_t AliITSv11GeometrySDD::fgkHybUnderNiThick    =  20*fgkmu;          // ??? ????
175 const Int_t    AliITSv11GeometrySDD::fgkNHybSMD = 25;
176 const Double_t AliITSv11GeometrySDD::fgkHybSMDposX[fgkNHybSMD]     = 
177           {2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,21.40*fgkmm,
178            2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,19.91*fgkmm,
179            2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,17.09*fgkmm,21.40*fgkmm,
180            2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,19.91*fgkmm,
181            1.63*fgkmm,5.22*fgkmm,13.59*fgkmm,21.40*fgkmm};
182 const Double_t AliITSv11GeometrySDD::fgkHybSMDposZ[fgkNHybSMD]     = 
183          { 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm,
184            17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,
185            32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,
186            47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,
187            62.68*fgkmm,62.06*fgkmm,62.06*fgkmm,62.06*fgkmm};
188 const Double_t AliITSv11GeometrySDD::fgkHybSMDmiddleW      =   0.954*fgkmm;
189 const Double_t AliITSv11GeometrySDD::fgkHybSMDmiddleL      =   0.47 *fgkmm;
190 const Double_t AliITSv11GeometrySDD::fgkHybSMDendW         =   1.132*fgkmm;
191 const Double_t AliITSv11GeometrySDD::fgkHybSMDendL         =   0.925*fgkmm;
192 const Double_t AliITSv11GeometrySDD::fgkHybSMDheight       = 400.*fgkmu;          // ??? ????!!!!!!!
193
194 const Double_t AliITSv11GeometrySDD::fgkWaferThickness     = 300.*fgkmu;
195 const Double_t AliITSv11GeometrySDD::fgkWaferWidth         =  72.5 *fgkmm;
196 const Double_t AliITSv11GeometrySDD::fgkWaferLength        =  87.6 *fgkmm;
197 const Double_t AliITSv11GeometrySDD::fgkWaferThickSens     = 299.8*fgkmu;
198 const Double_t AliITSv11GeometrySDD::fgkWaferWidthSens     =  70.17*fgkmm;
199 // 256 anodes times 294 microns of pitch
200 const Double_t AliITSv11GeometrySDD::fgkWaferLengthSens    =  256*294*fgkmicron;
201
202 const Double_t AliITSv11GeometrySDD::fgkDigitCablWidth     = 18.4*fgkmm;
203 const Double_t AliITSv11GeometrySDD::fgkDigitCablAlThick   = (30+30*8./10.)*fgkmicron; // will probably change
204 const Double_t AliITSv11GeometrySDD::fgkDigitCablPolyThick = (20+12)*fgkmicron;        // will probably change
205
206 const Double_t AliITSv11GeometrySDD::fgkWaHVcableAlThick   = 30*2./10.*fgkmu;  // will probably change // Al ratio is random !!!
207 const Double_t AliITSv11GeometrySDD::fgkWaHVcablePolyThick = 175*fgkmu;        // will probably change
208 const Double_t AliITSv11GeometrySDD::fgkWaHVcableLength    = 67.08*fgkmm;
209 const Double_t AliITSv11GeometrySDD::fgkWaHVcableWitdh     = 17.4*fgkmm;              //  check !!!
210 const Double_t AliITSv11GeometrySDD::fgkWaHVcableDW        = 5.24*fgkmm; //5.24*fgkmm;//  check !!!
211
212 const Double_t AliITSv11GeometrySDD::fgkSensorGlassLX      =   5.  *fgkmm; 
213 const Double_t AliITSv11GeometrySDD::fgkSensorGlassLZ      =   5.  *fgkmm; 
214 const Double_t AliITSv11GeometrySDD::fgkSensorGlassLY      = 150.  *fgkmu;
215 const Double_t AliITSv11GeometrySDD::fgkGlassDXOnSensor    =  26.28*fgkmm;             //  check !!!
216 const Double_t AliITSv11GeometrySDD::fgkGlassDZOnSensor    =  22.50*fgkmm;             //  check !!!
217
218 const Double_t AliITSv11GeometrySDD::fgkTransitHVAlThick    = 30*2./10.*fgkmu; //  check // will probably change //Al ratio is random
219 const Double_t AliITSv11GeometrySDD::fgkTransitHVPolyThick  = 100*fgkmu;       //  check  // will probably change
220 const Double_t AliITSv11GeometrySDD::fgkTransitHVHeadLX     =  71.46*fgkmm;           //  check !!!
221 const Double_t AliITSv11GeometrySDD::fgkTransitHVHeadLZ     =  21.3*fgkmm;
222 const Double_t AliITSv11GeometrySDD::fgkTransitHVBondingLZ  =   3.6*fgkmm;
223 const Double_t AliITSv11GeometrySDD::fgkTransitHVtailLength =  27*fgkmm;              // ???, not yet fixed ...
224 const Double_t AliITSv11GeometrySDD::fgkTransitHVtailWidth  =  26*fgkmm;
225 const Double_t AliITSv11GeometrySDD::fgkTransitHVtailXpos   =   8*fgkmm;    //8*fgkmm          // ???, a mesurer !!!
226 const Double_t AliITSv11GeometrySDD::fgkTransitHVsideLZ     =  10.34*fgkmm;
227 const Double_t AliITSv11GeometrySDD::fgkTransitHVsideLeftZ  =   4.11*fgkmm;
228 const Double_t AliITSv11GeometrySDD::fgkTransitHVsideRightZ =   3.5*fgkmm;           // ???, a mesurer !!!
229
230 const Double_t AliITSv11GeometrySDD::fgkLongHVcablePolyThick= (20+30+125+30+20+30+125+30+20)*fgkmu; //  check  // will probably change
231 const Double_t AliITSv11GeometrySDD::fgkLongHVcableAlThick  = (30+30*2/10+30)*fgkmu;                //  check  // will probably change
232 const Double_t AliITSv11GeometrySDD::fgkLongHVcableSeparation = 600*fgkmicron;
233
234 const Double_t AliITSv11GeometrySDD::fgkRubyDX              =  14.*fgkmm;
235 const Double_t AliITSv11GeometrySDD::fgkRubyZladd3          = 250*fgkmm;
236 const Double_t AliITSv11GeometrySDD::fgkRubyZladd4          = 325*fgkmm;
237
238 // the stesalite ladder foot at its end
239 const Double_t AliITSv11GeometrySDD::fgkLadFootX         = 60.*fgkmm;
240 const Double_t AliITSv11GeometrySDD::fgkLadFootZ         = 20.*fgkmm;
241 const Double_t AliITSv11GeometrySDD::fgkLadFootY         =  8.*fgkmm;
242 const Double_t AliITSv11GeometrySDD::fgkLadFootMiddleY    =  4.5*fgkmm;
243 const Double_t AliITSv11GeometrySDD::fgkLadBox1X         = 23.*fgkmm;
244 const Double_t AliITSv11GeometrySDD::fgkLadFingerPrintX  =  6.*fgkmm;
245 const Double_t AliITSv11GeometrySDD::fgkLadFingerPrintY  =  1.*fgkmm;
246 const Double_t AliITSv11GeometrySDD::fgkLadFingerPrintBorder = 4.*fgkmm;
247 const Double_t AliITSv11GeometrySDD::fgkRubyCageHoleZ     =  8.*fgkmm;
248 const Double_t AliITSv11GeometrySDD::fgkRubyCageHoleX     =  9.*fgkmm;
249 const Double_t AliITSv11GeometrySDD::fgkRubyCageHoleY     =  6.5*fgkmm;
250 const Double_t AliITSv11GeometrySDD::fgkRubyCageAxisShift =  0.5*fgkmm;
251 const Double_t AliITSv11GeometrySDD::fgkScrewM4diam       =  4.*fgkmm;
252
253 const Double_t AliITSv11GeometrySDD::fgkRubyScrewShiftToCenterY = 0.1;
254 const Double_t AliITSv11GeometrySDD::fgkRubyHoleDiam            = 0.5;
255
256 // the U cooling pipe and its heat exchanger in end-ladder cards system
257 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeUlengthLay3 = 138*fgkmm;
258 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeUlengthLay4 = 150*fgkmm;
259 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeUwidth      =  59*fgkmm;
260 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeRadius      =   5*fgkmm;
261 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeInnerDiam   =   2.8*fgkmm;
262 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeOuterDiam   =   3.*fgkmm;
263 //--- The al body of the cooling syst.of the heat exchanger :
264 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZLay3    = 112.*fgkmm;   //
265 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZLay4    = 125.*fgkmm;   //
266 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmX        =   4.75*fgkmm; // the arms of the U cooling tube
267 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmY        =   6.8*fgkmm;
268 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmBoxDY    =   1.03*fgkmm; // shift in Y of the arms from the axis
269 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmBoxDX    =   0.125*fgkmm;// shift in X of the arms from the axis
270 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZpos     =   8.9*fgkmm;  // 
271
272 // LV card :
273 const Double_t AliITSv11GeometrySDD::fgkLVcardX     = 26.525*fgkmm;
274 const Double_t AliITSv11GeometrySDD::fgkLVcardY     = 44.95*fgkmm;
275 const Double_t AliITSv11GeometrySDD::fgkLVcardZ     = 1.*fgkmm; // all except Cu layer   //???
276 const Double_t AliITSv11GeometrySDD::fgkLVcardCuZ   = 0.1*fgkmm;   //???
277
278 const Double_t AliITSv11GeometrySDD::fgkLVChip0X    = 16.525*fgkmm;
279 const Double_t AliITSv11GeometrySDD::fgkLVChip0Y    = 10.8*fgkmm;
280 const Double_t AliITSv11GeometrySDD::fgkLVChip0Z    =  3.5*fgkmm; // all except si layer   //???
281 const Double_t AliITSv11GeometrySDD::fgkLVChip0SiZ  =  0.2*fgkmm; //???????????????????????????????????????????????????
282 const Double_t AliITSv11GeometrySDD::fgkLVChip0PosX = 13.*fgkmm; //19.95*fgkmm;  ???
283 const Double_t AliITSv11GeometrySDD::fgkLVChip0PosY = 10.3*fgkmm;
284
285 const Double_t AliITSv11GeometrySDD::fgkLVChip1X    = 6.00*fgkmm;
286 const Double_t AliITSv11GeometrySDD::fgkLVChip1Y    = 6.00*fgkmm;
287 const Double_t AliITSv11GeometrySDD::fgkLVChip1Z    = 1*fgkmm;  // ???
288 const Double_t AliITSv11GeometrySDD::fgkLVChip1SiZ  = 0.2*fgkmm;  // ???
289 const Double_t AliITSv11GeometrySDD::fgkLVChip1PosX = 18.*fgkmm;
290 const Double_t AliITSv11GeometrySDD::fgkLVChip1PosY = 27.6*fgkmm;
291
292 const Double_t AliITSv11GeometrySDD::fgkLVChip2X    = 6.00*fgkmm;
293 const Double_t AliITSv11GeometrySDD::fgkLVChip2Y    = 6.00*fgkmm;
294 const Double_t AliITSv11GeometrySDD::fgkLVChip2Z    = 1*fgkmm;    // ???
295 const Double_t AliITSv11GeometrySDD::fgkLVChip2SiZ  = 0.2*fgkmm;  //???
296 const Double_t AliITSv11GeometrySDD::fgkLVChip2PosX = 18.0*fgkmm;
297 const Double_t AliITSv11GeometrySDD::fgkLVChip2PosY = 39.0*fgkmm;
298
299 const Double_t AliITSv11GeometrySDD::fgkLVChip3X    = 4.01*fgkmm;
300 const Double_t AliITSv11GeometrySDD::fgkLVChip3Y    = 4.01*fgkmm;
301 const Double_t AliITSv11GeometrySDD::fgkLVChip3Z    = 1*fgkmm; // ???
302 const Double_t AliITSv11GeometrySDD::fgkLVChip3SiZ  = 0.2*fgkmm;
303 const Double_t AliITSv11GeometrySDD::fgkLVChip3PosX = 20.7*fgkmm;
304 const Double_t AliITSv11GeometrySDD::fgkLVChip3PosY = 21.4*fgkmm;
305
306 const Double_t AliITSv11GeometrySDD::fgkLVcoolX1    = 17.25*fgkmm;
307 const Double_t AliITSv11GeometrySDD::fgkLVcoolY1    =  8.7*fgkmm;
308 const Double_t AliITSv11GeometrySDD::fgkLVcoolZ1    =  1.*fgkmm;
309
310 const Double_t AliITSv11GeometrySDD::fgkLVcoolX2    =  3.5*fgkmm;
311 const Double_t AliITSv11GeometrySDD::fgkLVcoolY2    =  8.7*fgkmm;
312 const Double_t AliITSv11GeometrySDD::fgkLVcoolZ2    =  2.3*fgkmm;
313
314 const Double_t AliITSv11GeometrySDD::fgkLVcoolX3    =  4.75*fgkmm;
315 const Double_t AliITSv11GeometrySDD::fgkLVcoolY3    =  3.1*fgkmm; //+0.1=glue
316 const Double_t AliITSv11GeometrySDD::fgkLVcoolPosY  = 6.5*fgkmm;
317
318 // HV card :
319 const Double_t AliITSv11GeometrySDD::fgkHVCardCeramX    = 54.01*fgkmm;
320 const Double_t AliITSv11GeometrySDD::fgkHVCardCeramY    = 40.89*fgkmm;
321 const Double_t AliITSv11GeometrySDD::fgkHVCardCeramZ    =  0.7*fgkmm;  // ???
322
323 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa1X    =   6.8*fgkmm;
324 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa1Z    =   1.*fgkmm;  // ???
325 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa1Ymid =   4.1*fgkmm;
326 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa1Yend =   0.95*fgkmm; // doesn't take into account the soldering
327 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa1PosX =  13.1*fgkmm;
328 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa1PosY =  14.5*fgkmm;
329
330 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa2X    =   6.8*fgkmm;
331 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa2Z    =   1.*fgkmm;  // ???
332 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa2Ymid =   2.9*fgkmm;
333 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa2Yend =   0.95*fgkmm;
334 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa2PosX = -12.6*fgkmm;
335 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa2PosY =  16.54*fgkmm;
336
337 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3Xmid =   3.0*fgkmm;
338 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3Xend =   0.91*fgkmm;
339 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3Z    =   2.*fgkmm;      // ???
340 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3Y    =   3.43*fgkmm;
341
342 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosX1 =  14.6*fgkmm;
343 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosX2 =   7.2*fgkmm;
344 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosX3 =   2.52*fgkmm;
345 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosX4 =  -4.96*fgkmm;
346 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosX5 = -13.82*fgkmm;
347 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosY1 =   6.27*fgkmm;
348 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosY2 =   0.7*fgkmm;
349 const Double_t AliITSv11GeometrySDD::fgkHVCardCapa3PosY3 =   9.1*fgkmm;
350
351 const Double_t AliITSv11GeometrySDD::fgkHVCardCool1X     =  14.*fgkmm;
352 const Double_t AliITSv11GeometrySDD::fgkHVCardCool1Y     =   9.5*fgkmm;
353 const Double_t AliITSv11GeometrySDD::fgkHVCardCool1Z     =   2.*fgkmm;
354 const Double_t AliITSv11GeometrySDD::fgkHVCardCool2X     =  14.25*fgkmm;
355 const Double_t AliITSv11GeometrySDD::fgkHVCardCool2Y     =   3.5*fgkmm;
356 const Double_t AliITSv11GeometrySDD::fgkHVCardCool2Z     =   4.5*fgkmm;
357 const Double_t AliITSv11GeometrySDD::fgkHVCardCool3X     =   4.5*fgkmm;
358 const Double_t AliITSv11GeometrySDD::fgkHVCardCool3Y     =   3.5*fgkmm;
359 const Double_t AliITSv11GeometrySDD::fgkHVCardCool3Z     =   7.2*fgkmm;
360 const Double_t AliITSv11GeometrySDD::fgkHVCardCoolDY     =   6.*fgkmm;
361
362 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppX1     = 19.5*fgkmm;
363 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppY1     =  2*fgkmm;
364 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppX2     = 35.*fgkmm;
365 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppY2     =  3.9*fgkmm;
366 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppZ      = 17.*fgkmm;
367 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppAngle  = 45;
368 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppX3     =  4.5*fgkmm;
369 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppY3     =  3.*fgkmm;
370 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppZ3     = 12.*fgkmm;
371 const Double_t AliITSv11GeometrySDD::fgkCarlosSuppTopLen = 8.65*fgkmm;
372
373 // screws fixing boards to the end-ladder on the U tube
374 const Double_t AliITSv11GeometrySDD::fgkLittleScrewHeadR   = 1.85*fgkmm;
375 const Double_t AliITSv11GeometrySDD::fgkLittleScrewHeadH   = 1.5*fgkmm;
376 const Double_t AliITSv11GeometrySDD::fgkLittleScrewR       = 0.7*fgkmm;
377 const Double_t AliITSv11GeometrySDD::fgkShiftLittleScrewLV = 3*fgkmm;     // ???
378 const Double_t AliITSv11GeometrySDD::fgkLittleLVScrewHeadR = 1.2*fgkmm;   // ???
379
380 // CARLOS board
381 const Double_t AliITSv11GeometrySDD::fgkCarlosCardX1          = (25.50+28.50)*fgkmm; // length (first part of Carlos card)
382 const Double_t AliITSv11GeometrySDD::fgkCarlosCardY1          =    1.6*fgkmm;        // thickness
383 const Double_t AliITSv11GeometrySDD::fgkCarlosCardZ1          =   40.8*fgkmm;        // width 
384 const Double_t AliITSv11GeometrySDD::fgkCarlosCardCuY         =    0.1*fgkmm;   // thickness of Cu layer (strips)
385 const Double_t AliITSv11GeometrySDD::fgkCarlosCardX2          =   25.50*fgkmm;  // length (2nd part of Carlos card)
386 const Double_t AliITSv11GeometrySDD::fgkCarlosCardZ2          =    8.20*fgkmm;  // width 
387
388 const Double_t AliITSv11GeometrySDD::fgkCarlosCardChipSiThick =   0.1*fgkmm;  // ??? idem for all chips ???
389 const Double_t AliITSv11GeometrySDD::fgkCarlosCardShift       =   9*fgkmm;   // ??? shift in z w.r.t. heat bridge 
390
391 // size and position of various chips on carlos end-ladder board
392 const Double_t AliITSv11GeometrySDD::fgkCarlosU1X             =  13*fgkmm;
393 const Double_t AliITSv11GeometrySDD::fgkCarlosU1Y             =   1.68*fgkmm; 
394 const Double_t AliITSv11GeometrySDD::fgkCarlosU1Z             =  13*fgkmm;
395 const Double_t AliITSv11GeometrySDD::fgkCarlosU1posX          =  18.4*fgkmm;
396 const Double_t AliITSv11GeometrySDD::fgkCarlosU1posZ          =  -7.2*fgkmm;
397
398 const Double_t AliITSv11GeometrySDD::fgkCarlosU2X             =  13.75*fgkmm;
399 const Double_t AliITSv11GeometrySDD::fgkCarlosU2Y             =   1.60*fgkmm; 
400 const Double_t AliITSv11GeometrySDD::fgkCarlosU2Z             =  13.85*fgkmm;
401 const Double_t AliITSv11GeometrySDD::fgkCarlosU2posX          =  -0.375*fgkmm;
402 const Double_t AliITSv11GeometrySDD::fgkCarlosU2posZ          =  -9.725*fgkmm;
403
404 const Double_t AliITSv11GeometrySDD::fgkCarlosU3X             =   5*fgkmm;
405 const Double_t AliITSv11GeometrySDD::fgkCarlosU3Y             =   1.*fgkmm;
406 const Double_t AliITSv11GeometrySDD::fgkCarlosU3Z             =   5*fgkmm; 
407 const Double_t AliITSv11GeometrySDD::fgkCarlosU3posX          =   6.4*fgkmm;
408 const Double_t AliITSv11GeometrySDD::fgkCarlosU3posZ          =   9.9*fgkmm;
409
410 // U4 like U3  
411 const Double_t AliITSv11GeometrySDD::fgkCarlosU4posX          = -12*fgkmm;
412 const Double_t AliITSv11GeometrySDD::fgkCarlosU4posZ          =   3.6*fgkmm;
413
414 const Double_t AliITSv11GeometrySDD::fgkCarlosU17X            =  16*fgkmm;
415 const Double_t AliITSv11GeometrySDD::fgkCarlosU17Y            =   3.5*fgkmm; 
416 const Double_t AliITSv11GeometrySDD::fgkCarlosU17Z            =  10.9*fgkmm;
417 const Double_t AliITSv11GeometrySDD::fgkCarlosU17posX         = -17.84*fgkmm;
418 const Double_t AliITSv11GeometrySDD::fgkCarlosU17posZ         = -10.95*fgkmm;
419
420 const Double_t AliITSv11GeometrySDD::fgkCarlosU35X            =   4*fgkmm;
421 const Double_t AliITSv11GeometrySDD::fgkCarlosU35Y            =   1.*fgkmm; 
422 const Double_t AliITSv11GeometrySDD::fgkCarlosU35Z            =   4*fgkmm;
423 const Double_t AliITSv11GeometrySDD::fgkCarlosU35posX         = -21.6*fgkmm;
424 const Double_t AliITSv11GeometrySDD::fgkCarlosU35posZ         =   2.3*fgkmm;
425
426 const Double_t AliITSv11GeometrySDD::fgkCarlosU36X            =   6*fgkmm;
427 const Double_t AliITSv11GeometrySDD::fgkCarlosU36Y            =   1.*fgkmm; 
428 const Double_t AliITSv11GeometrySDD::fgkCarlosU36Z            =   6*fgkmm;
429 const Double_t AliITSv11GeometrySDD::fgkCarlosU36posX         = -21.6*fgkmm;
430 const Double_t AliITSv11GeometrySDD::fgkCarlosU36posZ         =   9.6*fgkmm;
431   
432 const Double_t AliITSv11GeometrySDD::fgkCarlosQZ1X            =   8*fgkmm;
433 const Double_t AliITSv11GeometrySDD::fgkCarlosQZ1Y            =   1.7*fgkmm; // look thicker than design number (0.7) ! ??? 
434 const Double_t AliITSv11GeometrySDD::fgkCarlosQZ1Z            =   3.7*fgkmm;
435 const Double_t AliITSv11GeometrySDD::fgkCarlosQZ1posX         = -12*fgkmm;
436 const Double_t AliITSv11GeometrySDD::fgkCarlosQZ1posZ         =  10.6*fgkmm;
437
438 // distance from the heat bridge center to the card center :
439 const Double_t AliITSv11GeometrySDD::fgkCarlosCard2HeatBridge = fgkCarlosSuppY2/2+fgkCarlosCardY1/2+fgkCarlosU1Y+0.1*fgkmm;
440
441 // some pieces at the end of the carbon fiber ladder
442  const Double_t AliITSv11GeometrySDD::fgkCoolPipeLay3Len   = 467.*fgkmm;  // ???
443  const Double_t AliITSv11GeometrySDD::fgkCoolPipeLay4Len   = 616.*fgkmm;  // ???
444  const Double_t AliITSv11GeometrySDD::fgkHVguideX1         =  42.5*fgkmm;
445  const Double_t AliITSv11GeometrySDD::fgkHVguideY1         =   7.*fgkmm;
446  const Double_t AliITSv11GeometrySDD::fgkHVguideZ1         =  10.*fgkmm;
447  const Double_t AliITSv11GeometrySDD::fgkHVguideZ2         =   6.*fgkmm;
448  const Double_t AliITSv11GeometrySDD::fgkHVguideDX         =  -8.5*fgkmm;
449  const Double_t AliITSv11GeometrySDD::fgkHVguideSuppFullZ  = 37.5*fgkmm;
450
451 // Cooling connector between phynox and plastic cooling water tubes
452 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeRmin = 1 *fgkmm;
453 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeR1   = 2.5*fgkmm; // ???
454 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeL1   = 3.*fgkmm;  // ???
455 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeR2   = 3.5*fgkmm;  // ???
456 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeL2   = 2.*fgkmm;  // ???
457 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeR3   = 3.*fgkmm;  // ???
458 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeL3   = 5 *fgkmm;  // ???
459
460
461 // parameters for coding SDD cables on SDD and SSD cones
462 const Double_t AliITSv11GeometrySDD::fgkSectionCuPerMod = 3*2*0.006 + 3*2*0.0005 + 2*0.002;
463 //                                             copper :     LV     +  signal  +  HV(HV ???)
464 const Double_t AliITSv11GeometrySDD::fgkSectionPlastPerMod = (TMath::Pi()*(3*0.36*0.36/4 + 3*0.21*0.21/4 + 2*0.115*0.115/4) 
465                                                               - fgkSectionCuPerMod);
466
467 const Double_t AliITSv11GeometrySDD::fgkSectionGlassPerMod = 3*0.006; // ???
468 const Double_t AliITSv11GeometrySDD::fgkSectionCoolPolyuEL = 0.4672;
469 const Double_t AliITSv11GeometrySDD::fgkSectionCoolWaterEL = 0.3496;
470 const Double_t AliITSv11GeometrySDD::fgkEndLadderEarthCableR = 0.5*fgkmm;
471 // (sections are given in cm square)
472 const Double_t AliITSv11GeometrySDD::fgkCableBendRatio = 1.3; // ??? this factor account for the bending of cables
473
474 const Double_t AliITSv11GeometrySDD::fgkConeSDDr1 = 11.87574*fgkcm;
475 const Double_t AliITSv11GeometrySDD::fgkConeSDDr2 = 26.07574*fgkcm;
476 const Double_t AliITSv11GeometrySDD::fgkConeSDDz1 =  3.36066*fgkcm + 186.0*fgkmm + 0.5*790.0*fgkmm - 19.18934*fgkcm - 1.6;
477 const Double_t AliITSv11GeometrySDD::fgkConeSDDz2 = 17.56066*fgkcm + 186.0*fgkmm + 0.5*790.0*fgkmm - 19.18934*fgkcm - 1.6;
478 // These last parameters come from cone's code and define the slope
479 // and position of the SDD cone end.  For some unknown reason, this doesn't
480 // allow to stick on the SDD cone. This has to be checked when a correct
481 // version of the cone is available ... For now 'm applying some approximative
482 // corrections
483
484 const Double_t AliITSv11GeometrySDD::fgkSDDCableR1    = 16*fgkcm; // ??? // part 1 of "cable cone"
485 const Double_t AliITSv11GeometrySDD::fgkSDDCableR2    = 23*fgkcm; // ??? // part 1/2 of "cable cone"
486 const Double_t AliITSv11GeometrySDD::fgkSDDCableR3    = 26*fgkcm; // ??? // part 2 of "cable cone"
487
488 const Double_t AliITSv11GeometrySDD::fgkSDDCableDZint =  3.5*fgkcm;
489 const Double_t AliITSv11GeometrySDD::fgkSDDCableR5    =  37*fgkcm; // third part of "cable cone"
490 const Double_t AliITSv11GeometrySDD::fgkSDDCableZ5    =  65*fgkcm; // third part of "cable cone"
491
492
493
494
495
496
497
498 ClassImp(AliITSv11GeometrySDD)
499
500 //________________________________________________________________________
501 AliITSv11GeometrySDD::AliITSv11GeometrySDD(): 
502   AliITSv11Geometry(),
503   fPinSupport(0),
504   fCoolPipeSupportL(0),
505   fCoolPipeSupportR(0),
506   fSDDsensor3(0),
507   fSDDsensor4(0),
508   fBaseThermalBridge(0),
509   fHybrid(0),
510   fLadderFoot(0),
511   fCardLVR(0),
512   fCardLVL(0),
513   fCardHV(0),
514   fCardCarlos(0),
515   fRaccordoL(0),
516   fDigitCableLay3A(0),
517   fDigitCableLay3B(0),
518   fDigitCableLay4A(0),
519   fDigitCableLay4B(0),
520   fMotherVol(0),
521   fAddHybrids(kTRUE), 
522   fAddSensors(kTRUE),
523   fAddHVcables(kTRUE),
524   fAddCables(kTRUE), 
525   fAddCoolingSyst(kTRUE),
526   fCoolingOn(kTRUE),
527   fAddOnlyLadder3min(-1),
528   fAddOnlyLadder3max(-1),
529   fAddOnlyLadder4min(-1),
530   fAddOnlyLadder4max(-1),
531   fColorCarbonFiber(4),
532   fColorRyton(5),
533   fColorPhynox(7),
534   fColorSilicon(3),
535   fColorAl(7),
536   fColorPolyhamide(5),
537   fColorGlass(2),
538   fColorSMD(12),
539   fColorSMDweld(17),
540   fColorStesalite(20),
541   fLay3LadderUnderSegDH(0),
542   fLay4LadderUnderSegDH(0),
543   fLay3LaddShortRadius(0),
544   fLay3LaddLongRadius(0),
545   fLay4LaddShortRadius(0),
546   fLay4LaddLongRadius(0)
547 {
548   //
549   // Standard constructor
550   //
551   SetParameters();
552 }
553
554
555 //________________________________________________________________________
556 AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug) :
557   AliITSv11Geometry(debug),
558   fPinSupport(0),
559   fCoolPipeSupportL(0),
560   fCoolPipeSupportR(0),
561   fSDDsensor3(0),
562   fSDDsensor4(0),
563   fBaseThermalBridge(0),
564   fHybrid(0),
565   fLadderFoot(0),
566   fCardLVR(0),
567   fCardLVL(0),
568   fCardHV(0),
569   fCardCarlos(0),
570   fRaccordoL(0),
571   fDigitCableLay3A(0),
572   fDigitCableLay3B(0),
573   fDigitCableLay4A(0),
574   fDigitCableLay4B(0),
575   fMotherVol(0),
576   fAddHybrids(kTRUE), 
577   fAddSensors(kTRUE),
578   fAddHVcables(kTRUE),
579   fAddCables(kTRUE), 
580   fAddCoolingSyst(kTRUE),
581   fCoolingOn(kTRUE),
582   fAddOnlyLadder3min(-1),
583   fAddOnlyLadder3max(-1),
584   fAddOnlyLadder4min(-1),
585   fAddOnlyLadder4max(-1),
586   fColorCarbonFiber(4),
587   fColorRyton(5),
588   fColorPhynox(7),
589   fColorSilicon(3),
590   fColorAl(7),
591   fColorPolyhamide(5),
592   fColorGlass(2),
593   fColorSMD(12),
594   fColorSMDweld(17),
595   fColorStesalite(20),
596   fLay3LadderUnderSegDH(0),
597   fLay4LadderUnderSegDH(0),
598   fLay3LaddShortRadius(0),
599   fLay3LaddLongRadius(0),
600   fLay4LaddShortRadius(0),
601   fLay4LaddLongRadius(0)
602 {
603   //
604   // Constructor setting debugging level
605   //
606   SetParameters();
607 }
608
609 //________________________________________________________________________
610 AliITSv11GeometrySDD::AliITSv11GeometrySDD(const AliITSv11GeometrySDD &s) :
611   AliITSv11Geometry(s.GetDebug()),
612   fPinSupport(s.fPinSupport),
613   fCoolPipeSupportL(s.fCoolPipeSupportL),
614   fCoolPipeSupportR(s.fCoolPipeSupportR),
615   fSDDsensor3(s.fSDDsensor3),
616   fSDDsensor4(s.fSDDsensor4),
617   fBaseThermalBridge(s.fBaseThermalBridge),
618   fHybrid(s.fHybrid),
619   fLadderFoot(s.fLadderFoot),
620   fCardLVR(s.fCardLVR),
621   fCardLVL(s.fCardLVL),
622   fCardHV(s.fCardHV),
623   fCardCarlos(s.fCardCarlos),
624   fRaccordoL(s.fRaccordoL),
625   fDigitCableLay3A(s.fDigitCableLay3A),
626   fDigitCableLay3B(s.fDigitCableLay3B),
627   fDigitCableLay4A(s.fDigitCableLay4A),
628   fDigitCableLay4B(s.fDigitCableLay4B),
629   fMotherVol(s.fMotherVol),
630   fAddHybrids(s.fAddHybrids), 
631   fAddSensors(s.fAddSensors),
632   fAddHVcables(s.fAddHVcables),
633   fAddCables(s.fAddCables), 
634   fAddCoolingSyst(s.fAddCoolingSyst),
635   fCoolingOn(s.fCoolingOn),
636   fAddOnlyLadder3min(s.fAddOnlyLadder3min),
637   fAddOnlyLadder3max(s.fAddOnlyLadder3max),
638   fAddOnlyLadder4min(s.fAddOnlyLadder4min),
639   fAddOnlyLadder4max(s.fAddOnlyLadder4max),
640   fColorCarbonFiber(s.fColorCarbonFiber),
641   fColorRyton(s.fColorRyton),
642   fColorPhynox(s.fColorPhynox),
643   fColorSilicon(s.fColorSilicon),
644   fColorAl(s.fColorAl),
645   fColorPolyhamide(s.fColorPolyhamide),
646   fColorGlass(s.fColorGlass),
647   fColorSMD(s.fColorSMD),
648   fColorSMDweld(s.fColorSMDweld),
649   fColorStesalite(s.fColorStesalite),
650   fLay3LadderUnderSegDH(s.fLay3LadderUnderSegDH),
651   fLay4LadderUnderSegDH(s.fLay4LadderUnderSegDH),
652   fLay3LaddShortRadius(s.fLay3LaddShortRadius),
653   fLay3LaddLongRadius(s.fLay3LaddLongRadius),
654   fLay4LaddShortRadius(s.fLay4LaddShortRadius),
655   fLay4LaddLongRadius(s.fLay4LaddLongRadius)
656 {
657   //     Copy Constructor
658   // do only a "shallow copy" ...
659   SetParameters();
660 }
661
662 //________________________________________________________________________
663 AliITSv11GeometrySDD& AliITSv11GeometrySDD::
664 operator=(const AliITSv11GeometrySDD &s) {
665   //     Assignment operator
666   if(&s == this) return *this;
667   fMotherVol = s.fMotherVol;
668   fAddHybrids = s.fAddHybrids;
669   fAddSensors = s.fAddSensors;
670   fAddHVcables = s.fAddHVcables;
671   fAddCables = s.fAddCables;
672   fAddCoolingSyst = s.fAddCoolingSyst;
673   fCoolingOn = s.fCoolingOn;
674   fAddOnlyLadder3min = s.fAddOnlyLadder3min;
675   fAddOnlyLadder3max = s.fAddOnlyLadder3max;
676   fAddOnlyLadder4min = s.fAddOnlyLadder4min;
677   fAddOnlyLadder4max = s.fAddOnlyLadder4max;
678   return *this;
679 }
680
681 //________________________________________________________________________
682 AliITSv11GeometrySDD::~AliITSv11GeometrySDD() {
683   // Look like a destructor
684   // Smell like a destructor
685   // And actually is the destructor
686   if (fDigitCableLay3A) delete [] fDigitCableLay3A;
687   if (fDigitCableLay3B) delete [] fDigitCableLay3B;
688   if (fDigitCableLay4A) delete [] fDigitCableLay4A;
689   if (fDigitCableLay4B) delete [] fDigitCableLay4B;
690 }
691
692 //________________________________________________________________________
693 void AliITSv11GeometrySDD::SetParameters() {
694   //
695   // Define display colors and the non constant geometry parameters
696   //
697
698   Double_t detLadderDist = 8*fgkmm; 
699
700   fLay3LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
701   fLay4LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
702
703   // radius from the center to the CF ladder :
704   fLay3LaddShortRadius = (fgkLay3DetShortRadius
705                           + fgkLadWaferSep+2*fgkWaferThickness
706                           + detLadderDist); 
707   fLay3LaddLongRadius  = (fgkLay3DetLongRadius
708                           + fgkLadWaferSep+2*fgkWaferThickness
709                           + detLadderDist); 
710   fLay4LaddShortRadius = (fgkLay4DetShortRadius
711                           + fgkLadWaferSep+2*fgkWaferThickness
712                           + detLadderDist); 
713   fLay4LaddLongRadius  = (fgkLay4DetLongRadius
714                           + fgkLadWaferSep+2*fgkWaferThickness
715                           + detLadderDist); 
716
717   fLay3sensorZPos[0]= (  35.8+72.4+75.8 )*fgkmm;
718   fLay3sensorZPos[1]= (  35.8+72.4      )*fgkmm;
719   fLay3sensorZPos[2]= (  35.8           )*fgkmm;
720   fLay3sensorZPos[3]= ( -37.9           )*fgkmm;
721   fLay3sensorZPos[4]= ( -37.9-74.9      )*fgkmm;
722   fLay3sensorZPos[5]= ( -37.9-74.9-71.1 )*fgkmm;
723
724   fLay4sensorZPos[0] = (  38.5+73.2+75.4+71.6 )*fgkmm;
725   fLay4sensorZPos[1] = (  38.5+73.2+75.4      )*fgkmm;
726   fLay4sensorZPos[2] = (  38.5+73.2           )*fgkmm;
727   fLay4sensorZPos[3] = (  38.5                )*fgkmm;
728   fLay4sensorZPos[4] = ( -35.6                )*fgkmm;
729   fLay4sensorZPos[5] = ( -35.6-74.8           )*fgkmm;
730   fLay4sensorZPos[6] = ( -35.6-74.8-72.4      )*fgkmm;
731   fLay4sensorZPos[7] = ( -35.6-74.8-72.4-76.  )*fgkmm;
732 }
733
734
735 //________________________________________________________________________
736 TGeoMedium* AliITSv11GeometrySDD::GetMedium(const char* mediumName) {
737   //
738   // Called to get a medium, checks that it exists.
739   // If not, prints an error and returns 0
740   //
741
742   char ch[30];
743   sprintf(ch, "ITS_%s",mediumName);
744   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
745   if (! medium)
746     printf("Error(AliITSv11GeometrySDD)::medium %s not found !\n", mediumName);
747   return medium;
748 }
749
750
751 //________________________________________________________________________
752 Int_t AliITSv11GeometrySDD::GetLay3NLadders() const{
753   // Get the actual number of ladder in layer 3
754   if ( (fAddOnlyLadder3min<0) ||
755        (fAddOnlyLadder3min >= fgkLay3Nladd) ||
756        (fAddOnlyLadder3max<0) ||
757        (fAddOnlyLadder3max >= fgkLay3Nladd) )
758     return fgkLay3Nladd;
759   else return (fAddOnlyLadder3max-fAddOnlyLadder3min+1);
760 }
761
762
763 //________________________________________________________________________
764 Int_t AliITSv11GeometrySDD::GetLay4NLadders() const{
765   // Get the actual number of ladder in layer 4
766   if ( (fAddOnlyLadder4min<0) ||
767        (fAddOnlyLadder4min >= fgkLay4Nladd) ||
768        (fAddOnlyLadder4max<0) ||
769        (fAddOnlyLadder4max >= fgkLay4Nladd) )
770     return fgkLay4Nladd;
771   else return (fAddOnlyLadder4max-fAddOnlyLadder4min+1);
772 }
773
774
775 //________________________________________________________________________
776 void AliITSv11GeometrySDD::CreateBasicObjects() {
777   //
778   // Create basics objets which will be assembled together
779   // in Layer3 and Layer4 functions
780   //
781
782
783   fDigitCableLay3A = new AliITSv11GeomCableFlat[fgkLay3Ndet];
784   fDigitCableLay3B = new AliITSv11GeomCableFlat[fgkLay3Ndet];
785   fDigitCableLay4A = new AliITSv11GeomCableFlat[fgkLay4Ndet];
786   fDigitCableLay4B = new AliITSv11GeomCableFlat[fgkLay4Ndet];
787
788   fPinSupport = CreatePinSupport();
789   fCoolPipeSupportL = CreateCoolPipeSupportL();
790   fCoolPipeSupportR = CreateCoolPipeSupportR();
791   CreateSDDsensor();
792   fBaseThermalBridge = CreateBaseThermalBridge();
793   fHybrid = CreateHybrid(0);
794
795   TGeoMedium *carbonFiberLadderStruct = GetMedium("SDD C AL (M55J)$"); //ITSsddCarbonM55J
796   TGeoMedium *polyhamideSDD   = GetMedium("SDDKAPTON (POLYCH2)$");//ITSsddKAPTON_POLYCH2
797   TGeoMedium *alSDD           = GetMedium("AL$"); //ITSal
798   TGeoMedium *stainless       = GetMedium("INOX$"); // for screws, what is the material ???????????
799   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
800   TGeoMedium *raccordMedium   = GetMedium("INOX$");  // ??? material of raccordo ???
801
802   //********************************************************************
803   // pieces of the carbon fiber structure
804   //********************************************************************
805   Double_t dy             = fgkLadderSegBoxDH/2;
806   Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
807   Double_t halfTheta      = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
808   Double_t alpha          = TMath::Pi()*3./4. - halfTheta/2.;
809   Double_t beta           = (TMath::Pi() - 2.*halfTheta)/4.;
810   Double_t dYTranslation  = (fgkLadderHeight/2.
811                              -0.5*fgkLadderWidth*TMath::Tan(beta)
812                              -fgkLadderBeamRadius);
813   Double_t distCenterSideDown =  0.5*fgkLadderWidth/TMath::Cos(beta);
814
815   //--- the top V of the Carbon Fiber Ladder (segment)
816   TGeoArb8 *cfLaddTop1 = CreateLadderSide( "CFladdTopCornerVol1shape",
817                                            fgkSegmentLength/2., halfTheta, 
818                           -1, fgkLadderLa, fgkLadderHa, fgkLadderl);
819   TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
820                                   cfLaddTop1,carbonFiberLadderStruct);
821   TGeoArb8 *cfLaddTop2 = CreateLadderSide( "CFladdTopCornerVol2shape",
822                                            fgkSegmentLength/2., halfTheta,
823                            1, fgkLadderLa, fgkLadderHa, fgkLadderl);
824   TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerVol2",
825                                   cfLaddTop2, carbonFiberLadderStruct);
826   cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
827   cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
828   TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2-dy, 0);
829
830   //--- the 2 side V
831   TGeoArb8 *cfLaddSide1 = CreateLadderSide( "CFladdSideCornerVol1shape",
832                                             fgkSegmentLength/2., beta, -1,
833                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
834   TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerVol1",
835                                    cfLaddSide1,carbonFiberLadderStruct);
836   TGeoArb8 *cfLaddSide2 = CreateLadderSide( "CFladdSideCornerVol2shape",
837                                             fgkSegmentLength/2., beta, 1,
838                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
839   TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerVol2",
840                                    cfLaddSide2,carbonFiberLadderStruct);
841   cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
842   cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
843   TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
844                                              alpha*TMath::RadToDeg());
845   AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation-dy, 0);
846   TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,
847                                              -alpha*TMath::RadToDeg());
848   AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation-dy, 0);
849
850   //--- The beams
851   // Beams on the sides
852   Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
853            TMath::Sin(2*beta)/(TanD(fgkBeamSidePhi)*TanD(fgkBeamSidePhi))) ));
854   //cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
855   Double_t beamLength = TMath::Sqrt( fgkLadderHeight*fgkLadderHeight/
856                         ( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
857                         + fgkLadderWidth*fgkLadderWidth/4.)-fgkLadderLa/2-fgkLadderLb/2;
858   TGeoTubeSeg *sideBeamS = new TGeoTubeSeg(0, fgkLadderBeamRadius,beamLength/2.,
859                                            0, 180);
860   TGeoVolume *sideBeam = new TGeoVolume("ITSsddCFSideBeamVol", sideBeamS,
861                              carbonFiberLadderStruct);
862   sideBeam->SetLineColor(fColorCarbonFiber);
863
864   //Euler rotation : about Z, then new X, then new Z
865   TGeoRotation *beamRot1 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
866                                             -beamPhiPrime*TMath::RadToDeg(),-90);
867   TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
868                                             beamPhiPrime*TMath::RadToDeg(), -90);
869   TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
870                                             beamPhiPrime*TMath::RadToDeg(), -90);
871   TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
872                                             -beamPhiPrime*TMath::RadToDeg(),-90);
873
874   TGeoCombiTrans *beamTransf[8];
875   beamTransf[0] = new TGeoCombiTrans( 0.5*triangleHeight*
876                                       TMath::Tan(halfTheta),
877                                       fgkLadderBeamRadius/2. - dy,
878                                       -3*fgkSegmentLength/8, beamRot1);
879
880   beamTransf[1] = new TGeoCombiTrans( 0.5*triangleHeight*
881                                       TMath::Tan(halfTheta),
882                                       fgkLadderBeamRadius/2. - dy,
883                                       -3*fgkSegmentLength/8, beamRot1);
884   AddTranslationToCombiTrans(beamTransf[1], 0, 0, fgkSegmentLength/2);
885
886   beamTransf[2] = new TGeoCombiTrans(0.5*triangleHeight*
887                                      TMath::Tan(halfTheta),
888                                      fgkLadderBeamRadius/2. - dy,
889                                      -fgkSegmentLength/8, beamRot2);
890
891   beamTransf[3] = new TGeoCombiTrans(0.5*triangleHeight*
892                                      TMath::Tan(halfTheta),
893                                      fgkLadderBeamRadius/2. - dy,
894                                      -fgkSegmentLength/8, beamRot2);
895   AddTranslationToCombiTrans(beamTransf[3], 0, 0, fgkSegmentLength/2);
896
897   beamTransf[4] = new TGeoCombiTrans(-0.5*triangleHeight*
898                                      TMath::Tan(halfTheta),
899                                      fgkLadderBeamRadius/2. - dy,
900                                      -3*fgkSegmentLength/8, beamRot3);
901
902   beamTransf[5] = new TGeoCombiTrans(-0.5*triangleHeight*
903                                      TMath::Tan(halfTheta),
904                                      fgkLadderBeamRadius/2. - dy,
905                                      -3*fgkSegmentLength/8, beamRot3);
906   AddTranslationToCombiTrans(beamTransf[5], 0, 0, fgkSegmentLength/2);
907
908   beamTransf[6] = new TGeoCombiTrans(-0.5*triangleHeight*
909   TMath::Tan(halfTheta),fgkLadderBeamRadius/2.-dy, -fgkSegmentLength/8,beamRot4);
910   beamTransf[7] = new TGeoCombiTrans(-0.5*triangleHeight*
911   TMath::Tan(halfTheta),fgkLadderBeamRadius/2.-dy,3*fgkSegmentLength/8,beamRot4);
912
913   //--- Beams of the bottom
914   TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
915                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 180);
916   TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
917                                    bottomBeam1, carbonFiberLadderStruct);
918   bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
919   TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
920                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 90);
921   TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
922                                bottomBeam2, carbonFiberLadderStruct);
923   bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
924   TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
925                              0.5*fgkLadderWidth/SinD(fgkBottomBeamAngle)
926                              - fgkLadderLb/3, 0, 180);
927   TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol",
928                                    bottomBeam3, carbonFiberLadderStruct);
929   bottomBeam3Vol->SetLineColor(fColorCarbonFiber);
930   //bottomBeam3Vol->SetLineColor(2);
931   TGeoRotation *bottomBeamRot1 = new TGeoRotation("", 90, 90,  90);
932   TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
933
934   TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans
935     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,0, bottomBeamRot1);
936   TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
937                                       -(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,
938                                       -fgkSegmentLength/2, bottomBeamRot1);
939   TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,
940                                       -(fgkLadderHeight/2 - fgkLadderBeamRadius)
941                                       - dy, fgkSegmentLength/2, bottomBeamRot2);
942   // be careful for beams #3: when "reading" from -z to +z and 
943   // from the bottom of the ladder, it should draw a Lambda, and not a V
944   TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, fgkBottomBeamAngle, -90);
945   TGeoRotation *bottomBeamRot5 = new TGeoRotation("" ,-90,-fgkBottomBeamAngle, -90);
946   TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans
947     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,-fgkSegmentLength/4,bottomBeamRot4);
948   TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans
949     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,fgkSegmentLength/4, bottomBeamRot5);
950
951   fLaddSegCommonVol[0] = cfLaddTopVol1;  fLaddSegCommonTr[0] = trTop1;
952   fLaddSegCommonVol[1] = cfLaddTopVol2;  fLaddSegCommonTr[1] = trTop1;
953   fLaddSegCommonVol[2] = cfLaddSideVol1; fLaddSegCommonTr[2] = ctSideR;
954   fLaddSegCommonVol[3] = cfLaddSideVol1; fLaddSegCommonTr[3] = ctSideL;
955   fLaddSegCommonVol[4] = cfLaddSideVol2; fLaddSegCommonTr[4] = ctSideR;
956   fLaddSegCommonVol[5] = cfLaddSideVol2; fLaddSegCommonTr[5] = ctSideL;
957   fLaddSegCommonVol[6] = sideBeam;       fLaddSegCommonTr[6] = beamTransf[0];
958   fLaddSegCommonVol[7] = sideBeam;       fLaddSegCommonTr[7] = beamTransf[1];
959   fLaddSegCommonVol[8] = sideBeam;       fLaddSegCommonTr[8] = beamTransf[2];
960   fLaddSegCommonVol[9] = sideBeam;       fLaddSegCommonTr[9] = beamTransf[3];
961   fLaddSegCommonVol[10]= sideBeam;       fLaddSegCommonTr[10]= beamTransf[4];
962   fLaddSegCommonVol[11]= sideBeam;       fLaddSegCommonTr[11]= beamTransf[5];
963   fLaddSegCommonVol[12]= sideBeam;       fLaddSegCommonTr[12]= beamTransf[6];
964   fLaddSegCommonVol[13]= sideBeam;       fLaddSegCommonTr[13]= beamTransf[7];
965   fLaddSegCommonVol[14]= bottomBeam1Vol; fLaddSegCommonTr[14]= bottomBeamTransf1;
966   fLaddSegCommonVol[15]= bottomBeam2Vol; fLaddSegCommonTr[15]= bottomBeamTransf2;
967   fLaddSegCommonVol[16]= bottomBeam2Vol; fLaddSegCommonTr[16]= bottomBeamTransf3;
968   fLaddSegCommonVol[17]= bottomBeam3Vol; fLaddSegCommonTr[17]= bottomBeamTransf4;
969   fLaddSegCommonVol[18]= bottomBeam3Vol; fLaddSegCommonTr[18]= bottomBeamTransf5;
970
971  
972   //********************************************************************
973   // cables
974   //********************************************************************
975   char cableName[30];
976   for (Int_t i=0; i<fgkLay3Ndet; i++) {
977     sprintf(cableName, "digitCableLay3A_%i",i);
978     fDigitCableLay3A[i].SetName(cableName);
979     fDigitCableLay3A[i].SetWidth(fgkDigitCablWidth);
980     fDigitCableLay3A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
981     fDigitCableLay3A[i].SetNLayers(2);
982     fDigitCableLay3A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
983                                   fColorPolyhamide);
984     fDigitCableLay3A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
985     sprintf(cableName, "digitCableLay3B_%i",i);
986     fDigitCableLay3B[i].SetName(cableName);
987     fDigitCableLay3B[i].SetWidth(fgkDigitCablWidth);
988     fDigitCableLay3B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
989     fDigitCableLay3B[i].SetNLayers(2);
990     fDigitCableLay3B[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
991                                   fColorPolyhamide);
992     fDigitCableLay3B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
993   };
994   for (Int_t i=0; i<fgkLay4Ndet; i++) {
995     sprintf(cableName, "digitCableLay4A_%i",i);
996     fDigitCableLay4A[i].SetName(cableName);
997     fDigitCableLay4A[i].SetWidth(fgkDigitCablWidth);
998     fDigitCableLay4A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
999     fDigitCableLay4A[i].SetNLayers(2);
1000     fDigitCableLay4A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
1001                                   fColorPolyhamide);
1002     fDigitCableLay4A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
1003     sprintf(cableName, "digitCableLay4B_%i",i);
1004     fDigitCableLay4B[i].SetName(cableName);
1005     fDigitCableLay4B[i].SetWidth(fgkDigitCablWidth);
1006     fDigitCableLay4B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
1007     fDigitCableLay4B[i].SetNLayers(2);
1008     fDigitCableLay4B[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
1009                                   fColorPolyhamide);
1010     fDigitCableLay4B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
1011   };
1012                                         // Well, those digit cables could also include the analog cables
1013                                         // which have the same width and the same path, at least in the ladder.
1014                                         // It will gain some computing ressources (less volumes) and some
1015                                         // coding efforts ... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1016                                         // The only thing to do is to change the names and put the correct total
1017                                         // thicknesses
1018
1019   // some transformations and volumes used in several places
1020   fCommonTr[0] = new TGeoRotation("CarlosSuppRotN",
1021                                   0, -fgkCarlosSuppAngle, 0);
1022
1023   TGeoTube *littleScrewHead = new TGeoTube("littleScrewHead", 0, fgkLittleScrewHeadR,
1024                                            fgkLittleScrewHeadH/2);
1025   fCommonVol[0] = new TGeoVolume("vLittleScrewHead",
1026                                  littleScrewHead, stainless);
1027   fCommonVol[0]->SetLineColor(kGray);
1028
1029   fLadderFoot = CreateLadderFoot();
1030   CreateLVCard();
1031   fCardHV     = CreateHVCard(0);
1032   fCardCarlos = CreateCarlosCard(0);
1033
1034   //==================
1035   // link beteen phynox and plastic cooling tubes
1036   //==================
1037
1038   fRaccordoL = new TGeoVolumeAssembly("RaccordoL");
1039   Double_t fullRacLen = fgkConnectorCoolTubeL1+fgkConnectorCoolTubeL2+fgkConnectorCoolTubeL3;
1040   TGeoTube *waterRac = new TGeoTube("waterRac", 0, fgkConnectorCoolTubeRmin, fullRacLen/2);
1041   TGeoVolume * vwaterRac = new TGeoVolume("vwaterRac", waterRac, coolerMediumSDD);
1042   vwaterRac->SetLineColor(kBlue);
1043
1044   TGeoTube *tube1Rac = new TGeoTube("tube1Rac", fgkConnectorCoolTubeRmin,
1045                                     fgkConnectorCoolTubeR1, fgkConnectorCoolTubeL1/2);
1046   TGeoTube *tube2Rac = new TGeoTube("tube2Rac", fgkConnectorCoolTubeRmin,
1047                                     fgkConnectorCoolTubeR2, fgkConnectorCoolTubeL2/2);
1048   TGeoTube *tube3Rac = new TGeoTube("tube3Rac", fgkConnectorCoolTubeRmin,
1049                                     fgkConnectorCoolTubeR3, fgkConnectorCoolTubeL3/2);
1050   TGeoVolume *  vtube1Rac = new TGeoVolume("vtube1Rac", tube1Rac, raccordMedium);
1051   TGeoVolume *  vtube2Rac = new TGeoVolume("vtube2Rac", tube2Rac, raccordMedium);
1052   TGeoVolume *  vtube3Rac = new TGeoVolume("vtube3Rac", tube3Rac, raccordMedium);
1053   vtube1Rac->SetLineColor(kGray);
1054   vtube2Rac->SetLineColor(kGray);
1055   vtube3Rac->SetLineColor(kGray);
1056
1057   TGeoTranslation *trTube1Rac = new TGeoTranslation("trTube1Rac",0,0,
1058                                                     -fullRacLen/2+fgkConnectorCoolTubeL1/2);
1059   TGeoTranslation *trTube2Rac = new TGeoTranslation("trTube2Rac",0,0,
1060                                (-fullRacLen/2+fgkConnectorCoolTubeL1+fgkConnectorCoolTubeL2/2));
1061   TGeoTranslation *trTube3Rac = new TGeoTranslation("trTube3Rac",0,0,
1062                                     (-fullRacLen/2+fgkConnectorCoolTubeL1+
1063                                      fgkConnectorCoolTubeL2+fgkConnectorCoolTubeL3/2));
1064   fRaccordoL->AddNode(vwaterRac, 1,0);
1065   fRaccordoL->AddNode(vtube1Rac, 1,trTube1Rac);
1066   fRaccordoL->AddNode(vtube2Rac, 1,trTube2Rac);
1067   fRaccordoL->AddNode(vtube3Rac, 1,trTube3Rac);
1068 }
1069
1070
1071 //________________________________________________________________________
1072 void AliITSv11GeometrySDD::CheckOverlaps(Double_t precision){
1073   //
1074   // a debugging function for checking some possible overlaps
1075   //
1076   if (fSDDsensor3)        fSDDsensor3->CheckOverlaps(precision);
1077   if (fSDDsensor4)        fSDDsensor4->CheckOverlaps(precision);
1078   if (fHybrid)            fHybrid->CheckOverlaps(precision);
1079 }
1080
1081
1082 //________________________________________________________________________
1083 TGeoCombiTrans *AliITSv11GeometrySDD::
1084 CreateCombiTrans(const char *name, Double_t dy, Double_t dz, Double_t dphi,
1085                  Bool_t planeSym) {
1086     //
1087     // return the TGeoCombiTrans which make a translation in y and z
1088     // and a rotation in phi in the global coord system
1089     // If planeSym = true, the rotation places the object symetrically
1090     // (with respect to the transverse plane) to its position in the
1091     // case planeSym = false
1092     //
1093
1094     TGeoTranslation t1(dy*CosD(90.+dphi),dy*SinD(90.+dphi), dz);
1095     TGeoRotation r1("",0.,0.,dphi);
1096     TGeoRotation r2("",90, 180, -90-dphi);
1097
1098     TGeoCombiTrans *combiTrans1 = new TGeoCombiTrans(name);
1099     combiTrans1->SetTranslation(t1);
1100     if (planeSym) combiTrans1->SetRotation(r1);
1101     else  combiTrans1->SetRotation(r2);
1102     return combiTrans1;
1103 }
1104
1105
1106 //________________________________________________________________________
1107 void AliITSv11GeometrySDD::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
1108                                                        Double_t dx,
1109                                                        Double_t dy,
1110                                                        Double_t dz) const{
1111   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
1112   const Double_t *vect = ct->GetTranslation();
1113   Double_t newVect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
1114   ct->SetTranslation(newVect);
1115 }
1116
1117
1118 //________________________________________________________________________
1119 void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
1120 // for code developpment and debugging purposes
1121
1122   if (! fSDDsensor3) CreateBasicObjects();
1123
1124   //  moth->AddNode(fPinSupport, 1, 0);
1125   //  moth->AddNode(fCoolPipeSupportL, 1, 0);
1126   //  moth->AddNode(fSDDsensor3, 1, 0);
1127   //  moth->AddNode(fSDDsensor4, 1, 0);
1128   //  moth->AddNode(fBaseThermalBridge, 1, 0);
1129   //  moth->AddNode(fHybrid,100,0);
1130   //  moth->AddNode(fLadderFoot,1,0);
1131   //moth->AddNode(fCardLVL,1,0);
1132   //moth->AddNode(fCardLVR,1,0);
1133
1134    TGeoVolume* seg = CreateLadderSegment( 3, 0);
1135    moth->AddNode(seg, 1, 0);
1136
1137 //   TGeoVolumeAssembly *lay3Ladder = CreateLadder(3);
1138 //   moth->AddNode(lay3Ladder, 1, 0);
1139
1140 //   TGeoVolumeAssembly *lay3Detectors = CreateDetectorsAssembly(3);
1141 //   moth->AddNode(lay3Detectors, 1, 0);
1142
1143 //   TGeoVolumeAssembly *lay3Detectors = CreateDetectorsAssembly(3);
1144 //   moth->AddNode(lay3Detectors, 1, 0);
1145
1146
1147 //   TGeoVolumeAssembly *endLadder = CreateEndLadder( 4 );
1148 //   moth->AddNode(endLadder, 1, 0);
1149
1150 //   TGeoVolumeAssembly *highVCard = CreateHVCard( 4 );
1151 //   moth->AddNode(highVCard, 1, 0);
1152
1153 //   TGeoVolumeAssembly *supportRing = CreateSupportRing( 4 );
1154 //   moth->AddNode(supportRing, 1, 0);
1155
1156 //   TGeoVolume *endLadderCards = CreateEndLadderCardsV( 4 );
1157 //   moth->AddNode(endLadderCards, 1, 0);
1158
1159 //   TGeoVolumeAssembly *carlosCard = CreateCarlosCard( 4 );
1160 //   moth->AddNode(carlosCard, 1, 0);
1161
1162
1163
1164   /*
1165   //==================================
1166   //--- test of flat cable curvature
1167   //==================================
1168
1169   double angle = 90;
1170   AliITSv11GeomCableFlat cable("test", 3, 0.3);
1171   cable.SetNLayers(1);
1172   cable.SetNLayers(2);
1173   cable.SetLayer(0, 0.2, coolerMediumSDD, 2);
1174   cable.SetLayer(1, 0.1, coolerMediumSDD, 3);
1175   cable.SetInitialNode(endLadderCards);
1176
1177   Double_t p1[3], p2[3], vX[3] = {1,0,0},vY[3] = {0,5,0};
1178
1179   p1[0] = -3;
1180   p1[1] = 1;
1181   p1[2] = 10;
1182
1183   p2[0] = 0;
1184   p2[1] = 1;
1185   p2[2] = 10;
1186   cable.AddCheckPoint(endLadderCards, 0, p1, vX);
1187   cable.AddCheckPoint(endLadderCards, 1, p2, vX);
1188   cable.CreateAndInsertBoxCableSegment(1,angle);
1189
1190   Double_t p3[3], p4[3];
1191
1192   p3[0] = 2;
1193   p3[1] = 3;
1194   p3[2] = 10;
1195   cable.AddCheckPoint(endLadderCards, 2, p3, vY);
1196   cable.CreateAndInsertCableCylSegment(2,angle);
1197
1198   p4[0] = 2;
1199   p4[1] = 6;
1200   p4[2] = 10;
1201   cable.AddCheckPoint(endLadderCards, 3, p4, vY);
1202   cable.CreateAndInsertCableSegment(3,angle);
1203   */
1204 }
1205
1206
1207 //________________________________________________________________________
1208 void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
1209   //
1210   // Insert the layer 3 in the mother volume. This is a virtual volume
1211   // containing ladders of layer 3 and the supporting rings
1212   //
1213
1214   if (! moth) {
1215     printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
1216     return;
1217   };
1218
1219   TGeoMedium *airSDD = GetMedium("SDD AIR$");
1220
1221   fMotherVol = moth;
1222   if (! fSDDsensor3) CreateBasicObjects();
1223   
1224   //====================================
1225   // First we create the central barrel
1226   //====================================
1227
1228   TGeoVolumeAssembly *lay3Ladder    = CreateLadder(3);
1229   TGeoVolumeAssembly *lay3Detectors = CreateDetectorsAssembly(3);
1230   TGeoVolumeAssembly *lay3Ladd2Det  = CreateDetectorsAssemblyLadd2();
1231   //TGeoVolume *lay3Detectors = CreateDetectors(3);
1232   TGeoTube *virtualLayer3Shape = new TGeoTube("ITSsddLayer3Shape",
1233                                      fgkLay3Rmin,fgkLay3Rmax,fgkLay3Length*0.5);
1234   TGeoVolume *virtualLayer3 = new TGeoVolume("ITSsddLayer3",
1235                                              virtualLayer3Shape, airSDD);
1236
1237   Double_t dPhi = 360./fgkLay3Nladd;
1238   Double_t detectorsThick = fgkLadWaferSep + 2*fgkWaferThickness;
1239   // Placing virtual ladder and detectors volumes following
1240   // ladder ordering convention
1241   char rotName[30];
1242   Int_t iLaddMin = 0;
1243   Int_t iLaddMax = fgkLay3Nladd;
1244   if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
1245     iLaddMin = fAddOnlyLadder3min;
1246     iLaddMax = fAddOnlyLadder3max+1;
1247   };
1248
1249   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1250
1251     Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
1252     sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
1253     Double_t minRadiusLadBox = fLay3LaddShortRadius-fLay3LadderUnderSegDH;
1254     if (iLadd%2 != 0)
1255       minRadiusLadBox = fLay3LaddLongRadius-fLay3LadderUnderSegDH;
1256     minRadiusLadBox += ((TGeoBBox*)lay3Ladder->GetShape())->GetDY();
1257     TGeoCombiTrans *ctLadd;
1258     //=============================================================
1259     //
1260     //   Special modification  for ladder 2 of layer 3:
1261     //   It has been inverted (pi rotation around y axis)
1262     //
1263     //=============================================================
1264     if (iLadd != 2)
1265       ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,
1266                                 0, ladderPhi, kTRUE);
1267     else
1268       ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,
1269                                 0, ladderPhi, kFALSE);
1270     virtualLayer3->AddNode(lay3Ladder, iLadd, ctLadd);
1271     ///////////////////////////////////////////////////
1272     sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
1273     Double_t minRadiusDetBox = fgkLay3DetShortRadius;
1274     if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
1275     minRadiusDetBox += detectorsThick/2;
1276     TGeoCombiTrans *ctDet;
1277     ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
1278                              0, ladderPhi, kTRUE);
1279
1280     if (iLadd != 2)
1281       virtualLayer3->AddNode(lay3Detectors, iLadd, ctDet);
1282     else
1283       virtualLayer3->AddNode(lay3Ladd2Det , iLadd, ctDet);
1284
1285     ///////////////////////////////////////////////////
1286   }
1287
1288   /*
1289   //====================================
1290   // Then the forward rapidity pieces
1291   // (cooling, Carlos, LV, HV ...)
1292   //====================================
1293
1294   Double_t fgkForwardLay3Length = fgkEndLadPipeUlengthLay3+10*fgkmm;  // this has to be tune
1295   Double_t fgkForwardLay3Rmin = fgkLay3Rmin-7*fgkmm;
1296   Double_t fgkForwardLay3Rmax = fgkLay3Rmax-5*fgkmm;
1297
1298   TGeoVolumeAssembly* lay3EndLadder = CreateEndLadderCards(3);
1299   TGeoTube *virtualForward3Shape = new TGeoTube("virtualForward3Shape",
1300                                                 fgkForwardLay3Rmin, fgkForwardLay3Rmax,
1301                                                 fgkForwardLay3Length/2.);
1302
1303 //   TGeoPcon *virtualForward3Shape = new TGeoPcon("virtualForward3Shape",0,360,2);
1304 // // virtualForward3Shape->DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax);
1305 //   virtualForward3Shape->DefineSection(0, Double_t z, Double_t rmin, Double_t rmax);
1306
1307
1308   TGeoVolume *virtualForward3Pos = new TGeoVolume("ITSsddForward3Pos",
1309                                                   virtualForward3Shape, airSDD);
1310   TGeoVolume *virtualForward3Neg = new TGeoVolume("ITSsddForward3Neg",
1311                                                   virtualForward3Shape, airSDD);
1312 //   TGeoVolume *virtualForward3Neg = new TGeoVolumeAssembly("ITSsddForward3Neg");
1313 //   TGeoVolume *virtualForward3Pos = new TGeoVolumeAssembly("ITSsddForward3Pos");
1314
1315   TGeoTranslation *virtualForward3TrPos = new TGeoTranslation("virtualForward3TrPos",0,0,
1316                                           fgkLay3Length/2+fgkForwardLay3Length/2);
1317   TGeoTranslation *virtualForward3TrNeg = new TGeoTranslation("virtualForward3TrNeg",0,0,
1318                                           -fgkLay3Length/2-fgkForwardLay3Length/2);
1319
1320   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1321
1322     Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
1323     Double_t minRadiusDetBox = fgkLay3DetShortRadius;
1324     if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
1325     minRadiusDetBox += detectorsThick/2;
1326
1327     sprintf(rotName, "ITSsddLay3EndLadd%i",iLadd);
1328
1329     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1330                                    -fgkForwardLay3Length/2, ladderPhi, kTRUE);
1331     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1332                                    fgkForwardLay3Length/2, ladderPhi, kFALSE);
1333
1334     virtualForward3Pos->AddNode(lay3EndLadder, iLadd*2, ctEndLaddPos);
1335     virtualForward3Neg->AddNode(lay3EndLadder, iLadd*2, ctEndLaddNeg);
1336   }
1337
1338   */
1339
1340
1341   if(GetDebug(1)) {
1342     virtualLayer3->CheckOverlaps(0.01);
1343     //virtualForward3Pos->CheckOverlaps(0.01);
1344     //virtualForward3Neg->CheckOverlaps(0.01);
1345   }
1346
1347   virtualLayer3->SetVisibility(kFALSE);
1348   //virtualForward3Pos->SetVisibility(kFALSE);
1349   //virtualForward3Neg->SetVisibility(kFALSE);
1350
1351
1352   moth->AddNode(virtualLayer3, 1, 0);
1353   //moth->AddNode(virtualForward3Pos, 1, virtualForward3TrPos);
1354   //moth->AddNode(virtualForward3Neg, 1, virtualForward3TrNeg);
1355 }
1356
1357
1358 // //________________________________________________________________________
1359 // void AliITSv11GeometrySDD::ForwardLayer3(TGeoVolume *moth) {
1360 //   //
1361 //   // Insert the forward pieces of layer 3 in the mother volume. 
1362 //   // (cooling, Carlos, LV, HV ...)
1363 //   //
1364
1365 //   if (! moth) {
1366 //     printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
1367 //     return;
1368 //   };
1369
1370 //   TGeoMedium *airSDD = GetMedium("SDD AIR$");
1371
1372 //   if (! fSDDsensor3) CreateBasicObjects();
1373
1374 //   Double_t dPhi = 360./fgkLay3Nladd;
1375 //   Double_t detectorsThick = fgkLadWaferSep + 2*fgkWaferThickness;
1376 //   Int_t iLaddMin = 0;
1377 //   Int_t iLaddMax = fgkLay3Nladd;
1378 //   if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
1379 //     iLaddMin = fAddOnlyLadder3min;
1380 //     iLaddMax = fAddOnlyLadder3max+1;
1381 //   };
1382 //   char rotName[30];
1383
1384
1385 //   //=================
1386
1387 //   Double_t fgkForwardLay3Length = fgkEndLadPipeUlengthLay3+10*fgkmm;  // this has to be tune
1388 //   Double_t fgkForwardLay3Rmin = fgkLay3Rmin-7*fgkmm;
1389 //   Double_t fgkForwardLay3Rmax = fgkLay3Rmax-5*fgkmm;
1390
1391 //   TGeoVolumeAssembly* lay3EndLadder = CreateEndLadderCards(3);
1392 //   TGeoTube *virtualForward3Shape = new TGeoTube("virtualForward3Shape",
1393 //                                              fgkForwardLay3Rmin, fgkForwardLay3Rmax,
1394 //                                              fgkForwardLay3Length/2.);
1395
1396 // //   TGeoPcon *virtualForward3Shape = new TGeoPcon("virtualForward3Shape",0,360,2);
1397 // // // virtualForward3Shape->DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax);
1398 // //   virtualForward3Shape->DefineSection(0, Double_t z, Double_t rmin, Double_t rmax);
1399
1400
1401 //   TGeoVolume *virtualForward3Pos = new TGeoVolume("ITSsddForward3Pos",
1402 //                                                virtualForward3Shape, airSDD);
1403 //   TGeoVolume *virtualForward3Neg = new TGeoVolume("ITSsddForward3Neg",
1404 //                                                virtualForward3Shape, airSDD);
1405 // //   TGeoVolume *virtualForward3Neg = new TGeoVolumeAssembly("ITSsddForward3Neg");
1406 // //   TGeoVolume *virtualForward3Pos = new TGeoVolumeAssembly("ITSsddForward3Pos");
1407
1408 //   TGeoTranslation *virtualForward3TrPos = new TGeoTranslation("virtualForward3TrPos",0,0,
1409 //                                        fgkLay3Length/2+fgkForwardLay3Length/2);
1410 //   TGeoTranslation *virtualForward3TrNeg = new TGeoTranslation("virtualForward3TrNeg",0,0,
1411 //                                        -fgkLay3Length/2-fgkForwardLay3Length/2);
1412
1413 //   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1414
1415 //     Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
1416 //     Double_t minRadiusDetBox = fgkLay3DetShortRadius;
1417 //     if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
1418 //     minRadiusDetBox += detectorsThick/2;
1419
1420 //     sprintf(rotName, "ITSsddLay3EndLadd%i",iLadd);
1421
1422 //     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1423 //                                 -fgkForwardLay3Length/2, ladderPhi, kTRUE);
1424 //     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1425 //                                 fgkForwardLay3Length/2, ladderPhi, kFALSE);
1426
1427 //     virtualForward3Pos->AddNode(lay3EndLadder, iLadd*2, ctEndLaddPos);
1428 //     virtualForward3Neg->AddNode(lay3EndLadder, iLadd*2, ctEndLaddNeg);
1429 //   }
1430
1431 //   if(GetDebug(1)) {
1432 //     virtualForward3Pos->CheckOverlaps(0.01);
1433 //     virtualForward3Neg->CheckOverlaps(0.01);
1434 //   }
1435
1436 //   virtualForward3Pos->SetVisibility(kFALSE);
1437 //   virtualForward3Neg->SetVisibility(kFALSE);
1438
1439 //   moth->AddNode(virtualForward3Pos, 1, virtualForward3TrPos);
1440 //   moth->AddNode(virtualForward3Neg, 1, virtualForward3TrNeg);
1441 // }
1442
1443
1444
1445 //________________________________________________________________________
1446 void AliITSv11GeometrySDD::ForwardLayer3(TGeoVolume *moth) {
1447   //
1448   // Insert the end-ladder of layer 3 in the mother volume. 
1449   // (cooling, Carlos, LV, HV ...)
1450   //
1451
1452   if (! moth) {
1453     printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
1454     return;
1455   };
1456
1457   if (! fSDDsensor3) CreateBasicObjects();
1458
1459   Int_t iLaddMin = 0;
1460   Int_t iLaddMax = fgkLay3Nladd;
1461   if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
1462     iLaddMin = fAddOnlyLadder3min;
1463     iLaddMax = fAddOnlyLadder3max+1;
1464   };
1465
1466   TGeoVolume *virtualForward3Neg = new TGeoVolumeAssembly("ITSsddForward3Neg");
1467   TGeoVolume *virtualForward3Pos = new TGeoVolumeAssembly("ITSsddForward3Pos");
1468
1469   char rotName[30];
1470   Double_t dPhi = 360./fgkLay3Nladd;
1471   TGeoVolume* lay3EndLadder = CreateEndLadderCardsV(3);
1472
1473   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1474
1475     Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
1476     Double_t dR = 0;
1477     if (iLadd%2 != 0) dR = fgkLay3DetLongRadius-fgkLay3DetShortRadius;
1478
1479     sprintf(rotName, "ITSsddLay3EndLadd%i",iLadd);
1480
1481     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, dR,
1482                                     fgkLay3Length/2, ladderPhi, kTRUE);
1483     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, dR,
1484                                    -fgkLay3Length/2, ladderPhi, kFALSE);
1485
1486     virtualForward3Pos->AddNode(lay3EndLadder, iLadd*2, ctEndLaddPos);
1487     virtualForward3Neg->AddNode(lay3EndLadder, iLadd*2, ctEndLaddNeg);
1488   }
1489
1490   if(GetDebug(1)) {
1491     virtualForward3Pos->CheckOverlaps(0.01);
1492     virtualForward3Neg->CheckOverlaps(0.01);
1493   }
1494
1495   // 180deg Y rotation to compensate the cancellation of ITSD volume
1496   // (idortm[199] in AliITSv11Hybrid : z--->  -z;   x ---> -x;   y ---> y)
1497   TGeoRotation *y180 = new TGeoRotation();
1498   y180->SetAngles( 90.,180., 90., 90.,180.,  0.);
1499   moth->AddNode(virtualForward3Pos, 1, y180);
1500   moth->AddNode(virtualForward3Neg, 1, y180);
1501 }
1502
1503 //________________________________________________________________________
1504 void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
1505   //
1506   // Insert the layer 4 in the mother volume. This is a virtual volume
1507   // containing ladders of layer 4 and the supporting rings
1508   //
1509
1510   if (! moth) {
1511     printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
1512     return;
1513   };
1514
1515   fMotherVol = moth;
1516
1517   if (! fSDDsensor3) CreateBasicObjects();
1518
1519   TGeoTube *virtualLayer4Shape =new TGeoTube("ITSsddLayer4Shape",
1520                                     fgkLay4Rmin,fgkLay4Rmax,fgkLay4Length*0.5);
1521   TGeoMedium *airSDD = GetMedium("SDD AIR$");
1522   TGeoVolume *virtualLayer4 = new TGeoVolume("ITSsddLayer4",
1523                                              virtualLayer4Shape, airSDD);
1524
1525   //====================================
1526   // First we create the central barrel
1527   //====================================
1528
1529    TGeoVolumeAssembly *lay4Ladder    = CreateLadder(4);
1530   //TGeoVolume *lay4Detectors = CreateDetectors(4);
1531   TGeoVolumeAssembly *lay4Detectors = CreateDetectorsAssembly(4);
1532
1533   Double_t dPhi = 360./fgkLay4Nladd;
1534   Double_t detBoxThickness = fgkLadWaferSep + 2*fgkWaferThickness;
1535
1536   // placing virtual ladder and detectors volumes following ladder 
1537   // ordering convention
1538   char rotName[20];
1539   Int_t iLaddMin = 0;
1540   Int_t iLaddMax = fgkLay4Nladd;
1541   if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
1542     iLaddMin = fAddOnlyLadder4min;
1543     iLaddMax = fAddOnlyLadder4max+1;
1544   }
1545   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1546
1547     Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
1548     sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
1549     Double_t minRadiusLadBox = fLay4LaddShortRadius-fLay4LadderUnderSegDH;
1550     if (iLadd%2 != 0)
1551       minRadiusLadBox = fLay4LaddLongRadius-fLay4LadderUnderSegDH;
1552     minRadiusLadBox += ((TGeoBBox*)lay4Ladder->GetShape())->GetDY();
1553     TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName, minRadiusLadBox,
1554                                               0, ladderPhi, kTRUE);
1555     virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
1556     ///////////////////////////////////////////////////
1557     sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
1558     Double_t minRadiusDetBox = fgkLay4DetShortRadius;
1559     if (iLadd%2 != 0)
1560       minRadiusDetBox = fgkLay4DetLongRadius;
1561     minRadiusDetBox += detBoxThickness/2;
1562     TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
1563                                              0, ladderPhi, kTRUE);
1564     virtualLayer4->AddNode(lay4Detectors, iLadd, ctDet);
1565     ///////////////////////////////////////////////////
1566   }
1567
1568   /*
1569   //====================================
1570   // Then the pieces at forward rapidity
1571   // (cooling, Carlos, LV, HV ...)
1572   //====================================
1573
1574   Double_t fgkForwardLay4Length = fgkEndLadPipeUlengthLay4+10*fgkmm;  // this has to be tuned
1575   Double_t fgkForwardLay4Rmin = fgkLay4Rmin-9*fgkmm;
1576   Double_t fgkForwardLay4Rmax = fgkLay4Rmax-5*fgkmm;
1577
1578   TGeoVolumeAssembly* lay4EndLadder = CreateEndLadderCards(4);
1579   TGeoTube *virtualForward4Shape = new TGeoTube("virtualForward3Shape",
1580                                                 fgkForwardLay4Rmin, fgkForwardLay4Rmax,
1581                                                 fgkForwardLay4Length/2.);
1582   TGeoVolume *virtualForward4Pos = new TGeoVolume("ITSsddForward4Pos",
1583                                                   virtualForward4Shape, airSDD);
1584   TGeoVolume *virtualForward4Neg = new TGeoVolume("ITSsddForward4Neg",
1585                                                   virtualForward4Shape, airSDD);
1586 //   TGeoVolume *virtualForward4Pos = new TGeoVolumeAssembly("ITSsddForward4Pos");
1587 //   TGeoVolume *virtualForward4Neg = new TGeoVolumeAssembly("ITSsddForward4Neg");
1588
1589   TGeoTranslation *virtualForward4TrPos = new TGeoTranslation("virtualForward4TrPos",0,0,
1590                                           fgkLay4Length/2+fgkForwardLay4Length/2);
1591   TGeoTranslation *virtualForward4TrNeg = new TGeoTranslation("virtualForward4TrNeg",0,0,
1592                                           -fgkLay4Length/2-fgkForwardLay4Length/2);
1593
1594   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1595
1596     Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
1597     Double_t minRadiusDetBox = fgkLay4DetShortRadius;
1598     if (iLadd%2 != 0)
1599       minRadiusDetBox = fgkLay4DetLongRadius;
1600     minRadiusDetBox += detBoxThickness/2;
1601
1602     sprintf(rotName, "ITSsddLay4EndLadd%i",iLadd);
1603
1604     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1605                                    -fgkForwardLay4Length/2, ladderPhi, kTRUE);
1606     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1607                                     fgkForwardLay4Length/2, ladderPhi, kFALSE);
1608     virtualForward4Pos->AddNode(lay4EndLadder, iLadd*2, ctEndLaddPos);
1609     virtualForward4Neg->AddNode(lay4EndLadder, iLadd*2+1, ctEndLaddNeg);
1610   }
1611   */
1612
1613   if(GetDebug(1)) virtualLayer4->CheckOverlaps(0.01);
1614
1615   virtualLayer4->SetVisibility(kFALSE);
1616   //virtualForward4Pos->SetVisibility(kFALSE);
1617   //virtualForward4Neg->SetVisibility(kFALSE);
1618
1619   moth->AddNode(virtualLayer4,1,0);
1620   //moth->AddNode(virtualForward4Pos, 1, virtualForward4TrPos);
1621   //moth->AddNode(virtualForward4Neg, 1, virtualForward4TrNeg);
1622 }
1623
1624
1625 // //________________________________________________________________________
1626 // void AliITSv11GeometrySDD::ForwardLayer4(TGeoVolume *moth) {
1627 //   //
1628 //   // Insert the layer 4 in the mother volume. This is a virtual volume
1629 //   // containing ladders of layer 4 and the supporting rings
1630 //   // (cooling, Carlos, LV, HV ...)
1631 //   //
1632
1633 //   if (! moth) {
1634 //     printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
1635 //     return;
1636 //   };
1637
1638 //   TGeoMedium *airSDD = GetMedium("SDD AIR$");
1639
1640 //   if (! fSDDsensor3) CreateBasicObjects();
1641
1642 //   Double_t dPhi = 360./fgkLay4Nladd;
1643 //   Double_t detBoxThickness = fgkLadWaferSep + 2*fgkWaferThickness;
1644
1645 //   // placing virtual ladder and detectors volumes following ladder 
1646 //   // ordering convention
1647 //   char rotName[20];
1648 //   Int_t iLaddMin = 0;
1649 //   Int_t iLaddMax = fgkLay4Nladd;
1650 //   if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
1651 //     iLaddMin = fAddOnlyLadder4min;
1652 //     iLaddMax = fAddOnlyLadder4max+1;
1653 //   }
1654
1655 //   //=================
1656 //   Double_t fgkForwardLay4Length = fgkEndLadPipeUlengthLay4+10*fgkmm;  // this has to be tuned
1657 //   Double_t fgkForwardLay4Rmin = fgkLay4Rmin-9*fgkmm;
1658 //   Double_t fgkForwardLay4Rmax = fgkLay4Rmax-5*fgkmm;
1659
1660 //   TGeoVolumeAssembly* lay4EndLadder = CreateEndLadderCards(4);
1661 //   TGeoTube *virtualForward4Shape = new TGeoTube("virtualForward3Shape",
1662 //                                              fgkForwardLay4Rmin, fgkForwardLay4Rmax,
1663 //                                              fgkForwardLay4Length/2.);
1664 //   TGeoVolume *virtualForward4Pos = new TGeoVolume("ITSsddForward4Pos",
1665 //                                                virtualForward4Shape, airSDD);
1666 //   TGeoVolume *virtualForward4Neg = new TGeoVolume("ITSsddForward4Neg",
1667 //                                                virtualForward4Shape, airSDD);
1668 // //   TGeoVolume *virtualForward4Pos = new TGeoVolumeAssembly("ITSsddForward4Pos");
1669 // //   TGeoVolume *virtualForward4Neg = new TGeoVolumeAssembly("ITSsddForward4Neg");
1670
1671 //   TGeoTranslation *virtualForward4TrPos = new TGeoTranslation("virtualForward4TrPos",0,0,
1672 //                                        fgkLay4Length/2+fgkForwardLay4Length/2);
1673 //   TGeoTranslation *virtualForward4TrNeg = new TGeoTranslation("virtualForward4TrNeg",0,0,
1674 //                                        -fgkLay4Length/2-fgkForwardLay4Length/2);
1675
1676 //   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1677
1678 //     Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
1679 //     Double_t minRadiusDetBox = fgkLay4DetShortRadius;
1680 //     if (iLadd%2 != 0)
1681 //       minRadiusDetBox = fgkLay4DetLongRadius;
1682 //     minRadiusDetBox += detBoxThickness/2;
1683
1684 //     sprintf(rotName, "ITSsddLay4EndLadd%i",iLadd);
1685
1686 //     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1687 //                                 -fgkForwardLay4Length/2, ladderPhi, kTRUE);
1688 //     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
1689 //                                  fgkForwardLay4Length/2, ladderPhi, kFALSE);
1690 //     virtualForward4Pos->AddNode(lay4EndLadder, iLadd*2, ctEndLaddPos);
1691 //     virtualForward4Neg->AddNode(lay4EndLadder, iLadd*2+1, ctEndLaddNeg);
1692 //   }
1693
1694 //   virtualForward4Pos->SetVisibility(kFALSE);
1695 //   virtualForward4Neg->SetVisibility(kFALSE);
1696
1697 //   moth->AddNode(virtualForward4Pos, 1, virtualForward4TrPos);
1698 //   moth->AddNode(virtualForward4Neg, 1, virtualForward4TrNeg);
1699 // }
1700
1701
1702 //________________________________________________________________________
1703 void AliITSv11GeometrySDD::ForwardLayer4(TGeoVolume *moth) {
1704   //
1705   // Insert the end-ladder of layer 4 in the mother volume.
1706   // (cooling, Carlos, LV, HV ...)
1707   //
1708
1709   if (! moth) {
1710     printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
1711     return;
1712   };
1713
1714   if (! fSDDsensor3) CreateBasicObjects();
1715
1716   // placing virtual ladder and detectors volumes following ladder 
1717   // ordering convention
1718   Int_t iLaddMin = 0;
1719   Int_t iLaddMax = fgkLay4Nladd;
1720   if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
1721     iLaddMin = fAddOnlyLadder4min;
1722     iLaddMax = fAddOnlyLadder4max+1;
1723   }
1724
1725   TGeoVolume *virtualForward4Pos = new TGeoVolumeAssembly("ITSsddForward4Pos");
1726   TGeoVolume *virtualForward4Neg = new TGeoVolumeAssembly("ITSsddForward4Neg");
1727
1728   char rotName[30];
1729   Double_t dPhi = 360./fgkLay4Nladd;
1730   TGeoVolume* lay4EndLadder = CreateEndLadderCardsV(4);
1731
1732   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1733
1734     Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
1735     Double_t dR = 0;
1736     if (iLadd%2 != 0)
1737       dR = fgkLay4DetLongRadius-fgkLay4DetShortRadius;
1738
1739     sprintf(rotName, "ITSsddLay4EndLadd%i",iLadd);
1740
1741     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, dR,
1742                                    fgkLay4Length/2, ladderPhi, kTRUE);
1743     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, dR,
1744                                    -fgkLay4Length/2, ladderPhi, kFALSE);
1745     virtualForward4Pos->AddNode(lay4EndLadder, iLadd*2, ctEndLaddPos);
1746     virtualForward4Neg->AddNode(lay4EndLadder, iLadd*2, ctEndLaddNeg);
1747   }
1748
1749   // 180deg Y rotation to compensate the cancellation of ITSD volume
1750   // (idortm[199] in AliITSv11Hybrid : z--->  -z;   x ---> -x;   y ---> y)
1751   TGeoRotation *y180 = new TGeoRotation();
1752   y180->SetAngles( 90.,180., 90., 90.,180.,  0.);
1753   moth->AddNode(virtualForward4Pos, 1, y180);
1754   moth->AddNode(virtualForward4Neg, 1, y180);
1755 }
1756
1757
1758 //________________________________________________________________________
1759 TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
1760   //
1761   // return an assembly volume containing the CF ladder
1762   //
1763
1764   Int_t    nDetectors   = fgkLay3Ndet;
1765   Double_t ladderLength = fgkLay3LadderLength;
1766   Double_t underSegDH   = fLay3LadderUnderSegDH;
1767   Double_t *sensorZPos  = fLay3sensorZPos;
1768   AliITSv11GeomCableFlat *digitCableA = fDigitCableLay3A;
1769   AliITSv11GeomCableFlat *digitCableB = fDigitCableLay3B;
1770
1771   if (iLay==3) {}
1772   else if (iLay==4) {
1773     nDetectors   = fgkLay4Ndet;
1774     ladderLength = fgkLay4LadderLength;
1775     digitCableA  = fDigitCableLay4A;
1776     digitCableB  = fDigitCableLay4B;
1777     underSegDH   = fLay4LadderUnderSegDH;
1778     sensorZPos   = fLay4sensorZPos;
1779   }
1780   else {
1781     printf("AliITSv11GeometrySDD::CreateLadder : error=wrong layer\n");
1782   };
1783   Double_t ladderBoxDH = fgkLadderHeight+fgkLadderSegBoxDH+underSegDH;
1784   TGeoVolumeAssembly *virtualLadder = new TGeoVolumeAssembly("ITSsddLadder");
1785   
1786   // placing virtual ladder segment following detector ordering convention
1787   //=======================================================================
1788   char transName[30];
1789
1790   // adding segment this way to create cable points in the correct order ...
1791   for (Int_t iSegment = nDetectors/2-1; iSegment >= 0; iSegment-- ) {
1792
1793     //TGeoVolumeAssembly *laddSegment = CreateLadderSegment(iLay, iSegment);
1794     TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
1795     sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
1796     Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
1797                           + fgkSegmentLength/2;
1798     TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
1799                                                  underSegDH/2,segmentPos);
1800     ////
1801     virtualLadder->AddNode(laddSegment, iSegment, segTr);
1802   };
1803   for (Int_t iSegment = nDetectors/2; iSegment < nDetectors; iSegment++ ) {
1804
1805     TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
1806     //TGeoVolumeAssembly *laddSegment = CreateLadderSegment(iLay, iSegment);
1807     sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
1808     Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
1809                           + fgkSegmentLength/2;
1810     TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
1811                                                  underSegDH/2,segmentPos);
1812     ////
1813     virtualLadder->AddNode(laddSegment, iSegment, segTr);
1814   };
1815
1816   // putting virtual volume corresponding to the end of ladder
1817   //=======================================================================
1818   TGeoVolumeAssembly *endLadder = CreateEndLadder( iLay );
1819   Double_t endLength = (ladderLength - nDetectors*fgkSegmentLength)/2.;
1820   TGeoTranslation *endTrZPos = new TGeoTranslation("ITSsddEndTrZPos",0,0,
1821                                    fgkSegmentLength*(nDetectors/2)+endLength/2.);
1822   // Euler rotation : about Z, then new X, then new Z
1823   TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
1824   TGeoCombiTrans *endTrZNeg = new TGeoCombiTrans(0,0,
1825                   -fgkSegmentLength*(nDetectors/2)-endLength/2.,endZNegRot);
1826   virtualLadder->AddNode(endLadder, 1, endTrZPos);
1827   virtualLadder->AddNode(endLadder, 2, endTrZNeg);
1828
1829   // creating and inserting cable segments
1830   //   (check points are placed while creating segments)
1831   //=======================================================================
1832   if (fAddCables)
1833   for (Int_t iSegment = 0; iSegment < nDetectors; iSegment++ ) {
1834     
1835     digitCableA[iSegment].SetInitialNode(virtualLadder);
1836     digitCableB[iSegment].SetInitialNode(virtualLadder);
1837     
1838     for (Int_t iPt=1; iPt<digitCableA[iSegment].GetNCheckPoints(); iPt++ ) {
1839       Double_t rotation = 0;
1840       if (iPt>1) {
1841         rotation = 90-fgkHybridAngle; 
1842         digitCableA[iSegment].CreateAndInsertCableSegment(iPt, rotation);
1843       } else
1844         digitCableA[iSegment].CreateAndInsertCableSegment(iPt);
1845
1846     };
1847     
1848     for (Int_t iPt=1; iPt<digitCableB[iSegment].GetNCheckPoints(); iPt++ ) {
1849       Double_t rotation = 0;
1850       if (iPt>1) {
1851         rotation = fgkHybridAngle-90; 
1852         digitCableB[iSegment].CreateAndInsertCableSegment(iPt, rotation);
1853       } else
1854         digitCableB[iSegment].CreateAndInsertCableSegment(iPt);
1855     };
1856   };
1857   
1858   // HV cable
1859   //=======================================================================
1860   if (fAddHVcables) {
1861     TGeoMedium *polyhamideSDD = GetMedium("SDDKAPTON (POLYCH2)$");  //ITSsddKAPTON_POLYCH2
1862     TGeoMedium *alSDD         = GetMedium("AL$");   //ITSal
1863
1864   AliITSv11GeomCableFlat cableHV[fgkLay4Ndet];  // temp !!!
1865   char cableHVname[30];
1866   for (Int_t iSegment = 0; iSegment<nDetectors; iSegment++) {
1867     sprintf(cableHVname,"ITSsddHVcable%i", iSegment);
1868     cableHV[iSegment].SetName(cableHVname);
1869     cableHV[iSegment].SetThickness(fgkLongHVcablePolyThick+fgkLongHVcableAlThick);
1870     cableHV[iSegment].SetWidth(fgkTransitHVtailWidth);
1871     cableHV[iSegment].SetNLayers(2);
1872     cableHV[iSegment].SetLayer(0, fgkLongHVcablePolyThick, polyhamideSDD,
1873                                fColorPolyhamide);
1874     cableHV[iSegment].SetLayer(1, fgkLongHVcableAlThick, alSDD, fColorAl);
1875     cableHV[iSegment].SetInitialNode(virtualLadder);
1876   };
1877   Double_t x1[3], x2[3], x3[3],
1878            vY[3] = {0,1,0}, vZ[3] = {0,0,1}, vYZ[3]={0,1,1};
1879
1880   x1[0] = -fgkTransitHVtailXpos;
1881   x2[0] = -fgkTransitHVtailXpos;
1882   x3[0] = -fgkTransitHVtailXpos;
1883   for (Int_t iSegment  = nDetectors/2-1; iSegment >= 0; iSegment-- ) {
1884     Double_t cableSeparation = TMath::Abs(iSegment - (nDetectors/2-1))
1885                                *fgkLongHVcableSeparation;
1886     // adjust where HV long cable starts in Y
1887     // useful if you want to let some space for alignment
1888     x1[1] = - ladderBoxDH/2 + 2*fgkmm;
1889     x2[1] = - ladderBoxDH/2 + underSegDH - cableSeparation
1890             - (fgkLongHVcablePolyThick+fgkLongHVcableAlThick)/2;
1891     x3[1] = x2[1];
1892     x1[2] = sensorZPos[iSegment]+fgkTransitHVtailLength-5*fgkmm;
1893     x2[2] =  x1[2]+5*fgkmm;
1894     x3[2] = ladderLength/2-endLength;
1895     cableHV[iSegment].AddCheckPoint( virtualLadder, 0, x1, vY );
1896     cableHV[iSegment].AddCheckPoint( virtualLadder, 1, x2, vZ ); // vYZ
1897     cableHV[iSegment].AddCheckPoint( virtualLadder, 2, x3, vZ );
1898
1899     //cableHV[iSegment].CreateAndInsertCableSegment(1,0);
1900     cableHV[iSegment].CreateAndInsertCableCylSegment(1, -45+180);
1901     //cableHV[iSegment].CreateAndInsertCableSegment(2,0);
1902     cableHV[iSegment].CreateAndInsertBoxCableSegment(2,0);
1903   };
1904
1905   vYZ[2] = -1;
1906   x1[0] = fgkTransitHVtailXpos;
1907   x2[0] = fgkTransitHVtailXpos;
1908   x3[0] = fgkTransitHVtailXpos;
1909
1910   for (Int_t iSegment = nDetectors/2; iSegment < nDetectors; iSegment++ ) { 
1911     Double_t cableSeparation = TMath::Abs(iSegment - (nDetectors/2-1))
1912                                *fgkLongHVcableSeparation;
1913     x1[1] = - ladderBoxDH/2 + 2*fgkmm; // adjust where HV long cable starts in Y
1914     x2[1] = - ladderBoxDH/2 + underSegDH - cableSeparation
1915             - (fgkLongHVcablePolyThick+fgkLongHVcableAlThick)/2;
1916     x3[1] = x2[1];
1917     x1[2] = sensorZPos[iSegment]-fgkTransitHVtailLength+5*fgkmm;
1918     x2[2] =  x1[2]-5*fgkmm;
1919     x3[2] = -ladderLength/2+endLength;
1920     cableHV[iSegment].AddCheckPoint( virtualLadder, 0, x1, vY );
1921     cableHV[iSegment].AddCheckPoint( virtualLadder, 1, x2, vZ ); // vYZ
1922     cableHV[iSegment].AddCheckPoint( virtualLadder, 2, x3, vZ );
1923
1924     cableHV[iSegment].CreateAndInsertCableCylSegment(1, -45);
1925     cableHV[iSegment].CreateAndInsertBoxCableSegment(2,0);
1926   };
1927   };
1928
1929   //**********************************
1930   if(GetDebug(1)) virtualLadder->CheckOverlaps(0.01);
1931   return virtualLadder;
1932 }
1933
1934
1935 //________________________________________________________________________
1936 TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(const char *name,
1937                          Double_t dz, Double_t angle, Double_t xSign,
1938                          Double_t L, Double_t H, Double_t l) {
1939     // Create one half of the V shape corner of CF ladder
1940   
1941     TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
1942     cfLaddSide->SetName(name);
1943
1944     // Points must be in clockwise order
1945     cfLaddSide->SetVertex(0, 0,  0);
1946     cfLaddSide->SetVertex(2, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
1947                           -L*TMath::Cos(angle)-l*TMath::Sin(angle));
1948     cfLaddSide->SetVertex(4, 0,  0);
1949     cfLaddSide->SetVertex(6, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
1950                           -L*TMath::Cos(angle)-l*TMath::Sin(angle));
1951     if (xSign < 0) {
1952      cfLaddSide->SetVertex(1, 0, -H);
1953      cfLaddSide->SetVertex(3, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
1954      cfLaddSide->SetVertex(5, 0, -H);
1955      cfLaddSide->SetVertex(7, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
1956     } else {
1957      cfLaddSide->SetVertex(1, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
1958      cfLaddSide->SetVertex(3, 0, -H);
1959      cfLaddSide->SetVertex(5, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
1960      cfLaddSide->SetVertex(7, 0, -H);
1961     }
1962     return cfLaddSide;
1963 }
1964
1965
1966 //________________________________________________________________________
1967 TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
1968   //
1969   // return a box containing the front-end hybrid
1970   //
1971
1972   Double_t roundHoleX       = -fgkHybridWidth/2+fgkHybRndHoleX;
1973
1974   Double_t screenTotalThick = fgkHybGlueScrnThick+fgkHybUpThick+fgkHybAlThick;
1975   Double_t lowFLTotalThick  = fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick;
1976 //   Double_t upFLTotalThick   = fgkHybGlueUpThick +fgkHybUpThick+fgkHybAlThick;
1977   Double_t chipsCCTotThick  = fgkHybUnderNiThick+fgkHybGlueAgThick
1978                               +fgkHybChipThick+2*(fgkHybUpCCThick+fgkHybAlCCThick);
1979   Double_t ccUpLayerTotThick = fgkHybUpCCThick+fgkHybAlCCThick+fgkHybUpCCThick;
1980 //   Double_t volumeThick = (fgkHybridThBridgeThick+screenTotalThick+lowFLTotalThick
1981 //                        + upFLTotalThick + ccUpLayerTotThick);
1982   Double_t volumeThick = (fgkHybridThBridgeThick+screenTotalThick+lowFLTotalThick
1983                           +fgkHybSMDheight);
1984   Double_t lowLayerYmin     = -volumeThick/2+fgkHybridThBridgeThick
1985                               +screenTotalThick;
1986   Double_t flUpThick        = fgkHybGlueUpThick+fgkHybUpThick;
1987
1988   //**************************************************** media :
1989   TGeoMedium *airSDD                  = GetMedium("SDD AIR$");
1990   TGeoMedium *carbonFiberLadderStruct = GetMedium("SDDKAPTON (POLYCH2)$"); //ITSsddCarbonM55J
1991   TGeoMedium *alSDD                   = GetMedium("AL$"); //ITSal
1992   TGeoMedium *alSDD80p100             = GetMedium("AL$");                 // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1993   TGeoMedium *alSDD50p100             = GetMedium("AL$");                 // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1994   TGeoMedium *polyhamideSDD           = GetMedium("SDDKAPTON (POLYCH2)$"); //ITSsddKAPTON_POLYCH2
1995   TGeoMedium *niSDD                   = GetMedium("COPPER$");                // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1996   TGeoMedium *glueAG                  = GetMedium("SDDKAPTON (POLYCH2)$");  // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1997   TGeoMedium *siliconSDD              = GetMedium("SDD SI CHIP$"); //ITSsddSiChip
1998   TGeoMedium *medSMD                  = GetMedium("SDD X7R capacitors$");      //  SDDX7Rcapacitors   TO CHECK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1999   TGeoMedium *medSMDweld              = GetMedium("SDD X7R capacitors$");      //  SDDX7Rcapacitors  TO CHECK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2000
2001   //**************************************************** main volume :
2002   TGeoBBox *hybridBox = new TGeoBBox("",fgkHybridWidth/2, volumeThick/2,
2003                                      (fgkHybridLength)/2);
2004   TGeoVolume *hybrid = new TGeoVolume("ITSsddHybridVol", hybridBox,
2005                                       airSDD);
2006  
2007   TGeoBBox *sThermalBridge = new TGeoBBox( "", fgkHybridWidth/2,
2008                                            fgkHybridThBridgeThick/2,
2009                                            fgkHybridLength/2);
2010
2011   //**************************************************** Thermal bridge :
2012   TGeoVolume *vThermalBridge = new TGeoVolume("ITSsddHybridThBridge",
2013                                               sThermalBridge,
2014                                               carbonFiberLadderStruct);
2015   vThermalBridge->SetLineColor(fColorCarbonFiber);
2016   TGeoTranslation *thBridgeTr = new TGeoTranslation(0, -volumeThick/2
2017                                     +fgkHybridThBridgeThick/2, 0);
2018   hybrid->AddNode(vThermalBridge, 1, thBridgeTr);
2019
2020   //**************************************************** Screen layer :
2021   TGeoBBox *sAlScreenLayer = new TGeoBBox("sAlScreenLayer", fgkHybridWidth/2,
2022                                           fgkHybAlThick/2, fgkHybridLength/2);
2023   //here the upedex and glue layers are both assumed to be polyimide
2024   TGeoBBox *sUpGlueScreenLayer = new TGeoBBox("sUpGlueScreenLayer",
2025                                               fgkHybridWidth/2,
2026                                      (fgkHybUpThick+fgkHybGlueScrnThick)/2,
2027                                               fgkHybridLength/2);
2028   TGeoTube *sRoundHole = new TGeoTube("sRoundHole", 0, fgkHybRndHoleRad,
2029                                       (screenTotalThick+lowFLTotalThick)/2);
2030
2031   TGeoTranslation *upGlueScreenTr = new TGeoTranslation("upGlueScreenTr",0,
2032    -volumeThick/2+fgkHybridThBridgeThick+(fgkHybUpThick+fgkHybGlueScrnThick)/2,0);
2033
2034   TGeoTranslation *alScreenTr = new TGeoTranslation("AlScreenTr", 0,
2035    -volumeThick/2+fgkHybridThBridgeThick+fgkHybUpThick+fgkHybGlueScrnThick
2036    +fgkHybAlThick/2, 0);
2037
2038   TGeoTranslation hybHolePos1Tr(roundHoleX,
2039    -volumeThick/2+fgkHybridThBridgeThick+(screenTotalThick+lowFLTotalThick)/2,
2040                                 -fgkHybridLength/2+fgkHybRndHoleZ);
2041   TGeoTranslation hybHolePos2Tr(roundHoleX, 
2042    -volumeThick/2+fgkHybridThBridgeThick+(screenTotalThick+lowFLTotalThick)/2,
2043                                 fgkHybridLength/2-fgkHybRndHoleZ);
2044
2045   TGeoRotation *rotHole = new TGeoRotation("", 0, 90, 0);
2046   TGeoCombiTrans *hybHolePos1 = new TGeoCombiTrans(hybHolePos1Tr, *rotHole);
2047   hybHolePos1->SetName("hybHolePos1");
2048   TGeoCombiTrans *hybHolePos2 = new TGeoCombiTrans(hybHolePos2Tr, *rotHole);
2049   hybHolePos2->SetName("hybHolePos2");
2050
2051   upGlueScreenTr->RegisterYourself();
2052   alScreenTr->RegisterYourself();
2053   hybHolePos1->RegisterYourself();
2054   hybHolePos2->RegisterYourself();
2055   delete rotHole;
2056
2057   TGeoCompositeShape *sScreenAl = new TGeoCompositeShape(
2058                       "sAlScreenLayer:AlScreenTr-(sRoundHole:hybHolePos1"
2059                       "+sRoundHole:hybHolePos2)");
2060   TGeoVolume *vScreenAl = new TGeoVolume("vScreenAl",sScreenAl, alSDD);
2061   vScreenAl->SetLineColor(fColorAl);
2062   TGeoCompositeShape *sScreenUpGlue = new TGeoCompositeShape(
2063         "sUpGlueScreenLayer:upGlueScreenTr-(sRoundHole:hybHolePos1"
2064         "+sRoundHole:hybHolePos2)");
2065   TGeoVolume *vScreenUpGlue = new TGeoVolume("vScreenUpGlue",
2066                                              sScreenUpGlue,polyhamideSDD);
2067   vScreenUpGlue->SetLineColor(fColorPolyhamide);
2068
2069   hybrid->AddNode(vScreenUpGlue, 1, 0);
2070   hybrid->AddNode(vScreenAl, 1, 0);
2071
2072   //****************************************************  FL low layer :
2073   Double_t sideWidth1 = fgkHybFLlowChipZ1 - fgkHybFLlowHoleDZ/2;
2074   Double_t sideWidth2 = fgkHybridLength - fgkHybFLlowChipZ4 - fgkHybFLlowHoleDZ/2;
2075
2076   //here the upedex and glue layers are both assumed to be polyimide
2077   TGeoBBox *sUpGlueBar1 = new TGeoBBox("sUpGlueBar1", fgkHybridWidth/2,
2078                                       (fgkHybGlueLowThick+fgkHybUpThick)/2,
2079                                        sideWidth1/2);
2080   TGeoBBox *sAlBar1 = new TGeoBBox("sAlBar1", fgkHybridWidth/2,
2081                                   fgkHybAlThick/2, sideWidth1/2);
2082  
2083   TGeoTranslation *upGlueBarTr1 = new TGeoTranslation("upGlueBarTr1", 0,
2084                               lowLayerYmin+(fgkHybGlueLowThick+fgkHybUpThick)/2,
2085                                               -(fgkHybridLength-sideWidth1)/2);
2086   TGeoTranslation *alBarTr1 = new TGeoTranslation("alBarTr1", 0,
2087                     lowLayerYmin+fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick/2,
2088                                               -(fgkHybridLength-sideWidth1)/2);
2089   upGlueBarTr1->RegisterYourself();
2090   alBarTr1->RegisterYourself();
2091
2092   TGeoCompositeShape *sLowUpGlueBar1 = new TGeoCompositeShape(
2093                      "sUpGlueBar1:upGlueBarTr1-sRoundHole:hybHolePos1");
2094   TGeoCompositeShape *sLowAlBar1 = new TGeoCompositeShape(
2095                       "sAlBar1:alBarTr1-sRoundHole:hybHolePos1");
2096   TGeoVolume *vLowUpGlueBar1 = new TGeoVolume("vLowUpGlueBar1",
2097                                               sLowUpGlueBar1, polyhamideSDD);
2098   TGeoVolume *vLowAlBar1 = new TGeoVolume("vLowAlBar1",
2099                                           sLowAlBar1, alSDD);
2100   vLowUpGlueBar1->SetLineColor(fColorPolyhamide);
2101   vLowAlBar1->SetLineColor(fColorAl);
2102   hybrid->AddNode(vLowUpGlueBar1,1,0);
2103   hybrid->AddNode(vLowAlBar1,1,0);
2104
2105   //---
2106   //here the upedex and glue layers are both assumed to be polyimide
2107   TGeoBBox *sUpGlueBar2 = new TGeoBBox("sUpGlueBar2", fgkHybridWidth/2,
2108                                        (fgkHybGlueLowThick+fgkHybUpThick)/2,
2109                                        sideWidth2/2);
2110   TGeoBBox *sAlBar2 = new TGeoBBox("sAlBar2", fgkHybridWidth/2,
2111                                    fgkHybAlThick/2, sideWidth2/2);
2112
2113  TGeoTranslation *upGlueBarTr2 = new TGeoTranslation("upGlueBarTr2", 0,
2114                               lowLayerYmin+(fgkHybGlueLowThick+fgkHybUpThick)/2,
2115                                                (fgkHybridLength-sideWidth2)/2);
2116   TGeoTranslation *alBarTr2 = new TGeoTranslation("alBarTr2", 0,
2117                     lowLayerYmin+fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick/2,
2118                                                (fgkHybridLength-sideWidth2)/2);
2119   upGlueBarTr2->RegisterYourself();
2120   alBarTr2->RegisterYourself();
2121
2122   TGeoCompositeShape *sLowUpGlueBar2 = new TGeoCompositeShape(
2123                      "sUpGlueBar2:upGlueBarTr2-sRoundHole:hybHolePos2");
2124   TGeoCompositeShape *sLowAlBar2 = new TGeoCompositeShape(
2125                       "sAlBar2:alBarTr2-sRoundHole:hybHolePos2");
2126   TGeoVolume *vLowUpGlueBar2 = new TGeoVolume("vLowUpGlueBar2",sLowUpGlueBar2,
2127                                               polyhamideSDD);
2128   TGeoVolume *vLowAlBar2 = new TGeoVolume("vLowAlBar2",sLowAlBar2,
2129                                           alSDD);
2130   vLowUpGlueBar2->SetLineColor(fColorPolyhamide);
2131   vLowAlBar2->SetLineColor(fColorAl);
2132   hybrid->AddNode(vLowUpGlueBar2, 1, 0);
2133   hybrid->AddNode(vLowAlBar2, 1, 0);
2134
2135   if(GetDebug(3)) { // Remove compiler warning.
2136     sAlScreenLayer->InspectShape();
2137     sUpGlueScreenLayer->InspectShape();
2138     sRoundHole->InspectShape();
2139     sUpGlueBar1->InspectShape();
2140     sUpGlueBar2->InspectShape();
2141     sAlBar1->InspectShape();
2142     sAlBar2->InspectShape();
2143   };
2144   //---
2145   //using class AliITSv11GeomCableFlat to add 2-layer segments ... 
2146   Double_t piece1width = fgkHybFLlowPasX-fgkHybFLlowHolePasDX/2;
2147   AliITSv11GeomCableFlat lowFLpiece("lowFLpiece1",piece1width,
2148                                        lowFLTotalThick);
2149   lowFLpiece.SetNLayers(2);
2150   lowFLpiece.SetLayer(0, fgkHybGlueLowThick+fgkHybUpThick, polyhamideSDD,
2151                        fColorPolyhamide);
2152   lowFLpiece.SetLayer(1, fgkHybAlThick, alSDD80p100, fColorAl);
2153   // alSDD at 80% : mostly to take into account strips of piece 3
2154
2155   Double_t x1[3] = { -fgkHybridWidth/2 + piece1width/2,
2156                      lowLayerYmin + lowFLTotalThick/2,
2157                      -fgkHybridLength/2 + sideWidth1 };
2158   Double_t x2[3] ={ x1[0], x1[1], fgkHybridLength/2 - sideWidth2 };
2159   Double_t vZ[3] = {0,0,1};
2160   lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
2161   lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
2162   lowFLpiece.SetInitialNode(hybrid);
2163   lowFLpiece.CreateAndInsertBoxCableSegment(1);
2164   lowFLpiece.ResetPoints();
2165
2166   Double_t piece2width = fgkHybFLlowAmbX-fgkHybFLlowPasX
2167                          -fgkHybFLlowHolePasDX/2-fgkHybFLlowHoleAmbDX/2;
2168
2169   lowFLpiece.SetWidth(piece2width);
2170   lowFLpiece.SetName("lowFLpiece2");
2171   x1[0] = piece2width/2+fgkHybFLlowPasX+fgkHybFLlowHolePasDX/2-fgkHybridWidth/2;
2172   x2[0] = x1[0];
2173   lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
2174   lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
2175   lowFLpiece.CreateAndInsertBoxCableSegment(1);
2176   lowFLpiece.ResetPoints();
2177
2178   Double_t piece3width = fgkHybridWidth - fgkHybFLlowAmbX 
2179                          - fgkHybFLlowHoleAmbDX/2;
2180
2181   lowFLpiece.SetWidth(piece3width);
2182   lowFLpiece.SetName("lowFLpiece3");
2183   x1[0] = fgkHybridWidth/2-piece3width/2;
2184   x2[0] = x1[0];
2185   lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
2186   lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
2187   lowFLpiece.CreateAndInsertBoxCableSegment(1);
2188
2189   Double_t zChips[4] = {fgkHybFLlowChipZ1,fgkHybFLlowChipZ2,
2190                         fgkHybFLlowChipZ3,fgkHybFLlowChipZ4};
2191   Double_t vX[3] = {1,0,0};
2192   for (Int_t i=0; i<3; i++) {
2193     char ch[20];
2194     sprintf(ch, "lowFLpieceA%i", i+4);
2195     lowFLpiece.SetName(ch);
2196     lowFLpiece.SetWidth(zChips[i+1]-zChips[i]-fgkHybFLlowHoleDZ);
2197
2198     lowFLpiece.SetLayer(1, fgkHybAlThick, alSDD, fColorAl);
2199     x1[0] = -fgkHybridWidth/2 + piece1width;
2200     x2[0] = x1[0] + fgkHybFLlowHolePasDX;
2201     Double_t zPiece = (zChips[i+1]+zChips[i])/2 - fgkHybridLength/2;
2202     x1[2] = zPiece; x2[2] = zPiece; 
2203     lowFLpiece.AddCheckPoint( hybrid, 0, x2, vX );
2204     lowFLpiece.AddCheckPoint( hybrid, 1, x1, vX );
2205     lowFLpiece.CreateAndInsertBoxCableSegment(1,90);
2206     lowFLpiece.ResetPoints();
2207
2208     sprintf(ch, "lowFLpieceB%i", i+4);
2209     lowFLpiece.SetName(ch);
2210     x1[0] = fgkHybridWidth/2 - piece3width;
2211     x2[0] = x1[0] - fgkHybFLlowHoleAmbDX;
2212     lowFLpiece.AddCheckPoint( hybrid, 0, x1, vX );
2213     lowFLpiece.AddCheckPoint( hybrid, 1, x2, vX );
2214     lowFLpiece.CreateAndInsertBoxCableSegment(1,90);
2215   };
2216   
2217   //**************************************************** chips+CC:
2218   AliITSv11GeomCableFlat chip("", fgkHybChipsDZ, chipsCCTotThick);
2219   chip.SetInitialNode(hybrid);
2220   chip.SetNLayers(5);
2221   chip.SetLayer(0, fgkHybUnderNiThick, niSDD, 2);
2222   chip.SetLayer(1, fgkHybGlueAgThick, glueAG, 4);
2223   chip.SetLayer(2, fgkHybChipThick, siliconSDD, fColorSilicon);
2224   chip.SetLayer(3, fgkHybUpCCThick+fgkHybUpCCThick, polyhamideSDD,
2225                 fColorPolyhamide);
2226   chip.SetLayer(4, fgkHybAlCCThick+fgkHybAlCCThick, alSDD80p100, fColorAl);
2227   // Here the tho CC (low+up) are merged
2228   // In fact, the last layer has a smaller surface of Al -> I put 80%
2229   
2230   x1[1] = lowLayerYmin + chipsCCTotThick/2;
2231   x2[1] = x1[1];
2232   char ch[20];
2233
2234   for (Int_t i=0; i<4; i++) {
2235     sprintf(ch, "pascalCC%i", i);
2236     chip.SetName(ch);
2237     x1[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
2238     x2[0] = x1[0] + fgkHybPascalDX;
2239     x1[2] =  zChips[i] - fgkHybridLength/2;
2240     x2[2] = x1[2];
2241     chip.AddCheckPoint( hybrid, 0, x1, vX );
2242     chip.AddCheckPoint( hybrid, 1, x2, vX );
2243     chip.CreateAndInsertBoxCableSegment(1,-90);
2244     chip.ResetPoints();
2245
2246     sprintf(ch, "ambraCC%i", i);
2247     chip.SetName(ch);
2248     x1[0] = fgkHybFLlowAmbX - fgkHybridWidth/2 - fgkHybAmbraDX/2;
2249     x2[0] = x1[0] + fgkHybAmbraDX;
2250     chip.AddCheckPoint( hybrid, 0, x1, vX );
2251     chip.AddCheckPoint( hybrid, 1, x2, vX );
2252     chip.CreateAndInsertBoxCableSegment(1,-90);
2253     chip.ResetPoints();
2254   };
2255
2256   //**************************************************** CC outside chips:
2257   // I don't think there is a second aluminium layer here ...
2258   for (Int_t i = 0; i<4; i++) {
2259     sprintf(ch, "ccLayerA%i", i);
2260
2261     AliITSv11GeomCableFlat ccLayer1(ch, 6.6*fgkmm, ccUpLayerTotThick);
2262     ccLayer1.SetInitialNode(hybrid);
2263     ccLayer1.SetNLayers(2);
2264     ccLayer1.SetLayer(0, 2*fgkHybUpCCThick, polyhamideSDD, fColorPolyhamide);
2265     ccLayer1.SetLayer(1, fgkHybAlCCThick, alSDD50p100, fColorAl);
2266     // Al at ~50%
2267
2268     x1[0] = -fgkHybridWidth/2;
2269     x2[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
2270     x1[1] = lowLayerYmin + fgkHybUnderNiThick + fgkHybGlueAgThick
2271             + fgkHybChipThick + ccUpLayerTotThick/2;
2272     x2[1] = x1[1];
2273     x1[2] = zChips[i] - fgkHybridLength/2;
2274     x2[2] = x1[2];
2275     ccLayer1.AddCheckPoint( hybrid, 0, x1, vX );
2276     ccLayer1.AddCheckPoint( hybrid, 1, x2, vX );
2277     ccLayer1.CreateAndInsertBoxCableSegment(1,-90);
2278
2279     sprintf(ch, "ccLayerB%i", i);
2280     AliITSv11GeomCableFlat ccLayer2(ch, fgkHybChipsDZ, ccUpLayerTotThick);
2281     ccLayer2.SetInitialNode(hybrid);
2282     ccLayer2.SetNLayers(2);
2283     ccLayer2.SetLayer(0, 2*fgkHybUpCCThick, polyhamideSDD, fColorPolyhamide);
2284     ccLayer2.SetLayer(1, fgkHybAlCCThick, alSDD50p100, fColorAl);
2285      // Al at ~50%
2286
2287     x1[0] = -fgkHybridWidth/2 + fgkHybFLlowPasX + fgkHybPascalDX/2;
2288     x2[0] = -fgkHybridWidth/2 + fgkHybFLlowAmbX - fgkHybAmbraDX/2;
2289     ccLayer2.AddCheckPoint( hybrid, 0, x1, vX );
2290     ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
2291     ccLayer2.CreateAndInsertBoxCableSegment(1,-90);
2292     ccLayer2.ResetPoints();
2293     sprintf(ch, "ccLayerC%i", i);
2294     ccLayer2.SetName(ch);
2295     x1[0] =  -fgkHybridWidth/2 + fgkHybFLlowAmbX + fgkHybAmbraDX/2;
2296     x2[0] = fgkHybridWidth/2 - fgkHybFLUpperWidth + 3*fgkmm;
2297     x1[1] = lowLayerYmin + lowFLTotalThick + flUpThick + fgkHybAlThick
2298              + ccUpLayerTotThick/2;
2299     x2[1] = x1[1];
2300
2301     ccLayer2.AddCheckPoint( hybrid, 0, x1, vX );
2302     ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
2303     ccLayer2.CreateAndInsertBoxCableSegment(1,-90);
2304   };
2305
2306   //**************************************************** FL UP:
2307   // (last Al layer will be a special triangular shape)
2308   TGeoBBox *sFLupPolyhamide = new TGeoBBox("sFLupPolyhamide",
2309                               fgkHybFLUpperWidth/2, flUpThick/2,
2310                               fgkHybFLUpperLength/2);
2311   TGeoVolume *vFLupPolyhamide = new TGeoVolume("vFLupPolyhamide",
2312                                     sFLupPolyhamide, polyhamideSDD);
2313   vFLupPolyhamide->SetLineColor(fColorPolyhamide);
2314   TGeoTranslation *trFLupPolyhamide = 
2315     new TGeoTranslation(fgkHybridWidth/2-fgkHybFLUpperWidth/2,
2316                         lowLayerYmin+lowFLTotalThick+flUpThick/2,0);
2317
2318   hybrid->AddNode(vFLupPolyhamide, 1, trFLupPolyhamide);
2319
2320   TGeoArb8 *aluStrip = new TGeoArb8(fgkHybAlThick/2);
2321   aluStrip->SetVertex( 0,-fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
2322   aluStrip->SetVertex( 1, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
2323   aluStrip->SetVertex( 2, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth-fgkHybFLUpperAldx);
2324   aluStrip->SetVertex( 3,-fgkHybFLUpperAlDZ/2, 0);
2325   aluStrip->SetVertex( 4,-fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
2326   aluStrip->SetVertex( 5, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
2327   aluStrip->SetVertex( 6, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth-fgkHybFLUpperAldx);
2328   aluStrip->SetVertex( 7,-fgkHybFLUpperAlDZ/2, 0);
2329   TGeoVolume *vAluStrip = new TGeoVolume("vAluStrip",aluStrip, alSDD50p100);
2330   // Al at ~50%
2331
2332   vAluStrip->SetLineColor(fColorAl);
2333   //TGeoRotation rotAluStrip("rotAluStrip",0, -90, 90);
2334   TGeoRotation *rotAluStrip = new TGeoRotation("rotAluStrip",0, -90, 90);
2335
2336   Double_t yRotAluStrip = lowLayerYmin+lowFLTotalThick
2337                           +flUpThick+fgkHybAlThick/2;
2338   TGeoCombiTrans *aluStripTr1 = new TGeoCombiTrans(
2339                                     fgkHybridWidth/2,yRotAluStrip,
2340                     fgkHybridLength/2-fgkHybFLlowChipZ1+1*fgkmm, rotAluStrip);
2341   TGeoCombiTrans *aluStripTr2 = new TGeoCombiTrans(*aluStripTr1);
2342   AddTranslationToCombiTrans(aluStripTr2,0,0,
2343                              fgkHybFLlowChipZ1-fgkHybFLlowChipZ2);
2344   TGeoCombiTrans *aluStripTr3 = new TGeoCombiTrans(*aluStripTr2);
2345   AddTranslationToCombiTrans(aluStripTr3,0,0,
2346                              fgkHybFLlowChipZ2-fgkHybFLlowChipZ3);
2347   TGeoCombiTrans *aluStripTr4 = new TGeoCombiTrans(*aluStripTr3);
2348   AddTranslationToCombiTrans(aluStripTr4,0,0,
2349                              fgkHybFLlowChipZ3-fgkHybFLlowChipZ4);
2350
2351   hybrid->AddNode(vAluStrip, 1, aluStripTr1); 
2352   hybrid->AddNode(vAluStrip, 2, aluStripTr2); 
2353   hybrid->AddNode(vAluStrip, 3, aluStripTr3); 
2354   hybrid->AddNode(vAluStrip, 4, aluStripTr4); 
2355   //**************************************************** SMD:
2356   TGeoBBox *hybSMD = new TGeoBBox("ITSsddSMDshape",
2357                                   fgkHybSMDmiddleL/2+fgkHybSMDendL,
2358                                   fgkHybSMDheight/2,fgkHybSMDendW/2);
2359   TGeoVolume *vHybSMD = new TGeoVolume("ITSsddSMD",hybSMD,airSDD);
2360
2361   TGeoBBox *hybSMDmiddle = new TGeoBBox("ITSsddSMDmiddleShape",
2362                                fgkHybSMDmiddleL/2,fgkHybSMDheight/2,
2363                                         fgkHybSMDmiddleW/2);
2364   TGeoVolume *vHybSMDmiddle = new TGeoVolume("ITSsddSMDmiddle",
2365                                             hybSMDmiddle,medSMD);
2366   vHybSMDmiddle->SetLineColor(fColorSMD);
2367   TGeoBBox *hybSMDend = new TGeoBBox("ITSsddSMDendShape",
2368                             fgkHybSMDendL/2,fgkHybSMDheight/2,fgkHybSMDendW/2);
2369   TGeoVolume *vHybSMDend = new TGeoVolume("ITSsddSMDend",
2370                                           hybSMDend,medSMDweld);
2371   vHybSMDend->SetLineColor(fColorSMDweld);
2372   TGeoTranslation *vHybSMDendTr1 = new TGeoTranslation("",
2373                                        (fgkHybSMDmiddleL+fgkHybSMDendL)/2,0,0);
2374   TGeoTranslation *vHybSMDendTr2 = new TGeoTranslation("",
2375                                        -(fgkHybSMDmiddleL+fgkHybSMDendL)/2,0,0);
2376   vHybSMD->AddNode(vHybSMDmiddle,1,0);
2377   vHybSMD->AddNode(vHybSMDend,1,vHybSMDendTr1);
2378   vHybSMD->AddNode(vHybSMDend,2,vHybSMDendTr2);
2379   for (Int_t i=0; i<fgkNHybSMD; i++) {
2380     TGeoTranslation *vHybSMDtr = new TGeoTranslation("",
2381                                  -fgkHybridWidth/2+fgkHybSMDposX[i],
2382                                  lowLayerYmin+lowFLTotalThick+fgkHybSMDheight/2,
2383                                  -fgkHybridLength/2+fgkHybSMDposZ[i]);
2384     hybrid->AddNode(vHybSMD, i+1, vHybSMDtr);
2385   };
2386
2387   if (iLRSide == 0) {
2388   };
2389
2390   if(GetDebug(1)) hybrid->CheckOverlaps(0.01);
2391   hybrid->SetVisibility(kFALSE);
2392   return hybrid;
2393 }
2394
2395 //________________________________________________________________________
2396 TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
2397   //
2398   // Return a TGeoVolume* containing a segment of a ladder.
2399   //
2400
2401   TGeoMedium *phynoxSDD       = GetMedium("INOX$");
2402   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
2403   TGeoMedium *airSDD          = GetMedium("SDD AIR$");
2404
2405   Double_t tDY = fgkLadderSegBoxDH/2; //space left on top of the ladder 
2406   Double_t segmentLength = fgkSegmentLength;
2407   Double_t spaceBetweenCables = 500*fgkmicron;
2408   
2409   //*****************************************
2410   // Set parameters according to (iLay,iSeg):
2411   //*****************************************
2412   Int_t nDetectors          = fgkLay3Ndet;
2413   Double_t coolPipeSuppH    = fgkLay3CoolPipeSuppH;
2414   Double_t sensorCenterZPos = fLay3sensorZPos[iSeg]-
2415                               (fgkSegmentLength*fgkLay3Ndet/2. - 
2416                                fgkSegmentLength/2-(iSeg)*fgkSegmentLength);
2417  // sensorCenterZPos = z in segment local coord syst.
2418
2419   AliITSv11GeomCableFlat *digitCableA = fDigitCableLay3A;
2420   AliITSv11GeomCableFlat *digitCableB = fDigitCableLay3B;
2421
2422   if (iLay==3) {
2423   } else if (iLay==4) {
2424     nDetectors = fgkLay4Ndet;
2425     coolPipeSuppH = fgkLay4CoolPipeSuppH;
2426     sensorCenterZPos = fLay4sensorZPos[iSeg]-
2427                        (fgkSegmentLength*fgkLay4Ndet/2. -
2428                         fgkSegmentLength/2-(iSeg)*fgkSegmentLength);
2429     digitCableA = fDigitCableLay4A;
2430     digitCableB = fDigitCableLay4B;     
2431   } else
2432     printf("AliITSv11GeometrySDD::CreateLadderSegment Wrong layer index !");
2433
2434  
2435   Double_t cableSideSign = -1;
2436   if (iSeg<nDetectors/2) cableSideSign = 1;
2437   Double_t spaceForCables = spaceBetweenCables*
2438            (nDetectors-TMath::Abs(nDetectors-2*iSeg-1)-1)/2
2439            +0.1*fgkmicron;
2440   // gives [0-1-2-2-1-0]*spaceBetweenCables
2441   // or  [0-1-2-3-3-2-1-0]*spaceBetweenCables
2442   Int_t iUpdateCableMin;
2443   Int_t iUpdateCableMax;
2444   if (cableSideSign==-1) {
2445     iUpdateCableMin = nDetectors/2;
2446     iUpdateCableMax = iSeg-1;
2447   } else {
2448     iUpdateCableMin = iSeg+1;
2449     iUpdateCableMax = nDetectors/2-1;
2450   };
2451
2452   if(GetDebug(1)){
2453     cout << "Segment ("<< iLay <<',' << iSeg 
2454          << ") : sensor z shift in local segment coord.=" 
2455          << sensorCenterZPos << endl;
2456   };
2457
2458   //****************************
2459   // The segment volume
2460   //****************************
2461
2462   // Use of TGeoVolumeAssembly increases the calculation time of overlaps and very
2463   // likely slows down the transport of particles through the geometry
2464  
2465   //TGeoVolumeAssembly *virtualSeg = new TGeoVolumeAssembly("ITSsddSegment");
2466
2467   TGeoBBox *segBox = new TGeoBBox("ITSsddSegBox",
2468                                   fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW,
2469                                   fgkLadderHeight/2+fgkLadderSegBoxDH/2,
2470                                   segmentLength/2);
2471   
2472   TGeoVolume *virtualSeg = new TGeoVolume("ITSsddSegment",
2473                                           segBox, airSDD);
2474   virtualSeg->SetVisibility(kFALSE);
2475
2476   //******************************
2477   // Carbon fiber structure :
2478   //******************************
2479
2480    virtualSeg->AddNode(fLaddSegCommonVol[0], 1, fLaddSegCommonTr[0]);
2481   Int_t volumeIndex = 1;
2482   for (Int_t i = 1; i<fgkNladdSegCommonVol;i++ ) {
2483     if (fLaddSegCommonVol[i]==fLaddSegCommonVol[i-1])
2484       volumeIndex++;
2485     else
2486       volumeIndex = 1;
2487     virtualSeg->AddNode(fLaddSegCommonVol[i], volumeIndex,
2488                  fLaddSegCommonTr[i]);
2489   };
2490
2491   //**********************************
2492   // Pine support of the sensors :
2493   //**********************************
2494   TGeoRotation *rotPS1 = new TGeoRotation("",0,-90,90);
2495   TGeoRotation *rotPS2 = new TGeoRotation("",0,-90,-90);
2496
2497   // The use of the following constructor type allow to use rotPS1 and rotPS2
2498   // (and not copy them) therefore we gain some memory
2499   TGeoCombiTrans *transPS1 = new TGeoCombiTrans( fgkPinDYOnSensor,
2500                                 - fgkLadderHeight/2.-tDY
2501                                 + fgkPinSuppHeight/2.,
2502                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
2503
2504   TGeoCombiTrans *transPS2 = new TGeoCombiTrans( fgkPinDYOnSensor,
2505                                 - fgkLadderHeight/2.-tDY
2506                                 + fgkPinSuppHeight/2.,
2507                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
2508   AddTranslationToCombiTrans(transPS2, 0, 0, fgkPinPinDDXOnSensor);
2509
2510   TGeoCombiTrans *transPS3 = new TGeoCombiTrans( fgkPinDYOnSensor,
2511                                 - fgkLadderHeight/2.-tDY
2512                                 + fgkPinSuppHeight/2.,
2513                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
2514   AddTranslationToCombiTrans(transPS3, 0, 0, -2*fgkPinDXminOnSensor);
2515
2516   TGeoCombiTrans *transPS4 = new TGeoCombiTrans( fgkPinDYOnSensor,
2517                                 - fgkLadderHeight/2.-tDY
2518                                 + fgkPinSuppHeight/2.,
2519                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
2520   AddTranslationToCombiTrans(transPS4, 0, 0, -2*fgkPinDXminOnSensor-fgkPinPinDDXOnSensor);
2521
2522   TGeoCombiTrans *transPS5 = new TGeoCombiTrans( -fgkPinDYOnSensor,
2523                                  - fgkLadderHeight/2. - tDY
2524                                  + fgkPinSuppHeight/2.,
2525                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
2526
2527   TGeoCombiTrans *transPS6 = new TGeoCombiTrans( -fgkPinDYOnSensor,
2528                                  - fgkLadderHeight/2. - tDY
2529                                  + fgkPinSuppHeight/2.,
2530                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
2531   AddTranslationToCombiTrans(transPS6, 0, 0, fgkPinPinDDXOnSensor);
2532
2533   TGeoCombiTrans *transPS7 = new TGeoCombiTrans( -fgkPinDYOnSensor,
2534                                  - fgkLadderHeight/2. - tDY
2535                                  + fgkPinSuppHeight/2.,
2536                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
2537   AddTranslationToCombiTrans(transPS7, 0, 0, -2*fgkPinDXminOnSensor);
2538
2539   TGeoCombiTrans *transPS8 = new TGeoCombiTrans( -fgkPinDYOnSensor,
2540                                  - fgkLadderHeight/2. - tDY
2541                                  + fgkPinSuppHeight/2.,
2542                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
2543   AddTranslationToCombiTrans(transPS8, 0, 0, -2*fgkPinDXminOnSensor-fgkPinPinDDXOnSensor);
2544   
2545   virtualSeg->AddNode(fPinSupport, 1, transPS1);
2546   virtualSeg->AddNode(fPinSupport, 2, transPS2);
2547   virtualSeg->AddNode(fPinSupport, 3, transPS3);
2548   virtualSeg->AddNode(fPinSupport, 4, transPS4);
2549   virtualSeg->AddNode(fPinSupport, 5, transPS5);
2550   virtualSeg->AddNode(fPinSupport, 6, transPS6);
2551   virtualSeg->AddNode(fPinSupport, 7, transPS7);
2552   virtualSeg->AddNode(fPinSupport, 8, transPS8);
2553
2554   TGeoMedium *pinMed   = GetMedium("SDDKAPTON (POLYCH2)$");  // medium ???
2555   Double_t fgkPinHeight = 4.5*fgkmm;
2556   TGeoTube *pineS = new TGeoTube("ITSsddPin",0,fgkPinR,
2557                                 fgkPinHeight/2.);
2558   TGeoVolume *pineV = new TGeoVolume("ITSsddPinVol", pineS, pinMed);
2559
2560   TGeoCombiTrans *transPS2b = new TGeoCombiTrans( fgkPinDYOnSensor,
2561                                 - fgkLadderHeight/2.-tDY
2562                                 + fgkPinHeight/2.,
2563                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
2564   AddTranslationToCombiTrans(transPS2b, 0, 0, fgkPinPinDDXOnSensor);
2565   virtualSeg->AddNode(pineV, 1, transPS2b);
2566
2567   TGeoCombiTrans *transPS6b = new TGeoCombiTrans( -fgkPinDYOnSensor,
2568                                  - fgkLadderHeight/2. - tDY
2569                                  + fgkPinHeight/2.,
2570                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
2571   AddTranslationToCombiTrans(transPS6b, 0, 0, fgkPinPinDDXOnSensor);
2572   virtualSeg->AddNode(pineV, 2, transPS6b);
2573
2574  
2575   TGeoCombiTrans *transPS4b = new TGeoCombiTrans( fgkPinDYOnSensor,
2576                                 - fgkLadderHeight/2.-tDY
2577                                 + fgkPinHeight/2.,
2578                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
2579   AddTranslationToCombiTrans(transPS4b, 0, 0, -2*fgkPinDXminOnSensor-fgkPinPinDDXOnSensor);
2580   virtualSeg->AddNode(pineV, 3, transPS4b);
2581
2582   TGeoCombiTrans *transPS8b = new TGeoCombiTrans( -fgkPinDYOnSensor,
2583                                  - fgkLadderHeight/2. - tDY
2584                                  + fgkPinHeight/2.,
2585                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
2586   AddTranslationToCombiTrans(transPS8b, 0, 0, -2*fgkPinDXminOnSensor-fgkPinPinDDXOnSensor);
2587   virtualSeg->AddNode(pineV, 4, transPS8b);
2588
2589
2590   //******************************
2591   // Cooling pipe supports :
2592   //******************************
2593   Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
2594   Double_t halfTheta = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
2595   Double_t triangleCPaxeDist = fgkCoolPipeSuppAxeDist-fgkCoolPipeSuppWidthExt-
2596                                fgkCoolPipeSuppWidthIn+fgkLadderBeamRadius;
2597   
2598   Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
2599                            (triangleHeight+triangleCPaxeDist/
2600                             TMath::Sin(halfTheta)-coolPipeSuppH);
2601   if (fAddCoolingSyst) {
2602   TGeoRotation *rotCPS2 = new TGeoRotation("", -halfTheta*TMath::RadToDeg(), -90,  90);
2603   TGeoRotation *rotCPS1 = new TGeoRotation("",  halfTheta*TMath::RadToDeg(), -90, -90);
2604   TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
2605                                   -fgkLadderHeight/2. - tDY
2606                                   +coolPipeSuppH+fgkLadderBeamRadius,
2607                                   -segmentLength/2., rotCPS1);
2608
2609   TGeoCombiTrans *transCPS3 = new TGeoCombiTrans(coolPipeSuppL,
2610                                   -fgkLadderHeight/2. - tDY
2611                                   +coolPipeSuppH+fgkLadderBeamRadius,
2612                                   -segmentLength/2., rotCPS1);
2613   AddTranslationToCombiTrans(transCPS3, 0, 0, segmentLength);
2614   
2615   TGeoCombiTrans *transCPS2 = new TGeoCombiTrans(-coolPipeSuppL,
2616                                   -fgkLadderHeight/2.- tDY
2617                                   +coolPipeSuppH+fgkLadderBeamRadius,
2618                                   segmentLength/2., rotCPS2);
2619
2620   TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
2621                                   -fgkLadderHeight/2.- tDY
2622                                   +coolPipeSuppH+fgkLadderBeamRadius,
2623                                   segmentLength/2., rotCPS2);
2624   AddTranslationToCombiTrans(transCPS4, 0, 0, -segmentLength);
2625   
2626   virtualSeg->AddNode(fCoolPipeSupportL, 1, transCPS1);
2627   virtualSeg->AddNode(fCoolPipeSupportL, 2, transCPS2);
2628   virtualSeg->AddNode(fCoolPipeSupportR, 1, transCPS3);
2629   virtualSeg->AddNode(fCoolPipeSupportR, 2, transCPS4);
2630   };
2631   
2632   //************************
2633   // Cooling pipes :
2634   //************************
2635   TGeoTranslation *pipeTr1 = new TGeoTranslation(coolPipeSuppL,
2636                                  -fgkLadderHeight/2. - tDY +
2637                                  fgkLadderBeamRadius+coolPipeSuppH, 0);
2638   TGeoTranslation *pipeTr2 = new TGeoTranslation(-coolPipeSuppL,
2639                                  -fgkLadderHeight/2.- tDY +
2640                                   fgkLadderBeamRadius+coolPipeSuppH, 0);
2641
2642   if (fAddCoolingSyst) {
2643     TGeoTube *coolingPipeShape = new TGeoTube( fgkCoolPipeInnerDiam/2,
2644                                                fgkCoolPipeOuterDiam/2,
2645                                                segmentLength/2);
2646     TGeoTube *coolerShape = new TGeoTube( 0, fgkCoolPipeInnerDiam/2,
2647                                           segmentLength/2);
2648     
2649     TGeoVolume *coolingPipe = new TGeoVolume("ITSsddCoolingPipe",
2650                                              coolingPipeShape, phynoxSDD );
2651     coolingPipe->SetLineColor(fColorPhynox);
2652     TGeoVolume *cooler = new  TGeoVolume("ITSsddCoolingLiquid",coolerShape,
2653                                          coolerMediumSDD );
2654     
2655     
2656     virtualSeg->AddNode(coolingPipe, 1, pipeTr1);
2657     virtualSeg->AddNode(coolingPipe, 2, pipeTr2);
2658     if (fCoolingOn) {
2659       virtualSeg->AddNode(cooler, 1, pipeTr1);
2660       virtualSeg->AddNode(cooler, 2, pipeTr2);
2661     };
2662   };
2663
2664   //**********************************
2665   // Bases of hybrid thermal bridges
2666   //**********************************
2667   Double_t shiftHyb = 1.05; // shift between thermal Bridge base and thermal bridge
2668                            // approx !!! not clear on 0752/14-A
2669   if (fAddCoolingSyst) {
2670   TGeoRotation rotHybrid1("", 0,   0, -90 - fgkHybridAngle);
2671   TGeoRotation rotHybrid2("", 0 ,180,  90 - fgkHybridAngle);
2672   TGeoCombiTrans *baseTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid1);
2673   TGeoCombiTrans *baseTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid2);
2674   
2675   virtualSeg->AddNode(fBaseThermalBridge, 1, baseTr1);
2676   virtualSeg->AddNode(fBaseThermalBridge, 2, baseTr2);
2677   };
2678
2679   //*************************
2680   // the 2 hybrids :
2681   //*************************
2682   Double_t hybDy = ((TGeoBBox*)fHybrid->GetShape())->GetDY();
2683   Double_t distAxeToHybridCenter = fgkBTBaxisAtoBase+hybDy;
2684   
2685   Double_t hybrVolX = ( distAxeToHybridCenter*CosD(fgkHybridAngle) 
2686                          - shiftHyb*SinD(fgkHybridAngle) );
2687   Double_t hybrVolY = ( distAxeToHybridCenter*SinD(fgkHybridAngle)
2688                          + shiftHyb*CosD(fgkHybridAngle) );
2689   if (fAddHybrids) {
2690     TGeoRotation rotHybrid3("", 0,   0,  90. - fgkHybridAngle);
2691     TGeoRotation rotHybrid4("", 0 ,180, -90. - fgkHybridAngle);
2692     TGeoCombiTrans *hybTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid3);
2693     TGeoCombiTrans *hybTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid4);
2694     AddTranslationToCombiTrans( hybTr1, -hybrVolX, hybrVolY, 0);
2695     AddTranslationToCombiTrans( hybTr2,  hybrVolX, hybrVolY, 0);
2696     
2697     virtualSeg->AddNode(fHybrid, 1, hybTr1);
2698     virtualSeg->AddNode(fHybrid, 2, hybTr2);
2699   };
2700
2701   //***********
2702   // cables
2703   //***********
2704   if (fAddCables) {
2705   // Starting from this segment
2706   Double_t hybDz = ((TGeoBBox*)fHybrid->GetShape())->GetDZ();
2707   Double_t hybDx = ((TGeoBBox*)fHybrid->GetShape())->GetDX();
2708   Double_t posDigitCableAlongHyb = shiftHyb+ hybDx 
2709                                    - digitCableA->GetWidth()/2;
2710   Double_t distAxeToDigitCableCenter = distAxeToHybridCenter+hybDy
2711                                        - digitCableA->GetThickness()/2;
2712
2713   Double_t digitCableX = ( coolPipeSuppL
2714                            + distAxeToDigitCableCenter*CosD(fgkHybridAngle)
2715                            - posDigitCableAlongHyb*SinD(fgkHybridAngle) );
2716   Double_t digitCableY = ( - fgkLadderHeight/2.-TMath::Abs(tDY)
2717                            + fgkLadderBeamRadius+coolPipeSuppH
2718                            + distAxeToDigitCableCenter*SinD(fgkHybridAngle)
2719                            + posDigitCableAlongHyb*CosD(fgkHybridAngle) );
2720
2721
2722   Double_t digitCableCenterA0[3]={ -cableSideSign*digitCableX,
2723                                    digitCableY, cableSideSign*hybDz };
2724   Double_t digitCableCenterA1[3] = { 
2725            -cableSideSign*(digitCableX+spaceForCables*CosD(fgkHybridAngle)),
2726            digitCableY+spaceForCables*SinD(fgkHybridAngle),
2727            cableSideSign*segmentLength/2 };
2728
2729   Double_t digitCableCenterB0[3]={ cableSideSign*digitCableX,
2730                                    digitCableY,cableSideSign*hybDz};
2731   Double_t digitCableCenterB1[3]={ 
2732            cableSideSign*(digitCableX+spaceForCables*CosD(fgkHybridAngle)),
2733            digitCableY+spaceForCables*SinD(fgkHybridAngle),
2734            cableSideSign*segmentLength/2 };
2735
2736   Double_t vZ[3] = {0,0,1};
2737   digitCableA[iSeg].AddCheckPoint( virtualSeg, 0, digitCableCenterA0, vZ);
2738   digitCableA[iSeg].AddCheckPoint( virtualSeg, 1, digitCableCenterA1, vZ);
2739   digitCableB[iSeg].AddCheckPoint( virtualSeg, 0, digitCableCenterB0, vZ);
2740   digitCableB[iSeg].AddCheckPoint( virtualSeg, 1, digitCableCenterB1, vZ);
2741
2742   // Updating the other cables
2743   for (Int_t iCable=iUpdateCableMin; iCable<=iUpdateCableMax; iCable++) {
2744
2745     Int_t iPoint = TMath::Abs(iCable-iSeg)+1;
2746     Double_t coord[3];
2747     digitCableA[iCable].GetPoint( 1, coord);
2748     digitCableA[iCable].AddCheckPoint( virtualSeg, iPoint, coord, vZ);
2749     digitCableB[iCable].GetPoint( 1, coord);
2750     digitCableB[iCable].AddCheckPoint( virtualSeg, iPoint, coord, vZ);
2751   };
2752   };
2753
2754   //**********************************
2755   if(GetDebug(1)) virtualSeg->CheckOverlaps(0.01);
2756   return virtualSeg;
2757 }
2758
2759
2760 //________________________________________________________________________
2761 TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
2762 //
2763 // Create a pine support and its pine
2764 // axis of rotation is the cone axis, center in its middle
2765 //
2766     TGeoMedium *rytonSDD = GetMedium("SDD C AL (M55J)$"); //medium = ryton ?
2767
2768     TGeoCone *cone = new TGeoCone("ITSsddPinSuppCone",fgkPinSuppHeight/2.,
2769                                   0,fgkPinSuppRmax,0,fgkPinSuppRmax-
2770                                   fgkPinSuppHeight*TanD(fgkPinSuppConeAngle) );
2771     TGeoBBox *tong = new TGeoBBox("ITSsddPinSuppTong",fgkPinSuppRmax,
2772                                   fgkPinSuppLength/2.,fgkPinSuppThickness/2.);
2773     TGeoTube *hole = new TGeoTube("ITSsddPinSuppHole",0,fgkPinR,
2774                                   fgkPinSuppHeight/2.+0.00001);
2775     // 0.00001 is for seing the actual hole (avoid viewer artefact)
2776
2777     if(GetDebug(3)){// Remove compiler warning.
2778         cone->InspectShape();
2779         tong->InspectShape();
2780         hole->InspectShape();
2781     };
2782
2783     TGeoTranslation *tongTrans = new TGeoTranslation("ITSsddPinSuppTongTr",0,
2784                    fgkPinSuppLength/2.,-fgkPinSuppHeight/2.+fgkPinSuppThickness/2.);
2785     tongTrans->RegisterYourself();
2786     TGeoCompositeShape *pinSupportShape = new TGeoCompositeShape(
2787                "ITSsddPinSupportShape","(ITSsddPinSuppCone+"
2788                "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
2789
2790     TGeoVolume *pinSupport = new TGeoVolume("ITSsddPinSupport", pinSupportShape,
2791                                             rytonSDD);
2792     pinSupport->SetLineColor(fColorRyton);
2793
2794     return pinSupport;
2795 }
2796
2797
2798 //________________________________________________________________________
2799 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportL() {
2800 //
2801 // Create half of the cooling pipe support (ALR-0752/3)
2802 //
2803
2804   Double_t diffX = fgkCoolPipeSuppHeight*TanD(fgkCoolPipeSuppAngle);
2805   
2806   TGeoArb8 *side1 = new TGeoArb8(fgkCoolPipeSuppHeight/2.);
2807   side1->SetName("ITSsddCPSside1");
2808   side1->SetVertex( 0, 0, -fgkCoolPipeSuppWidthExt/2.);
2809   side1->SetVertex( 1, 0,  fgkCoolPipeSuppWidthExt/2.);
2810   side1->SetVertex( 2, fgkCoolPipeSuppMaxLength/2.-diffX,
2811                        fgkCoolPipeSuppWidthExt/2.);
2812   side1->SetVertex( 3, fgkCoolPipeSuppMaxLength/2.-diffX,
2813                        -fgkCoolPipeSuppWidthExt/2.);
2814   side1->SetVertex( 4, 0, -fgkCoolPipeSuppWidthExt/2.);
2815   side1->SetVertex( 5, 0,  fgkCoolPipeSuppWidthExt/2.);
2816   side1->SetVertex( 6, fgkCoolPipeSuppMaxLength/2.,
2817                        fgkCoolPipeSuppWidthExt/2.);
2818   side1->SetVertex( 7, fgkCoolPipeSuppMaxLength/2.,
2819                        -fgkCoolPipeSuppWidthExt/2.);
2820
2821   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1",0,
2822                                  - fgkCoolPipeSuppAxeDist
2823                                  + fgkCoolPipeSuppWidthExt/2., 0);
2824   side1Tr->RegisterYourself();
2825   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2",0,
2826                                  - fgkCoolPipeSuppAxeDist
2827                                  + fgkCoolPipeSuppWidthExt*3/2.
2828                                  + fgkCoolPipeSuppWidthIn,0);
2829   side2Tr->RegisterYourself();
2830   
2831   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddle",
2832                          (fgkCoolPipeSuppMaxLength/2.-fgkCoolPipeSuppSlitL)/2.,
2833                          fgkCoolPipeSuppWidthIn/2., fgkCoolPipeSuppHeight/2.);
2834   TGeoTranslation *middleTr = 
2835     new TGeoTranslation("ITSsddCPStr3",
2836                         (fgkCoolPipeSuppMaxLength/2.-fgkCoolPipeSuppSlitL)/2.,
2837                         -fgkCoolPipeSuppAxeDist+fgkCoolPipeSuppWidthExt
2838                         +fgkCoolPipeSuppWidthIn/2., 0);
2839   middleTr->RegisterYourself();
2840   
2841   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBox",
2842                                   fgkCoolPipeSuppTongW/4.,
2843                                   (fgkCoolPipeSuppFulWidth
2844                                    - 2*fgkCoolPipeSuppWidthExt
2845                                    - fgkCoolPipeSuppWidthIn)/2,
2846                                   fgkCoolPipeSuppHeight/2.);
2847   
2848   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTr",
2849                                   fgkCoolPipeSuppTongW/4.,
2850                                   - fgkCoolPipeSuppAxeDist
2851                                   + fgkCoolPipeSuppFulWidth
2852                                   - axeBox->GetDY(), 0);
2853   axeBoxTr->RegisterYourself();
2854
2855   TGeoTube *axe = new TGeoTube("ITSsddCPSaxe",0,fgkCoolPipeSuppHoleDiam/2.,
2856                                fgkCoolPipeSuppTongW/4.);
2857
2858   TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRot",90,90,0);
2859   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTr",
2860                                  fgkCoolPipeSuppTongW/4.,0,0,axeRot);
2861   axeTrans->RegisterYourself();
2862   //delete axeRot; // make the code crash, no idea of why !!!
2863
2864   if(GetDebug(3)){
2865     middle->InspectShape();
2866     axe->InspectShape();
2867   };
2868
2869   TGeoMedium *rytonSDD = GetMedium("SDD C AL (M55J)$"); //medium = ryton ?  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2870   
2871   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
2872                                         "ITSsddCoolPipeSuppShapeL",
2873                                         "ITSsddCPSmiddle:ITSsddCPStr3"
2874                                         "+ITSsddCPSside1:ITSsddCPStr1"
2875                                         "+ITSsddCPSside1:ITSsddCPStr2"
2876                                         "+ITSsddCPSaxeBox:ITSsddCPSAxBoxTr"
2877                                         "-ITSsddCPSaxe:ITSsddCPSaxeTr");
2878   TGeoVolume *coolPipeSupp = new  TGeoVolume("ITSsddCoolPipeSupportL",
2879                                              coolPipeSuppShape, rytonSDD);
2880
2881   coolPipeSupp->SetLineColor(fColorRyton);
2882
2883   return coolPipeSupp;
2884 }
2885
2886
2887 //________________________________________________________________________
2888 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportR() {
2889 //
2890 //Create half of the cooling pipe support (ALR-0752/3)
2891 //
2892
2893   Double_t diffX = fgkCoolPipeSuppHeight*TanD(fgkCoolPipeSuppAngle);
2894   
2895   TGeoArb8 *side1 = new TGeoArb8(fgkCoolPipeSuppHeight/2.);
2896   side1->SetName("ITSsddCPSside1R");
2897   side1->SetVertex( 0, 0, -fgkCoolPipeSuppWidthExt/2.);
2898   side1->SetVertex( 1, -(fgkCoolPipeSuppMaxLength/2.-diffX),
2899                        -fgkCoolPipeSuppWidthExt/2.);
2900   side1->SetVertex( 2, -(fgkCoolPipeSuppMaxLength/2.-diffX),
2901                        fgkCoolPipeSuppWidthExt/2.);
2902   side1->SetVertex( 3, 0,  fgkCoolPipeSuppWidthExt/2.);
2903   side1->SetVertex( 4, 0, -fgkCoolPipeSuppWidthExt/2.);
2904   side1->SetVertex( 5, -fgkCoolPipeSuppMaxLength/2.,
2905                        -fgkCoolPipeSuppWidthExt/2.);
2906   side1->SetVertex( 6, -fgkCoolPipeSuppMaxLength/2.,
2907                        fgkCoolPipeSuppWidthExt/2.);
2908   side1->SetVertex( 7, 0,  fgkCoolPipeSuppWidthExt/2.);
2909
2910   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1R",0,
2911                                  - fgkCoolPipeSuppAxeDist
2912                                  + fgkCoolPipeSuppWidthExt/2., 0);
2913   side1Tr->RegisterYourself();
2914   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2R",0,
2915                                  - fgkCoolPipeSuppAxeDist
2916                                  + fgkCoolPipeSuppWidthExt*3/2.
2917                                  + fgkCoolPipeSuppWidthIn, 0);
2918   side2Tr->RegisterYourself();
2919   
2920   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddleR",
2921                                   (fgkCoolPipeSuppMaxLength/2.
2922                                    - fgkCoolPipeSuppSlitL)/2.,
2923                                   fgkCoolPipeSuppWidthIn/2., 
2924                                   fgkCoolPipeSuppHeight/2.);
2925   TGeoTranslation *middleTr = 
2926     new TGeoTranslation("ITSsddCPStr3R",
2927                         -( fgkCoolPipeSuppMaxLength/2.
2928                            -fgkCoolPipeSuppSlitL)/2.,
2929                         -fgkCoolPipeSuppAxeDist + fgkCoolPipeSuppWidthExt
2930                         + fgkCoolPipeSuppWidthIn/2.,0);
2931   middleTr->RegisterYourself();
2932   
2933   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBoxR",
2934                                   fgkCoolPipeSuppTongW/4.,
2935                                   (fgkCoolPipeSuppFulWidth
2936                                    - 2*fgkCoolPipeSuppWidthExt
2937                                    - fgkCoolPipeSuppWidthIn)/2,
2938                                   fgkCoolPipeSuppHeight/2.);
2939   
2940   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTrR",
2941                                   - fgkCoolPipeSuppTongW/4.,
2942                                   - fgkCoolPipeSuppAxeDist
2943                                   + fgkCoolPipeSuppFulWidth
2944                                   - axeBox->GetDY(),0);
2945   axeBoxTr->RegisterYourself();
2946
2947   TGeoTube *axe = new TGeoTube("ITSsddCPSaxeR",0,fgkCoolPipeSuppHoleDiam/2.,
2948                                fgkCoolPipeSuppTongW/4.);
2949
2950   TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRotR",90,90,0);
2951   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTrR",
2952                                                 -fgkCoolPipeSuppTongW/4.,0,0,axeRot);
2953   axeTrans->RegisterYourself();
2954   //delete axeRot;
2955
2956   if(GetDebug(3)){
2957     middle->InspectShape();
2958     axe->InspectShape();
2959   };
2960   
2961   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
2962                                       "ITSsddCoolPipeSuppShapeR",
2963                                       "ITSsddCPSmiddleR:ITSsddCPStr3R"
2964                                       "+ITSsddCPSside1R:ITSsddCPStr1R"
2965                                       "+ITSsddCPSside1R:ITSsddCPStr2R"
2966                                       "+ITSsddCPSaxeBoxR:ITSsddCPSAxBoxTrR"
2967                                       "-ITSsddCPSaxeR:ITSsddCPSaxeTrR");
2968   
2969   TGeoMedium *rytonSDD = GetMedium("SDD C AL (M55J)$"); //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2970   TGeoVolume *coolPipeSupp = new TGeoVolume( "ITSsddCoolPipeSupportR",
2971                                              coolPipeSuppShape, rytonSDD);
2972   coolPipeSupp->SetLineColor(fColorRyton);
2973
2974   return coolPipeSupp;
2975 }
2976
2977 //________________________________________________________________________
2978 TGeoVolume* AliITSv11GeometrySDD::CreateBaseThermalBridge() {
2979   //
2980   // based on ALR 0752/8
2981   //
2982
2983   Double_t dy = fgkBTBaxisAtoBase - fgkRadiusBminBTB - fgkBTBthick;
2984
2985   Double_t base1width = fgkBTBwidth - fgkBTBaxisAtoBottom - fgkRadiusBminBTB
2986                         - (fgkRadiusAminBTB+fgkBTBthick);
2987   TGeoBBox *base1 = new TGeoBBox( "ITSsddBTBbase1", base1width/2.,
2988                                   fgkBTBthick/2., fgkBTBlength/2.);
2989   TGeoTranslation *base1Tr = new TGeoTranslation("ITSsddBTBtr1",
2990                                  fgkBTBaxisAtoBottom-fgkBTBwidth+base1width/2.,
2991                                  -(fgkBTBaxisAtoBase-fgkBTBthick/2.), 0);
2992   base1Tr->RegisterYourself();
2993
2994   Double_t base2width = fgkBTBaxisAtoBottom - fgkRadiusAminBTB - fgkBTBthick
2995                         - fgkRadiusBminBTB;
2996   TGeoBBox *base2 = new TGeoBBox( "ITSsddBTBbase2", base2width/2.,
2997                                   fgkBTBthick/2., fgkBTBlength/2.);
2998   TGeoTranslation *base2Tr = new TGeoTranslation("ITSsddBTBtr2",
2999                                  fgkBTBaxisAtoBottom - base2width/2.,
3000                                  -(fgkBTBaxisAtoBase-fgkBTBthick/2.), 0);
3001   base2Tr->RegisterYourself();
3002
3003   TGeoBBox *side = new TGeoBBox( "ITSsddBTBside",
3004                                  fgkBTBthick/2., dy/2., fgkBTBlength/2.);
3005   TGeoTranslation *sideTr1 = new TGeoTranslation("ITSsddBTBsideTr1",
3006                                  -fgkRadiusAminBTB-fgkBTBthick/2., -dy/2., 0);
3007   TGeoTranslation *sideTr2 = new TGeoTranslation("ITSsddBTBsideTr2",
3008                                  fgkRadiusAminBTB+fgkBTBthick/2., -dy/2., 0);
3009   sideTr1->RegisterYourself();
3010   sideTr2->RegisterYourself();
3011
3012   TGeoBBox *hole = new TGeoBBox( "ITSsddBTBhole", fgkBTBHolewidth/2.,
3013                                  fgkBTBthick/2., fgkBTBHoleLength/2.);
3014   TGeoTranslation *holeTr1 = new TGeoTranslation("ITSsddBTBholeTr1",
3015                                  - fgkBTBHoleRefX + fgkBTBHolewidth/2.,
3016                                  - (fgkBTBaxisAtoBase-fgkBTBthick/2.),
3017                                  fgkBTBHoleRefY+(fgkBTBHoleLength-fgkBTBlength)/2.);
3018   TGeoTranslation *holeTr2 = new TGeoTranslation("ITSsddBTBholeTr2",
3019                                  - fgkBTBHoleRefX + fgkBTBHolewidth/2.,
3020                                  - (fgkBTBaxisAtoBase-fgkBTBthick/2.),
3021                                  - fgkBTBHoleRefY-(fgkBTBHoleLength-fgkBTBlength)/2.);
3022   holeTr1->RegisterYourself();
3023   holeTr2->RegisterYourself();
3024
3025   Double_t radiusAmaxBTB = fgkRadiusAminBTB + fgkBTBthick;
3026   TGeoTubeSeg *mainAxis = new TGeoTubeSeg( "ITSsddBTBmainAxis",
3027                                            fgkRadiusAminBTB, radiusAmaxBTB,
3028                                            fgkBTBlength/2., 0., 180.);
3029   TGeoTubeSeg *round1 = new TGeoTubeSeg( "ITSsddBTBround1",
3030                            fgkRadiusBminBTB, fgkRadiusBminBTB+fgkBTBthick,
3031                            fgkBTBlength/2., 270., 360.);
3032   TGeoTranslation *roundTr1 = new TGeoTranslation("ITSsddBTBround1Tr",
3033                                   -(fgkRadiusAminBTB+fgkBTBthick+fgkRadiusBminBTB),
3034                                   -dy, 0);
3035   roundTr1->RegisterYourself();
3036
3037   TGeoTubeSeg *round2 = new TGeoTubeSeg( "ITSsddBTBround2",
3038                            fgkRadiusBminBTB, fgkRadiusBminBTB+fgkBTBthick,
3039                            fgkBTBlength/2., 180., 270.);
3040   TGeoTranslation *roundTr2 = new TGeoTranslation("ITSsddBTBround2Tr",
3041                                   (fgkRadiusAminBTB+fgkBTBthick+fgkRadiusBminBTB),
3042                                   -dy, 0);
3043   roundTr2->RegisterYourself();
3044
3045   TGeoCompositeShape *sBaseThermalBridge = new TGeoCompositeShape(
3046                                       "ITSsddBaseThermalBridgeShape",
3047                                       "ITSsddBTBbase1:ITSsddBTBtr1"
3048                                       "+ ITSsddBTBbase2:ITSsddBTBtr2"
3049                                       "+ ITSsddBTBround1:ITSsddBTBround1Tr"
3050                                       "+ ITSsddBTBround2:ITSsddBTBround2Tr"
3051                                       "+ ITSsddBTBside:ITSsddBTBsideTr1"
3052                                       "+ ITSsddBTBside:ITSsddBTBsideTr2"
3053                                       "- ITSsddBTBhole:ITSsddBTBholeTr1"
3054                                       "- ITSsddBTBhole:ITSsddBTBholeTr2"
3055                                       "+ ITSsddBTBmainAxis");
3056
3057     if(GetDebug(3)){// Remove compiler warning.
3058         base1->InspectShape();
3059         base2->InspectShape();
3060         side->InspectShape();
3061         hole->InspectShape();
3062         mainAxis->InspectShape();
3063         round1->InspectShape();
3064         round2->InspectShape();
3065     };
3066
3067   TGeoMedium *carbonFiberLadderStruct = GetMedium("SDD C AL (M55J)$");
3068   TGeoVolume *vBaseThermalBridge = new TGeoVolume( "ITSsddBaseThermalBridge",
3069                                                    sBaseThermalBridge,
3070                                                    carbonFiberLadderStruct);
3071
3072   vBaseThermalBridge->SetLineColor(fColorCarbonFiber);
3073   return vBaseThermalBridge;
3074 }
3075
3076
3077 //________________________________________________________________________
3078 TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay) {
3079   //
3080   // Return an assembly containing a end of a CF ladder.
3081   //
3082
3083   TGeoMedium *carbonFiberLadderStruct = GetMedium("SDD C AL (M55J)$"); // ITSsddCarbonM55J
3084   TGeoMedium *stesalite       = GetMedium("G10FR4$");
3085   TGeoMedium *phynoxSDD       = GetMedium("INOX$");
3086   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
3087
3088   Double_t length        = (fgkLay3LadderLength-fgkLay3Ndet*fgkSegmentLength)/2.;
3089   Double_t coolPipeSuppH = fgkLay3CoolPipeSuppH;
3090   Double_t underSegDH    = fLay3LadderUnderSegDH;
3091   Double_t footDZ    = fgkRubyZladd3 - fgkLay3Ndet*fgkSegmentLength/2 - length/2;
3092   // footDZ is also where to place the ruby's center in local Z
3093   Double_t coolPipeEndLen = (fgkCoolPipeLay3Len-fgkSegmentLength*fgkLay3Ndet)/2;
3094
3095   if (iLay==3) {
3096   } else if (iLay==4) {
3097     length         = (fgkLay4LadderLength-fgkLay4Ndet*fgkSegmentLength)/2.;
3098     coolPipeSuppH  = fgkLay4CoolPipeSuppH;
3099     underSegDH     = fLay4LadderUnderSegDH;
3100     footDZ         = fgkRubyZladd4 - fgkLay4Ndet*fgkSegmentLength/2 - length/2;
3101     coolPipeEndLen = (fgkCoolPipeLay4Len-fgkSegmentLength*fgkLay4Ndet)/2;
3102   } else {
3103     printf("error in AliITSv11GeometrySDD::CreateEndLadder: Wrong layer");
3104     return 0;
3105   };
3106     
3107   Double_t tDY = (- fgkLadderSegBoxDH/2       //space left on top of the ladder
3108                   + underSegDH/2);          //space under ladder segment
3109         // here tDY is not the same as for the segment because the end ladder
3110         // does not have a space under it, inside the general ladder volume.
3111   Double_t segmentLength   = fgkSegmentLength;
3112   Double_t topCornerLength = fgkSegmentLength/2.-fgkLay4LaddTopCornerEnd;
3113
3114   TGeoVolumeAssembly *virtualEnd = new TGeoVolumeAssembly("ITSsddEnd");
3115   
3116   //**********************************
3117   // coding real matter :
3118   //**********************************
3119   Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
3120   Double_t halfTheta   = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
3121   Double_t beta        = (TMath::Pi()-2.*halfTheta)/4.;
3122   Double_t alpha       = TMath::Pi()*3./4. - halfTheta/2.;
3123   
3124   //--- The 3 V shape corners of the Carbon Fiber Ladder
3125   //--- the top V
3126   TGeoArb8 *cfLaddTop1 = CreateLadderSide("CFladdTopCornerV1shape",
3127                                           topCornerLength/2., halfTheta, -1,
3128                                           fgkLadderLa, fgkLadderHa, fgkLadderl);
3129   TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerV1",
3130                                   cfLaddTop1,carbonFiberLadderStruct);
3131   cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
3132   TGeoArb8 *cfLaddTop2 = CreateLadderSide( "CFladdTopCornerV2shape",
3133                                            topCornerLength/2., halfTheta, 1,
3134                                            fgkLadderLa, fgkLadderHa, fgkLadderl);
3135   TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
3136                                   cfLaddTop2,carbonFiberLadderStruct);
3137   cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
3138   TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2+tDY,
3139                                                 -(length-topCornerLength)/2.);
3140   virtualEnd->AddNode(cfLaddTopVol1, 1, trTop1);
3141   virtualEnd->AddNode(cfLaddTopVol2, 1, trTop1);
3142
3143   //--- the 2 side V
3144   TGeoArb8 *cfLaddSide1 = CreateLadderSide( "CFladdSideCornerV1shape",
3145                                             length/2., beta, -1,
3146                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
3147   TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
3148                                    cfLaddSide1,carbonFiberLadderStruct);
3149   cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
3150   TGeoArb8 *cfLaddSide2 = CreateLadderSide( "CFladdSideCornerV2shape",
3151                                             length/2., beta, 1,
3152                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
3153   TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
3154                                    cfLaddSide2,carbonFiberLadderStruct);
3155   cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
3156   Double_t dYTranslation = ( fgkLadderHeight/2. - 0.5*fgkLadderWidth*
3157                              TMath::Tan(beta) - fgkLadderBeamRadius );
3158   
3159   // because center of the triangle doesn't correspond to virtual vol. center
3160   Double_t distCenterSideDown =  0.5*fgkLadderWidth/TMath::Cos(beta);
3161   TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
3162                                              alpha*TMath::RadToDeg());
3163   AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+tDY, 0);
3164   TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown, 0, 
3165                                              -alpha*TMath::RadToDeg());
3166   AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+tDY, 0);
3167   virtualEnd->AddNode(cfLaddSideVol1, 1, ctSideR);
3168   virtualEnd->AddNode(cfLaddSideVol2, 1, ctSideR);
3169   virtualEnd->AddNode(cfLaddSideVol1, 2, ctSideL);
3170   virtualEnd->AddNode(cfLaddSideVol2, 2, ctSideL);
3171   
3172   //--- The beams
3173   // Beams on the sides
3174   Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
3175                   TMath::Sin(2*beta)/(TanD(fgkBeamSidePhi)*TanD(fgkBeamSidePhi))) ));
3176
3177   //Euler rotation : about Z, then new X, then new Z
3178   TGeoRotation *beamRot1 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
3179                         -beamPhiPrime*TMath::RadToDeg(), -90);
3180   TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
3181                         beamPhiPrime*TMath::RadToDeg(), -90);
3182   TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
3183                         beamPhiPrime*TMath::RadToDeg(), -90);
3184   TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
3185                         -beamPhiPrime*TMath::RadToDeg(), -90);
3186   TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
3187                                                    TMath::Tan(halfTheta),
3188                                               fgkLadderBeamRadius/2. + tDY,
3189                                  -length/2 + segmentLength/8, beamRot1);
3190   TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans( 0.5*triangleHeight*
3191                                                     TMath::Tan(halfTheta),
3192                                                  fgkLadderBeamRadius/2.+tDY,
3193                                 -length/2 + 3*segmentLength/8, beamRot2);
3194   TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
3195                                                    TMath::Tan(halfTheta),
3196                                                 fgkLadderBeamRadius/2.+tDY,
3197                                  -length/2 + segmentLength/8, beamRot3);
3198   TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
3199                                                    TMath::Tan(halfTheta),
3200                                               fgkLadderBeamRadius/2. + tDY,
3201                                  -length/2+3*segmentLength/8, beamRot4);
3202
3203   virtualEnd->AddNode(fLaddSegCommonVol[6], 1, beamTransf1);
3204   virtualEnd->AddNode(fLaddSegCommonVol[6], 2, beamTransf3);
3205   virtualEnd->AddNode(fLaddSegCommonVol[6], 3, beamTransf5);
3206   virtualEnd->AddNode(fLaddSegCommonVol[6], 4, beamTransf7);
3207
3208   //--- Beams of the bottom
3209   TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
3210
3211   /* Not there actually
3212   TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
3213                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 180);
3214   TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
3215                                    bottomBeam1, carbonFiberLadderStruct);
3216   bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
3217
3218   TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
3219                             -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY,
3220                             -length/2+fgkSegmentLength/2, bottomBeamRot1);
3221   virtualEnd->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
3222 */
3223   TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
3224                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 90);
3225   TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
3226                                    bottomBeam2, carbonFiberLadderStruct);
3227   bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
3228   TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
3229      -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY,-length/2,bottomBeamRot1);
3230   virtualEnd->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
3231
3232   //**********************************
3233   //the cooling pipe supports
3234   Double_t triangleCPaxeDist = fgkCoolPipeSuppAxeDist-fgkCoolPipeSuppWidthExt-
3235                                fgkCoolPipeSuppWidthIn+fgkLadderBeamRadius;
3236
3237   Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
3238                            (triangleHeight+triangleCPaxeDist/
3239                             TMath::Sin(halfTheta)-coolPipeSuppH);
3240   
3241   if (fAddCoolingSyst) {
3242     TGeoRotation *rotCPS2 = new TGeoRotation("",-halfTheta*TMath::RadToDeg(),-90, 90);
3243     TGeoRotation *rotCPS1 = new TGeoRotation("", halfTheta*TMath::RadToDeg(),-90,-90);
3244     TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
3245                                                    -fgkLadderHeight/2.+ tDY +
3246                                                    coolPipeSuppH+fgkLadderBeamRadius,
3247                                                    -length/2., rotCPS1);
3248     TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
3249                                                    -fgkLadderHeight/2.+ tDY +
3250                                                    coolPipeSuppH+fgkLadderBeamRadius,
3251                                                    -length/2., rotCPS2);
3252     
3253     virtualEnd->AddNode(fCoolPipeSupportL, 1, transCPS1);
3254     virtualEnd->AddNode(fCoolPipeSupportR, 1, transCPS4);
3255   };
3256
3257   //**********************************
3258   //--- The stesalite foot of the ladder
3259
3260   Double_t footDY = -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY
3261                     - fgkLadFootY/2+fgkLadFingerPrintY;
3262
3263   TGeoTranslation *footTr = new TGeoTranslation("SDDfootTr",0,footDY,footDZ);
3264   virtualEnd->AddNode(fLadderFoot, 1, footTr);
3265
3266   //=====================================
3267   //--- cooling pipe
3268
3269   if (fAddCoolingSyst) {
3270
3271     TGeoTranslation *pipeTr1 = new TGeoTranslation(coolPipeSuppL,
3272                                        -fgkLadderHeight/2.+ tDY +
3273                                        coolPipeSuppH + fgkLadderBeamRadius,
3274                                        -length/2.+coolPipeEndLen/2.);
3275     TGeoTranslation *pipeTr2 = new TGeoTranslation(-coolPipeSuppL,
3276                                    -fgkLadderHeight/2. + tDY +
3277                                     fgkLadderBeamRadius + coolPipeSuppH,
3278                                     -length/2.+coolPipeEndLen/2.);
3279
3280     TGeoTube *coolingPipeShape = new TGeoTube( fgkCoolPipeInnerDiam/2,
3281                                                fgkCoolPipeOuterDiam/2,
3282                                                coolPipeEndLen/2);
3283     TGeoTube *coolerShape = new TGeoTube( 0, fgkCoolPipeInnerDiam/2,
3284                                           coolPipeEndLen/2);
3285     
3286     TGeoVolume *coolingPipe = new TGeoVolume("ITSsddCoolingPipeEnd",
3287                                              coolingPipeShape, phynoxSDD );
3288     coolingPipe->SetLineColor(fColorPhynox);
3289     TGeoVolume *cooler = new  TGeoVolume("ITSsddCoolingEndLiquid",coolerShape,
3290                                          coolerMediumSDD );
3291
3292     virtualEnd->AddNode(coolingPipe, 1, pipeTr1);
3293     virtualEnd->AddNode(coolingPipe, 2, pipeTr2);
3294     if (fCoolingOn) {
3295       virtualEnd->AddNode(cooler, 1, pipeTr1);
3296       virtualEnd->AddNode(cooler, 2, pipeTr2);
3297     };
3298   };
3299
3300   //=====================================
3301   //--- HV cable guide
3302
3303
3304   TGeoBBox* guideHVbox = new TGeoBBox("guideHVbox",fgkHVguideX1/2,
3305                                       fgkHVguideY1/2,fgkHVguideZ1/2);
3306   TGeoVolume *guideHV = new TGeoVolume("guideHV",guideHVbox,stesalite);
3307
3308   TGeoTranslation* guideHVtr = new TGeoTranslation(fgkHVguideDX,
3309      -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY-fgkHVguideY1/2,
3310      footDZ+fgkLadFootZ/2+fgkHVguideZ1/2-(fgkHVguideSuppFullZ-fgkHVguideZ2));
3311   virtualEnd->AddNode(guideHV, 1, guideHVtr);
3312
3313   //=====================================
3314   //--- raccordo
3315   Double_t raccordFullLen = fgkConnectorCoolTubeL1+fgkConnectorCoolTubeL2+fgkConnectorCoolTubeL3;
3316   TGeoTranslation *trRaccordo1 = new TGeoTranslation("trRaccordo1",-coolPipeSuppL,
3317                                                      -fgkLadderHeight/2.+ tDY +
3318                                                      coolPipeSuppH+fgkLadderBeamRadius,
3319                                             -length/2.+coolPipeEndLen+raccordFullLen/2);
3320   TGeoTranslation *trRaccordo2 = new TGeoTranslation("trRaccordo2", coolPipeSuppL,
3321                                                      -fgkLadderHeight/2.+ tDY +
3322                                                      coolPipeSuppH+fgkLadderBeamRadius,
3323                                             -length/2.+coolPipeEndLen+raccordFullLen/2);
3324
3325   virtualEnd->AddNode(fRaccordoL, 1, trRaccordo1);
3326   virtualEnd->AddNode(fRaccordoL, 2, trRaccordo2);
3327
3328   if(GetDebug(1)) virtualEnd->CheckOverlaps(0.01);
3329
3330   return virtualEnd;
3331 }
3332
3333 //________________________________________________________________________
3334 TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateLadderFoot() {
3335
3336   //--- The stesalite foot of the ladder
3337   // Are missing :
3338   // The 2 screw holes on the left part
3339   // the small holes at each corner of the ruby cage (diam 2mm)
3340   // the really small level difference of 0.3mm on the bottom
3341
3342
3343   TGeoMedium *stesalite = GetMedium("G10FR4$");
3344
3345   TGeoVolumeAssembly *virtualFoot = new TGeoVolumeAssembly("ITSsddFoot");
3346
3347   Double_t epsilon = 2e-10;
3348   TGeoBBox *ladFootBox1 = new TGeoBBox("ladFootBox1",fgkLadBox1X/2, fgkLadFootY/2,
3349                                        fgkLadFootZ/2);
3350   TGeoTranslation *ladFootBox1Tr = new TGeoTranslation("ladFootBox1Tr",
3351                                                        fgkLadFootX/2-fgkLadBox1X/2,0,0);
3352   TGeoBBox *ladFingerPrint = new TGeoBBox("ladFingerPrint",fgkLadFingerPrintX/2,
3353                                           fgkLadFingerPrintY/2+epsilon, fgkLadFootZ/2+epsilon);
3354
3355   TGeoTranslation *ladFingerPrintTr = new TGeoTranslation("ladFingerPrintTr",
3356                             fgkLadFootX/2-fgkLadFingerPrintBorder-fgkLadFingerPrintX/2,
3357                             fgkLadFootY/2-fgkLadFingerPrintY/2+epsilon,
3358                             0);
3359
3360   TGeoBBox *rubyCageHole = new TGeoBBox("rubyCageHole",fgkRubyCageHoleX/2,
3361                                         fgkRubyCageHoleY/2+epsilon, fgkRubyCageHoleZ/2);
3362
3363   TGeoTranslation *rubyCageHoleTr = new TGeoTranslation("rubyCageHoleTr",
3364                                  fgkLadFootX/2-(fgkLadFootX/2-fgkRubyDX)+fgkRubyCageAxisShift,
3365                                  fgkLadFootY/2-fgkRubyCageHoleY/2,0);
3366
3367   double rubyScrewHoleLen = fgkLadFootX/2-fgkRubyDX;
3368   TGeoTube *rubyScrewHole = new TGeoTube("rubyScrewHole", 0,fgkScrewM4diam/2,
3369                             rubyScrewHoleLen/2);
3370
3371   TGeoRotation *rot9090 = new TGeoRotation("",90,90,0);
3372   TGeoCombiTrans *rubyScrewHoleTr = new TGeoCombiTrans("rubyScrewHoleTr",
3373                                     fgkLadFootX/2-rubyScrewHoleLen/2,
3374                                     -fgkRubyScrewShiftToCenterY, 0, rot9090);
3375
3376   Double_t rubyHoleLen = fgkLadFootY-fgkRubyCageHoleY;
3377   TGeoTube *rubyHole = new TGeoTube("rubyHole", 0,fgkRubyHoleDiam/2,
3378                                     rubyHoleLen/2);
3379
3380   TGeoRotation *rot90 = new TGeoRotation("",0,90,0);
3381   TGeoCombiTrans *rubyHoleTr = new TGeoCombiTrans("rubyHoleTr", fgkRubyDX,
3382                                    -(fgkLadFootY-rubyHoleLen)/2, 0, rot90);
3383
3384   ladFootBox1Tr->RegisterYourself();
3385   ladFingerPrintTr->RegisterYourself();
3386   rubyCageHoleTr->RegisterYourself();
3387   rubyScrewHoleTr->RegisterYourself();
3388   rubyHoleTr->RegisterYourself();
3389
3390   TGeoCompositeShape *footRightPart = new TGeoCompositeShape(
3391               "ladFootBox1:ladFootBox1Tr-(ladFingerPrint:ladFingerPrintTr"
3392               "+rubyCageHole:rubyCageHoleTr+rubyScrewHole:rubyScrewHoleTr"
3393               "+rubyHole:rubyHoleTr)");
3394   TGeoVolume *vFootRightPart = new TGeoVolume("vFootRightPart",
3395                                               footRightPart,stesalite);
3396   vFootRightPart->SetLineColor(fColorStesalite);
3397  
3398   virtualFoot->AddNode(vFootRightPart, 1, 0);
3399
3400
3401   //--- This was the right part of the foot, now let's do the middle
3402   //--- and the right parts
3403
3404   Double_t middleX = fgkLadFootX-fgkLadBox1X-fgkLadFingerPrintX-fgkLadFingerPrintBorder;
3405   TGeoBBox *footMiddle = new TGeoBBox("footMiddle", middleX/2, fgkLadFootMiddleY/2,
3406                                       fgkLadFootZ/2);
3407   TGeoTranslation *middleXTr = new TGeoTranslation("middleXTr",
3408                                    fgkLadFootX/2-fgkLadBox1X-middleX/2,
3409                                    fgkLadFootY/2-fgkLadFootMiddleY/2, 0);
3410
3411   TGeoVolume *vFootMiddle = new TGeoVolume("vFootMiddle", footMiddle,stesalite);
3412   vFootMiddle->SetLineColor(fColorStesalite);
3413   virtualFoot->AddNode(vFootMiddle, 1, middleXTr);
3414   
3415   //--
3416   TGeoBBox *footLeftLadFinger = new TGeoBBox("footLeftLadFinger", fgkLadFingerPrintX/2,
3417                                              (fgkLadFootY-fgkLadFingerPrintY)/2,
3418                                              fgkLadFootZ/2);
3419   TGeoTranslation *footLeftLadFingerTr = new TGeoTranslation("footLeftLadFingerTr",
3420                                    -fgkLadFootX/2+fgkLadFingerPrintBorder+fgkLadFingerPrintX/2,
3421                                    -fgkLadFingerPrintY/2, 0);
3422   TGeoVolume *vFootLeftLadFinger = new TGeoVolume("vFootLeftLadFinger",footLeftLadFinger,
3423                                                   stesalite);
3424   vFootLeftLadFinger->SetLineColor(fColorStesalite);
3425   virtualFoot->AddNode(vFootLeftLadFinger, 1, footLeftLadFingerTr);
3426
3427   //--
3428   TGeoBBox *footLeft = new TGeoBBox("footLeft", fgkLadFingerPrintBorder/2,
3429                                     fgkLadFootY/2,
3430                                     fgkLadFootZ/2);
3431   TGeoTranslation *footLeftTr = new TGeoTranslation("footLeftTr",
3432                                    -fgkLadFootX/2+fgkLadFingerPrintBorder/2,
3433                                     0, 0);
3434   TGeoVolume *vFootLeft = new TGeoVolume("vFootLeft",footLeft,stesalite);
3435   vFootLeft->SetLineColor(fColorStesalite);
3436   virtualFoot->AddNode(vFootLeft, 1, footLeftTr);
3437
3438   if(GetDebug(3)){ // Remove compiler warning.
3439     ladFingerPrint->InspectShape();
3440     ladFootBox1->InspectShape();
3441     rubyCageHole->InspectShape();
3442     rubyScrewHole->InspectShape();
3443     rubyHole->InspectShape();
3444   }
3445
3446   return virtualFoot;
3447 }
3448
3449 //________________________________________________________________________
3450 TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateCarlosCard(Int_t iLay) {
3451   //
3452   // return an assembly containing the CARLOS end-ladder board
3453   // and the heat bridge
3454   //
3455
3456   (void) iLay;
3457   TGeoMedium *glassFiber  = GetMedium("SDD SI CHIP$");// glassFiber   TO CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3458   TGeoMedium *siliconChip = GetMedium("SDD SI CHIP$");// ITSsddSiChip
3459   TGeoMedium *plastiChip  = GetMedium("SDDKAPTON (POLYCH2)$"); // ITSsddKAPTON_POLYCH2
3460   TGeoMedium *copper      = GetMedium("COPPER$"); 
3461   TGeoMedium *alCu12SDD   = GetMedium("INOX$"); // ITSsddAlCu12,  to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3462   TGeoMedium *stainless   = GetMedium("INOX$"); // for screws, what is the material ???????????
3463
3464   //=========================================
3465   // cooling support of the Carlos card (HeatBridge):
3466   TGeoVolumeAssembly *assemblySupCarlos = new TGeoVolumeAssembly("assemblySupCarlos");
3467
3468   TGeoBBox *supCarlosBoard1 = new TGeoBBox("",fgkCarlosSuppX1/2,fgkCarlosSuppY1/2,
3469                                            fgkCarlosSuppZ/2);
3470   TGeoBBox *supCarlosBoard2 = new TGeoBBox("",fgkCarlosSuppX2/2,fgkCarlosSuppY2/2,
3471                                            fgkCarlosSuppZ/2);
3472   TGeoVolume *vSupCarlosBoard1 = new TGeoVolume("vSupCarlosBoard1",
3473                                                 supCarlosBoard1, alCu12SDD);
3474   TGeoVolume *vSupCarlosBoard2 = new TGeoVolume("vSupCarlosBoard2",
3475                                                 supCarlosBoard2, alCu12SDD);
3476   vSupCarlosBoard1->SetLineColor(4);
3477   vSupCarlosBoard2->SetLineColor(4);
3478
3479
3480   Double_t shiftGlob = -fgkCarlosSuppZ/2+fgkCarlosSuppTopLen;
3481   // shift of the main planes in the direction of their width 
3482   // the center is fixed at the center of the 2 small fixing arms on each sides.
3483   //shiftGlob=0.5;
3484
3485   shiftGlob+= 0.5*fgkCarlosSuppY3/cos((90-fgkCarlosSuppAngle)*TMath::DegToRad());
3486   shiftGlob-= 0.5*fgkCarlosSuppY2*tan((90-fgkCarlosSuppAngle)*TMath::DegToRad());
3487   Double_t shiftGlobY = shiftGlob*sin(fgkCarlosSuppAngle*TMath::DegToRad());
3488   Double_t shiftGlobZ = shiftGlob*cos(fgkCarlosSuppAngle*TMath::DegToRad());
3489
3490   TGeoTranslation *carlosSupTr1 = new TGeoTranslation( -fgkCarlosSuppX2/2,
3491                                  (-fgkCarlosSuppY1+fgkCarlosSuppY2)/2+shiftGlobY,
3492                                                        +shiftGlobZ);
3493
3494   TGeoTranslation *carlosSupTr2 = new TGeoTranslation( fgkCarlosSuppX1/2,
3495                                                      shiftGlobY,
3496                                                      shiftGlobZ);
3497
3498   assemblySupCarlos->AddNode(vSupCarlosBoard1, 0, carlosSupTr1);
3499   assemblySupCarlos->AddNode(vSupCarlosBoard2, 0, carlosSupTr2);
3500
3501   //=========================================
3502   // fixing arm of the cooling support :
3503   TGeoBBox *supCarlosBoard3 = new TGeoBBox("",fgkCarlosSuppX3/2,fgkCarlosSuppY3/2,
3504                                            fgkCarlosSuppZ3/2);
3505   TGeoVolume *vSupCarlosBoard3 = new TGeoVolume("vSupCarlosBoard3",
3506                                                 supCarlosBoard3, alCu12SDD);
3507   vSupCarlosBoard3->SetLineColor(4);
3508
3509   // screw inside :
3510   TGeoTube *littleScrew = new TGeoTube("littleScrew", 0, fgkLittleScrewR,
3511                                        fgkCarlosSuppY3/2);
3512   TGeoVolume *vLittleScrew = new TGeoVolume("vLittleScrew",
3513                                             littleScrew, stainless);
3514   TGeoRotation *rotScrew = new TGeoRotation("",0,90,0);
3515   TGeoCombiTrans *cbScrew1 = new TGeoCombiTrans(0, 0, fgkCarlosSuppZ3/2 -
3516                                                 fgkLittleScrewHeadR-0.07, rotScrew);
3517   TGeoCombiTrans *cbScrew2 = new TGeoCombiTrans(0, 0, -fgkCarlosSuppZ3/2 +
3518                                                 fgkLittleScrewHeadR+0.07, rotScrew);
3519   vSupCarlosBoard3->AddNode(vLittleScrew,1, cbScrew1);
3520   vSupCarlosBoard3->AddNode(vLittleScrew,2, cbScrew2);
3521
3522   TGeoRotation *carlosSupRot = new TGeoRotation("carlosSuppInvertAngle",
3523                                                  0, fgkCarlosSuppAngle, 0);
3524   TGeoCombiTrans *carlosSupTr3 = new TGeoCombiTrans((fgkCarlosSuppX1+
3525                                  fgkCarlosSuppX2+fgkCarlosSuppX3)/2,0,0, carlosSupRot);
3526   TGeoCombiTrans *carlosSupTr4 = new TGeoCombiTrans(-(fgkCarlosSuppX1+
3527                                  fgkCarlosSuppX2+fgkCarlosSuppX3)/2,0,0, carlosSupRot);
3528   assemblySupCarlos->AddNode(vSupCarlosBoard3, 0, carlosSupTr3);
3529   assemblySupCarlos->AddNode(vSupCarlosBoard3, 1, carlosSupTr4);
3530
3531
3532   //=========================================
3533   // screws fixing the board on the U tube
3534   Double_t aaa = fgkCarlosSuppY3; // ???
3535   //Double_t aaa = fgkCarlosSuppY3/2 + fgkLittleScrewHeadH/2;
3536   Double_t bbb = fgkCarlosSuppZ3/2 - fgkLittleScrewHeadR;
3537   Double_t screw1y = ( aaa*cos(TMath::DegToRad()*fgkCarlosSuppAngle) - 
3538                        bbb*sin(TMath::DegToRad()*fgkCarlosSuppAngle) );
3539   Double_t screw1z = ( aaa*sin(TMath::DegToRad()*fgkCarlosSuppAngle) + 
3540                        bbb*cos(TMath::DegToRad()*fgkCarlosSuppAngle) )-0.07;
3541
3542   TGeoRotation *CarlosSuppRot = (TGeoRotation *)fCommonTr[0];   
3543
3544   TGeoCombiTrans* lScrewTr1 = new TGeoCombiTrans((fgkCarlosSuppX1+
3545                               fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
3546                               screw1y,screw1z, CarlosSuppRot);
3547
3548   TGeoCombiTrans* lScrewTr2 = new TGeoCombiTrans((fgkCarlosSuppX1+
3549                               fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
3550                               screw1z,screw1y, CarlosSuppRot);
3551
3552   TGeoCombiTrans *lScrewTr3 = new TGeoCombiTrans(-(fgkCarlosSuppX1+
3553                               fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
3554                               screw1y,screw1z, CarlosSuppRot);
3555
3556   TGeoCombiTrans *lScrewTr4 = new TGeoCombiTrans(-(fgkCarlosSuppX1+
3557                               fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
3558                               screw1z,screw1y, CarlosSuppRot);
3559
3560   assemblySupCarlos->AddNode(fCommonVol[0], 1, lScrewTr1);
3561   assemblySupCarlos->AddNode(fCommonVol[0], 2, lScrewTr2);
3562   assemblySupCarlos->AddNode(fCommonVol[0], 3, lScrewTr3);
3563   assemblySupCarlos->AddNode(fCommonVol[0], 4, lScrewTr4);
3564
3565   //=========================================
3566   // board
3567   Double_t p1[3], p2[3], vX[3] = {1,0,0};
3568   AliITSv11GeomCableFlat card1("cardCarlos1", fgkCarlosCardZ1, fgkCarlosCardY1); // name, width, thickness
3569   card1.SetNLayers(2);
3570   card1.SetLayer(0, fgkCarlosCardCuY, copper,     kOrange); // index, thickness, material, color
3571   card1.SetLayer(1, fgkCarlosCardY1-fgkCarlosCardCuY,   glassFiber, 30);
3572   card1.SetInitialNode( (TGeoVolume *) assemblySupCarlos);
3573   p1[0] = -fgkCarlosCardX1/2;
3574   p1[1] = shiftGlobY - fgkCarlosCard2HeatBridge;
3575   p1[2] = fgkCarlosCardShift;
3576   p2[0] = fgkCarlosCardX1/2;
3577   p2[1] = shiftGlobY - fgkCarlosCard2HeatBridge;
3578   p2[2] = fgkCarlosCardShift;
3579   card1.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 0, p1, vX);
3580   card1.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 1, p2, vX);
3581   card1.CreateAndInsertBoxCableSegment(1,90);
3582
3583   AliITSv11GeomCableFlat card2("cardCarlos2", fgkCarlosCardZ2, fgkCarlosCardY1); // name, width, thickness
3584   card2.SetNLayers(2);
3585   card2.SetLayer(0, fgkCarlosCardCuY, copper,     kOrange); // index, thickness, material, color
3586   card2.SetLayer(1, fgkCarlosCardY1-fgkCarlosCardCuY,   glassFiber, 30);
3587   card2.SetInitialNode( (TGeoVolume *) assemblySupCarlos);
3588
3589   p1[0] = -fgkCarlosCardX1/2;
3590   p1[1] = shiftGlobY - fgkCarlosCard2HeatBridge;
3591   p1[2] = fgkCarlosCardShift + fgkCarlosCardZ1/2 + fgkCarlosCardZ2/2;
3592
3593   p2[0] = -fgkCarlosCardX1/2 + fgkCarlosCardX2;
3594   p2[1] = shiftGlobY - fgkCarlosCard2HeatBridge;
3595   p2[2] = fgkCarlosCardShift + fgkCarlosCardZ1/2 + fgkCarlosCardZ2/2;
3596   card2.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 0, p1, vX);
3597   card2.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 1, p2, vX);
3598   card2.CreateAndInsertBoxCableSegment(1,90);
3599
3600   //=========================================
3601   // some chips on the board 
3602
3603   AliITSv11GeomCableFlat u1("carlosCardU1", fgkCarlosU1Z, fgkCarlosU1Y); // name, width, thickness
3604   u1.SetNLayers(2);
3605   u1.SetLayer(0, fgkCarlosCardChipSiThick, siliconChip, kGreen); // index, thickness, material, color
3606   u1.SetLayer(1, fgkCarlosU1Y - fgkCarlosCardChipSiThick, plastiChip, kGray+3);
3607   u1.SetInitialNode( (TGeoVolume *) assemblySupCarlos);
3608
3609   p1[0] = fgkCarlosU1posX - fgkCarlosU1X/2;
3610   p1[1] = shiftGlobY - fgkCarlosCard2HeatBridge + fgkCarlosCardY1/2 + fgkCarlosU1Y/2;
3611   p1[2] = fgkCarlosCardShift + fgkCarlosU1posZ;
3612
3613   p2[0] = fgkCarlosU1posX + fgkCarlosU1X/2;
3614   p2[1] = shiftGlobY - fgkCarlosCard2HeatBridge + fgkCarlosCardY1/2 + fgkCarlosU1Y/2;
3615   p2[2] = fgkCarlosCardShift + fgkCarlosU1posZ;
3616   u1.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 0, p1, vX);
3617   u1.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 1, p2, vX);
3618   u1.CreateAndInsertBoxCableSegment(1,90);
3619
3620   //---
3621   AliITSv11GeomCableFlat u2("carlosCardU2", fgkCarlosU2Z, fgkCarlosU2Y); // name, width, thickness
3622   u2.SetNLayers(2);
3623   u2.SetLayer(0, fgkCarlosCardChipSiThick, siliconChip, kGreen); // index, thickness, material, color
3624   u2.SetLayer(1, fgkCarlosU2Y - fgkCarlosCardChipSiThick, plastiChip, kGray+3);
3625   u2.SetInitialNode( (TGeoVolume *) assemblySupCarlos);
3626
3627   p1[0] = fgkCarlosU2posX - fgkCarlosU2X/2;
3628   p1[1] = shiftGlobY - fgkCarlosCard2HeatBridge + fgkCarlosCardY1/2 + fgkCarlosU2Y/2;
3629   p1[2] = fgkCarlosCardShift + fgkCarlosU2posZ;
3630
3631   p2[0] = fgkCarlosU2posX + fgkCarlosU2X/2;
3632   p2[1] = shiftGlobY - fgkCarlosCard2HeatBridge + fgkCarlosCardY1/2 + fgkCarlosU2Y/2;
3633   p2[2] = fgkCarlosCardShift + fgkCarlosU2posZ;
3634   u2.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 0, p1, vX);
3635   u2.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 1, p2, vX);
3636   u2.CreateAndInsertBoxCableSegment(1,90);
3637
3638   //---
3639   AliITSv11GeomCableFlat u3("carlosCardU3", fgkCarlosU3Z, fgkCarlosU3Y); // name, width, thickness
3640   u3.SetNLayers(2);
3641   u3.SetLayer(0, fgkCarlosCardChipSiThick, siliconChip, kGreen); // index, thickness, material, color
3642   u3.SetLayer(1, fgkCarlosU3Y - fgkCarlosCardChipSiThick, plastiChip, kGray+3);
3643   u3.SetInitialNode( (TGeoVolume *) assemblySupCarlos);
3644
3645   Double_t u3Y = shiftGlobY - fgkCarlosCard2HeatBridge + fgkCarlosCardY1/2 + fgkCarlosU3Y/2;
3646   p1[0] = fgkCarlosU3posX - fgkCarlosU3X/2;
3647   p1[1] = u3Y;
3648   p1[2] = fgkCarlosCardShift + fgkCarlosU3posZ;
3649
3650   p2[0] = fgkCarlosU3posX + fgkCarlosU3X/2;
3651   p2[1] = u3Y;
3652   p2[2] = fgkCarlosCardShift + fgkCarlosU3posZ;
3653   u3.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 0, p1, vX);
3654   u3.AddCheckPoint( (TGeoVolume *) assemblySupCarlos, 1, p2, vX);
3655   TGeoVolume *u3Vol = u3.CreateAndInsertBoxCableSegment(1,90);
3656
3657   //--- U4 is like U3 (?)
3658   TGeoCombiTrans *u4Trans = new TGeoCombiTrans;
3659   u4Trans->RotateX(90);
3660   u4Trans->SetTranslation(fgkCarlosU4posX, u3Y,
3661                           fgkCarlosCardShift + fgkCarlosU4posZ);
3662   assemblySupCarlos->AddNode(u3Vol, 2, u4Trans);
3663                                                  
3664   //---
3665   AliITSv11GeomCableFlat u17("carlosCardU17", fgkCarlosU17Z, fgkCarlosU17Y); // name, width, thickness
3666   u17.SetNLayers(2);
3667   u17.SetLayer(0, fgkCarlosCardChipSiThick, siliconChip, kGreen); // index, thickness, material, color
3668   u17.SetLayer(1, fgkCarlosU17Y - fgkCarlosCardChipSiThick, plastiChip, kGray+3);
3669   u17.SetInitialNode( (TGeoVolume *) assemblySupCarlos);
3670
3671   p1[0] = fgkCarlosU17posX - fgkCarlosU17X/2;
3672   p1[1] = shiftGlobY - fgkCarlosCard2HeatBridge + fgkCarlosCardY1/2 + fgkCarlosU17Y/2;
3673   p1[2] = fgkCarlosCardShift + fgkCarlosU17posZ;
3674
3675   p2[0] = fgkCarlosU17posX + fgkCarlosU17X/2;
3676   p2[1] = shiftGlobY - fgkCarlosCar