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