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