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