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