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