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