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