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