modifications to be compliant with -Weffc++ option (L. Gaudichet)
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySDD.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16
17 //*************************************************************************
18 // SDD geometry, based on ROOT geometrical modeler
19 //
20 // Ludovic Gaudichet                                   gaudichet@to.infn.it
21 //*************************************************************************
22
23
24
25 // General Root includes
26 //#include <Riostream.h>
27 #include <TMath.h>
28
29 // Root Geometry includes
30 #include <TGeoManager.h>
31 #include <TGeoVolume.h>
32 #include <TGeoCone.h>
33 #include <TGeoTube.h>
34 #include <TGeoArb8.h>
35 #include <TGeoCompositeShape.h>
36 #include <TGeoMatrix.h>
37 #include <TGeoNode.h>
38
39 #include "AliITSgeom.h"
40 #include "AliITSgeomSDD.h"
41 #include "AliITSv11GeometrySDD.h"
42 #include "AliITSv11GeomCableFlat.h"
43 #include "AliITSv11GeomCableRound.h"
44 #include "TList.h"
45
46 const char*    AliITSv11GeometrySDD::fgSDDsensitiveVolName = "ITSsddSensitiv";
47 const Double_t AliITSv11GeometrySDD::fgkSegmentLength     = 37.2*2*fgkmm;
48 const Double_t AliITSv11GeometrySDD::fgkLadderWidth       = 50.0*fgkmm;
49 const Double_t AliITSv11GeometrySDD::fgkLadderHeight      = 30.0*fgkmm;
50 const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDW    =  3.5*fgkmm;
51 const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDH    =  3.*fgkmm;
52
53 const Double_t AliITSv11GeometrySDD::fgkLadderBeamRadius  =  0.6*fgkmm;
54 const Double_t AliITSv11GeometrySDD::fgkLadderLa          =  3.*fgkmm;
55 const Double_t AliITSv11GeometrySDD::fgkLadderHa          =  0.721979*fgkmm;
56 const Double_t AliITSv11GeometrySDD::fgkLadderLb          =  3.7*fgkmm;
57 const Double_t AliITSv11GeometrySDD::fgkLadderHb          =  0.890428*fgkmm;
58 const Double_t AliITSv11GeometrySDD::fgkLadderl           =  0.25*fgkmm;
59
60 const Double_t AliITSv11GeometrySDD::fgkBottomBeamAngle   = 56.5;
61 const Double_t AliITSv11GeometrySDD::fgkBeamSidePhi       = 65;
62
63 const Double_t AliITSv11GeometrySDD::fgkLadWaferSep       = 2*fgkmm;
64 const Double_t AliITSv11GeometrySDD::fgkPinSuppWidth      = 2.5*fgkmm;
65 const Double_t AliITSv11GeometrySDD::fgkPinSuppHeight     = 2.*fgkmm;
66 const Double_t AliITSv11GeometrySDD::fgkPinSuppRmax       = 2.5/2.*fgkmm;
67 const Double_t AliITSv11GeometrySDD::fgkPinR              = 1.5/2.*fgkmm;
68 const Double_t AliITSv11GeometrySDD::fgkPinSuppLength     = 5.*fgkmm;
69 const Double_t AliITSv11GeometrySDD::fgkPinSuppThickness  = 0.5*fgkmm;
70 const Double_t AliITSv11GeometrySDD::fgkPinSuppConeAngle  = 4;
71 const Double_t AliITSv11GeometrySDD::fgkPinDXminOnSensor  = (39./2.)*fgkmm;
72 const Double_t AliITSv11GeometrySDD::fgkPinPinDDXOnSensor = 3*fgkmm;
73 const Double_t AliITSv11GeometrySDD::fgkPinDYOnSensor     = (52.5/2.)*fgkmm;
74
75 // parameters from ALR-0752/3
76 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppHeight    =  3.2*fgkmm;  
77 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppMaxLength = 14*fgkmm;
78 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppWidthExt  =  0.4*fgkmm;
79 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppWidthIn   =  0.65*fgkmm;
80 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppHoleDiam  =  2*fgkmm;
81 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppFulWidth  =  5.15*fgkmm;
82 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppTongW     =  0.8*fgkmm; 
83 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppAngle     = 22.5;
84 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppSlitL     =  4.9*fgkmm;
85 const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppAxeDist   =  3.05*fgkmm;
86 const Double_t AliITSv11GeometrySDD::fgkCoolPipeInnerDiam     =  1.84*fgkmm;
87 const Double_t AliITSv11GeometrySDD::fgkCoolPipeOuterDiam     =  2.*fgkmm;
88
89 const Double_t AliITSv11GeometrySDD::fgkBTBthick           =  0.25 *fgkmm;
90 const Double_t AliITSv11GeometrySDD::fgkBTBlength          = 55. *fgkmm;
91 const Double_t AliITSv11GeometrySDD::fgkBTBwidth           = 18*fgkmm;
92 const Double_t AliITSv11GeometrySDD::fgkBTBaxisAtoBottom   =  4*fgkmm;
93 const Double_t AliITSv11GeometrySDD::fgkBTBaxisAtoBase     =  1.2*fgkmm;
94 const Double_t AliITSv11GeometrySDD::fgkRadiusAminBTB      =  1. *fgkmm;
95 const Double_t AliITSv11GeometrySDD::fgkRadiusBminBTB      =  0.53 *fgkmm;
96 const Double_t AliITSv11GeometrySDD::fgkBTBHoleLength      = 15 *fgkmm;
97 const Double_t AliITSv11GeometrySDD::fgkBTBHolewidth       =  6 *fgkmm;
98 const Double_t AliITSv11GeometrySDD::fgkBTBHoleRefX        = 10 *fgkmm;
99 const Double_t AliITSv11GeometrySDD::fgkBTBHoleRefY        =  6.5 *fgkmm;
100
101 const Double_t AliITSv11GeometrySDD::fgkLay3Rmin           = 145.*fgkmm;      // not min! Rmin virtual tube
102 const Double_t AliITSv11GeometrySDD::fgkLay3Rmax           = 205.*fgkmm;      // not min! Rmax virtual tube
103 const Double_t AliITSv11GeometrySDD::fgkLay3Length         = (524.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
104 const Double_t AliITSv11GeometrySDD::fgkLay3LadderLength   = 524.*fgkmm;
105 const Double_t AliITSv11GeometrySDD::fgkLay3DetShortRadius = 146.0*fgkmm;
106 const Double_t AliITSv11GeometrySDD::fgkLay3DetLongRadius  = 152.0*fgkmm;
107 const Double_t AliITSv11GeometrySDD::fgkLay3LaddTopCornerEnd = 15.6*fgkmm;
108 const Int_t    AliITSv11GeometrySDD::fgkLay3Ndet           =  6;
109 const Int_t    AliITSv11GeometrySDD::fgkLay3Nladd          = 14;
110 const Double_t AliITSv11GeometrySDD::fgkLay3CoolPipeSuppH  =  7.5*fgkmm;
111
112 const Double_t AliITSv11GeometrySDD::fgkLay4Rmin           = 220.*fgkmm;         // not min! Rmin virtual tube
113 const Double_t AliITSv11GeometrySDD::fgkLay4Rmax           = 290.*fgkmm;         // not min! Rmax virtual tube
114 const Double_t AliITSv11GeometrySDD::fgkLay4Length         = (671.+0.)*fgkmm;    // ladder+supporting rings (length of the virtual tube)
115 const Double_t AliITSv11GeometrySDD::fgkLay4LadderLength   = 671.*fgkmm;
116 const Double_t AliITSv11GeometrySDD::fgkLay4DetShortRadius = 235.0*fgkmm;
117 const Double_t AliITSv11GeometrySDD::fgkLay4DetLongRadius  = 240.5*fgkmm;
118 const Double_t AliITSv11GeometrySDD::fgkLay4LaddTopCornerEnd = 15.6*fgkmm;
119 const Int_t    AliITSv11GeometrySDD::fgkLay4Ndet           = 8;
120 const Int_t    AliITSv11GeometrySDD::fgkLay4Nladd          = 22;
121 const Double_t AliITSv11GeometrySDD::fgkLay4CoolPipeSuppH  = 7.5*fgkmm;
122
123 //hybrid 
124 const Double_t AliITSv11GeometrySDD::fgkHybridAngle       = 46;           // approx !!!
125 // Origine taken at the hybrid corner :
126 const Double_t AliITSv11GeometrySDD::fgkHybridLength      = 65*fgkmm;
127 const Double_t AliITSv11GeometrySDD::fgkHybridWidth       = 41*fgkmm;
128 const Double_t AliITSv11GeometrySDD::fgkHybRndHoleRad     = 1.05*fgkmm;
129 const Double_t AliITSv11GeometrySDD::fgkHybRndHoleZ       = 2.5*fgkmm;
130 const Double_t AliITSv11GeometrySDD::fgkHybRndHoleX       = fgkHybridWidth-23.599*fgkmm;
131
132 const Double_t AliITSv11GeometrySDD::fgkHybFLlowHoleDZ    =   9.698*fgkmm; 
133 const Double_t AliITSv11GeometrySDD::fgkHybFLlowHolePasDX =  10.754*fgkmm; 
134 const Double_t AliITSv11GeometrySDD::fgkHybFLlowHoleAmbDX =   9.122*fgkmm;
135   // center of ships to the border
136 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ4    = fgkHybridLength-(4.654      )*fgkmm-fgkHybFLlowHoleDZ/2;
137 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ3    = fgkHybridLength-(4.654+15.  )*fgkmm-fgkHybFLlowHoleDZ/2;
138 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ2    = fgkHybridLength-(4.654+15.*2)*fgkmm-fgkHybFLlowHoleDZ/2;
139 const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ1    = fgkHybridLength-(4.654+15.*3)*fgkmm-fgkHybFLlowHoleDZ/2;
140 const Double_t AliITSv11GeometrySDD::fgkHybFLlowPasX      = fgkHybridWidth-32.775*fgkmm;       
141 const Double_t AliITSv11GeometrySDD::fgkHybFLlowAmbX      = fgkHybridWidth-20.791*fgkmm;
142 const Double_t AliITSv11GeometrySDD::fgkHybChipsDZ        =  9.221*fgkmm; 
143 const Double_t AliITSv11GeometrySDD::fgkHybPascalDX       = 10.245*fgkmm; 
144 const Double_t AliITSv11GeometrySDD::fgkHybAmbraDX        =  8.51*fgkmm; 
145 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperWidth   = 15.012*fgkmm;
146 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperLength  = 59.878*fgkmm;
147 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperAlDZ    = 11.183*fgkmm;
148 const Double_t AliITSv11GeometrySDD::fgkHybFLUpperAldx    =  2.307*fgkmm;
149
150 const Double_t AliITSv11GeometrySDD::fgkmu = 1*fgkmicron; // 1*fgkmicron; // can be increase for checking thin objects
151 const Double_t AliITSv11GeometrySDD::fgkHybridThBridgeThick =  0.25*fgkmm;               // ???
152 const Double_t AliITSv11GeometrySDD::fgkHybAlThick         =  30*fgkmu;
153 const Double_t AliITSv11GeometrySDD::fgkHybUpThick         =  20*fgkmu;
154 const Double_t AliITSv11GeometrySDD::fgkHybGlueScrnThick   =  50*fgkmu;           // ??? ?????
155 const Double_t AliITSv11GeometrySDD::fgkHybGlueLowThick    =  90*fgkmu;
156 const Double_t AliITSv11GeometrySDD::fgkHybGlueUpThick     =  90*fgkmu;           // sur ?????
157 const Double_t AliITSv11GeometrySDD::fgkHybAlCCThick       =  12*fgkmu;
158 const Double_t AliITSv11GeometrySDD::fgkHybUpCCThick       =  12*fgkmu;
159 const Double_t AliITSv11GeometrySDD::fgkHybChipThick       = 150*fgkmu;
160 const Double_t AliITSv11GeometrySDD::fgkHybGlueAgThick     =  50*fgkmu;          // ??? ????
161 const Double_t AliITSv11GeometrySDD::fgkHybUnderNiThick    =  20*fgkmu;          // ??? ????
162 const Int_t    AliITSv11GeometrySDD::fgkNHybSMD = 25;
163 const Double_t AliITSv11GeometrySDD::fgkHybSMDposX[fgkNHybSMD]     = 
164           {2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,21.40*fgkmm,
165            2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,19.91*fgkmm,
166            2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,17.09*fgkmm,21.40*fgkmm,
167            2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,19.91*fgkmm,
168            1.63*fgkmm,5.22*fgkmm,13.59*fgkmm,21.40*fgkmm};
169 const Double_t AliITSv11GeometrySDD::fgkHybSMDposZ[fgkNHybSMD]     = 
170          { 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm,
171            17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,
172            32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,
173            47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,
174            62.68*fgkmm,62.06*fgkmm,62.06*fgkmm,62.06*fgkmm};
175 const Double_t AliITSv11GeometrySDD::fgkHybSMDmiddleW      =   0.954*fgkmm;
176 const Double_t AliITSv11GeometrySDD::fgkHybSMDmiddleL      =   0.47 *fgkmm;
177 const Double_t AliITSv11GeometrySDD::fgkHybSMDendW         =   1.132*fgkmm;
178 const Double_t AliITSv11GeometrySDD::fgkHybSMDendL         =   0.925*fgkmm;
179 const Double_t AliITSv11GeometrySDD::fgkHybSMDheight       = 400.*fgkmu;          // ??? ????!!!!!!!
180
181 const Double_t AliITSv11GeometrySDD::fgkWaferThickness     = 300.*fgkmu;
182 const Double_t AliITSv11GeometrySDD::fgkWaferWidth         =  72.5 *fgkmm;
183 const Double_t AliITSv11GeometrySDD::fgkWaferLength        =  87.6 *fgkmm;
184 const Double_t AliITSv11GeometrySDD::fgkWaferThickSens     = 299.8*fgkmu;
185 const Double_t AliITSv11GeometrySDD::fgkWaferWidthSens     =  70.17*fgkmm;
186 const Double_t AliITSv11GeometrySDD::fgkWaferLengthSens    =  74.97*fgkmm;
187
188 const Double_t AliITSv11GeometrySDD::fgkDigitCablWidth     = 18.4*fgkmm;
189 const Double_t AliITSv11GeometrySDD::fgkDigitCablAlThick   = (30+30*8./10.)*fgkmicron; // will probably change
190 const Double_t AliITSv11GeometrySDD::fgkDigitCablPolyThick = (20+12)*fgkmicron;        // will probably change
191
192 const Double_t AliITSv11GeometrySDD::fgkWaHVcableAlThick   = 30*2./10.*fgkmu;  // will probably change // Al ratio is random !!!
193 const Double_t AliITSv11GeometrySDD::fgkWaHVcablePolyThick = 175*fgkmu;        // will probably change
194 const Double_t AliITSv11GeometrySDD::fgkWaHVcableLength    = 67.08*fgkmm;
195 const Double_t AliITSv11GeometrySDD::fgkWaHVcableWitdh     = 17.4 *fgkmm;              //  check !!!
196 const Double_t AliITSv11GeometrySDD::fgkWaHVcableDW        =  13.*fgkmm; //5.24*fgkmm;             //  check !!!
197
198 const Double_t AliITSv11GeometrySDD::fgkSensorGlassLX      =   5.  *fgkmm; 
199 const Double_t AliITSv11GeometrySDD::fgkSensorGlassLZ      =   5.  *fgkmm; 
200 const Double_t AliITSv11GeometrySDD::fgkSensorGlassLY      = 150.  *fgkmu;
201 const Double_t AliITSv11GeometrySDD::fgkGlassDXOnSensor    =  26.28*fgkmm;             //  check !!!
202 const Double_t AliITSv11GeometrySDD::fgkGlassDZOnSensor    =  22.50*fgkmm;             //  check !!!
203
204 const Double_t AliITSv11GeometrySDD::fgkTransitHVAlThick    = 30*2./10.*fgkmu; //  check // will probably change //Al ratio is random
205 const Double_t AliITSv11GeometrySDD::fgkTransitHVPolyThick  = 100*fgkmu;       //  check  // will probably change
206 const Double_t AliITSv11GeometrySDD::fgkTransitHVHeadLX     =  71.46*fgkmm;           //  check !!!
207 const Double_t AliITSv11GeometrySDD::fgkTransitHVHeadLZ     =  21.3*fgkmm;
208 const Double_t AliITSv11GeometrySDD::fgkTransitHVBondingLZ  =   3.6*fgkmm;
209 const Double_t AliITSv11GeometrySDD::fgkTransitHVtailLength =  27*fgkmm;              // ???, not yet fixed ...
210 const Double_t AliITSv11GeometrySDD::fgkTransitHVtailWidth  =  26*fgkmm;
211 const Double_t AliITSv11GeometrySDD::fgkTransitHVtailXpos   =   8*fgkmm;              // ???, a mesurer !!!
212 const Double_t AliITSv11GeometrySDD::fgkTransitHVsideLZ     =  10.34*fgkmm;
213 const Double_t AliITSv11GeometrySDD::fgkTransitHVsideLeftZ  =   4.11*fgkmm;
214 const Double_t AliITSv11GeometrySDD::fgkTransitHVsideRightZ =   3.5*fgkmm;           // ???, a mesurer !!!
215
216 const Double_t AliITSv11GeometrySDD::fgkLongHVcablePolyThick= (20+30+125+30+20+30+125+30+20)*fgkmu; //  check  // will probably change
217 const Double_t AliITSv11GeometrySDD::fgkLongHVcableAlThick  = (30+30*2/10+30)*fgkmu;                //  check  // will probably change
218 const Double_t AliITSv11GeometrySDD::fgkLongHVcableSeparation = 600*fgkmicron;
219
220
221 ClassImp(AliITSv11GeometrySDD)
222
223 //________________________________________________________________________
224 AliITSv11GeometrySDD::AliITSv11GeometrySDD(): 
225   AliITSv11Geometry(),
226   fPinSupport(0),
227   fCoolPipeSupportL(0),
228   fCoolPipeSupportR(0),
229   fSDDsensor(0),
230   fBaseThermalBridge(0),
231   fHybrid(0),
232   fDigitCableLay3A(0),
233   fDigitCableLay3B(0),
234   fDigitCableLay4A(0),
235   fDigitCableLay4B(0),
236   fMotherVol(0),
237   fAddHybrids(kTRUE), 
238   fAddSensors(kTRUE),
239   fAddHVcables(kTRUE),
240   fAddCables(kTRUE), 
241   fAddCoolingSyst(kTRUE),
242   fCoolingOn(kTRUE),
243   fAddOnlyLadder3min(-1),
244   fAddOnlyLadder3max(-1),
245   fAddOnlyLadder4min(-1),
246   fAddOnlyLadder4max(-1),
247   fColorCarbonFiber(2),
248   fColorRyton(2),
249   fColorPhynox(2),
250   fColorSilicon(2),
251   fColorAl(2),
252   fColorPolyhamide(2),
253   fColorGlass(2),
254   fColorSMD(2),
255   fColorSMDweld(2),
256   fLay3LadderUnderSegDH(0),
257   fLay4LadderUnderSegDH(0),
258   fLay3LaddShortRadius(0),
259   fLay3LaddLongRadius(0),
260   fLay4LaddShortRadius(0),
261   fLay4LaddLongRadius(0)
262 {
263   //
264   // Standard constructor
265   //
266   SetParameters();
267 }
268
269 //________________________________________________________________________
270 AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug) :
271   AliITSv11Geometry(debug),
272   fPinSupport(0),
273   fCoolPipeSupportL(0),
274   fCoolPipeSupportR(0),
275   fSDDsensor(0),
276   fBaseThermalBridge(0),
277   fHybrid(0),
278   fDigitCableLay3A(0),
279   fDigitCableLay3B(0),
280   fDigitCableLay4A(0),
281   fDigitCableLay4B(0),
282   fMotherVol(0),
283   fAddHybrids(kTRUE), 
284   fAddSensors(kTRUE),
285   fAddHVcables(kTRUE),
286   fAddCables(kTRUE), 
287   fAddCoolingSyst(kTRUE),
288   fCoolingOn(kTRUE),
289   fAddOnlyLadder3min(-1),
290   fAddOnlyLadder3max(-1),
291   fAddOnlyLadder4min(-1),
292   fAddOnlyLadder4max(-1),
293   fColorCarbonFiber(2),
294   fColorRyton(2),
295   fColorPhynox(2),
296   fColorSilicon(2),
297   fColorAl(2),
298   fColorPolyhamide(2),
299   fColorGlass(2),
300   fColorSMD(2),
301   fColorSMDweld(2),
302   fLay3LadderUnderSegDH(0),
303   fLay4LadderUnderSegDH(0),
304   fLay3LaddShortRadius(0),
305   fLay3LaddLongRadius(0),
306   fLay4LaddShortRadius(0),
307   fLay4LaddLongRadius(0)
308 {
309   //
310   // Constructor setting debugging level
311   //
312   SetParameters();
313 }
314
315 //________________________________________________________________________
316 AliITSv11GeometrySDD::AliITSv11GeometrySDD(const AliITSv11GeometrySDD &s) :
317  AliITSv11Geometry(s.GetDebug()),
318   fPinSupport(s.fPinSupport),
319   fCoolPipeSupportL(s.fCoolPipeSupportL),
320   fCoolPipeSupportR(s.fCoolPipeSupportR),
321   fSDDsensor(s.fSDDsensor),
322   fBaseThermalBridge(s.fBaseThermalBridge),
323   fHybrid(s.fHybrid),
324   fDigitCableLay3A(s.fDigitCableLay3A),
325   fDigitCableLay3B(s.fDigitCableLay3B),
326   fDigitCableLay4A(s.fDigitCableLay4A),
327   fDigitCableLay4B(s.fDigitCableLay4B),
328   fMotherVol(s.fMotherVol),
329   fAddHybrids(s.fAddHybrids), 
330   fAddSensors(s.fAddSensors),
331   fAddHVcables(s.fAddHVcables),
332   fAddCables(s.fAddCables), 
333   fAddCoolingSyst(s.fAddCoolingSyst),
334   fCoolingOn(s.fCoolingOn),
335   fAddOnlyLadder3min(s.fAddOnlyLadder3min),
336   fAddOnlyLadder3max(s.fAddOnlyLadder3max),
337   fAddOnlyLadder4min(s.fAddOnlyLadder4min),
338  fAddOnlyLadder4max(s.fAddOnlyLadder4max),
339   fColorCarbonFiber(s.fColorCarbonFiber),
340   fColorRyton(s.fColorRyton),
341   fColorPhynox(s.fColorPhynox),
342   fColorSilicon(s.fColorSilicon),
343   fColorAl(s.fColorAl),
344   fColorPolyhamide(s.fColorPolyhamide),
345   fColorGlass(s.fColorGlass),
346   fColorSMD(s.fColorSMD),
347   fColorSMDweld(s.fColorSMDweld),
348   fLay3LadderUnderSegDH(s.fLay3LadderUnderSegDH),
349   fLay4LadderUnderSegDH(s.fLay4LadderUnderSegDH),
350   fLay3LaddShortRadius(s.fLay3LaddShortRadius),
351   fLay3LaddLongRadius(s.fLay3LaddLongRadius),
352   fLay4LaddShortRadius(s.fLay4LaddShortRadius),
353   fLay4LaddLongRadius(s.fLay4LaddLongRadius)
354 {
355   //     Copy Constructor
356   // do only a "shallow copy" ...
357   SetParameters();
358 }
359
360 //________________________________________________________________________
361 AliITSv11GeometrySDD& AliITSv11GeometrySDD::
362 operator=(const AliITSv11GeometrySDD &s) {
363   //     Assignment operator
364   if(&s == this) return *this;
365   fMotherVol = s.fMotherVol;
366   fAddHybrids = s.fAddHybrids;
367   fAddSensors = s.fAddSensors;
368   fAddHVcables = s.fAddHVcables;
369   fAddCables = s.fAddCables;
370   fAddCoolingSyst = s.fAddCoolingSyst;
371   fCoolingOn = s.fCoolingOn;
372   fAddOnlyLadder3min = s.fAddOnlyLadder3min;
373   fAddOnlyLadder3max = s.fAddOnlyLadder3max;
374   fAddOnlyLadder4min = s.fAddOnlyLadder4min;
375   fAddOnlyLadder4max = s.fAddOnlyLadder4max;
376   return *this;
377 }
378
379 //________________________________________________________________________
380 AliITSv11GeometrySDD::~AliITSv11GeometrySDD() {
381   // Look like a destructor
382   // Smell like a destructor
383   // And actually is the destructor
384   if (fDigitCableLay3A) delete [] fDigitCableLay3A;
385   if (fDigitCableLay3B) delete [] fDigitCableLay3B;
386   if (fDigitCableLay4A) delete [] fDigitCableLay4A;
387   if (fDigitCableLay4B) delete [] fDigitCableLay4B;
388 }
389
390 //________________________________________________________________________
391 void AliITSv11GeometrySDD::SetParameters() {
392   //
393   // Define display colors and the non constant geometry parameters
394   //
395
396   fColorCarbonFiber =  4;
397   fColorRyton       =  5;
398   fColorPhynox      =  7;
399   fColorSilicon     =  3;
400   fColorAl          =  7;
401   fColorPolyhamide  =  5;
402   fColorGlass       =  2;
403   fColorSMD         = 12;
404   fColorSMDweld     = 17;
405
406   fPinSupport       = 0;
407   fCoolPipeSupportL = 0;
408   fCoolPipeSupportR = 0;
409   fSDDsensor        = 0;
410   fBaseThermalBridge= 0;
411   fHybrid           = 0;
412
413   Double_t detLadderDist = 8*fgkmm; 
414
415   fLay3LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
416   fLay4LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
417
418   // radius from the center to the CF ladder :
419   fLay3LaddShortRadius = (fgkLay3DetShortRadius
420                           + fgkLadWaferSep+2*fgkWaferThickness
421                           + detLadderDist); 
422   fLay3LaddLongRadius  = (fgkLay3DetLongRadius
423                           + fgkLadWaferSep+2*fgkWaferThickness
424                           + detLadderDist); 
425   fLay4LaddShortRadius = (fgkLay4DetShortRadius
426                           + fgkLadWaferSep+2*fgkWaferThickness
427                           + detLadderDist); 
428   fLay4LaddLongRadius  = (fgkLay4DetLongRadius
429                           + fgkLadWaferSep+2*fgkWaferThickness
430                           + detLadderDist); 
431
432   fLay3sensorZPos[0]= (  35.8+72.4+75.8 )*fgkmm;
433   fLay3sensorZPos[1]= (  35.8+72.4      )*fgkmm;
434   fLay3sensorZPos[2]= (  35.8           )*fgkmm;
435   fLay3sensorZPos[3]= ( -37.9           )*fgkmm;
436   fLay3sensorZPos[4]= ( -37.9-74.9      )*fgkmm;
437   fLay3sensorZPos[5]= ( -37.9-74.9-71.1 )*fgkmm;
438
439   fLay4sensorZPos[0] = (  38.5+73.2+75.4+71.6 )*fgkmm;
440   fLay4sensorZPos[1] = (  38.5+73.2+75.4      )*fgkmm;
441   fLay4sensorZPos[2] = (  38.5+73.2           )*fgkmm;
442   fLay4sensorZPos[3] = (  38.5                )*fgkmm;
443   fLay4sensorZPos[4] = ( -35.6                )*fgkmm;
444   fLay4sensorZPos[5] = ( -35.6-74.8           )*fgkmm;
445   fLay4sensorZPos[6] = ( -35.6-74.8-72.4      )*fgkmm;
446   fLay4sensorZPos[7] = ( -35.6-74.8-72.4-76.  )*fgkmm;
447 }
448
449
450 //________________________________________________________________________
451 TGeoMedium* AliITSv11GeometrySDD::GetMedium(const char* mediumName) {
452   //
453   // Called to get a medium, checks that it exists.
454   // If not, prints an error and returns 0
455   //
456
457   char ch[30];
458   sprintf(ch, "ITS_%s",mediumName);
459   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
460   if (! medium)
461     printf("Error(AliITSv11GeometrySDD)::medium %s not found !\n", mediumName);
462   return medium;
463 }
464
465
466 //________________________________________________________________________
467 Int_t AliITSv11GeometrySDD::GetLay3NLadders() const{
468   // Get the actual number of ladder in layer 3
469   if ( (fAddOnlyLadder3min<0) ||
470        (fAddOnlyLadder3min >= fgkLay3Nladd) ||
471        (fAddOnlyLadder3max<0) ||
472        (fAddOnlyLadder3max >= fgkLay3Nladd) )
473     return fgkLay3Nladd;
474   else return (fAddOnlyLadder3max-fAddOnlyLadder3min+1);
475 }
476
477
478 //________________________________________________________________________
479 Int_t AliITSv11GeometrySDD::GetLay4NLadders() const{
480   // Get the actual number of ladder in layer 4
481   if ( (fAddOnlyLadder4min<0) ||
482        (fAddOnlyLadder4min >= fgkLay4Nladd) ||
483        (fAddOnlyLadder4max<0) ||
484        (fAddOnlyLadder4max >= fgkLay4Nladd) )
485     return fgkLay4Nladd;
486   else return (fAddOnlyLadder4max-fAddOnlyLadder4min+1);
487 }
488
489
490 //________________________________________________________________________
491 void AliITSv11GeometrySDD::CreateBasicObjects() {
492   //
493   // Create basics objets which will be assembled together
494   // in Layer3 and Layer4 functions
495   //
496
497
498   fDigitCableLay3A = new AliITSv11GeomCableFlat[fgkLay3Ndet];
499   fDigitCableLay3B = new AliITSv11GeomCableFlat[fgkLay3Ndet];
500   fDigitCableLay4A = new AliITSv11GeomCableFlat[fgkLay4Ndet];
501   fDigitCableLay4B = new AliITSv11GeomCableFlat[fgkLay4Ndet];
502
503   fPinSupport = CreatePinSupport();
504   fCoolPipeSupportL = CreateCoolPipeSupportL();
505   fCoolPipeSupportR = CreateCoolPipeSupportR();
506   fSDDsensor = CreateSDDsensor();
507   fBaseThermalBridge = CreateBaseThermalBridge();
508   fHybrid = CreateHybrid(0);
509
510
511   TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
512   TGeoMedium *polyhamideSDD = GetMedium("ITSsddKAPTON_POLYCH2");
513   TGeoMedium *alSDD         = GetMedium("ITSal");
514
515   //********************************************************************
516   // pieces of the carbon fiber structure
517   //********************************************************************
518   Double_t dy             = fgkLadderSegBoxDH/2;
519   Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
520   Double_t halfTheta      = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
521   Double_t alpha          = TMath::Pi()*3./4. - halfTheta/2.;
522   Double_t beta           = (TMath::Pi() - 2.*halfTheta)/4.;
523   Double_t dYTranslation  = (fgkLadderHeight/2.
524                              -0.5*fgkLadderWidth*TMath::Tan(beta)
525                              -fgkLadderBeamRadius);
526   Double_t distCenterSideDown =  0.5*fgkLadderWidth/TMath::Cos(beta);
527
528   //--- the top V of the Carbon Fiber Ladder (segment)
529   TGeoArb8 *cfLaddTop1 = CreateLadderSide( fgkSegmentLength/2., halfTheta, 
530                           -1, fgkLadderLa, fgkLadderHa, fgkLadderl);
531   TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
532                                   cfLaddTop1,carbonFiberLadderStruct);
533   TGeoArb8 *cfLaddTop2 = CreateLadderSide( fgkSegmentLength/2., halfTheta,
534                            1, fgkLadderLa, fgkLadderHa, fgkLadderl);
535   TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerVol2",
536                                   cfLaddTop2, carbonFiberLadderStruct);
537   cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
538   cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
539   TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2-dy, 0);
540
541   //--- the 2 side V
542   TGeoArb8 *cfLaddSide1 = CreateLadderSide( fgkSegmentLength/2., beta, -1,
543                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
544   TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerVol1",
545                                    cfLaddSide1,carbonFiberLadderStruct);
546   TGeoArb8 *cfLaddSide2 = CreateLadderSide( fgkSegmentLength/2., beta, 1,
547                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
548   TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerVol2",
549                                    cfLaddSide2,carbonFiberLadderStruct);
550   cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
551   cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
552   TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
553                                              alpha*TMath::RadToDeg());
554   AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation-dy, 0);
555   TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,
556                                              -alpha*TMath::RadToDeg());
557   AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation-dy, 0);
558
559   //--- The beams
560   // Beams on the sides
561   Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
562            TMath::Sin(2*beta)/(TanD(fgkBeamSidePhi)*TanD(fgkBeamSidePhi))) ));
563   //cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
564   Double_t beamLength = TMath::Sqrt( fgkLadderHeight*fgkLadderHeight/
565                         ( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
566                         + fgkLadderWidth*fgkLadderWidth/4.)-fgkLadderLa/2-fgkLadderLb/2;
567   TGeoTubeSeg *sideBeamS = new TGeoTubeSeg(0, fgkLadderBeamRadius,beamLength/2.,
568                                            0, 180);
569   TGeoVolume *sideBeam = new TGeoVolume("ITSsddCFSideBeamVol", sideBeamS,
570                              carbonFiberLadderStruct);
571   sideBeam->SetLineColor(fColorCarbonFiber);
572
573   //Euler rotation : about Z, then new X, then new Z
574   TGeoRotation *beamRot1 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
575                                             -beamPhiPrime*TMath::RadToDeg(),-90);
576   TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
577                                             beamPhiPrime*TMath::RadToDeg(), -90);
578   TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
579                                             beamPhiPrime*TMath::RadToDeg(), -90);
580   TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
581                                             -beamPhiPrime*TMath::RadToDeg(),-90);
582
583   TGeoCombiTrans *beamTransf[8];
584   beamTransf[0] = new TGeoCombiTrans( 0.5*triangleHeight*
585                                       TMath::Tan(halfTheta),
586                                       fgkLadderBeamRadius/2. - dy,
587                                       -3*fgkSegmentLength/8, beamRot1);
588   beamTransf[1] = new TGeoCombiTrans(*beamTransf[0]);
589   AddTranslationToCombiTrans(beamTransf[1], 0, 0, fgkSegmentLength/2);
590
591   beamTransf[2] = new TGeoCombiTrans(0.5*triangleHeight*
592                                      TMath::Tan(halfTheta),
593                                      fgkLadderBeamRadius/2. - dy,
594                                      -fgkSegmentLength/8, beamRot2);
595   beamTransf[3] = new TGeoCombiTrans(*beamTransf[2]);
596   AddTranslationToCombiTrans(beamTransf[3], 0, 0, fgkSegmentLength/2);
597
598   beamTransf[4] = new TGeoCombiTrans(-0.5*triangleHeight*
599                                      TMath::Tan(halfTheta),
600                                      fgkLadderBeamRadius/2. - dy,
601                                      -3*fgkSegmentLength/8, beamRot3);
602   beamTransf[5] = new TGeoCombiTrans(*beamTransf[4]);
603   AddTranslationToCombiTrans(beamTransf[5], 0, 0, fgkSegmentLength/2);
604
605   beamTransf[6] = new TGeoCombiTrans(-0.5*triangleHeight*
606   TMath::Tan(halfTheta),fgkLadderBeamRadius/2.-dy, -fgkSegmentLength/8,beamRot4);
607   beamTransf[7] = new TGeoCombiTrans(-0.5*triangleHeight*
608   TMath::Tan(halfTheta),fgkLadderBeamRadius/2.-dy,3*fgkSegmentLength/8,beamRot4);
609
610   //--- Beams of the bottom
611   TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
612                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 180);
613   TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
614                                    bottomBeam1, carbonFiberLadderStruct);
615   bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
616   TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
617                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 90);
618   TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
619                                bottomBeam2, carbonFiberLadderStruct);
620   bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
621   TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
622                              0.5*fgkLadderWidth/SinD(fgkBottomBeamAngle)
623                              - fgkLadderLb/3, 0, 180);
624   TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol",
625                                    bottomBeam3, carbonFiberLadderStruct);
626   bottomBeam3Vol->SetLineColor(fColorCarbonFiber);
627   //bottomBeam3Vol->SetLineColor(2);
628   TGeoRotation *bottomBeamRot1 = new TGeoRotation("", 90, 90,  90);
629   TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
630
631   TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans
632     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,0, bottomBeamRot1);
633   TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
634                                       -(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,
635                                       -fgkSegmentLength/2, bottomBeamRot1);
636   TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,
637                                       -(fgkLadderHeight/2 - fgkLadderBeamRadius)
638                                       - dy, fgkSegmentLength/2, bottomBeamRot2);
639   // be careful for beams #3: when "reading" from -z to +z and 
640   // from the bottom of the ladder, it should draw a Lambda, and not a V
641   TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, fgkBottomBeamAngle, -90);
642   TGeoRotation *bottomBeamRot5 = new TGeoRotation("" ,-90,-fgkBottomBeamAngle, -90);
643   TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans
644     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,-fgkSegmentLength/4,bottomBeamRot4);
645   TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans
646     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,fgkSegmentLength/4, bottomBeamRot5);
647
648   fLaddSegCommonVol[0] = cfLaddTopVol1;  fLaddSegCommonTr[0] = trTop1;
649   fLaddSegCommonVol[1] = cfLaddTopVol2;  fLaddSegCommonTr[1] = trTop1;
650   fLaddSegCommonVol[2] = cfLaddSideVol1; fLaddSegCommonTr[2] = ctSideR;
651   fLaddSegCommonVol[3] = cfLaddSideVol1; fLaddSegCommonTr[3] = ctSideL;
652   fLaddSegCommonVol[4] = cfLaddSideVol2; fLaddSegCommonTr[4] = ctSideR;
653   fLaddSegCommonVol[5] = cfLaddSideVol2; fLaddSegCommonTr[5] = ctSideL;
654   fLaddSegCommonVol[6] = sideBeam;       fLaddSegCommonTr[6] = beamTransf[0];
655   fLaddSegCommonVol[7] = sideBeam;       fLaddSegCommonTr[7] = beamTransf[1];
656   fLaddSegCommonVol[8] = sideBeam;       fLaddSegCommonTr[8] = beamTransf[2];
657   fLaddSegCommonVol[9] = sideBeam;       fLaddSegCommonTr[9] = beamTransf[3];
658   fLaddSegCommonVol[10]= sideBeam;       fLaddSegCommonTr[10]= beamTransf[4];
659   fLaddSegCommonVol[11]= sideBeam;       fLaddSegCommonTr[11]= beamTransf[5];
660   fLaddSegCommonVol[12]= sideBeam;       fLaddSegCommonTr[12]= beamTransf[6];
661   fLaddSegCommonVol[13]= sideBeam;       fLaddSegCommonTr[13]= beamTransf[7];
662   fLaddSegCommonVol[14]= bottomBeam1Vol; fLaddSegCommonTr[14]= bottomBeamTransf1;
663   fLaddSegCommonVol[15]= bottomBeam2Vol; fLaddSegCommonTr[15]= bottomBeamTransf2;
664   fLaddSegCommonVol[16]= bottomBeam2Vol; fLaddSegCommonTr[16]= bottomBeamTransf3;
665   fLaddSegCommonVol[17]= bottomBeam3Vol; fLaddSegCommonTr[17]= bottomBeamTransf4;
666   fLaddSegCommonVol[18]= bottomBeam3Vol; fLaddSegCommonTr[18]= bottomBeamTransf5;
667
668  
669   //********************************************************************
670   // cables
671   //********************************************************************
672   char cableName[30];
673   for (Int_t i=0; i<fgkLay3Ndet; i++) {
674     sprintf(cableName, "digitCableLay3A_%i",i);
675     fDigitCableLay3A[i].SetName(cableName);
676     fDigitCableLay3A[i].SetWidth(fgkDigitCablWidth);
677     fDigitCableLay3A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
678     fDigitCableLay3A[i].SetNLayers(2);
679     fDigitCableLay3A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
680                                   fColorPolyhamide);
681     fDigitCableLay3A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
682     sprintf(cableName, "digitCableLay3B_%i",i);
683     fDigitCableLay3B[i].SetName(cableName);
684     fDigitCableLay3B[i].SetWidth(fgkDigitCablWidth);
685     fDigitCableLay3B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
686     fDigitCableLay3B[i].SetNLayers(2);
687     fDigitCableLay3B[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
688                                   fColorPolyhamide);
689     fDigitCableLay3B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
690   };
691   for (Int_t i=0; i<fgkLay4Ndet; i++) {
692     sprintf(cableName, "digitCableLay4A_%i",i);
693     fDigitCableLay4A[i].SetName(cableName);
694     fDigitCableLay4A[i].SetWidth(fgkDigitCablWidth);
695     fDigitCableLay4A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
696     fDigitCableLay4A[i].SetNLayers(2);
697     fDigitCableLay4A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
698                                   fColorPolyhamide);
699     fDigitCableLay4A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
700     sprintf(cableName, "digitCableLay4B_%i",i);
701     fDigitCableLay4B[i].SetName(cableName);
702     fDigitCableLay4B[i].SetWidth(fgkDigitCablWidth);
703     fDigitCableLay4B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
704     fDigitCableLay4B[i].SetNLayers(2);
705     fDigitCableLay4B[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
706                                   fColorPolyhamide);
707     fDigitCableLay4B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
708   };
709                                         // Well, those digit cables could also include the analog cables
710                                         // which have the same width and the same path, at least in the ladder.
711                                         // It will gain some computing ressources (less volumes) and some
712                                         // coding efforts ... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
713                                         // The only thing to do is to change the names and put the correct total
714                                         // thicknesses
715 }
716
717
718 //________________________________________________________________________
719 void AliITSv11GeometrySDD::CheckOverlaps(Double_t precision){
720   //
721   // a debugging function for checking some possible overlaps
722   //
723   if (fSDDsensor)         fSDDsensor->CheckOverlaps(precision);
724   if (fHybrid)            fHybrid->CheckOverlaps(precision);
725 }
726
727
728 //________________________________________________________________________
729 TGeoCombiTrans *AliITSv11GeometrySDD::
730 CreateCombiTrans(const char *name, Double_t dy, Double_t dz, Double_t dphi) {
731     //
732     // return the TGeoCombiTrans which make a translation in y and z
733     // and a rotation in phi in the global coord system
734     //
735
736     TGeoTranslation t1(dy*CosD(90.+dphi),dy*SinD(90.+dphi), dz);
737     TGeoRotation r1("",0.,0.,dphi);
738
739     TGeoCombiTrans *combiTrans1 = new TGeoCombiTrans(name);
740     combiTrans1->SetTranslation(t1);
741     combiTrans1->SetRotation(r1);
742     return combiTrans1;
743 }
744
745
746 //________________________________________________________________________
747 void AliITSv11GeometrySDD::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
748                                                        Double_t dx,
749                                                        Double_t dy,
750                                                        Double_t dz) const{
751   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
752   const Double_t *vect = ct->GetTranslation();
753   Double_t newVect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
754   ct->SetTranslation(newVect);
755 }
756
757
758 //________________________________________________________________________
759 void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
760 // for code developpment and debugging purposes
761
762   if (! fSDDsensor) CreateBasicObjects();
763
764   //  moth->AddNode(fPinSupport, 1, 0);
765   //  moth->AddNode(fCoolPipeSupportL, 1, 0);
766     moth->AddNode(fSDDsensor, 1, 0);
767   //  moth->AddNode(fBaseThermalBridge, 1, 0);
768   //  moth->AddNode(fHybrid,100,0);
769
770
771 //    TGeoVolume* seg = CreateLadderSegment( 3, 0);
772 //    moth->AddNode(seg, 1, 0);
773
774
775 //   TGeoVolume *lay3Ladder = CreateLadder(3);
776 //   moth->AddNode(lay3Ladder, 1, 0);
777
778 //   TGeoVolume *lay3Detectors = CreateDetectors(3);
779 //   moth->AddNode(lay3Detectors, 1, 0);
780
781 }
782
783
784 //________________________________________________________________________
785 void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
786   //
787   // Insert the layer 3 in the mother volume. This is a virtual volume
788   // containing ladders of layer 3 and the supporting rings
789   //
790
791   if (! moth) {
792     printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
793     return;
794   };
795
796   TGeoMedium *airSDD = GetMedium("ITSair");
797
798   fMotherVol = moth;
799   if (! fSDDsensor) CreateBasicObjects();
800   
801   TGeoVolume *lay3Ladder    = CreateLadder(3);
802   TGeoVolume *lay3Detectors = CreateDetectors(3);
803   TGeoTube *virtualLayer3Shape = new TGeoTube("ITSsddLayer3Shape",
804                                      fgkLay3Rmin,fgkLay3Rmax,fgkLay3Length*0.5);
805   TGeoVolume *virtualLayer3 = new TGeoVolume("ITSsddLayer3",
806                                              virtualLayer3Shape, airSDD);
807
808   Double_t dPhi = 360./fgkLay3Nladd;
809   Double_t detectorsThick = fgkLadWaferSep + 2*fgkWaferThickness;
810   // Placing virtual ladder and detectors volumes following
811   // ladder ordering convention
812   char rotName[30];
813   Int_t iLaddMin = 0;
814   Int_t iLaddMax = fgkLay3Nladd;
815   if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
816     iLaddMin = fAddOnlyLadder3min;
817     iLaddMax = fAddOnlyLadder3max+1;
818   };
819
820   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
821
822     sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
823     Double_t minRadiusLadBox = fLay3LaddShortRadius-fLay3LadderUnderSegDH;
824     if (iLadd%2 != 0)
825       minRadiusLadBox = fLay3LaddLongRadius-fLay3LadderUnderSegDH;
826     minRadiusLadBox += ((TGeoBBox*)lay3Ladder->GetShape())->GetDY();
827     TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,
828                                               0,-90+iLadd*dPhi);
829     virtualLayer3->AddNode(lay3Ladder, iLadd, ctLadd);
830     ///////////////////////////////////////////////////
831     sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
832     Double_t minRadiusDetBox = fgkLay3DetShortRadius;
833     if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
834     minRadiusDetBox += detectorsThick/2;
835     TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
836                                              0,-90+iLadd*dPhi);
837     virtualLayer3->AddNode(lay3Detectors, iLadd, ctDet);
838     ///////////////////////////////////////////////////
839   }
840
841   if(GetDebug(1)) virtualLayer3->CheckOverlaps(0.01);
842   virtualLayer3->SetVisibility(kFALSE);
843   moth->AddNode(virtualLayer3, 1, 0);
844 }
845
846
847 //________________________________________________________________________
848 void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
849   //
850   // Insert the layer 4 in the mother volume. This is a virtual volume
851   // containing ladders of layer 4 and the supporting rings
852   //
853
854   if (! moth) {
855     printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
856     return;
857   };
858
859   fMotherVol = moth;
860
861   if (! fSDDsensor) CreateBasicObjects();
862
863   TGeoTube *virtualLayer4Shape =new TGeoTube("ITSsddLayer4Shape",
864                                     fgkLay4Rmin,fgkLay4Rmax,fgkLay4Length*0.5);
865   TGeoMedium *airSDD = GetMedium("ITSair");
866   TGeoVolume *virtualLayer4 = new TGeoVolume("ITSsddLayer4",
867                                              virtualLayer4Shape, airSDD);
868   TGeoVolume *lay4Ladder    = CreateLadder(4);
869   TGeoVolume *lay4Detectors = CreateDetectors(4);
870   Double_t dPhi = 360./fgkLay4Nladd;
871   Double_t detBoxThickness = fgkLadWaferSep + 2*fgkWaferThickness;
872   // placing virtual ladder and detectors volumes following ladder 
873   // ordering convention
874   char rotName[20];
875   Int_t iLaddMin = 0;
876   Int_t iLaddMax = fgkLay4Nladd;
877   if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
878     iLaddMin = fAddOnlyLadder4min;
879     iLaddMax = fAddOnlyLadder4max+1;
880   }
881   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
882     sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
883     Double_t minRadiusLadBox = fLay4LaddShortRadius-fLay4LadderUnderSegDH;
884     if (iLadd%2 != 0)
885       minRadiusLadBox = fLay4LaddLongRadius-fLay4LadderUnderSegDH;
886     minRadiusLadBox += ((TGeoBBox*)lay4Ladder->GetShape())->GetDY();
887     TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName, minRadiusLadBox,
888                                               0, -90+iLadd*dPhi);
889     virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
890     sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
891     Double_t minRadiusDetBox = fgkLay4DetShortRadius;
892     if (iLadd%2 != 0)
893       minRadiusDetBox = fgkLay4DetLongRadius;
894     minRadiusDetBox += detBoxThickness/2;
895     TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
896                                              0, -90+iLadd*dPhi);
897     virtualLayer4->AddNode(lay4Detectors, iLadd, ctDet);
898   }
899
900   if(GetDebug(1)) virtualLayer4->CheckOverlaps(0.01);
901   virtualLayer4->SetVisibility(kFALSE);
902   moth->AddNode(virtualLayer4,1,0);
903 }
904
905
906 //________________________________________________________________________
907 TGeoVolume *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
908   //
909   // return a box volume containing the CF ladder
910   //
911
912   Int_t    nDetectors   = fgkLay3Ndet;
913   Double_t ladderLength = fgkLay3LadderLength;
914   Double_t underSegDH   = fLay3LadderUnderSegDH;
915   Double_t *sensorZPos  = fLay3sensorZPos;
916   AliITSv11GeomCableFlat *digitCableA = fDigitCableLay3A;
917   AliITSv11GeomCableFlat *digitCableB = fDigitCableLay3B;
918
919   if (iLay==3) {}
920   else if (iLay==4) {
921     nDetectors   = fgkLay4Ndet;
922     ladderLength = fgkLay4LadderLength;
923     digitCableA  = fDigitCableLay4A;
924     digitCableB  = fDigitCableLay4B;
925     underSegDH   = fLay4LadderUnderSegDH;
926     sensorZPos   = fLay4sensorZPos;
927   }
928   else {
929     printf("AliITSv11GeometrySDD::CreateLadder : error=wrong layer\n");
930   };
931   Double_t ladderBoxDH = fgkLadderHeight+fgkLadderSegBoxDH+underSegDH;
932   TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
933                          fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW,
934                          ladderBoxDH/2, ladderLength/2);
935   TGeoMedium *airSDD = GetMedium("ITSair");
936   TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
937   
938   // placing virtual ladder segment following detector ordering convention
939   //=======================================================================
940   char transName[30];
941
942   // adding segment this way to create cable points in the correct order ...
943   for (Int_t iSegment = nDetectors/2-1; iSegment >= 0; iSegment-- ) {
944
945     TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
946     sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
947     Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
948                           + fgkSegmentLength/2;
949     TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
950                                                  underSegDH/2,segmentPos);
951     ////
952     virtualLadder->AddNode(laddSegment, iSegment, segTr);
953   };
954   for (Int_t iSegment = nDetectors/2; iSegment < nDetectors; iSegment++ ) {
955
956     TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
957     sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
958     Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
959                           + fgkSegmentLength/2;
960     TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
961                                                  underSegDH/2,segmentPos);
962     ////
963     virtualLadder->AddNode(laddSegment, iSegment, segTr);
964   };
965
966   // putting virtual volume corresponding to the end of ladder
967   //=======================================================================
968   TGeoVolume *endLadder = CreateEndLadder( iLay );
969   Double_t endLength = (ladderLength - nDetectors*fgkSegmentLength)/2.;
970   TGeoTranslation *endTrZPos = new TGeoTranslation("ITSsddEndTrZPos",0,0,
971                                    fgkSegmentLength*(nDetectors/2)+endLength/2.);
972   // Euler rotation : about Z, then new X, then new Z
973   TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
974   TGeoCombiTrans *endTrZNeg = new TGeoCombiTrans(0,0,
975                   -fgkSegmentLength*(nDetectors/2)-endLength/2.,endZNegRot);
976   virtualLadder->AddNode(endLadder, 1, endTrZPos);
977   virtualLadder->AddNode(endLadder, 2, endTrZNeg);
978
979   // creating and inserting cable segments
980   //   (check points are placed while creating segments)
981   //=======================================================================
982   if (fAddCables)
983   for (Int_t iSegment = 0; iSegment < nDetectors; iSegment++ ) {
984     
985     digitCableA[iSegment].SetInitialNode(virtualLadder);
986     digitCableB[iSegment].SetInitialNode(virtualLadder);
987     
988     for (Int_t iPt=1; iPt<digitCableA[iSegment].GetNCheckPoints(); iPt++ ) {
989       Double_t rotation = 0;
990       if (iPt>1) rotation = 90-fgkHybridAngle; 
991       digitCableA[iSegment].CreateAndInsertCableSegment(iPt, rotation);
992     };
993     
994     for (Int_t iPt=1; iPt<digitCableB[iSegment].GetNCheckPoints(); iPt++ ) {
995       Double_t rotation = 0;
996       if (iPt>1) rotation = fgkHybridAngle-90; 
997       digitCableB[iSegment].CreateAndInsertCableSegment(iPt, rotation);
998     };
999   };
1000   
1001   // HV cable
1002   //=======================================================================
1003   if (fAddHVcables) {
1004   TGeoMedium *polyhamideSDD = GetMedium("ITSsddKAPTON_POLYCH2");
1005   TGeoMedium *alSDD         = GetMedium("ITSal");
1006
1007   AliITSv11GeomCableFlat cableHV[fgkLay4Ndet];  // temp !!!
1008   char cableHVname[30];
1009   for (Int_t iSegment = 0; iSegment<nDetectors; iSegment++) {
1010     sprintf(cableHVname,"ITSsddHVcable%i", iSegment);
1011     cableHV[iSegment].SetName(cableHVname);
1012     cableHV[iSegment].SetThickness(fgkLongHVcablePolyThick+fgkLongHVcableAlThick);
1013     cableHV[iSegment].SetWidth(fgkTransitHVtailWidth);
1014     cableHV[iSegment].SetNLayers(2);
1015     cableHV[iSegment].SetLayer(0, fgkLongHVcablePolyThick, polyhamideSDD,
1016                                fColorPolyhamide);
1017     cableHV[iSegment].SetLayer(1, fgkLongHVcableAlThick, alSDD, fColorAl);
1018     cableHV[iSegment].SetInitialNode(virtualLadder);
1019   };
1020   Double_t x1[3], x2[3], x3[3],
1021            vY[3] = {0,1,0}, vZ[3] = {0,0,1}, vYZ[3]={0,1,1};
1022
1023   x1[0] = -fgkTransitHVtailXpos;
1024   x2[0] = -fgkTransitHVtailXpos;
1025   x3[0] = -fgkTransitHVtailXpos;
1026   for (Int_t iSegment  = nDetectors/2-1; iSegment >= 0; iSegment-- ) {
1027     Double_t cableSeparation = TMath::Abs(iSegment - (nDetectors/2-1))
1028                                *fgkLongHVcableSeparation;
1029     x1[1] = - ladderBoxDH/2;
1030     x2[1] = - ladderBoxDH/2 + underSegDH - cableSeparation
1031             - (fgkLongHVcablePolyThick+fgkLongHVcableAlThick)/2;
1032     x3[1] = x2[1];
1033     x1[2] = sensorZPos[iSegment]+fgkTransitHVtailLength-5*fgkmm;
1034     x2[2] =  x1[2]+5*fgkmm;
1035     x3[2] = ladderLength/2-endLength;
1036     cableHV[iSegment].AddCheckPoint( virtualLadder, 0, x1, vY );
1037     cableHV[iSegment].AddCheckPoint( virtualLadder, 1, x2, vYZ );
1038     cableHV[iSegment].AddCheckPoint( virtualLadder, 2, x3, vZ );
1039
1040     cableHV[iSegment].CreateAndInsertCableSegment(1,0);
1041     cableHV[iSegment].CreateAndInsertCableSegment(2,0);
1042   };
1043
1044   vYZ[2] = -1;
1045   x1[0] = fgkTransitHVtailXpos;
1046   x2[0] = fgkTransitHVtailXpos;
1047   x3[0] = fgkTransitHVtailXpos;
1048
1049   for (Int_t iSegment = nDetectors/2; iSegment < nDetectors; iSegment++ ) { 
1050     Double_t cableSeparation = TMath::Abs(iSegment - (nDetectors/2-1))
1051                                *fgkLongHVcableSeparation;
1052     x1[1] = - ladderBoxDH/2;
1053     x2[1] = - ladderBoxDH/2 + underSegDH - cableSeparation
1054             - (fgkLongHVcablePolyThick+fgkLongHVcableAlThick)/2;
1055     x3[1] = x2[1];
1056     x1[2] = sensorZPos[iSegment]-fgkTransitHVtailLength+5*fgkmm;
1057     x2[2] =  x1[2]-5*fgkmm;
1058     x3[2] = -ladderLength/2+endLength;
1059     cableHV[iSegment].AddCheckPoint( virtualLadder, 0, x1, vY );
1060     cableHV[iSegment].AddCheckPoint( virtualLadder, 1, x2, vYZ );
1061     cableHV[iSegment].AddCheckPoint( virtualLadder, 2, x3, vZ );
1062
1063     cableHV[iSegment].CreateAndInsertCableSegment(1,0);
1064     cableHV[iSegment].CreateAndInsertCableSegment(2,0);
1065   };
1066   };
1067
1068   //**********************************
1069   if(GetDebug(1)) virtualLadder->CheckOverlaps(0.01);
1070   virtualLadder->SetVisibility(kFALSE);
1071   return virtualLadder;
1072 }
1073
1074
1075 //________________________________________________________________________
1076 TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(Double_t dz, Double_t angle,
1077                          Double_t xSign, Double_t L, Double_t H, Double_t l) {
1078     // Create one half of the V shape corner of CF ladder
1079   
1080     TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
1081     cfLaddSide->SetVertex( 0, 0,  0);
1082     cfLaddSide->SetVertex( 1, 0, -H);
1083     cfLaddSide->SetVertex( 2, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
1084                            -L*TMath::Cos(angle)-l*TMath::Sin(angle));
1085     cfLaddSide->SetVertex( 3, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
1086     cfLaddSide->SetVertex( 4, 0,  0);
1087     cfLaddSide->SetVertex( 5, 0, -H);
1088     cfLaddSide->SetVertex( 6, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
1089                            -L*TMath::Cos(angle)-l*TMath::Sin(angle));
1090     cfLaddSide->SetVertex(7, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
1091     return cfLaddSide;
1092 }
1093
1094
1095 //________________________________________________________________________
1096 TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
1097   //
1098   // return a box containing the front-end hybrid
1099   //
1100
1101   Double_t roundHoleX       = -fgkHybridWidth/2+fgkHybRndHoleX;
1102
1103   Double_t screenTotalThick = fgkHybGlueScrnThick+fgkHybUpThick+fgkHybAlThick;
1104   Double_t lowFLTotalThick  = fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick;
1105 //   Double_t upFLTotalThick   = fgkHybGlueUpThick +fgkHybUpThick+fgkHybAlThick;
1106   Double_t chipsCCTotThick  = fgkHybUnderNiThick+fgkHybGlueAgThick
1107                               +fgkHybChipThick+2*(fgkHybUpCCThick+fgkHybAlCCThick);
1108   Double_t ccUpLayerTotThick = fgkHybUpCCThick+fgkHybAlCCThick+fgkHybUpCCThick;
1109 //   Double_t volumeThick = (fgkHybridThBridgeThick+screenTotalThick+lowFLTotalThick
1110 //                        + upFLTotalThick + ccUpLayerTotThick);
1111   Double_t volumeThick = (fgkHybridThBridgeThick+screenTotalThick+lowFLTotalThick
1112                           +fgkHybSMDheight);
1113   Double_t lowLayerYmin     = -volumeThick/2+fgkHybridThBridgeThick
1114                               +screenTotalThick;
1115   Double_t flUpThick        = fgkHybGlueUpThick+fgkHybUpThick;
1116
1117   //**************************************************** media :
1118   TGeoMedium *airSDD                  = GetMedium("ITSair");
1119   TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
1120   TGeoMedium *alSDD                   = GetMedium("ITSal");
1121   TGeoMedium *alSDD80p100             = GetMedium("ITSal");                 // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1122   TGeoMedium *alSDD50p100             = GetMedium("ITSal");                 // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1123   TGeoMedium *polyhamideSDD           = GetMedium("ITSsddKAPTON_POLYCH2");
1124   TGeoMedium *niSDD                   = GetMedium("COPPER");                // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1125   TGeoMedium *glueAG                  = GetMedium("ITSsddKAPTON_POLYCH2");  // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1126   TGeoMedium *siliconSDD              = GetMedium("ITSsddSiChip");
1127   TGeoMedium *medSMD                  = GetMedium("SDDX7Rcapacitors");      //     TO CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1128   TGeoMedium *medSMDweld              = GetMedium("SDDX7Rcapacitors");      //    TO CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1129
1130   //**************************************************** main volume :
1131   TGeoBBox *hybridBox = new TGeoBBox("",fgkHybridWidth/2, volumeThick/2,
1132                                      (fgkHybridLength)/2);
1133   TGeoVolume *hybrid = new TGeoVolume("ITSsddHybridVol", hybridBox,
1134                                       airSDD);
1135  
1136   TGeoBBox *sThermalBridge = new TGeoBBox( "", fgkHybridWidth/2,
1137                                            fgkHybridThBridgeThick/2,
1138                                            fgkHybridLength/2);
1139
1140   //**************************************************** Thermal bridge :
1141   TGeoVolume *vThermalBridge = new TGeoVolume("ITSsddHybridThBridge",
1142                                               sThermalBridge,
1143                                               carbonFiberLadderStruct);
1144   vThermalBridge->SetLineColor(fColorCarbonFiber);
1145   TGeoTranslation *thBridgeTr = new TGeoTranslation(0, -volumeThick/2
1146                                     +fgkHybridThBridgeThick/2, 0);
1147   hybrid->AddNode(vThermalBridge, 1, thBridgeTr);
1148
1149   //**************************************************** Screen layer :
1150   TGeoBBox *sAlScreenLayer = new TGeoBBox("sAlScreenLayer", fgkHybridWidth/2,
1151                                           fgkHybAlThick/2, fgkHybridLength/2);
1152   //here the upedex and glue layers are both assumed to be polyimide
1153   TGeoBBox *sUpGlueScreenLayer = new TGeoBBox("sUpGlueScreenLayer",
1154                                               fgkHybridWidth/2,
1155                                      (fgkHybUpThick+fgkHybGlueScrnThick)/2,
1156                                               fgkHybridLength/2);
1157   TGeoTube *sRoundHole = new TGeoTube("sRoundHole", 0, fgkHybRndHoleRad,
1158                                       (screenTotalThick+lowFLTotalThick)/2);
1159
1160   TGeoTranslation *upGlueScreenTr = new TGeoTranslation("upGlueScreenTr",0,
1161    -volumeThick/2+fgkHybridThBridgeThick+(fgkHybUpThick+fgkHybGlueScrnThick)/2,0);
1162
1163   TGeoTranslation *alScreenTr = new TGeoTranslation("AlScreenTr", 0,
1164    -volumeThick/2+fgkHybridThBridgeThick+fgkHybUpThick+fgkHybGlueScrnThick
1165    +fgkHybAlThick/2, 0);
1166
1167   TGeoTranslation hybHolePos1Tr(roundHoleX,
1168    -volumeThick/2+fgkHybridThBridgeThick+(screenTotalThick+lowFLTotalThick)/2,
1169                                 -fgkHybridLength/2+fgkHybRndHoleZ);
1170   TGeoTranslation hybHolePos2Tr(roundHoleX, 
1171    -volumeThick/2+fgkHybridThBridgeThick+(screenTotalThick+lowFLTotalThick)/2,
1172                                 fgkHybridLength/2-fgkHybRndHoleZ);
1173
1174   TGeoRotation *rotHole = new TGeoRotation("", 0, 90, 0);
1175   TGeoCombiTrans *hybHolePos1 = new TGeoCombiTrans(hybHolePos1Tr, *rotHole);
1176   hybHolePos1->SetName("hybHolePos1");
1177   TGeoCombiTrans *hybHolePos2 = new TGeoCombiTrans(hybHolePos2Tr, *rotHole);
1178   hybHolePos2->SetName("hybHolePos2");
1179
1180   upGlueScreenTr->RegisterYourself();
1181   alScreenTr->RegisterYourself();
1182   hybHolePos1->RegisterYourself();
1183   hybHolePos2->RegisterYourself();
1184   delete rotHole;
1185
1186   TGeoCompositeShape *sScreenAl = new TGeoCompositeShape(
1187                       "sAlScreenLayer:AlScreenTr-(sRoundHole:hybHolePos1"
1188                       "+sRoundHole:hybHolePos2)");
1189   TGeoVolume *vScreenAl = new TGeoVolume("vScreenAl",sScreenAl, alSDD);
1190   vScreenAl->SetLineColor(fColorAl);
1191   TGeoCompositeShape *sScreenUpGlue = new TGeoCompositeShape(
1192         "sUpGlueScreenLayer:upGlueScreenTr-(sRoundHole:hybHolePos1"
1193         "+sRoundHole:hybHolePos2)");
1194   TGeoVolume *vScreenUpGlue = new TGeoVolume("vScreenUpGlue",
1195                                              sScreenUpGlue,polyhamideSDD);
1196   vScreenUpGlue->SetLineColor(fColorPolyhamide);
1197
1198   hybrid->AddNode(vScreenUpGlue, 1, 0);
1199   hybrid->AddNode(vScreenAl, 1, 0);
1200
1201   //****************************************************  FL low layer :
1202   Double_t sideWidth1 = fgkHybFLlowChipZ1 - fgkHybFLlowHoleDZ/2;
1203   Double_t sideWidth2 = fgkHybridLength - fgkHybFLlowChipZ4 - fgkHybFLlowHoleDZ/2;
1204
1205   //here the upedex and glue layers are both assumed to be polyimide
1206   TGeoBBox *sUpGlueBar1 = new TGeoBBox("sUpGlueBar1", fgkHybridWidth/2,
1207                                       (fgkHybGlueLowThick+fgkHybUpThick)/2,
1208                                        sideWidth1/2);
1209   TGeoBBox *sAlBar1 = new TGeoBBox("sAlBar1", fgkHybridWidth/2,
1210                                   fgkHybAlThick/2, sideWidth1/2);
1211  
1212   TGeoTranslation *upGlueBarTr1 = new TGeoTranslation("upGlueBarTr1", 0,
1213                               lowLayerYmin+(fgkHybGlueLowThick+fgkHybUpThick)/2,
1214                                               -(fgkHybridLength-sideWidth1)/2);
1215   TGeoTranslation *alBarTr1 = new TGeoTranslation("alBarTr1", 0,
1216                     lowLayerYmin+fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick/2,
1217                                               -(fgkHybridLength-sideWidth1)/2);
1218   upGlueBarTr1->RegisterYourself();
1219   alBarTr1->RegisterYourself();
1220
1221   TGeoCompositeShape *sLowUpGlueBar1 = new TGeoCompositeShape(
1222                      "sUpGlueBar1:upGlueBarTr1-sRoundHole:hybHolePos1");
1223   TGeoCompositeShape *sLowAlBar1 = new TGeoCompositeShape(
1224                       "sAlBar1:alBarTr1-sRoundHole:hybHolePos1");
1225   TGeoVolume *vLowUpGlueBar1 = new TGeoVolume("vLowUpGlueBar1",
1226                                               sLowUpGlueBar1, polyhamideSDD);
1227   TGeoVolume *vLowAlBar1 = new TGeoVolume("vLowAlBar1",
1228                                           sLowAlBar1, alSDD);
1229   vLowUpGlueBar1->SetLineColor(fColorPolyhamide);
1230   vLowAlBar1->SetLineColor(fColorAl);
1231   hybrid->AddNode(vLowUpGlueBar1,1,0);
1232   hybrid->AddNode(vLowAlBar1,1,0);
1233
1234   //---
1235   //here the upedex and glue layers are both assumed to be polyimide
1236   TGeoBBox *sUpGlueBar2 = new TGeoBBox("sUpGlueBar2", fgkHybridWidth/2,
1237                                        (fgkHybGlueLowThick+fgkHybUpThick)/2,
1238                                        sideWidth2/2);
1239   TGeoBBox *sAlBar2 = new TGeoBBox("sAlBar2", fgkHybridWidth/2,
1240                                    fgkHybAlThick/2, sideWidth2/2);
1241
1242  TGeoTranslation *upGlueBarTr2 = new TGeoTranslation("upGlueBarTr2", 0,
1243                               lowLayerYmin+(fgkHybGlueLowThick+fgkHybUpThick)/2,
1244                                                (fgkHybridLength-sideWidth2)/2);
1245   TGeoTranslation *alBarTr2 = new TGeoTranslation("alBarTr2", 0,
1246                     lowLayerYmin+fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick/2,
1247                                                (fgkHybridLength-sideWidth2)/2);
1248   upGlueBarTr2->RegisterYourself();
1249   alBarTr2->RegisterYourself();
1250
1251   TGeoCompositeShape *sLowUpGlueBar2 = new TGeoCompositeShape(
1252                      "sUpGlueBar2:upGlueBarTr2-sRoundHole:hybHolePos2");
1253   TGeoCompositeShape *sLowAlBar2 = new TGeoCompositeShape(
1254                       "sAlBar2:alBarTr2-sRoundHole:hybHolePos2");
1255   TGeoVolume *vLowUpGlueBar2 = new TGeoVolume("vLowUpGlueBar2",sLowUpGlueBar2,
1256                                               polyhamideSDD);
1257   TGeoVolume *vLowAlBar2 = new TGeoVolume("vLowAlBar2",sLowAlBar2,
1258                                           alSDD);
1259   vLowUpGlueBar2->SetLineColor(fColorPolyhamide);
1260   vLowAlBar2->SetLineColor(fColorAl);
1261   hybrid->AddNode(vLowUpGlueBar2, 1, 0);
1262   hybrid->AddNode(vLowAlBar2, 1, 0);
1263
1264   if(GetDebug(3)){ // Remove compiler warning.
1265     sAlScreenLayer->InspectShape();
1266     sUpGlueScreenLayer->InspectShape();
1267     sRoundHole->InspectShape();
1268     sUpGlueBar1->InspectShape();
1269     sUpGlueBar2->InspectShape();
1270     sAlBar1->InspectShape();
1271     sAlBar2->InspectShape();
1272   };
1273   //---
1274   //using class AliITSv11GeomCableFlat to add 2-layer segments ... 
1275   Double_t piece1width = fgkHybFLlowPasX-fgkHybFLlowHolePasDX/2;
1276   AliITSv11GeomCableFlat lowFLpiece("lowFLpiece1",piece1width,
1277                                        lowFLTotalThick);
1278   lowFLpiece.SetNLayers(2);
1279   lowFLpiece.SetLayer(0, fgkHybGlueLowThick+fgkHybUpThick, polyhamideSDD,
1280                        fColorPolyhamide);
1281   lowFLpiece.SetLayer(1, fgkHybAlThick, alSDD80p100, fColorAl);
1282   // alSDD at 80% : mostly to take into account strips of piece 3
1283
1284   Double_t x1[3] = { -fgkHybridWidth/2 + piece1width/2,
1285                      lowLayerYmin + lowFLTotalThick/2,
1286                      -fgkHybridLength/2 + sideWidth1 };
1287   Double_t x2[3] ={ x1[0], x1[1], fgkHybridLength/2 - sideWidth2 };
1288   Double_t vZ[3] = {0,0,1};
1289   lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
1290   lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
1291   lowFLpiece.SetInitialNode(hybrid);
1292   lowFLpiece.CreateAndInsertCableSegment(1);
1293   lowFLpiece.ResetPoints();
1294
1295   Double_t piece2width = fgkHybFLlowAmbX-fgkHybFLlowPasX
1296                          -fgkHybFLlowHolePasDX/2-fgkHybFLlowHoleAmbDX/2;
1297
1298   lowFLpiece.SetWidth(piece2width);
1299   lowFLpiece.SetName("lowFLpiece2");
1300   x1[0] = piece2width/2+fgkHybFLlowPasX+fgkHybFLlowHolePasDX/2-fgkHybridWidth/2;
1301   x2[0] = x1[0];
1302   lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
1303   lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
1304   lowFLpiece.CreateAndInsertCableSegment(1);
1305   lowFLpiece.ResetPoints();
1306
1307   Double_t piece3width = fgkHybridWidth - fgkHybFLlowAmbX 
1308                          - fgkHybFLlowHoleAmbDX/2;
1309
1310   lowFLpiece.SetWidth(piece3width);
1311   lowFLpiece.SetName("lowFLpiece3");
1312   x1[0] = fgkHybridWidth/2-piece3width/2;
1313   x2[0] = x1[0];
1314   lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
1315   lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
1316   lowFLpiece.CreateAndInsertCableSegment(1);
1317
1318   Double_t zChips[4] = {fgkHybFLlowChipZ1,fgkHybFLlowChipZ2,
1319                         fgkHybFLlowChipZ3,fgkHybFLlowChipZ4};
1320   Double_t vX[3] = {1,0,0};
1321   for (Int_t i=0; i<3; i++) {
1322     char ch[20];
1323     sprintf(ch, "lowFLpieceA%i", i+4);
1324     lowFLpiece.SetName(ch);
1325     lowFLpiece.SetWidth(zChips[i+1]-zChips[i]-fgkHybFLlowHoleDZ);
1326
1327     lowFLpiece.SetLayer(1, fgkHybAlThick, alSDD, fColorAl);
1328     x1[0] = -fgkHybridWidth/2 + piece1width;
1329     x2[0] = x1[0] + fgkHybFLlowHolePasDX;
1330     Double_t zPiece = (zChips[i+1]+zChips[i])/2 - fgkHybridLength/2;
1331     x1[2] = zPiece; x2[2] = zPiece; 
1332     lowFLpiece.AddCheckPoint( hybrid, 0, x2, vX );
1333     lowFLpiece.AddCheckPoint( hybrid, 1, x1, vX );
1334     lowFLpiece.CreateAndInsertCableSegment(1,90);
1335     lowFLpiece.ResetPoints();
1336
1337     sprintf(ch, "lowFLpieceB%i", i+4);
1338     lowFLpiece.SetName(ch);
1339     x1[0] = fgkHybridWidth/2 - piece3width;
1340     x2[0] = x1[0] - fgkHybFLlowHoleAmbDX;
1341     lowFLpiece.AddCheckPoint( hybrid, 0, x1, vX );
1342     lowFLpiece.AddCheckPoint( hybrid, 1, x2, vX );
1343     lowFLpiece.CreateAndInsertCableSegment(1,90);
1344   };
1345   
1346   //**************************************************** chips+CC:
1347   AliITSv11GeomCableFlat chip("", fgkHybChipsDZ, chipsCCTotThick);
1348   chip.SetInitialNode(hybrid);
1349   chip.SetNLayers(5);
1350   chip.SetLayer(0, fgkHybUnderNiThick, niSDD, 2);
1351   chip.SetLayer(1, fgkHybGlueAgThick, glueAG, 4);
1352   chip.SetLayer(2, fgkHybChipThick, siliconSDD, fColorSilicon);
1353   chip.SetLayer(3, fgkHybUpCCThick+fgkHybUpCCThick, polyhamideSDD,
1354                 fColorPolyhamide);
1355   chip.SetLayer(4, fgkHybAlCCThick+fgkHybAlCCThick, alSDD80p100, fColorAl);
1356   // Here the tho CC (low+up) are merged
1357   // In fact, the last layer has a smaller surface of Al -> I put 80%
1358   
1359   x1[1] = lowLayerYmin + chipsCCTotThick/2;
1360   x2[1] = x1[1];
1361   char ch[20];
1362
1363   for (Int_t i=0; i<4; i++) {
1364     sprintf(ch, "pascalCC%i", i);
1365     chip.SetName(ch);
1366     x1[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
1367     x2[0] = x1[0] + fgkHybPascalDX;
1368     x1[2] =  zChips[i] - fgkHybridLength/2;
1369     x2[2] = x1[2];
1370     chip.AddCheckPoint( hybrid, 0, x1, vX );
1371     chip.AddCheckPoint( hybrid, 1, x2, vX );
1372     chip.CreateAndInsertCableSegment(1,-90);
1373     chip.ResetPoints();
1374
1375     sprintf(ch, "ambraCC%i", i);
1376     chip.SetName(ch);
1377     x1[0] = fgkHybFLlowAmbX - fgkHybridWidth/2 - fgkHybAmbraDX/2;
1378     x2[0] = x1[0] + fgkHybAmbraDX;
1379     chip.AddCheckPoint( hybrid, 0, x1, vX );
1380     chip.AddCheckPoint( hybrid, 1, x2, vX );
1381     chip.CreateAndInsertCableSegment(1,-90);
1382     chip.ResetPoints();
1383   };
1384
1385   //**************************************************** CC outside chips:
1386   // je crois qu'il n'y a pas de 2ieme couche d'alu ici ... 
1387   for (Int_t i = 0; i<4; i++) {
1388     char ch[20];
1389     sprintf(ch, "ccLayerA%i", i);
1390
1391     AliITSv11GeomCableFlat ccLayer1(ch, 6.6*fgkmm, ccUpLayerTotThick);
1392     ccLayer1.SetInitialNode(hybrid);
1393     ccLayer1.SetNLayers(2);
1394     ccLayer1.SetLayer(0, 2*fgkHybUpCCThick, polyhamideSDD, fColorPolyhamide);
1395     ccLayer1.SetLayer(1, fgkHybAlCCThick, alSDD50p100, fColorAl);
1396     // Al at ~50%
1397
1398     x1[0] = -fgkHybridWidth/2;
1399     x2[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
1400     x1[1] = lowLayerYmin + fgkHybUnderNiThick + fgkHybGlueAgThick
1401             + fgkHybChipThick + ccUpLayerTotThick/2;
1402     x2[1] = x1[1];
1403     x1[2] = zChips[i] - fgkHybridLength/2;
1404     x2[2] = x1[2];
1405     ccLayer1.AddCheckPoint( hybrid, 0, x1, vX );
1406     ccLayer1.AddCheckPoint( hybrid, 1, x2, vX );
1407     ccLayer1.CreateAndInsertCableSegment(1,-90);
1408
1409     sprintf(ch, "ccLayerB%i", i);
1410     AliITSv11GeomCableFlat ccLayer2(ch, fgkHybChipsDZ, ccUpLayerTotThick);
1411     ccLayer2.SetInitialNode(hybrid);
1412     ccLayer2.SetNLayers(2);
1413     ccLayer2.SetLayer(0, 2*fgkHybUpCCThick, polyhamideSDD, fColorPolyhamide);
1414     ccLayer2.SetLayer(1, fgkHybAlCCThick, alSDD50p100, fColorAl);
1415      // Al at ~50%
1416
1417     x1[0] = -fgkHybridWidth/2 + fgkHybFLlowPasX + fgkHybPascalDX/2;
1418     x2[0] = -fgkHybridWidth/2 + fgkHybFLlowAmbX - fgkHybAmbraDX/2;
1419     ccLayer2.AddCheckPoint( hybrid, 0, x1, vX );
1420     ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
1421     ccLayer2.CreateAndInsertCableSegment(1,-90);
1422     ccLayer2.ResetPoints();
1423     sprintf(ch, "ccLayerC%i", i);
1424     ccLayer2.SetName(ch);
1425     x1[0] =  -fgkHybridWidth/2 + fgkHybFLlowAmbX + fgkHybAmbraDX/2;
1426     x2[0] = fgkHybridWidth/2 - fgkHybFLUpperWidth + 3*fgkmm;
1427     x1[1] = lowLayerYmin + lowFLTotalThick + flUpThick + fgkHybAlThick
1428              + ccUpLayerTotThick/2;
1429     x2[1] = x1[1];
1430
1431     ccLayer2.AddCheckPoint( hybrid, 0, x1, vX );
1432     ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
1433     ccLayer2.CreateAndInsertCableSegment(1,-90);
1434   };
1435
1436   //**************************************************** FL UP:
1437   // (last Al layer will be a special triangular shape)
1438   TGeoBBox *sFLupPolyhamide = new TGeoBBox("sFLupPolyhamide",
1439                               fgkHybFLUpperWidth/2, flUpThick/2,
1440                               fgkHybFLUpperLength/2);
1441   TGeoVolume *vFLupPolyhamide = new TGeoVolume("vFLupPolyhamide",
1442                                     sFLupPolyhamide, polyhamideSDD);
1443   vFLupPolyhamide->SetLineColor(fColorPolyhamide);
1444   TGeoTranslation *trFLupPolyhamide = 
1445     new TGeoTranslation(fgkHybridWidth/2-fgkHybFLUpperWidth/2,
1446                         lowLayerYmin+lowFLTotalThick+flUpThick/2,0);
1447
1448   hybrid->AddNode(vFLupPolyhamide, 1, trFLupPolyhamide);
1449
1450   TGeoArb8 *aluStrip = new TGeoArb8(fgkHybAlThick/2);
1451   aluStrip->SetVertex( 0,-fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
1452   aluStrip->SetVertex( 1, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
1453   aluStrip->SetVertex( 2, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth-fgkHybFLUpperAldx);
1454   aluStrip->SetVertex( 3,-fgkHybFLUpperAlDZ/2, 0);
1455   aluStrip->SetVertex( 4,-fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
1456   aluStrip->SetVertex( 5, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
1457   aluStrip->SetVertex( 6, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth-fgkHybFLUpperAldx);
1458   aluStrip->SetVertex( 7,-fgkHybFLUpperAlDZ/2, 0);
1459   TGeoVolume *vAluStrip = new TGeoVolume("vAluStrip",aluStrip, alSDD50p100);
1460   // Al at ~50%
1461
1462   vAluStrip->SetLineColor(fColorAl);
1463   //TGeoRotation rotAluStrip("rotAluStrip",0, -90, 90);
1464   TGeoRotation *rotAluStrip = new TGeoRotation("rotAluStrip",0, -90, 90);
1465
1466   Double_t yRotAluStrip = lowLayerYmin+lowFLTotalThick
1467                           +flUpThick+fgkHybAlThick/2;
1468   TGeoCombiTrans *aluStripTr1 = new TGeoCombiTrans(
1469                                     fgkHybridWidth/2,yRotAluStrip,
1470                     fgkHybridLength/2-fgkHybFLlowChipZ1+1*fgkmm, rotAluStrip);
1471   TGeoCombiTrans *aluStripTr2 = new TGeoCombiTrans(*aluStripTr1);
1472   AddTranslationToCombiTrans(aluStripTr2,0,0,
1473                              fgkHybFLlowChipZ1-fgkHybFLlowChipZ2);
1474   TGeoCombiTrans *aluStripTr3 = new TGeoCombiTrans(*aluStripTr2);
1475   AddTranslationToCombiTrans(aluStripTr3,0,0,
1476                              fgkHybFLlowChipZ2-fgkHybFLlowChipZ3);
1477   TGeoCombiTrans *aluStripTr4 = new TGeoCombiTrans(*aluStripTr3);
1478   AddTranslationToCombiTrans(aluStripTr4,0,0,
1479                              fgkHybFLlowChipZ3-fgkHybFLlowChipZ4);
1480
1481   hybrid->AddNode(vAluStrip, 1, aluStripTr1); 
1482   hybrid->AddNode(vAluStrip, 2, aluStripTr2); 
1483   hybrid->AddNode(vAluStrip, 3, aluStripTr3); 
1484   hybrid->AddNode(vAluStrip, 4, aluStripTr4); 
1485   //**************************************************** SMD:
1486   TGeoBBox *hybSMD = new TGeoBBox("ITSsddSMDshape",
1487                                   fgkHybSMDmiddleL/2+fgkHybSMDendL,
1488                                   fgkHybSMDheight/2,fgkHybSMDendW/2);
1489   TGeoVolume *vHybSMD = new TGeoVolume("ITSsddSMD",hybSMD,airSDD);
1490
1491   TGeoBBox *hybSMDmiddle = new TGeoBBox("ITSsddSMDmiddleShape",
1492                                fgkHybSMDmiddleL/2,fgkHybSMDheight/2,
1493                                         fgkHybSMDmiddleW/2);
1494   TGeoVolume *vHybSMDmiddle = new TGeoVolume("ITSsddSMDmiddle",
1495                                             hybSMDmiddle,medSMD);
1496   vHybSMDmiddle->SetLineColor(fColorSMD);
1497   TGeoBBox *hybSMDend = new TGeoBBox("ITSsddSMDendShape",
1498                             fgkHybSMDendL/2,fgkHybSMDheight/2,fgkHybSMDendW/2);
1499   TGeoVolume *vHybSMDend = new TGeoVolume("ITSsddSMDend",
1500                                           hybSMDend,medSMDweld);
1501   vHybSMDend->SetLineColor(fColorSMDweld);
1502   TGeoTranslation *vHybSMDendTr1 = new TGeoTranslation("",
1503                                        (fgkHybSMDmiddleL+fgkHybSMDendL)/2,0,0);
1504   TGeoTranslation *vHybSMDendTr2 = new TGeoTranslation("",
1505                                        -(fgkHybSMDmiddleL+fgkHybSMDendL)/2,0,0);
1506   vHybSMD->AddNode(vHybSMDmiddle,1,0);
1507   vHybSMD->AddNode(vHybSMDend,1,vHybSMDendTr1);
1508   vHybSMD->AddNode(vHybSMDend,2,vHybSMDendTr2);
1509   for (Int_t i=0; i<fgkNHybSMD; i++) {
1510     TGeoTranslation *vHybSMDtr = new TGeoTranslation("",
1511                                  -fgkHybridWidth/2+fgkHybSMDposX[i],
1512                                  lowLayerYmin+lowFLTotalThick+fgkHybSMDheight/2,
1513                                  -fgkHybridLength/2+fgkHybSMDposZ[i]);
1514     hybrid->AddNode(vHybSMD, i+1, vHybSMDtr);
1515   };
1516
1517
1518   if (iLRSide == 0) {
1519   };
1520
1521   if(GetDebug(1)) hybrid->CheckOverlaps(0.01);
1522   hybrid->SetVisibility(kFALSE);
1523   return hybrid;
1524 }
1525
1526
1527 //________________________________________________________________________
1528 TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
1529   //
1530   // Return a box volume containing a segment of a ladder.
1531   //
1532
1533   TGeoMedium *airSDD          = GetMedium("ITSair");
1534   TGeoMedium *phynoxSDD       = GetMedium("ITSal"); // phynoxSDD To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1535   TGeoMedium *coolerMediumSDD = GetMedium("WATER");
1536
1537   Double_t tDY = fgkLadderSegBoxDH/2; //space left on top of the ladder 
1538   Double_t segmentLength = fgkSegmentLength;
1539   Double_t spaceBetweenCables = 500*fgkmicron;
1540   
1541   //*****************************************
1542   // Set parameters according to (iLay,iSeg):
1543   //*****************************************
1544   Int_t nDetectors          = fgkLay3Ndet;
1545   Double_t coolPipeSuppH    = fgkLay3CoolPipeSuppH;
1546   Double_t sensorCenterZPos = fLay3sensorZPos[iSeg]-
1547                               (fgkSegmentLength*fgkLay3Ndet/2. - 
1548                                fgkSegmentLength/2-(iSeg)*fgkSegmentLength);
1549  // sensorCenterZPos = z in segment local coord syst.
1550
1551   AliITSv11GeomCableFlat *digitCableA = fDigitCableLay3A;
1552   AliITSv11GeomCableFlat *digitCableB = fDigitCableLay3B;
1553
1554   if (iLay==3) {
1555   } else if (iLay==4) {
1556     nDetectors = fgkLay4Ndet;
1557     coolPipeSuppH = fgkLay4CoolPipeSuppH;
1558     sensorCenterZPos = fLay4sensorZPos[iSeg]-
1559                        (fgkSegmentLength*fgkLay4Ndet/2. -
1560                         fgkSegmentLength/2-(iSeg)*fgkSegmentLength);
1561     digitCableA = fDigitCableLay4A;
1562     digitCableB = fDigitCableLay4B;     
1563   } else
1564     printf("AliITSv11GeometrySDD::CreateLadderSegment Wrong layer index !");
1565
1566  
1567   Double_t cableSideSign = -1;
1568   if (iSeg<nDetectors/2) cableSideSign = 1;
1569   Double_t spaceForCables = spaceBetweenCables*
1570            (nDetectors-TMath::Abs(nDetectors-2*iSeg-1)-1)/2
1571            +0.1*fgkmicron;
1572   // gives [0-1-2-2-1-0]*spaceBetweenCables
1573   // or  [0-1-2-3-3-2-1-0]*spaceBetweenCables
1574   Int_t iUpdateCableMin;
1575   Int_t iUpdateCableMax;
1576   if (cableSideSign==-1) {
1577     iUpdateCableMin = nDetectors/2;
1578     iUpdateCableMax = iSeg-1;
1579   } else {
1580     iUpdateCableMin = iSeg+1;
1581     iUpdateCableMax = nDetectors/2-1;
1582   };
1583
1584   if(GetDebug(1)){
1585     cout << "Segment ("<< iLay <<',' << iSeg 
1586          << ") : sensor z shift in local segment coord.=" 
1587          << sensorCenterZPos << endl;
1588   };
1589
1590   //****************************
1591   // The segment volume
1592   //****************************
1593   TGeoBBox *segBox = new TGeoBBox("ITSsddSegBox",
1594                                   fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW,
1595                                   fgkLadderHeight/2+fgkLadderSegBoxDH/2,
1596                                   segmentLength/2);
1597   
1598   TGeoVolume *virtualSeg = new TGeoVolume("ITSsddSegment",
1599                                           segBox, airSDD);
1600
1601   //******************************
1602   // Carbon fiber structure :
1603   //******************************
1604
1605    virtualSeg->AddNode(fLaddSegCommonVol[0], 1, fLaddSegCommonTr[0]);
1606   Int_t volumeIndex = 1;
1607   for (Int_t i = 1; i<fgkNladdSegCommonVol;i++ ) {
1608     if (fLaddSegCommonVol[i]==fLaddSegCommonVol[i-1])
1609       volumeIndex++;
1610     else
1611       volumeIndex = 1;
1612     virtualSeg->AddNode(fLaddSegCommonVol[i], volumeIndex,
1613                  fLaddSegCommonTr[i]);
1614   };
1615
1616   //**********************************
1617   // Pine support of the sensors :
1618   //**********************************
1619   TGeoRotation *rotPS1 = new TGeoRotation("",0,-90,90);
1620   TGeoRotation *rotPS2 = new TGeoRotation("",0,-90,-90);
1621
1622   TGeoCombiTrans *transPS1 = new TGeoCombiTrans( fgkPinDYOnSensor,
1623                                 - fgkLadderHeight/2.-tDY
1624                                 + fgkPinSuppHeight/2.,
1625                                 sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
1626   TGeoCombiTrans *transPS2 = new TGeoCombiTrans(*transPS1);
1627   AddTranslationToCombiTrans(transPS2, 0, 0, fgkPinPinDDXOnSensor);
1628   TGeoCombiTrans *transPS3 = new TGeoCombiTrans(*transPS1);
1629   AddTranslationToCombiTrans(transPS3, 0, 0, -2*fgkPinDXminOnSensor);
1630   TGeoCombiTrans *transPS4 = new TGeoCombiTrans(*transPS3);
1631   AddTranslationToCombiTrans(transPS4, 0, 0, -fgkPinPinDDXOnSensor);
1632
1633   TGeoCombiTrans *transPS5 = new TGeoCombiTrans( -fgkPinDYOnSensor,
1634                                  - fgkLadderHeight/2. - tDY
1635                                  + fgkPinSuppHeight/2.,
1636                                  sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
1637   TGeoCombiTrans *transPS6 = new TGeoCombiTrans(*transPS5);
1638   AddTranslationToCombiTrans(transPS6, 0, 0, fgkPinPinDDXOnSensor);
1639   TGeoCombiTrans *transPS7 = new TGeoCombiTrans(*transPS5);
1640   AddTranslationToCombiTrans(transPS7, 0, 0, -2*fgkPinDXminOnSensor);
1641   TGeoCombiTrans *transPS8 = new TGeoCombiTrans(*transPS7);
1642   AddTranslationToCombiTrans(transPS8, 0, 0, -fgkPinPinDDXOnSensor);
1643   
1644   virtualSeg->AddNode(fPinSupport, 1, transPS1);
1645   virtualSeg->AddNode(fPinSupport, 2, transPS2);
1646   virtualSeg->AddNode(fPinSupport, 3, transPS3);
1647   virtualSeg->AddNode(fPinSupport, 4, transPS4);
1648   virtualSeg->AddNode(fPinSupport, 5, transPS5);
1649   virtualSeg->AddNode(fPinSupport, 6, transPS6);
1650   virtualSeg->AddNode(fPinSupport, 7, transPS7);
1651   virtualSeg->AddNode(fPinSupport, 8, transPS8);
1652   
1653   //******************************
1654   // Cooling pipe supports :
1655   //******************************
1656   Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
1657   Double_t halfTheta = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
1658   Double_t triangleCPaxeDist = fgkCoolPipeSuppAxeDist-fgkCoolPipeSuppWidthExt-
1659                                fgkCoolPipeSuppWidthIn+fgkLadderBeamRadius;
1660   
1661   Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
1662                            (triangleHeight+triangleCPaxeDist/
1663                             TMath::Sin(halfTheta)-coolPipeSuppH);
1664   if (fAddCoolingSyst) {
1665   TGeoRotation *rotCPS2 = new TGeoRotation("", -halfTheta*TMath::RadToDeg(), -90,  90);
1666   TGeoRotation *rotCPS1 = new TGeoRotation("",  halfTheta*TMath::RadToDeg(), -90, -90);
1667   TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
1668                                   -fgkLadderHeight/2. - tDY
1669                                   +coolPipeSuppH+fgkLadderBeamRadius,
1670                                   -segmentLength/2., rotCPS1);
1671   TGeoCombiTrans *transCPS3 = new TGeoCombiTrans(*transCPS1);
1672   AddTranslationToCombiTrans(transCPS3, 0, 0, segmentLength);
1673   
1674   TGeoCombiTrans *transCPS2 = new TGeoCombiTrans(-coolPipeSuppL,
1675                                   -fgkLadderHeight/2.- tDY
1676                                   +coolPipeSuppH+fgkLadderBeamRadius,
1677                                   segmentLength/2., rotCPS2);
1678   TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(*transCPS2);
1679   AddTranslationToCombiTrans(transCPS4, 0, 0, -segmentLength);
1680   
1681   virtualSeg->AddNode(fCoolPipeSupportL, 1, transCPS1);
1682   virtualSeg->AddNode(fCoolPipeSupportL, 2, transCPS2);
1683   virtualSeg->AddNode(fCoolPipeSupportR, 1, transCPS3);
1684   virtualSeg->AddNode(fCoolPipeSupportR, 2, transCPS4);
1685   };
1686   
1687   //************************
1688   // Cooling pipes :
1689   //************************
1690   TGeoTranslation *pipeTr1 = new TGeoTranslation(coolPipeSuppL,
1691                                  -fgkLadderHeight/2. - tDY +
1692                                  fgkLadderBeamRadius+coolPipeSuppH, 0);
1693   TGeoTranslation *pipeTr2 = new TGeoTranslation(-coolPipeSuppL,
1694                                  -fgkLadderHeight/2.- tDY +
1695                                   fgkLadderBeamRadius+coolPipeSuppH, 0);
1696
1697   if (fAddCoolingSyst) {
1698   TGeoTube *coolingPipeShape = new TGeoTube( fgkCoolPipeInnerDiam/2,
1699                                              fgkCoolPipeOuterDiam/2,
1700                                              segmentLength/2);
1701   TGeoTube *coolerShape = new TGeoTube( 0, fgkCoolPipeInnerDiam/2,
1702                                         segmentLength/2);
1703   
1704   TGeoVolume *coolingPipe = new TGeoVolume("ITSsddCoolingPipe",
1705                                            coolingPipeShape, phynoxSDD );
1706   coolingPipe->SetLineColor(fColorPhynox);
1707   TGeoVolume *cooler = new  TGeoVolume("ITSsddCoolingLiquid",coolerShape,
1708                                        coolerMediumSDD );
1709
1710
1711   virtualSeg->AddNode(coolingPipe, 1, pipeTr1);
1712   virtualSeg->AddNode(coolingPipe, 2, pipeTr2);
1713   if (fCoolingOn) {
1714     virtualSeg->AddNode(cooler, 1, pipeTr1);
1715     virtualSeg->AddNode(cooler, 2, pipeTr2);
1716   };
1717   };
1718
1719   //**********************************
1720   // Bases of hybrid thermal bridges
1721   //**********************************
1722   Double_t shiftHyb = 1.05; // shift between thermal Bridge base and thermal bridge
1723                            // approx !!! not clear on 0752/14-A
1724   if (fAddCoolingSyst) {
1725   TGeoRotation *rotHybrid1 = new TGeoRotation("", 0,   0, -90 - fgkHybridAngle);
1726   TGeoRotation *rotHybrid2 = new TGeoRotation("", 0 ,180,  90 - fgkHybridAngle);
1727   TGeoCombiTrans *baseTr1 = new TGeoCombiTrans(*pipeTr2, *rotHybrid1);
1728   TGeoCombiTrans *baseTr2 = new TGeoCombiTrans(*pipeTr1, *rotHybrid2);
1729   
1730   virtualSeg->AddNode(fBaseThermalBridge, 1, baseTr1);
1731   virtualSeg->AddNode(fBaseThermalBridge, 2, baseTr2);
1732   };
1733
1734   //*************************
1735   // the 2 hybrids :
1736   //*************************
1737   Double_t hybDy = ((TGeoBBox*)fHybrid->GetShape())->GetDY();
1738   Double_t distAxeToHybridCenter = fgkBTBaxisAtoBase+hybDy;
1739   
1740   Double_t hybrVolX = ( distAxeToHybridCenter*CosD(fgkHybridAngle) 
1741                          - shiftHyb*SinD(fgkHybridAngle) );
1742   Double_t hybrVolY = ( distAxeToHybridCenter*SinD(fgkHybridAngle)
1743                          + shiftHyb*CosD(fgkHybridAngle) );
1744   if (fAddHybrids) {
1745     TGeoRotation rotHybrid3("", 0,   0,  90. - fgkHybridAngle);
1746     TGeoRotation rotHybrid4("", 0 ,180, -90. - fgkHybridAngle);
1747     TGeoCombiTrans *hybTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid3);
1748     TGeoCombiTrans *hybTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid4);
1749     AddTranslationToCombiTrans( hybTr1, -hybrVolX, hybrVolY, 0);
1750     AddTranslationToCombiTrans( hybTr2,  hybrVolX, hybrVolY, 0);
1751     
1752     virtualSeg->AddNode(fHybrid, 1, hybTr1);
1753     virtualSeg->AddNode(fHybrid, 2, hybTr2);
1754   };
1755
1756   //***********
1757   // cables
1758   //***********
1759   if (fAddCables) {
1760   // Starting from this segment
1761   Double_t hybDz = ((TGeoBBox*)fHybrid->GetShape())->GetDZ();
1762   Double_t hybDx = ((TGeoBBox*)fHybrid->GetShape())->GetDX();
1763   Double_t posDigitCableAlongHyb = shiftHyb+ hybDx 
1764                                    - digitCableA->GetWidth()/2;
1765   Double_t distAxeToDigitCableCenter = distAxeToHybridCenter+hybDy
1766                                        - digitCableA->GetThickness()/2;
1767
1768   Double_t digitCableX = ( coolPipeSuppL
1769                            + distAxeToDigitCableCenter*CosD(fgkHybridAngle)
1770                            - posDigitCableAlongHyb*SinD(fgkHybridAngle) );
1771   Double_t digitCableY = ( - fgkLadderHeight/2.-TMath::Abs(tDY)
1772                            + fgkLadderBeamRadius+coolPipeSuppH
1773                            + distAxeToDigitCableCenter*SinD(fgkHybridAngle)
1774                            + posDigitCableAlongHyb*CosD(fgkHybridAngle) );
1775
1776
1777   Double_t digitCableCenterA0[3]={ -cableSideSign*digitCableX,
1778                                    digitCableY, cableSideSign*hybDz };
1779   Double_t digitCableCenterA1[3] = { 
1780            -cableSideSign*(digitCableX+spaceForCables*CosD(fgkHybridAngle)),
1781            digitCableY+spaceForCables*SinD(fgkHybridAngle),
1782            cableSideSign*segmentLength/2 };
1783
1784   Double_t digitCableCenterB0[3]={ cableSideSign*digitCableX,
1785                                    digitCableY,cableSideSign*hybDz};
1786   Double_t digitCableCenterB1[3]={ 
1787            cableSideSign*(digitCableX+spaceForCables*CosD(fgkHybridAngle)),
1788            digitCableY+spaceForCables*SinD(fgkHybridAngle),
1789            cableSideSign*segmentLength/2 };
1790
1791   Double_t vZ[3] = {0,0,1};
1792   digitCableA[iSeg].AddCheckPoint( virtualSeg, 0, digitCableCenterA0, vZ);
1793   digitCableA[iSeg].AddCheckPoint( virtualSeg, 1, digitCableCenterA1, vZ);
1794   digitCableB[iSeg].AddCheckPoint( virtualSeg, 0, digitCableCenterB0, vZ);
1795   digitCableB[iSeg].AddCheckPoint( virtualSeg, 1, digitCableCenterB1, vZ);
1796
1797   // Updating the other cables
1798   for (Int_t iCable=iUpdateCableMin; iCable<=iUpdateCableMax; iCable++) {
1799
1800     Int_t iPoint = TMath::Abs(iCable-iSeg)+1;
1801     Double_t coord[3];
1802     digitCableA[iCable].GetPoint( 1, coord);
1803     digitCableA[iCable].AddCheckPoint( virtualSeg, iPoint, coord, vZ);
1804     digitCableB[iCable].GetPoint( 1, coord);
1805     digitCableB[iCable].AddCheckPoint( virtualSeg, iPoint, coord, vZ);
1806   };
1807   };
1808
1809   //**********************************
1810   if(GetDebug(1)) virtualSeg->CheckOverlaps(0.01);
1811   virtualSeg->SetVisibility(kFALSE);
1812   return virtualSeg;
1813 }
1814
1815
1816 //________________________________________________________________________
1817 TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
1818 //
1819 // Create a pine support
1820 // axis of rotation is the cone axis, center in its middle
1821 //
1822     TGeoCone *cone = new TGeoCone("ITSsddPinSuppCone",fgkPinSuppHeight/2.,
1823                                   0,fgkPinSuppRmax,0,fgkPinSuppRmax-
1824                                   fgkPinSuppHeight*TanD(fgkPinSuppConeAngle) );
1825     TGeoBBox *tong = new TGeoBBox("ITSsddPinSuppTong",fgkPinSuppRmax,
1826                                   fgkPinSuppLength/2.,fgkPinSuppThickness/2.);
1827     TGeoTube *hole = new TGeoTube("ITSsddPinSuppHole",0,fgkPinR,
1828                                   fgkPinSuppHeight/2.);
1829     if(GetDebug(3)){// Remove compiler warning.
1830         cone->InspectShape();
1831         tong->InspectShape();
1832         hole->InspectShape();
1833     };
1834
1835     TGeoTranslation *tongTrans = new TGeoTranslation("ITSsddPinSuppTongTr",0,
1836                    fgkPinSuppLength/2.,-fgkPinSuppHeight/2.+fgkPinSuppThickness/2.);
1837     tongTrans->RegisterYourself();
1838     TGeoCompositeShape *pinSupportShape = new TGeoCompositeShape(
1839                "ITSsddPinSupportShape","(ITSsddPinSuppCone+"
1840                "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
1841
1842     
1843     TGeoMedium *rytonSDD = GetMedium("ITSsddCarbonM55J"); //medium = ryton ?  To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1844     TGeoVolume *pinSupport = new TGeoVolume("ITSsddPinSupport",pinSupportShape,
1845                                             rytonSDD);
1846     pinSupport->SetLineColor(fColorRyton);
1847     return pinSupport;
1848     // include the pin itself                           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1849 }
1850
1851
1852 //________________________________________________________________________
1853 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportL() {
1854 //
1855 // Create half of the cooling pipe support (ALR-0752/3)
1856 //
1857
1858   Double_t diffX = fgkCoolPipeSuppHeight*TanD(fgkCoolPipeSuppAngle);
1859   
1860   TGeoArb8 *side1 = new TGeoArb8(fgkCoolPipeSuppHeight/2.);
1861   side1->SetVertex( 0, 0, -fgkCoolPipeSuppWidthExt/2.);
1862   side1->SetVertex( 1, fgkCoolPipeSuppMaxLength/2.-diffX,
1863                        -fgkCoolPipeSuppWidthExt/2.);
1864   side1->SetVertex( 2, fgkCoolPipeSuppMaxLength/2.-diffX,
1865                        fgkCoolPipeSuppWidthExt/2.);
1866   side1->SetVertex( 3, 0,  fgkCoolPipeSuppWidthExt/2.);
1867   side1->SetVertex( 4, 0, -fgkCoolPipeSuppWidthExt/2.);
1868   side1->SetVertex( 5, fgkCoolPipeSuppMaxLength/2.,
1869                        -fgkCoolPipeSuppWidthExt/2.);
1870   side1->SetVertex( 6, fgkCoolPipeSuppMaxLength/2.,
1871                        fgkCoolPipeSuppWidthExt/2.);
1872   side1->SetVertex( 7, 0,  fgkCoolPipeSuppWidthExt/2.);
1873   side1->SetName("ITSsddCPSside1");
1874
1875   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1",0,
1876                                  - fgkCoolPipeSuppAxeDist
1877                                  + fgkCoolPipeSuppWidthExt/2., 0);
1878   side1Tr->RegisterYourself();
1879   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2",0,
1880                                  - fgkCoolPipeSuppAxeDist
1881                                  + fgkCoolPipeSuppWidthExt*3/2.
1882                                  + fgkCoolPipeSuppWidthIn,0);
1883   side2Tr->RegisterYourself();
1884   
1885   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddle",
1886                          (fgkCoolPipeSuppMaxLength/2.-fgkCoolPipeSuppSlitL)/2.,
1887                          fgkCoolPipeSuppWidthIn/2., fgkCoolPipeSuppHeight/2.);
1888   TGeoTranslation *middleTr = 
1889     new TGeoTranslation("ITSsddCPStr3",
1890                         (fgkCoolPipeSuppMaxLength/2.-fgkCoolPipeSuppSlitL)/2.,
1891                         -fgkCoolPipeSuppAxeDist+fgkCoolPipeSuppWidthExt
1892                         +fgkCoolPipeSuppWidthIn/2., 0);
1893   middleTr->RegisterYourself();
1894   
1895   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBox",
1896                                   fgkCoolPipeSuppTongW/4.,
1897                                   (fgkCoolPipeSuppFulWidth
1898                                    - 2*fgkCoolPipeSuppWidthExt
1899                                    - fgkCoolPipeSuppWidthIn)/2,
1900                                   fgkCoolPipeSuppHeight/2.);
1901   
1902   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTr",
1903                                   fgkCoolPipeSuppTongW/4.,
1904                                   - fgkCoolPipeSuppAxeDist
1905                                   + fgkCoolPipeSuppFulWidth
1906                                   - axeBox->GetDY(), 0);
1907   axeBoxTr->RegisterYourself();
1908
1909   TGeoTube *axe = new TGeoTube("ITSsddCPSaxe",0,fgkCoolPipeSuppHoleDiam/2.,
1910                                fgkCoolPipeSuppTongW/4.);
1911
1912   TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRot",90,90,0);
1913   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTr",
1914                                  fgkCoolPipeSuppTongW/4.,0,0,axeRot);
1915   axeTrans->RegisterYourself();
1916   //delete axeRot; // make the code crash, no idea of why !!!
1917
1918   if(GetDebug(3)){
1919     middle->InspectShape();
1920     axe->InspectShape();
1921   };
1922
1923   TGeoMedium *rytonSDD = GetMedium("ITSsddCarbonM55J"); //medium = ryton ?  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1924   
1925   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
1926                                         "ITSsddCoolPipeSuppShapeL",
1927                                         "ITSsddCPSmiddle:ITSsddCPStr3"
1928                                         "+ITSsddCPSside1:ITSsddCPStr1"
1929                                         "+ITSsddCPSside1:ITSsddCPStr2"
1930                                         "+ITSsddCPSaxeBox:ITSsddCPSAxBoxTr"
1931                                         "-ITSsddCPSaxe:ITSsddCPSaxeTr");
1932   TGeoVolume *coolPipeSupp = new  TGeoVolume("ITSsddCoolPipeSupportL",
1933                                              coolPipeSuppShape, rytonSDD);
1934
1935   coolPipeSupp->SetLineColor(fColorRyton);
1936
1937   return coolPipeSupp;
1938 }
1939
1940
1941 //________________________________________________________________________
1942 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportR() {
1943 //
1944 //Create half of the cooling pipe support (ALR-0752/3)
1945 //
1946
1947   Double_t diffX = fgkCoolPipeSuppHeight*TanD(fgkCoolPipeSuppAngle);
1948   
1949   TGeoArb8 *side1 = new TGeoArb8(fgkCoolPipeSuppHeight/2.);
1950   side1->SetVertex( 0, 0, -fgkCoolPipeSuppWidthExt/2.);
1951   side1->SetVertex( 1, -(fgkCoolPipeSuppMaxLength/2.-diffX),
1952                        -fgkCoolPipeSuppWidthExt/2.);
1953   side1->SetVertex( 2, -(fgkCoolPipeSuppMaxLength/2.-diffX),
1954                        fgkCoolPipeSuppWidthExt/2.);
1955   side1->SetVertex( 3, 0,  fgkCoolPipeSuppWidthExt/2.);
1956   side1->SetVertex( 4, 0, -fgkCoolPipeSuppWidthExt/2.);
1957   side1->SetVertex( 5, -fgkCoolPipeSuppMaxLength/2.,
1958                        -fgkCoolPipeSuppWidthExt/2.);
1959   side1->SetVertex( 6, -fgkCoolPipeSuppMaxLength/2.,
1960                        fgkCoolPipeSuppWidthExt/2.);
1961   side1->SetVertex( 7, 0,  fgkCoolPipeSuppWidthExt/2.);
1962   side1->SetName("ITSsddCPSside1R");
1963
1964   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1R",0,
1965                                  - fgkCoolPipeSuppAxeDist
1966                                  + fgkCoolPipeSuppWidthExt/2., 0);
1967   side1Tr->RegisterYourself();
1968   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2R",0,
1969                                  - fgkCoolPipeSuppAxeDist
1970                                  + fgkCoolPipeSuppWidthExt*3/2.
1971                                  + fgkCoolPipeSuppWidthIn, 0);
1972   side2Tr->RegisterYourself();
1973   
1974   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddleR",
1975                                   (fgkCoolPipeSuppMaxLength/2.
1976                                    - fgkCoolPipeSuppSlitL)/2.,
1977                                   fgkCoolPipeSuppWidthIn/2., 
1978                                   fgkCoolPipeSuppHeight/2.);
1979   TGeoTranslation *middleTr = 
1980     new TGeoTranslation("ITSsddCPStr3R",
1981                         -( fgkCoolPipeSuppMaxLength/2.
1982                            -fgkCoolPipeSuppSlitL)/2.,
1983                         -fgkCoolPipeSuppAxeDist + fgkCoolPipeSuppWidthExt
1984                         + fgkCoolPipeSuppWidthIn/2.,0);
1985   middleTr->RegisterYourself();
1986   
1987   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBoxR",
1988                                   fgkCoolPipeSuppTongW/4.,
1989                                   (fgkCoolPipeSuppFulWidth
1990                                    - 2*fgkCoolPipeSuppWidthExt
1991                                    - fgkCoolPipeSuppWidthIn)/2,
1992                                   fgkCoolPipeSuppHeight/2.);
1993   
1994   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTrR",
1995                                   - fgkCoolPipeSuppTongW/4.,
1996                                   - fgkCoolPipeSuppAxeDist
1997                                   + fgkCoolPipeSuppFulWidth
1998                                   - axeBox->GetDY(),0);
1999   axeBoxTr->RegisterYourself();
2000
2001   TGeoTube *axe = new TGeoTube("ITSsddCPSaxeR",0,fgkCoolPipeSuppHoleDiam/2.,
2002                                fgkCoolPipeSuppTongW/4.);
2003
2004   TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRotR",90,90,0);
2005   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTrR",
2006                                                 -fgkCoolPipeSuppTongW/4.,0,0,axeRot);
2007   axeTrans->RegisterYourself();
2008   //delete axeRot;
2009
2010   if(GetDebug(3)){
2011     middle->InspectShape();
2012     axe->InspectShape();
2013   };
2014   
2015   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
2016                                       "ITSsddCoolPipeSuppShapeR",
2017                                       "ITSsddCPSmiddleR:ITSsddCPStr3R"
2018                                       "+ITSsddCPSside1R:ITSsddCPStr1R"
2019                                       "+ITSsddCPSside1R:ITSsddCPStr2R"
2020                                       "+ITSsddCPSaxeBoxR:ITSsddCPSAxBoxTrR"
2021                                       "-ITSsddCPSaxeR:ITSsddCPSaxeTrR");
2022   
2023   TGeoMedium *rytonSDD = GetMedium("ITSsddCarbonM55J"); //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2024   TGeoVolume *coolPipeSupp = new TGeoVolume( "ITSsddCoolPipeSupportR",
2025                                              coolPipeSuppShape, rytonSDD);
2026   coolPipeSupp->SetLineColor(fColorRyton);
2027
2028   return coolPipeSupp;
2029 }
2030
2031 //________________________________________________________________________
2032 TGeoVolume* AliITSv11GeometrySDD::CreateBaseThermalBridge() {
2033 // ALR 0752/8
2034
2035   Double_t dy = fgkBTBaxisAtoBase - fgkRadiusBminBTB - fgkBTBthick;
2036
2037   Double_t base1width = fgkBTBwidth - fgkBTBaxisAtoBottom - fgkRadiusBminBTB
2038                         - (fgkRadiusAminBTB+fgkBTBthick);
2039   TGeoBBox *base1 = new TGeoBBox( "ITSsddBTBbase1", base1width/2.,
2040                                   fgkBTBthick/2., fgkBTBlength/2.);
2041   TGeoTranslation *base1Tr = new TGeoTranslation("ITSsddBTBtr1",
2042                                  fgkBTBaxisAtoBottom-fgkBTBwidth+base1width/2.,
2043                                  -(fgkBTBaxisAtoBase-fgkBTBthick/2.), 0);
2044   base1Tr->RegisterYourself();
2045
2046   Double_t base2width = fgkBTBaxisAtoBottom - fgkRadiusAminBTB - fgkBTBthick
2047                         - fgkRadiusBminBTB;
2048   TGeoBBox *base2 = new TGeoBBox( "ITSsddBTBbase2", base2width/2.,
2049                                   fgkBTBthick/2., fgkBTBlength/2.);
2050   TGeoTranslation *base2Tr = new TGeoTranslation("ITSsddBTBtr2",
2051                                  fgkBTBaxisAtoBottom - base2width/2.,
2052                                  -(fgkBTBaxisAtoBase-fgkBTBthick/2.), 0);
2053   base2Tr->RegisterYourself();
2054
2055   TGeoBBox *side = new TGeoBBox( "ITSsddBTBside",
2056                                  fgkBTBthick/2., dy/2., fgkBTBlength/2.);
2057   TGeoTranslation *sideTr1 = new TGeoTranslation("ITSsddBTBsideTr1",
2058                                  -fgkRadiusAminBTB-fgkBTBthick/2., -dy/2., 0);
2059   TGeoTranslation *sideTr2 = new TGeoTranslation("ITSsddBTBsideTr2",
2060                                  fgkRadiusAminBTB+fgkBTBthick/2., -dy/2., 0);
2061   sideTr1->RegisterYourself();
2062   sideTr2->RegisterYourself();
2063
2064   TGeoBBox *hole = new TGeoBBox( "ITSsddBTBhole", fgkBTBHolewidth/2.,
2065                                  fgkBTBthick/2., fgkBTBHoleLength/2.);
2066   TGeoTranslation *holeTr1 = new TGeoTranslation("ITSsddBTBholeTr1",
2067                                  - fgkBTBHoleRefX + fgkBTBHolewidth/2.,
2068                                  - (fgkBTBaxisAtoBase-fgkBTBthick/2.),
2069                                  fgkBTBHoleRefY+(fgkBTBHoleLength-fgkBTBlength)/2.);
2070   TGeoTranslation *holeTr2 = new TGeoTranslation("ITSsddBTBholeTr2",
2071                                  - fgkBTBHoleRefX + fgkBTBHolewidth/2.,
2072                                  - (fgkBTBaxisAtoBase-fgkBTBthick/2.),
2073                                  - fgkBTBHoleRefY-(fgkBTBHoleLength-fgkBTBlength)/2.);
2074   holeTr1->RegisterYourself();
2075   holeTr2->RegisterYourself();
2076
2077   Double_t radiusAmaxBTB = fgkRadiusAminBTB + fgkBTBthick;
2078   TGeoTubeSeg *mainAxis = new TGeoTubeSeg( "ITSsddBTBmainAxis",
2079                                            fgkRadiusAminBTB, radiusAmaxBTB,
2080                                            fgkBTBlength/2., 0., 180.);
2081   TGeoTubeSeg *round1 = new TGeoTubeSeg( "ITSsddBTBround1",
2082                            fgkRadiusBminBTB, fgkRadiusBminBTB+fgkBTBthick,
2083                            fgkBTBlength/2., 270., 360.);
2084   TGeoTranslation *roundTr1 = new TGeoTranslation("ITSsddBTBround1Tr",
2085                                   -(fgkRadiusAminBTB+fgkBTBthick+fgkRadiusBminBTB),
2086                                   -dy, 0);
2087   roundTr1->RegisterYourself();
2088
2089   TGeoTubeSeg *round2 = new TGeoTubeSeg( "ITSsddBTBround2",
2090                            fgkRadiusBminBTB, fgkRadiusBminBTB+fgkBTBthick,
2091                            fgkBTBlength/2., 180., 270.);
2092   TGeoTranslation *roundTr2 = new TGeoTranslation("ITSsddBTBround2Tr",
2093                                   (fgkRadiusAminBTB+fgkBTBthick+fgkRadiusBminBTB),
2094                                   -dy, 0);
2095   roundTr2->RegisterYourself();
2096
2097   TGeoCompositeShape *sBaseThermalBridge = new TGeoCompositeShape(
2098                                       "ITSsddBaseThermalBridgeShape",
2099                                       "ITSsddBTBbase1:ITSsddBTBtr1"
2100                                       "+ ITSsddBTBbase2:ITSsddBTBtr2"
2101                                       "+ ITSsddBTBround1:ITSsddBTBround1Tr"
2102                                       "+ ITSsddBTBround2:ITSsddBTBround2Tr"
2103                                       "+ ITSsddBTBside:ITSsddBTBsideTr1"
2104                                       "+ ITSsddBTBside:ITSsddBTBsideTr2"
2105                                       "- ITSsddBTBhole:ITSsddBTBholeTr1"
2106                                       "- ITSsddBTBhole:ITSsddBTBholeTr2"
2107                                       "+ ITSsddBTBmainAxis");
2108
2109     if(GetDebug(3)){// Remove compiler warning.
2110         base1->InspectShape();
2111         base2->InspectShape();
2112         side->InspectShape();
2113         hole->InspectShape();
2114         mainAxis->InspectShape();
2115         round1->InspectShape();
2116         round2->InspectShape();
2117     };
2118
2119   TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
2120   TGeoVolume *vBaseThermalBridge = new TGeoVolume( "ITSsddBaseThermalBridge",
2121                                                    sBaseThermalBridge,
2122                                                    carbonFiberLadderStruct);
2123
2124   vBaseThermalBridge->SetLineColor(fColorCarbonFiber);
2125   return vBaseThermalBridge;
2126 }
2127
2128
2129 //________________________________________________________________________
2130 TGeoVolume* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay) {
2131   //
2132   // Return a box volume containing a end of a CF ladder.
2133   //
2134
2135   TGeoMedium *airSDD                  = GetMedium("ITSair");
2136   TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
2137
2138   Double_t length        = (fgkLay3LadderLength-fgkLay3Ndet*fgkSegmentLength)/2.;
2139   Double_t coolPipeSuppH = fgkLay3CoolPipeSuppH;
2140   Double_t underSegDH    = fLay3LadderUnderSegDH;
2141   if (iLay==3) {
2142   } else if (iLay==4) {
2143     length        = (fgkLay4LadderLength-fgkLay4Ndet*fgkSegmentLength)/2.;
2144     coolPipeSuppH = fgkLay4CoolPipeSuppH;
2145     underSegDH    = fLay4LadderUnderSegDH;
2146   } else {
2147     printf("error in AliITSv11GeometrySDD::CreateEndLadder: Wrong layer");
2148     return 0;
2149   };
2150     
2151   Double_t tDY = (- fgkLadderSegBoxDH/2       //space left on top of the ladder
2152                   + underSegDH/2);          //space under ladder segment
2153         // here tDY is not the same as for the segment because the end ladder
2154         // does not have a space under it, inside the general ladder volume.
2155   Double_t segmentLength   = fgkSegmentLength;
2156   Double_t topCornerLength = fgkSegmentLength/2.-fgkLay4LaddTopCornerEnd;
2157
2158   TGeoBBox *endBox = new TGeoBBox("ITSsddEndLaddBox",
2159                          (fgkLadderWidth)/2,
2160                          fgkLadderHeight/2+fgkLadderSegBoxDH/2+underSegDH/2,
2161                          length/2);
2162   TGeoVolume *virtualEnd = new TGeoVolume("ITSsddEnd",endBox, airSDD);
2163   
2164   //**********************************
2165   // coding real matter :
2166   //**********************************
2167   Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
2168   Double_t halfTheta   = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
2169   Double_t beta        = (TMath::Pi()-2.*halfTheta)/4.;
2170   Double_t alpha       = TMath::Pi()*3./4. - halfTheta/2.;
2171   
2172   //--- The 3 V shape corners of the Carbon Fiber Ladder
2173   //--- the top V
2174   TGeoArb8 *cfLaddTop1 = CreateLadderSide(topCornerLength/2., halfTheta, -1,
2175                                           fgkLadderLa, fgkLadderHa, fgkLadderl);
2176   TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
2177                                   cfLaddTop1,carbonFiberLadderStruct);
2178   cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
2179   TGeoArb8 *cfLaddTop2 = CreateLadderSide( topCornerLength/2., halfTheta, 1,
2180                                            fgkLadderLa, fgkLadderHa, fgkLadderl);
2181   TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
2182                                   cfLaddTop2,carbonFiberLadderStruct);
2183   cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
2184   TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2+tDY,
2185                                                 -(length-topCornerLength)/2.);
2186   virtualEnd->AddNode(cfLaddTopVol1, 1, trTop1);
2187   virtualEnd->AddNode(cfLaddTopVol2, 1, trTop1);
2188
2189   //--- the 2 side V
2190   TGeoArb8 *cfLaddSide1 = CreateLadderSide( length/2., beta, -1,
2191                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
2192   TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
2193                                    cfLaddSide1,carbonFiberLadderStruct);
2194   cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
2195   TGeoArb8 *cfLaddSide2 = CreateLadderSide( length/2., beta, 1,
2196                                             fgkLadderLb, fgkLadderHb, fgkLadderl);
2197   TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
2198                                    cfLaddSide2,carbonFiberLadderStruct);
2199   cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
2200   Double_t dYTranslation = ( fgkLadderHeight/2. - 0.5*fgkLadderWidth*
2201                              TMath::Tan(beta) - fgkLadderBeamRadius );
2202   
2203   // because center of the triangle doesn't correspond to virtual vol. center
2204   Double_t distCenterSideDown =  0.5*fgkLadderWidth/TMath::Cos(beta);
2205   TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
2206                                              alpha*TMath::RadToDeg());
2207   AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+tDY, 0);
2208   TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown, 0, 
2209                                              -alpha*TMath::RadToDeg());
2210   AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+tDY, 0);
2211   virtualEnd->AddNode(cfLaddSideVol1, 1, ctSideR);
2212   virtualEnd->AddNode(cfLaddSideVol2, 1, ctSideR);
2213   virtualEnd->AddNode(cfLaddSideVol1, 2, ctSideL);
2214   virtualEnd->AddNode(cfLaddSideVol2, 2, ctSideL);
2215   
2216   //--- The beams
2217   // Beams on the sides
2218   Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
2219                   TMath::Sin(2*beta)/(TanD(fgkBeamSidePhi)*TanD(fgkBeamSidePhi))) ));
2220
2221   //Euler rotation : about Z, then new X, then new Z
2222   TGeoRotation *beamRot1 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
2223                         -beamPhiPrime*TMath::RadToDeg(), -90);
2224   TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
2225                         beamPhiPrime*TMath::RadToDeg(), -90);
2226   TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
2227                         beamPhiPrime*TMath::RadToDeg(), -90);
2228   TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
2229                         -beamPhiPrime*TMath::RadToDeg(), -90);
2230   TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
2231                                                    TMath::Tan(halfTheta),
2232                                               fgkLadderBeamRadius/2. + tDY,
2233                                  -length/2 + segmentLength/8, beamRot1);
2234   TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans( 0.5*triangleHeight*
2235                                                     TMath::Tan(halfTheta),
2236                                                  fgkLadderBeamRadius/2.+tDY,
2237                                 -length/2 + 3*segmentLength/8, beamRot2);
2238   TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
2239                                                    TMath::Tan(halfTheta),
2240                                                 fgkLadderBeamRadius/2.+tDY,
2241                                  -length/2 + segmentLength/8, beamRot3);
2242   TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
2243                                                    TMath::Tan(halfTheta),
2244                                               fgkLadderBeamRadius/2. + tDY,
2245                                  -length/2+3*segmentLength/8, beamRot4);
2246
2247   virtualEnd->AddNode(fLaddSegCommonVol[6], 1, beamTransf1);
2248   virtualEnd->AddNode(fLaddSegCommonVol[6], 2, beamTransf3);
2249   virtualEnd->AddNode(fLaddSegCommonVol[6], 3, beamTransf5);
2250   virtualEnd->AddNode(fLaddSegCommonVol[6], 4, beamTransf7);
2251
2252   //--- Beams of the bottom
2253   TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
2254                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 180);
2255   TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
2256                                    bottomBeam1, carbonFiberLadderStruct);
2257   bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
2258
2259   TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
2260   TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
2261                             -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY,
2262                             -length/2+fgkSegmentLength/2, bottomBeamRot1);
2263   virtualEnd->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
2264   TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
2265                                  fgkLadderWidth/2.-fgkLadderLb/3, 0, 90);
2266   TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
2267                                    bottomBeam2, carbonFiberLadderStruct);
2268   bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
2269   TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
2270      -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY,-length/2,bottomBeamRot1);
2271   virtualEnd->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
2272
2273   //**********************************
2274   //the cooling pipe supports
2275   Double_t triangleCPaxeDist = fgkCoolPipeSuppAxeDist-fgkCoolPipeSuppWidthExt-
2276                                fgkCoolPipeSuppWidthIn+fgkLadderBeamRadius;
2277
2278   Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
2279                            (triangleHeight+triangleCPaxeDist/
2280                             TMath::Sin(halfTheta)-coolPipeSuppH);
2281   
2282   if (fAddCoolingSyst) {
2283   TGeoRotation *rotCPS2 = new TGeoRotation("",-halfTheta*TMath::RadToDeg(),-90, 90);
2284   TGeoRotation *rotCPS1 = new TGeoRotation("", halfTheta*TMath::RadToDeg(),-90,-90);
2285   TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
2286                                   -fgkLadderHeight/2.+ tDY +
2287                                   coolPipeSuppH+fgkLadderBeamRadius,
2288                                   -length/2., rotCPS1);
2289   TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
2290                                   -fgkLadderHeight/2.+ tDY +
2291                                   coolPipeSuppH+fgkLadderBeamRadius,
2292                                   -length/2., rotCPS2);
2293
2294   virtualEnd->AddNode(fCoolPipeSupportL, 1, transCPS1);
2295   virtualEnd->AddNode(fCoolPipeSupportR, 1, transCPS4);
2296   };
2297
2298   //**********************************
2299   if(GetDebug(1)) virtualEnd->CheckOverlaps(0.01);
2300   virtualEnd->SetVisibility(kFALSE);
2301   return virtualEnd;
2302 }
2303
2304
2305 //________________________________________________________________________
2306 TGeoVolume* AliITSv11GeometrySDD::CreateSDDsensor() {
2307   //
2308   // return a box containing the SDD sensor
2309   //
2310
2311   TGeoMedium *airSDD        = GetMedium("ITSair");
2312   TGeoMedium *siliconSDD    = GetMedium("ITSsddSi");
2313   TGeoMedium *alSDD         = GetMedium("ITSal");
2314   TGeoMedium *polyhamideSDD = GetMedium("ITSsddKAPTON_POLYCH2");
2315   TGeoMedium *glassSDD      = GetMedium("ITSsddSi");       //  To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2316
2317
2318   Double_t rWraping = fgkWaferThickness/2+fgkWaHVcableAlThick+fgkWaHVcablePolyThick;
2319   Double_t witdhCableBox = (fgkWaHVcableWitdh - TMath::Pi()*rWraping)/2;
2320
2321   Double_t sensoxBoxLength = ( fgkWaferLength +
2322                                2*(rWraping+witdhCableBox-fgkWaHVcableDW) );
2323   // Makes life easier to include the space for the WA HV cable on both sides 
2324   Double_t sensoxBoxThick = fgkWaferThickness +
2325                             2*(fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
2326
2327   TGeoBBox *box = new TGeoBBox("ITSsddSensorBox",
2328                       fgkWaferWidth/2, sensoxBoxThick/2, sensoxBoxLength/2);
2329   TGeoVolume *virtualSensor = new TGeoVolume("ITSsddSensor",box,airSDD);
2330
2331   //****************************
2332   // silicon wafer
2333   //****************************
2334   if (fAddSensors) {
2335     TGeoBBox *waferShape = new TGeoBBox("ITSsddWaferShape",
2336                            fgkWaferWidth/2, fgkWaferThickness/2, fgkWaferLength/2);
2337     TGeoVolume *wafer = new TGeoVolume("ITSsddWafer", waferShape, siliconSDD);
2338     wafer->SetLineColor(fColorSilicon);
2339     TGeoBBox *sensBox = new TGeoBBox("ITSsddSensorSensBox",
2340                         fgkWaferWidthSens/2,fgkWaferThickSens/2,fgkWaferLengthSens/2);
2341     TGeoVolume *sensVol=new TGeoVolume(fgSDDsensitiveVolName,sensBox,siliconSDD);
2342     sensVol->SetLineColor(fColorSilicon);
2343     
2344     wafer->AddNode(sensVol, 1, 0);
2345     virtualSensor->AddNode(wafer, 1, 0);
2346   };
2347   
2348   //****************************
2349   // glass
2350   //****************************
2351   TGeoBBox *glass = new TGeoBBox("ITSsddGlassBox", fgkSensorGlassLX/2,
2352                                  fgkSensorGlassLY/2, fgkSensorGlassLZ/2);
2353   TGeoVolume *vGlass  = new  TGeoVolume("ITSsddGlass",glass, glassSDD);
2354   vGlass->SetLineColor(fColorGlass);
2355   TGeoTranslation *glassTr1 = new TGeoTranslation("",fgkGlassDXOnSensor,
2356                                   fgkWaferThickness/2+fgkSensorGlassLY/2,
2357                                   fgkGlassDZOnSensor);
2358   TGeoTranslation *glassTr2 = new TGeoTranslation("",-fgkGlassDXOnSensor,
2359                                   fgkWaferThickness/2+fgkSensorGlassLY/2,
2360                                   fgkGlassDZOnSensor);
2361   TGeoTranslation *glassTr3 = new TGeoTranslation("",fgkGlassDXOnSensor,
2362                                   fgkWaferThickness/2+fgkSensorGlassLY/2,
2363                                   -fgkGlassDZOnSensor);
2364   TGeoTranslation *glassTr4 = new TGeoTranslation("",-fgkGlassDXOnSensor,
2365                                   fgkWaferThickness/2+fgkSensorGlassLY/2,
2366                                   -fgkGlassDZOnSensor);
2367   virtualSensor->AddNode(vGlass, 1, glassTr1);
2368   virtualSensor->AddNode(vGlass, 2, glassTr2);
2369   virtualSensor->AddNode(vGlass, 3, glassTr3);
2370   virtualSensor->AddNode(vGlass, 4, glassTr4);
2371
2372   //****************************
2373   // Wrap-around cable
2374   //****************************
2375   if (fAddHVcables) {
2376   AliITSv11GeomCableFlat waHVCable("ITSsddWaHVCableU",witdhCableBox,
2377                                       fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
2378   waHVCable.SetNLayers(2);
2379   waHVCable.SetLayer(0, fgkWaHVcablePolyThick,polyhamideSDD,fColorPolyhamide);
2380   waHVCable.SetLayer(1, fgkWaHVcableAlThick, alSDD, fColorAl);
2381   waHVCable.SetInitialNode(virtualSensor);
2382
2383   Double_t x1[3], x2[3], vX[3] = {1,0,0};
2384   x1[0] = -fgkWaHVcableLength/2;
2385   x2[0] = -x1[0];
2386   x1[1] = (fgkWaferThickness + waHVCable.GetThickness())/2;
2387   x2[1] = x1[1];
2388   x1[2] = fgkWaferLength/2+waHVCable.GetWidth()/2-fgkWaHVcableDW;
2389   x2[2] = x1[2];
2390
2391   waHVCable.AddCheckPoint(virtualSensor, 0, x1, vX);
2392   waHVCable.AddCheckPoint(virtualSensor, 1, x2, vX);
2393   waHVCable.CreateAndInsertCableSegment(1,-90);
2394   x1[1] = -x1[1];
2395   x2[1] = x1[1];
2396   waHVCable.SetName("ITSsddWaHVCableD");
2397   waHVCable.ResetPoints();
2398   waHVCable.AddCheckPoint(virtualSensor, 0, x1, vX);
2399   waHVCable.AddCheckPoint(virtualSensor, 1, x2, vX);
2400   waHVCable.CreateAndInsertCableSegment(1, 90);
2401
2402   AliITSv11GeomCableRound waHVCableFold("ITSsddWaHVCableFold",
2403                                            rWraping);
2404   waHVCableFold.SetPhi(180,360);
2405   waHVCableFold.SetNLayers(2);
2406   waHVCableFold.SetLayer(0, fgkWaferThickness/2+fgkWaHVcablePolyThick,
2407                          polyhamideSDD, fColorPolyhamide);
2408   waHVCableFold.SetLayer(1, fgkWaHVcableAlThick, alSDD, fColorAl);
2409   waHVCableFold.SetInitialNode(virtualSensor);
2410   x1[1] = 0;
2411   x2[1] = 0;
2412   x1[2] = fgkWaferLength/2-fgkWaHVcableDW+witdhCableBox;
2413   x2[2] = x1[2];
2414   waHVCableFold.AddCheckPoint(virtualSensor, 0, x1, vX);
2415   waHVCableFold.AddCheckPoint(virtualSensor, 1, x2, vX);
2416   waHVCableFold.CreateAndInsertCableSegment(1);
2417
2418   //****************************
2419   // transition cable
2420   //****************************
2421   Double_t headRadius = (fgkTransitHVHeadLX*fgkTransitHVHeadLX/4.+
2422                          fgkTransitHVHeadLZ*fgkTransitHVHeadLZ)
2423                         /(2.*fgkTransitHVHeadLZ);
2424   Double_t theta = TMath::ATan2(fgkTransitHVHeadLX/2,
2425                                 headRadius-fgkTransitHVHeadLZ)
2426                    *TMath::RadToDeg();
2427
2428   TGeoTubeSeg *headPoly = new TGeoTubeSeg(0,headRadius,
2429                                           fgkTransitHVPolyThick/2,
2430                                           90-theta,90+theta);
2431   headPoly->SetName("headPoly");
2432   TGeoTranslation *headPolyTr = new TGeoTranslation(0,0,
2433                                     -fgkTransitHVPolyThick/2);
2434   headPolyTr->SetName("headPolyTr");
2435   headPolyTr->RegisterYourself();
2436
2437   TGeoTubeSeg *headAl = new TGeoTubeSeg(0,headRadius,
2438                                         fgkTransitHVAlThick/2,
2439                                         90-theta,90+theta);
2440   headAl->SetName("headAl");
2441   TGeoTranslation *headAlTr = new TGeoTranslation(0,0,
2442                                   -fgkTransitHVPolyThick
2443                                   -fgkTransitHVAlThick/2);
2444   headAlTr->SetName("headAlTr");
2445   headAlTr->RegisterYourself();
2446
2447   TGeoBBox *cache = new TGeoBBox(fgkTransitHVHeadLX/2,
2448                                  (headRadius-fgkTransitHVHeadLZ)/2,
2449                        (fgkTransitHVPolyThick+fgkTransitHVAlThick)/2);
2450   cache->SetName("cache");
2451
2452   TGeoTranslation *headCacheTr = new TGeoTranslation(0,
2453                                 (headRadius-fgkTransitHVHeadLZ)/2,
2454                                  -(fgkTransitHVPolyThick
2455                                    +fgkTransitHVAlThick)/2);
2456   headCacheTr->SetName("cacheTr");
2457   headCacheTr->RegisterYourself();
2458
2459   TGeoCompositeShape *headPolyComp = new TGeoCompositeShape(
2460                       "headPoly:headPolyTr-cache:cacheTr");
2461   TGeoVolume *vHeadPolyComp = new TGeoVolume(
2462               "ITSsddHVtransitHeadPoly",headPolyComp, polyhamideSDD);
2463   vHeadPolyComp->SetLineColor(fColorPolyhamide);
2464   TGeoCompositeShape *headAlComp = new TGeoCompositeShape(
2465                                        "headAl:headAlTr-cache:cacheTr");
2466   TGeoVolume *vHeadAlComp = new TGeoVolume(
2467               "ITSsddHVtransitHeadAl",headAlComp, alSDD);
2468   vHeadAlComp->SetLineColor(fColorAl);
2469
2470
2471 //   TGeoRotation rotHead("",0,90,0);
2472 //   TGeoCombiTrans *rotHeadTr = new TGeoCombiTrans(0,fgkWaferThickness/2,
2473 //                -headRadius+fgkTransitHVHeadLZ+fgkTransitHVBondingLZ/2,
2474 //                                               &rotHead);
2475   TGeoRotation *rotHead = new TGeoRotation("",0,90,0);
2476   TGeoCombiTrans *rotHeadTr = new TGeoCombiTrans(0,fgkWaferThickness/2,
2477                   -headRadius+fgkTransitHVHeadLZ+fgkTransitHVBondingLZ/2,
2478                                                  rotHead);
2479
2480   virtualSensor->AddNode(vHeadPolyComp,1,rotHeadTr);
2481   virtualSensor->AddNode(vHeadAlComp,1,rotHeadTr);
2482
2483   //---
2484   AliITSv11GeomCableFlat transitHVCable("ITSsddHVtransitCenter",
2485                                         fgkTransitHVBondingLZ,
2486                             fgkTransitHVPolyThick+fgkTransitHVAlThick);
2487   transitHVCable.SetNLayers(2);
2488   transitHVCable.SetLayer(0, fgkTransitHVPolyThick,polyhamideSDD,
2489                           fColorPolyhamide);
2490   transitHVCable.SetLayer(1, fgkTransitHVAlThick, alSDD, fColorAl);
2491   transitHVCable.SetInitialNode(virtualSensor);
2492
2493   x1[0] = -fgkTransitHVHeadLX/2;
2494   x2[0] = -x1[0];
2495   x1[1] = (fgkWaferThickness+fgkTransitHVPolyThick+fgkTransitHVAlThick)/2;
2496   x2[1] = x1[1];
2497   x1[2] = 0;
2498   x2[2] = 0;
2499   transitHVCable.AddCheckPoint(virtualSensor, 0, x1, vX);
2500   transitHVCable.AddCheckPoint(virtualSensor, 1, x2, vX);
2501   transitHVCable.CreateAndInsertCableSegment(1,-90);
2502   transitHVCable.ResetPoints();
2503   transitHVCable.SetName("ITSsddHVtransitTail");
2504   transitHVCable.SetWidth(fgkTransitHVtailWidth);
2505   x1[0] = fgkTransitHVtailXpos;
2506   x2[0] = fgkTransitHVtailXpos;
2507   x1[2] = -fgkTransitHVBondingLZ/2;
2508   x2[2] = -fgkTransitHVBondingLZ/2-fgkTransitHVtailLength;
2509   Double_t vZ[3] = {0,0,1};
2510   transitHVCable.AddCheckPoint(virtualSensor, 0, x1, vZ);
2511   transitHVCable.AddCheckPoint(virtualSensor, 1, x2, vZ);
2512   transitHVCable.CreateAndInsertCableSegment(1,0);
2513
2514   //---
2515   TGeoArb8 *sideLeft = new TGeoArb8( fgkTransitHVPolyThick/2 );
2516   sideLeft->SetVertex(0, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
2517   sideLeft->SetVertex(1, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
2518                       fgkTransitHVsideLZ);
2519   sideLeft->SetVertex(2, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
2520   sideLeft->SetVertex(3, fgkTransitHVHeadLX/2, 0);
2521   sideLeft->SetVertex(4, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
2522   sideLeft->SetVertex(5, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
2523                       fgkTransitHVsideLZ);
2524   sideLeft->SetVertex(6, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
2525   sideLeft->SetVertex(7, fgkTransitHVHeadLX/2, 0);
2526
2527   TGeoArb8 *sideLeftAl = new TGeoArb8( fgkTransitHVAlThick/2 );
2528   sideLeftAl->SetVertex(0, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
2529   sideLeftAl->SetVertex(1, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
2530                         fgkTransitHVsideLZ);
2531   sideLeftAl->SetVertex(2, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
2532   sideLeftAl->SetVertex(3, fgkTransitHVHeadLX/2, 0);
2533   sideLeftAl->SetVertex(4, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
2534   sideLeftAl->SetVertex(5, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
2535                         fgkTransitHVsideLZ);
2536   sideLeftAl->SetVertex(6, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
2537   sideLeftAl->SetVertex(7, fgkTransitHVHeadLX/2, 0);
2538
2539   TGeoArb8 *sideRight = new TGeoArb8( fgkTransitHVPolyThick/2 );
2540   sideRight->SetVertex(0, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,0);
2541   sideRight->SetVertex(1, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,
2542                        fgkTransitHVsideLZ);
2543   sideRight->SetVertex(2, -fgkTransitHVHeadLX/2, fgkTransitHVsideRightZ);
2544   sideRight->SetVertex(3, -fgkTransitHVHeadLX/2, 0);
2545   sideRight->SetVertex(4, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,0);
2546   sideRight->SetVertex(5, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,
2547                        fgkTransitHVsideLZ);
2548   sideRight->SetVertex(6, -fgkTransitHVHeadLX/2, fgkTransitHVsideRightZ);
2549   sideRight->SetVertex(7, -fgkTransitHVHeadLX/2, 0);
2550
2551 //   TGeoRotation rotSide("",0,-90,0);
2552 //   TGeoCombiTrans *sideRightTr = new TGeoCombiTrans(0,
2553 //                              (fgkWaferThickness+fgkTransitHVPolyThick)/2,
2554 //                              -fgkTransitHVBondingLZ/2,&rotSide);
2555 //   TGeoCombiTrans *sideLeftTr = new TGeoCombiTrans(0,
2556 //                             (fgkWaferThickness+fgkTransitHVPolyThick)/2,
2557 //                             -fgkTransitHVBondingLZ/2, &rotSide);
2558 //   TGeoCombiTrans *sideLeftAlTr = new TGeoCombiTrans(0,
2559 //                fgkTransitHVPolyThick+(fgkWaferThickness+fgkTransitHVAlThick)/2,
2560 //                -fgkTransitHVBondingLZ/2, &rotSide);
2561   TGeoRotation *rotSide = new TGeoRotation("",0,-90,0);
2562   TGeoCombiTrans *sideRightTr = new TGeoCombiTrans(0,
2563                                 (fgkWaferThickness+fgkTransitHVPolyThick)/2,
2564                                 -fgkTransitHVBondingLZ/2,rotSide);
2565   TGeoCombiTrans *sideLeftTr = new TGeoCombiTrans(0,
2566                                (fgkWaferThickness+fgkTransitHVPolyThick)/2,
2567                                -fgkTransitHVBondingLZ/2, rotSide);
2568   TGeoCombiTrans *sideLeftAlTr = new TGeoCombiTrans(0,
2569                   fgkTransitHVPolyThick+(fgkWaferThickness+fgkTransitHVAlThick)/2,
2570                   -fgkTransitHVBondingLZ/2, rotSide);
2571
2572
2573   TGeoVolume *vSideLeft = new TGeoVolume("ITSsddHVtransitSideLeft",
2574                                          sideLeft,polyhamideSDD);
2575   vSideLeft->SetLineColor(fColorPolyhamide);
2576   TGeoVolume *vSideLeftAl = new TGeoVolume("ITSsddHVtransitSideLeftAl",
2577                                            sideLeftAl,alSDD);
2578   vSideLeftAl->SetLineColor(fColorAl);
2579   TGeoVolume *vSideRight = new TGeoVolume("ITSsddHVtransitSideRight",
2580                                           sideRight,polyhamideSDD);
2581   vSideRight->SetLineColor(fColorPolyhamide);
2582
2583   virtualSensor->AddNode(vSideLeft,   1, sideLeftTr);
2584   virtualSensor->AddNode(vSideLeftAl, 1, sideLeftAlTr);
2585   virtualSensor->AddNode(vSideRight,  1, sideRightTr);
2586   };
2587
2588   //****************************
2589   if(GetDebug(1)) virtualSensor->CheckOverlaps(0.01);
2590   virtualSensor->SetVisibility(kFALSE);
2591   return virtualSensor;
2592 }
2593
2594
2595 //________________________________________________________________________
2596 TGeoVolume *AliITSv11GeometrySDD::CreateDetectors(Int_t iLay) {
2597   //
2598   // return a box volume containing the detectors
2599   //
2600
2601   TGeoMedium *airSDD = GetMedium("ITSair");
2602
2603   Int_t    nDetectors   = fgkLay3Ndet;
2604   Double_t ladderLength = fgkLay3LadderLength;
2605   Double_t *sensorZPos  = fLay3sensorZPos;
2606   
2607   if (iLay==3) {}
2608   else if (iLay==4) {
2609     nDetectors   = fgkLay4Ndet;
2610     ladderLength = fgkLay4LadderLength;
2611     sensorZPos   = fLay4sensorZPos;
2612   } else {
2613     printf("AliITSv11GeometrySDD::CreateDetectors: Error : Wrong layer");
2614   };
2615
2616   char name[30];
2617   Double_t volThickness = ( fgkLadWaferSep + 2*fgkWaferThickness +
2618                             2*(fgkWaHVcableAlThick+fgkWaHVcablePolyThick));
2619   
2620   sprintf(name,"ITSsddDetBox%i",iLay);
2621   TGeoBBox *detBox = new TGeoBBox(name, fgkWaferWidth/2, volThickness/2,
2622                          ladderLength*((nDetectors-0.5)/nDetectors)/2);
2623   TGeoVolume *virtualDet = new TGeoVolume("ITSsddLadd",detBox, airSDD);
2624  
2625     for (Int_t i=0; i<nDetectors; i++) {
2626         Double_t localZ = sensorZPos[i];
2627         Double_t localY = fgkLadWaferSep/2+fgkWaferThickness/2;
2628         if (iLay==3) if (i%2!=0) localY = -localY;
2629         if (iLay==4) if (i%2==0) localY = -localY;
2630         sprintf(name, "ITSsddLay%iSensorPos%i",iLay, i);
2631
2632         if (i >= nDetectors/2) {
2633           TGeoTranslation *sensorPos = new TGeoTranslation(0,localY,localZ);
2634           sensorPos->SetName(name);
2635           virtualDet->AddNode(fSDDsensor, i, sensorPos);
2636         }
2637         else {
2638           TGeoRotation *rotSensor = new TGeoRotation("",0, 180, 180);
2639           TGeoCombiTrans *sensorPos = new TGeoCombiTrans(0,localY,
2640                                                  localZ, rotSensor);
2641           sensorPos->SetName(name);
2642           virtualDet->AddNode(fSDDsensor, i, sensorPos);
2643         };
2644     }
2645
2646     if(GetDebug(1)) virtualDet->CheckOverlaps(0.01);
2647     virtualDet->SetVisibility(kFALSE);
2648     return virtualDet;
2649 }
2650
2651
2652 //________________________________________________________________________
2653 Int_t AliITSv11GeometrySDD::ExportSensorGeometry(AliITSgeom *geom, Int_t iLaySDD,
2654                                                  Int_t startMod) {
2655   //
2656   // export the geometry in a AliITSgeom object
2657   //
2658
2659   if (! geom) {
2660     printf("error:Try to fill null (AliITSgeom *) object");
2661     return kFALSE;
2662   };
2663   if (! fMotherVol) {
2664     printf("error:Try to set sensor geometry while geometry is not defined\n");
2665     return kFALSE;
2666   };
2667
2668   const Float_t kDxyz[3] = {fgkWaferWidthSens/2., fgkWaferThickSens/2.,
2669                             fgkWaferLengthSens/2.};
2670   if(!(geom->IsShapeDefined(kSDD)))
2671     geom->ReSetShape(kSDD, new AliITSgeomSDD256(3, kDxyz));
2672
2673   char layerName[30];
2674   char ladderName[30];
2675   char sensorName[30];
2676   char senstivName[30];
2677   const Int_t kNLay = 2;
2678   const Int_t kNLadd[kNLay] = {fgkLay3Nladd, fgkLay4Nladd};
2679   const Int_t kNDet[kNLay]  = {fgkLay3Ndet,  fgkLay4Ndet};
2680
2681   if (GetDebug(1))
2682     printf("AliITSv11GeometrySDD::SetSensorGeometry(), nodes found :\n");
2683
2684   Int_t firstSDDmod = startMod;
2685   for (Int_t iLay=0; iLay<kNLay; iLay++) {
2686     /////////////////////////////////////////
2687     sprintf(layerName, "ITSsddLayer%i_1",iLay+3);
2688     TGeoNode *layNode = fMotherVol->GetNode(layerName);
2689     if (layNode) {
2690       if (GetDebug(1)) printf("%s\n",layNode->GetName());
2691       TGeoVolume *layVolume = layNode->GetVolume();
2692       TGeoHMatrix layMatrix(*layNode->GetMatrix());
2693
2694       for (Int_t iLadd=0; iLadd<kNLadd[iLay]; iLadd++) {
2695         /////////////////////////////////////////
2696         sprintf(ladderName, "ITSsddLadd_%i", iLadd);
2697         TGeoNode *laddNode = layVolume->GetNode(ladderName);
2698         if (laddNode) {
2699           if (GetDebug(1)) printf("|   %s\n",laddNode->GetName());
2700           TGeoVolume *laddVolume = laddNode->GetVolume();
2701           TGeoHMatrix laddMatrix(layMatrix);
2702           laddMatrix.Multiply(laddNode->GetMatrix());
2703
2704           for (Int_t iDet=0; iDet<kNDet[iLay]; iDet++) {
2705             /////////////////////////////////////////
2706             sprintf(sensorName, "ITSsddSensor_%i",iDet);
2707             TGeoNode *detNode = laddVolume->GetNode(sensorName);
2708             if (detNode) {
2709               if (GetDebug(1)) printf("|   |   %s\n",detNode->GetName());
2710               TGeoVolume *detVolume = detNode->GetVolume();
2711               TGeoHMatrix detMatrix(laddMatrix);
2712               detMatrix.Multiply(detNode->GetMatrix());
2713
2714               TGeoNode *wafNode = detVolume->GetNode("ITSsddWafer_1");
2715               if (wafNode) {
2716                 TGeoVolume *wafVolume = wafNode->GetVolume();
2717                 TGeoHMatrix wafMatrix(detMatrix);
2718                 detMatrix.Multiply(wafNode->GetMatrix());
2719                 //--------------------------------------------------------
2720                 sprintf(senstivName, "%s%s", fgSDDsensitiveVolName,"_1");
2721                 TGeoNode *sensitivNode = wafVolume->GetNode(senstivName);
2722               if (sensitivNode) {
2723                 TGeoHMatrix sensMatrix(wafMatrix);
2724                 sensMatrix.Multiply(sensitivNode->GetMatrix());
2725
2726                 // Sticking to the convention for local wafer coordinate
2727                 // in AliITSgeom :
2728                 if (iDet >= kNDet[iLay]/2) {
2729                   //              TGeoRotation rotY("",0,180,0);
2730                   TGeoRotation rotY("",-180,-180,0);
2731                   sensMatrix.Multiply(&rotY);
2732                 };
2733                 // Creating the matrix in AliITSgeom for
2734                 // this sensitive volume :
2735                 Double_t *trans = sensMatrix.GetTranslation();
2736                 Double_t *r     = sensMatrix.GetRotationMatrix();
2737                 Double_t rot[10] = {r[0],r[1],r[2],
2738                                     r[3],r[4],r[5],
2739                                     r[6],r[7],r[8], 1.0};
2740                 //rot[9]!=0.0 => not a unity matrix
2741                 geom->CreateMatrix(startMod,iLay+iLaySDD,iLadd+1,iDet+1,
2742                                   kSDD,trans,rot);
2743                 // iLadd+1, iDet+1 because ladd. and det. start at +1
2744                 // elsewhere
2745                 startMod++;
2746
2747               } else
2748                 printf("Error (ExportSensorGeometry) %s not found !\n",
2749                        senstivName);
2750               } else
2751                 printf("Error (ExportSensorGeometry) %s not found !\n",
2752                        "ITSsddWafer_1");
2753             } else
2754               printf("Error (ExportSensorGeometry) %s not found !\n",
2755                      sensorName);
2756           };
2757         } else 
2758           printf("Error (ExportSensorGeometry) %s not found !\n",
2759                  ladderName);
2760       };  
2761     } else
2762       printf("Error (ExportSensorGeometry) %s not found !\n",
2763              layerName);
2764   };
2765
2766   return (startMod-firstSDDmod);
2767 }
2768
2769
2770 //________________________________________________________________________
2771 Int_t AliITSv11GeometrySDD::
2772 GetCurrentLayLaddDet(Int_t &lay, Int_t &ladd, Int_t&det) const {
2773   //
2774   // Function which gives the layer, ladder and det.
2775   // index of the current volume. To be used in
2776   // AliITS::StepManager()
2777   //
2778
2779   if (gGeoManager->GetLevel()<3) return kFALSE;
2780   // Get the det index :
2781   TGeoNode *node = gGeoManager->GetMother(2);
2782   if (!node) return kFALSE;
2783   det = node->GetNumber()+1;
2784
2785   // Get the ladder index :
2786   node = gGeoManager->GetMother(3);
2787   if (!node) return kFALSE;
2788   ladd = node->GetNumber()+1;
2789
2790  // Get the layer index :
2791   if (node->GetNdaughters()==fgkLay3Ndet)
2792     lay = 3;            // this has to be equal to the iLaySDD argument given to ExportSensorGeometry() !!!
2793   else lay = 4;
2794
2795   return kTRUE;
2796 }