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