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