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