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