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