]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySDD.cxx
Using default Root containers for Root tags bigger than v4-00-01. Removing fast wrapp...
[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 // SDD geometry, based on ROOT geometrical modeler
18 //
19 // Ludovic Gaudichet (Ludovic.Gaudichet@to.infn.it)
20 //*************************************************************************
21
22
23 #include <stdio.h>
24 #include <stdlib.h>
25
26 // General Root includes
27 #include <Riostream.h>
28 #include <TMath.h>
29 #include <TVectorD.h>
30
31 // Root Geometry includes
32 #include <TGeoManager.h>
33 #include <TGeoVolume.h>
34 #include <TGeoPcon.h>
35 #include <TGeoCone.h>
36 #include <TGeoTube.h>
37 #include <TGeoArb8.h>
38 #include <TGeoCompositeShape.h>
39 #include <TGeoMatrix.h>
40 #include <TGeoMaterial.h>
41 #include <TGeoMedium.h>
42 #include <TGeoNode.h>
43
44 #include "AliITSv11Geometry.h"
45 #include "AliITSv11GeometrySDD.h"
46
47 extern TGeoManager* gGeoManager;
48
49 ClassImp(AliITSv11GeomSDDcable)
50
51 //----------------------------------------------------------------------
52 AliITSv11GeomSDDcable::~AliITSv11GeomSDDcable() { 
53   if (fInitialNode) delete fInitialNode; };
54
55
56 //----------------------------------------------------------------------
57 void AliITSv11GeomSDDcable::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
58                                            Double_t *coord)
59 {
60   if (iCheckPt>=fVolumeArray.GetEntriesFast()) {
61     fVolumeArray.AddLast(vol);
62     TVectorD *point = new TVectorD(3,coord);
63     fPointArray.AddLast(point);
64
65   } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) {
66     fVolumeArray.AddAt(vol, iCheckPt);
67     TVectorD *point = new TVectorD(3,coord);
68     fPointArray.AddAt(point, iCheckPt);
69   };
70 };
71
72
73 //----------------------------------------------------------------------
74 Int_t AliITSv11GeomSDDcable::
75 GetCheckPoint( Int_t iCheckPt, Int_t iOccur, Int_t motherLevel,
76                Double_t *coord ) {
77 // Get the coordinate of the #i check point of the #iOccur occurrence of
78 // its containing volume in the node tree. Coord. are given in the coordinate
79 // system of the #motherLevel mother level of this volume
80   
81   if (iCheckPt >= fVolumeArray.GetEntriesFast()) return kFALSE;
82   fCurrentVol = (TGeoVolume *) fVolumeArray.UncheckedAt(iCheckPt);
83
84   TGeoNode *mainNode;
85   if (fInitialNode==0) {
86     TObjArray *nodes = gGeoManager->GetListOfNodes();
87     if (nodes->GetEntriesFast()==0) return kFALSE;
88     mainNode = (TGeoNode *) nodes->UncheckedAt(0);
89   } else {
90     mainNode = fInitialNode;
91   };
92
93   for (Int_t i=0; i<50; i++) fNodeInd[i]=-1;  
94   Int_t currentOccur = 0;
95
96   // loop to get the volume position in the tree of nodes
97   while ( CheckDaughter(0, mainNode) && (currentOccur!=iOccur) ) {
98     currentOccur++;
99     Int_t maxLevel = 0;
100     while (fNodeInd[maxLevel]!=-1) maxLevel++;
101     fNodeInd[maxLevel-1]++;
102   };
103
104   Int_t maxLevel = 0;
105   while (fNodeInd[maxLevel]!=-1) maxLevel++;
106   if (maxLevel==0) return kFALSE;
107
108   if (motherLevel>maxLevel) motherLevel = maxLevel;
109   TGeoNode *pathNode[50];
110   pathNode[0] = mainNode;
111   for (Int_t i=0; i<motherLevel; i++)
112     pathNode[i+1] = pathNode[i]->GetDaughter(fNodeInd[i]);
113
114
115   TVectorD *coordVector = (TVectorD *)fPointArray.UncheckedAt(iCheckPt);
116   Double_t localCoord[3], globalCoord[3];
117   localCoord[0] = (coordVector->GetMatrixArray())[0];
118   localCoord[1] = (coordVector->GetMatrixArray())[1];
119   localCoord[2] = (coordVector->GetMatrixArray())[2];
120
121 //   cout << '(' << localCoord[0] << ',' << localCoord[1] << ','
122 //        << localCoord[2] << ") "<< endl;
123
124   for (Int_t i=motherLevel; i>=0; i--) {
125 //     cout << pathNode[i]->GetName() << " > ";
126     pathNode[i]->GetMatrix()->LocalToMaster(localCoord, globalCoord);
127     localCoord[0] = globalCoord[0];
128     localCoord[1] = globalCoord[1];
129     localCoord[2] = globalCoord[2];
130 //     cout << '(' << localCoord[0] << ',' << localCoord[1] << ','
131 //       << localCoord[2] << ") "<< endl;
132   };
133   coord[0] = globalCoord[0];
134   coord[1] = globalCoord[1];
135   coord[2] = globalCoord[2];
136
137   return kTRUE;
138 };
139
140
141 //----------------------------------------------------------------------
142 void AliITSv11GeomSDDcable::SetInitialNode(TGeoVolume *vol) {
143   if (fInitialNode) delete fInitialNode;
144   fInitialNode = new TGeoNodeMatrix(vol,0);
145   fInitialNode->SetName("nodeInConstruction");
146 };
147
148
149 //----------------------------------------------------------------------
150 void AliITSv11GeomSDDcable:: ResetInitialNode() {
151   if (fInitialNode) delete fInitialNode;
152   fInitialNode = 0;
153 };
154
155
156 //----------------------------------------------------------------------
157 bool AliITSv11GeomSDDcable::CheckDaughter(Int_t i, TGeoNode* node) {
158 // Search where is the current volume in the tree of nodes
159 // stop each time it find the pointer of the current volume
160 // the path is recorded in fNodeInd[]
161 // !!! recursiv function !!!
162
163   Int_t j = fNodeInd[i];
164   if (node->GetVolume()==fCurrentVol) return kTRUE;
165   TObjArray *array = node->GetNodes();
166   if (array) {
167     Int_t nDaughters = array->GetEntriesFast();
168     if (j==-1) j++;
169     while (j<nDaughters) {
170       TGeoNode *subNode = (TGeoNode *) array->UncheckedAt(j);
171       //cout << "level " <<  i << "  " <<  subNode->GetName()<< endl;
172       fNodeInd[i] = j;
173       if (CheckDaughter(i+1, subNode)) return kTRUE;
174       j++;
175     };
176     fNodeInd[i] = -1;
177   };
178   return kFALSE;
179 };
180
181
182
183 ClassImp(AliITSv11GeomSDDcableNap)
184
185 //----------------------------------------------------------------------
186 //----------------------------------------------------------------------
187 AliITSv11GeomSDDcableNap::
188 AliITSv11GeomSDDcableNap(Double_t width, Double_t thick):AliITSv11GeomSDDcable()
189 {
190   fWidth = width;
191   fThick = thick;
192 };
193
194
195 #include <TGeoSphere.h>
196 //----------------------------------------------------------------------
197 Int_t AliITSv11GeomSDDcableNap::
198 CreateAndInsertCableSegment(Int_t p1, Int_t p2, TGeoVolume *motherVol) {
199
200   Double_t coord1[3], coord2[3];
201   GetCheckPoint(p1, 0, 0, coord1);
202   GetCheckPoint(p2, 0, 0, coord2);
203   cout << coord1[0] << ','<< coord1[1] << ','<< coord1[2] << endl;
204   cout << coord2[0] << ','<< coord2[1] << ','<< coord2[2] << endl;
205   coord2[0] = 5;
206   coord2[1] = 0;
207
208   Double_t cx = (coord1[0]+coord2[0])/2;
209   Double_t cy = (coord1[1]+coord2[1])/2;
210   Double_t cz = (coord1[2]+coord2[2])/2;
211   Double_t dx = coord2[0]-coord1[0];
212   Double_t dy = coord2[1]-coord1[1];
213   Double_t dz = coord2[2]-coord1[2];
214
215   Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
216   TGeoBBox *cableSeg = new TGeoBBox("", fWidth/2,fThick/2,length/2); 
217
218   TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
219   TGeoVolume *vCableSeg = new TGeoVolume("vCableSeg",cableSeg, airSDD);
220
221   TGeoTranslation *trans = new TGeoTranslation("",cx, cy, cz);
222   TGeoRotation*rot = new TGeoRotation("",-TMath::ATan(dx/dy)*TMath::RadToDeg(),
223                                       -TMath::ATan(dy/dz)*TMath::RadToDeg(),0);
224   //rot->RotateZ( -TMath::ATan(dx/dy)*TMath::RadToDeg() );
225   //rot->RotateX( -TMath::ATan(dy/dz)*TMath::RadToDeg() );
226   cout << TMath::ATan(dy/dz)*TMath::RadToDeg() << " ######### " 
227        << TMath::ATan(dx/dy)*TMath::RadToDeg() << endl;
228
229   TGeoCombiTrans *combi = new TGeoCombiTrans(*trans, *rot);
230   motherVol->AddNode(vCableSeg, 1, combi);
231
232
233
234   //------------
235   TGeoSphere *sphere = new TGeoSphere(0, 0.1);
236   TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD);
237   TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz);
238   TGeoTranslation *tr1 = new TGeoTranslation("",coord1[0],coord1[1],coord1[2]);
239   TGeoTranslation *tr2 = new TGeoTranslation("",coord2[0],coord2[1],coord2[2]);
240   motherVol->AddNode(vSphere, 1, trC);
241   motherVol->AddNode(vSphere, 2, tr1);
242   motherVol->AddNode(vSphere, 3, tr2);
243
244   return kTRUE;
245 };
246
247
248
249 //________________________________________________________________________
250
251
252 const Double_t AliITSv11GeometrySDD::fSegmentLength    = 37.2*2*fgkmm;
253 const Double_t AliITSv11GeometrySDD::fLadderWidth      = 50.0*fgkmm;
254 const Double_t AliITSv11GeometrySDD::fLadderHeight     = 30.0*fgkmm;
255 const Double_t AliITSv11GeometrySDD::fLadderBeamRadius =  0.6*fgkmm;
256 const Double_t AliITSv11GeometrySDD::fLadderLa         =  3.*fgkmm;
257 const Double_t AliITSv11GeometrySDD::fLadderHa         =  0.6*fgkmm; //total pifometer
258 const Double_t AliITSv11GeometrySDD::fLadderLb         =  3.7*fgkmm;
259 const Double_t AliITSv11GeometrySDD::fLadderHb         =  0.6*fgkmm; //total pifometer
260 const Double_t AliITSv11GeometrySDD::fLadderl          =  0.25*fgkmm;
261
262 const Double_t AliITSv11GeometrySDD::fBottomBeamAngle  = 56.5;
263 const Double_t AliITSv11GeometrySDD::fBeamSidePhi      = 65;
264
265 const Double_t AliITSv11GeometrySDD::fWaferThickness   = 0.3*fgkmm;
266 const Double_t AliITSv11GeometrySDD::fWaferWidth       = 72.5*fgkmm;
267 const Double_t AliITSv11GeometrySDD::fWaferLength      = 87.6*fgkmm;
268
269 const Double_t AliITSv11GeometrySDD::fHybridLength     = 65*fgkmm;
270 const Double_t AliITSv11GeometrySDD::fHybridWidth      = 41*fgkmm;  // pifometer
271 const Double_t AliITSv11GeometrySDD::fHybridThBridgeThick = 0.25*fgkmm; // pifometer
272
273 const Double_t AliITSv11GeometrySDD::fLadWaferSep      = 2*fgkmm;
274 const Double_t AliITSv11GeometrySDD::fPinSuppWidth     = 2.5*fgkmm; // pifometer
275 const Double_t AliITSv11GeometrySDD::fPinSuppHeight    = 2.*fgkmm; // pifometer
276 const Double_t AliITSv11GeometrySDD::fPinSuppRmax      = 2.5/2.*fgkmm;
277 const Double_t AliITSv11GeometrySDD::fPinR             = 1.5/2.*fgkmm;
278 const Double_t AliITSv11GeometrySDD::fPinSuppLength    = 5.*fgkmm;
279 const Double_t AliITSv11GeometrySDD::fPinSuppThickness = 0.5*fgkmm;
280 const Double_t AliITSv11GeometrySDD::fPinSuppConeAngle = 4;
281 const Double_t AliITSv11GeometrySDD::fPinDXminOnSensor = (39./2.)*fgkmm; //placement of pins on sensor
282 const Double_t AliITSv11GeometrySDD::fPinPinDDXOnSensor = 3*fgkmm;
283 const Double_t AliITSv11GeometrySDD::fPinDYOnSensor    = (52.5/2.)*fgkmm;
284
285 // parameters from ALR-0752/3
286 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppHeight    = 3.2*fgkmm;  
287 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppMaxLength = 14*fgkmm;
288 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppWidthExt  = 0.4*fgkmm;
289 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppWidthIn   = 0.65*fgkmm;
290 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppHoleDiam  = 2*fgkmm;
291 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppFulWidth  = 5.15*fgkmm;
292 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppTongW     = 0.8*fgkmm; 
293 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppAngle     = 22.5;
294 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppSlitL     = 4.9*fgkmm;
295 const Double_t AliITSv11GeometrySDD::fCoolPipeSuppAxeDist   = 3.05*fgkmm;
296 const Double_t AliITSv11GeometrySDD::fCoolPipeInnerDiam     = 1.84*fgkmm;
297 const Double_t AliITSv11GeometrySDD::fCoolPipeOuterDiam     = 2.*fgkmm;
298
299 const Double_t AliITSv11GeometrySDD::fBTBthick          = 0.25 *fgkmm;
300 const Double_t AliITSv11GeometrySDD::fBTBlength         = 55. *fgkmm;
301 const Double_t AliITSv11GeometrySDD::fBTBwidth          = 18*fgkmm;
302 const Double_t AliITSv11GeometrySDD::fBTBaxisAtoBottom  = 4*fgkmm;
303 const Double_t AliITSv11GeometrySDD::fBTBaxisAtoBase    = 1.2*fgkmm;
304 const Double_t AliITSv11GeometrySDD::fRadiusAminBTB     = 1. *fgkmm;
305 const Double_t AliITSv11GeometrySDD::fRadiusBminBTB     = 0.53 *fgkmm;
306 const Double_t AliITSv11GeometrySDD::fBTBHoleLength     = 15 *fgkmm;
307 const Double_t AliITSv11GeometrySDD::fBTBHolewidth      =  6 *fgkmm;
308 const Double_t AliITSv11GeometrySDD::fBTBHoleRefX       = 10 *fgkmm;
309 const Double_t AliITSv11GeometrySDD::fBTBHoleRefY       = 6.5 *fgkmm;
310
311 const Double_t AliITSv11GeometrySDD::fLay3Rmin          = 130.*fgkmm; //not min! Rmin virtual tube
312 const Double_t AliITSv11GeometrySDD::fLay3Rmax          = 190.*fgkmm; //not min! Rmax virtual tube
313 const Double_t AliITSv11GeometrySDD::fLay3Length        = (524.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
314 const Double_t AliITSv11GeometrySDD::fLay3LadderLength  = 524.*fgkmm;
315 const Double_t AliITSv11GeometrySDD::fLay3DetShortRadius = 146.0*fgkmm;
316 const Double_t AliITSv11GeometrySDD::fLay3DetLongRadius  = 152.0*fgkmm;
317 const Double_t AliITSv11GeometrySDD::fLay3LaddTopCornerEnd = 15.6*fgkmm;
318 const Int_t    AliITSv11GeometrySDD::fLay3Ndet          = 6;
319 const Int_t    AliITSv11GeometrySDD::fLay3Nladd         = 14;
320 const Double_t AliITSv11GeometrySDD::fLay3CoolPipeSuppH = 7.5*fgkmm;
321
322 const Double_t AliITSv11GeometrySDD::fLay4Rmin          = 220.*fgkmm; //not min! Rmin virtual tube
323 const Double_t AliITSv11GeometrySDD::fLay4Rmax          = 290.*fgkmm; //not min! Rmax virtual tube
324 const Double_t AliITSv11GeometrySDD::fLay4Length        = (671.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
325 const Double_t AliITSv11GeometrySDD::fLay4LadderLength   = 671.*fgkmm;
326 const Double_t AliITSv11GeometrySDD::fLay4DetShortRadius = 235.0*fgkmm;
327 const Double_t AliITSv11GeometrySDD::fLay4DetLongRadius  = 240.5*fgkmm;
328 const Double_t AliITSv11GeometrySDD::fLay4LaddTopCornerEnd = 15.6*fgkmm;
329 const Int_t    AliITSv11GeometrySDD::fLay4Ndet           = 8;
330 const Int_t    AliITSv11GeometrySDD::fLay4Nladd          = 22;
331 const Double_t AliITSv11GeometrySDD::fLay4CoolPipeSuppH  = 10*fgkmm;
332
333
334 ClassImp(AliITSv11GeometrySDD)
335
336
337 //________________________________________________________________________
338 AliITSv11GeometrySDD::AliITSv11GeometrySDD():AliITSv11Geometry() {
339   SetGeomParameters();
340   fCoolingOn = kTRUE;
341   fAddOnlyLadder3min = -1;
342   fAddOnlyLadder3max = -1;
343   fAddOnlyLadder4min = -1;
344   fAddOnlyLadder4max = -1;
345   fAddOnlySegment = -1;
346   fColorCarbonFiber = 4;
347   fColorRyton = 5;
348   fColorPhynox = 7;
349   fColorSilicon = 3;
350 };
351
352
353 //________________________________________________________________________
354 AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug)
355   : AliITSv11Geometry(debug) {
356   SetGeomParameters();
357   fCoolingOn = kTRUE;
358   fAddOnlyLadder3min = -1;
359   fAddOnlyLadder3max = -1;
360   fAddOnlyLadder4min = -1;
361   fAddOnlyLadder4max = -1;
362   fAddOnlySegment = -1;
363   fColorCarbonFiber = 4;
364   fColorRyton = 5;
365   fColorPhynox = 7;
366   fColorSilicon = 3;
367 };
368
369
370 //________________________________________________________________________
371 void AliITSv11GeometrySDD::SetGeomParameters() {
372
373   fLay3LaddShortRadius  = fLay3DetShortRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
374   fLay3LaddLongRadius   = fLay3DetLongRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
375   fLay4LaddShortRadius  = fLay4DetShortRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
376   fLay4LaddLongRadius   = fLay4DetLongRadius-fLadderBeamRadius+(8-1)*fgkmm;  // radius from the center to the CF ladder
377
378
379   fLay3sensorZPos[0]= (  35.8+72.4+75.8 )*fgkmm;
380   fLay3sensorZPos[1]= (  35.8+72.4      )*fgkmm;
381   fLay3sensorZPos[2]= (  35.8           )*fgkmm;
382   fLay3sensorZPos[3]= ( -37.9           )*fgkmm;
383   fLay3sensorZPos[4]= ( -37.9-74.9      )*fgkmm;
384   fLay3sensorZPos[5]= ( -37.9-74.9-71.1 )*fgkmm;
385
386   fLay4sensorZPos[0] = (  38.5+73.2+75.4+71.6 )*fgkmm;
387   fLay4sensorZPos[1] = (  38.5+73.2+75.4      )*fgkmm;
388   fLay4sensorZPos[2] = (  38.5+73.2           )*fgkmm;
389   fLay4sensorZPos[3] = (  38.5                )*fgkmm;
390   fLay4sensorZPos[4] = ( -35.6                )*fgkmm;
391   fLay4sensorZPos[5] = ( -35.6-74.8           )*fgkmm;
392   fLay4sensorZPos[6] = ( -35.6-74.8-72.4      )*fgkmm;
393   fLay4sensorZPos[7] = ( -35.6-74.8-72.4-76.  )*fgkmm;
394
395 };
396
397
398 //________________________________________________________________________
399 void AliITSv11GeometrySDD::CheckOverlaps(Double_t precision){
400
401   TGeoVolume *segment = CreateLadderSegment(4,1);
402   segment->CheckOverlaps(precision);
403
404   TGeoVolume *ladd3 = CreateLay3Ladder();
405   ladd3->CheckOverlaps(precision);
406
407   TGeoVolume *ladd4 = CreateLay4Ladder();
408   ladd4->CheckOverlaps(precision);
409
410   TGeoVolume *endLad = CreateEndLadder(3,0);
411   endLad->CheckOverlaps(precision);
412
413   TGeoVolume *det3 = CreateLay3Detectors();
414   det3->CheckOverlaps(precision);
415
416   TGeoVolume *det4 = CreateLay4Detectors();
417   det4->CheckOverlaps(precision);
418
419   TGeoVolume *hyb = CreateHybrid(0);
420   hyb->CheckOverlaps(precision);
421
422   TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
423   TGeoBBox *layBox = new  TGeoBBox("", 300, 300, 300);
424   TGeoVolume *lay = new TGeoVolume("lay", layBox, airSDD);
425   Layer3(lay);
426   Layer4(lay);
427   lay->CheckOverlaps(precision);
428
429 };
430
431
432 //________________________________________________________________________
433 TGeoCombiTrans *AliITSv11GeometrySDD::
434 CreateCombiTrans(const char *name, Double_t dy, Double_t dz, Double_t dphi) {
435     //
436     // return the TGeoCombiTrans which make a translation in y and z
437     // and a rotation in phi in the global coord system
438     //
439
440     TGeoTranslation t1(dy*CosD(90.+dphi),dy*SinD(90.+dphi), dz);
441     TGeoRotation r1("",0.,0.,dphi);
442
443     TGeoCombiTrans *combiTrans1 = new TGeoCombiTrans(name);
444     combiTrans1->SetTranslation(t1);
445     combiTrans1->SetRotation(r1);
446     return combiTrans1;
447 };
448
449
450 //________________________________________________________________________
451 void AliITSv11GeometrySDD::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
452                                                        Double_t dx,
453                                                        Double_t dy,
454                                                        Double_t dz) {
455     // Add a dx,dy,dz translation to the initial TGeoCombiTrans
456     const Double_t *vect = ct->GetTranslation();
457     Double_t newVect[3];
458     newVect[0] = vect[0]+dx; 
459     newVect[1] = vect[1]+dy; 
460     newVect[2] = vect[2]+dz;
461     ct->SetTranslation(newVect);
462 };
463
464
465 //________________________________________________________________________
466 void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
467 // for code developpment and debugging purposes
468
469 //     TGeoVolume *vBaseThermalBridge = CreateBaseThermalBridge();
470 //     Moth->AddNode(vBaseThermalBridge, 1, 0);
471
472 //   TGeoVolume* seg = CreateLadderSegment( 4, 0); //lay 4
473 //   Moth->AddNode(seg, 1, 0);
474
475   AliITSv11GeomSDDcableNap napCable(2.0,0.2);
476   Double_t coord1[3] = {0,0,0};
477   Double_t coord2[3] = {5,5,5};
478
479   napCable.AddCheckPoint( moth, 0, coord1);
480   napCable.AddCheckPoint( moth, 1, coord2);
481   napCable.CreateAndInsertCableSegment( 0, 1, moth);
482
483 };
484
485
486 //________________________________________________________________________
487 void AliITSv11GeometrySDD::Layer3(TGeoVolume *Moth) {
488     // Insert the layer 3 in the mother volume. This is a virtual volume
489     // containing ladders of layer 3 and the supporting rings
490
491     TGeoTube *virtualLayer3Shape = new TGeoTube("ITSsddLayer3Shape",
492                                        fLay3Rmin,fLay3Rmax,fLay3Length*0.5);
493     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
494     TGeoVolume *virtualLayer3 = new TGeoVolume("ITSsddLayer3",
495                                                virtualLayer3Shape, airSDD);
496     TGeoVolume *lay3Ladder = CreateLay3Ladder();
497     TGeoVolume *lay3Detectors = CreateLay3Detectors();
498
499     Double_t dPhi = 360./fLay3Nladd;
500     Double_t detBoxThickness = fLadWaferSep + 2*fWaferThickness;
501     // Placing virtual ladder and detectors volumes following
502     // ladder ordering convention
503     char rotName[20];
504     Int_t iLaddMin = 0;
505     Int_t iLaddMax = fLay3Nladd;
506     if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fLay3Nladd)) {
507         iLaddMin = fAddOnlyLadder3min;
508         iLaddMax = fAddOnlyLadder3max+1;
509     }
510     for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
511         sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
512         Double_t minRadiusLadBox = fLay3LaddShortRadius;
513         if (iLadd%2 != 0) minRadiusLadBox = fLay3LaddLongRadius;
514         minRadiusLadBox += ((TGeoBBox*)lay3Ladder->GetShape())->GetDY();
515         
516         TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,
517                                                   0,-90+iLadd*dPhi);
518         virtualLayer3->AddNode(lay3Ladder,iLadd,ctLadd);
519         sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
520         Double_t minRadiusDetBox = fLay3DetShortRadius;
521         if (iLadd%2 != 0) minRadiusDetBox = fLay3DetLongRadius;
522         minRadiusDetBox += detBoxThickness/2;
523         TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
524                                                  0,-90+iLadd*dPhi);
525         virtualLayer3->AddNode(lay3Detectors, iLadd, ctDet);
526     }
527     virtualLayer3->SetVisibility(kFALSE);
528     Moth->AddNode(virtualLayer3,1,0);
529 };
530
531
532 //________________________________________________________________________
533 TGeoVolume *AliITSv11GeometrySDD::CreateLay3Ladder() {
534     // return a box volume containing the CF ladder
535
536     Double_t segmentLength = fSegmentLength;
537     TGeoVolume *laddSegmentTemp = CreateLadderSegment(3,0);
538     TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
539                            ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDX(),
540                            ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDY(),
541                                     //dX,dY = dX,dY of the segment
542                                fLay3LadderLength/2);
543     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
544     TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
545     cable.SetInitialNode(virtualLadder);
546
547     // placing virtual ladder segment following detector ordering convention
548     //=======================================================================
549     char transName[20];
550     Int_t iSegmentMin = 0;
551     Int_t iSegmentMax = fLay3Ndet;
552     if (fAddOnlySegment>=0) {
553         iSegmentMin = fAddOnlySegment;
554         iSegmentMax = fAddOnlySegment+1;
555     }
556     for (Int_t iSegment = iSegmentMin; iSegment < iSegmentMax; iSegment++ ) {
557
558         TGeoVolume *laddSegment = CreateLadderSegment(3, iSegment);
559         sprintf(transName, "ITSsddLay3LaddSeg%i", iSegment);
560         Double_t segmentPos = segmentLength*(fLay3Ndet/2-1-iSegment) 
561                               + segmentLength/2;
562         TGeoTranslation *segTr = new TGeoTranslation(transName,0,0,segmentPos);
563         virtualLadder->AddNode(laddSegment, iSegment, segTr);
564     }
565
566     // putting virtual volume corresponding to the end of ladder
567     //=======================================================================
568     TGeoVolume *endLadder = CreateEndLadder( 3,0 );
569     Double_t endLength = (fLay3LadderLength-fLay3Ndet*fSegmentLength)/2.;
570     TGeoTranslation *endTrZPos = new TGeoTranslation("ITSsddEndTrZPos",0,0,
571                                    fSegmentLength*(fLay3Ndet/2)+endLength/2.);
572     //Euler rotation : about Z, then new X, then new Z
573     TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
574     TGeoCombiTrans *endTrZNeg = new TGeoCombiTrans(0,0,
575                     -fSegmentLength*(fLay3Ndet/2)-endLength/2., endZNegRot);
576     if ((fAddOnlySegment==-1)||(fAddOnlySegment==0))
577         virtualLadder->AddNode(endLadder, 1, endTrZPos);
578     if ((fAddOnlySegment==-1)||(fAddOnlySegment==fLay3Ndet-1))
579         virtualLadder->AddNode(endLadder, 2, endTrZNeg);
580
581     cable.ResetInitialNode();
582
583     virtualLadder->SetVisibility(kFALSE);
584     return virtualLadder;
585 };
586
587
588 //________________________________________________________________________
589 TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(Double_t dz,Double_t angle,
590                           Double_t xSign,Double_t L, Double_t H, Double_t l) {
591     // Create one half of the V shape corner of CF ladder
592   
593     TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
594     cfLaddSide->SetVertex( 0, 0,  0);
595     cfLaddSide->SetVertex( 1, 0, -H);
596     cfLaddSide->SetVertex( 2, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
597                            -L*TMath::Cos(angle)-l*TMath::Sin(angle));
598     cfLaddSide->SetVertex( 3, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
599     cfLaddSide->SetVertex( 4, 0,  0);
600     cfLaddSide->SetVertex( 5, 0, -H);
601     cfLaddSide->SetVertex( 6, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
602                            -L*TMath::Cos(angle)-l*TMath::Sin(angle));
603     cfLaddSide->SetVertex(7, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
604     return cfLaddSide;
605 };
606
607
608 //________________________________________________________________________
609 void AliITSv11GeometrySDD::AddLadderCFstruct(Double_t dy, TGeoVolume* vol) {
610     // fill a volume (segment) with the CF structure of a ladder
611
612     TGeoMedium *carbonFiberLadderStruct = 
613       gGeoManager->GetMedium("ITSsddCarbonFiber");
614     Double_t segmentLength = fSegmentLength;
615     Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
616     Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
617     Double_t beta = (TMath::Pi()-2.*halfTheta)/4.;
618     Double_t alpha = TMath::Pi()*3./4. - halfTheta/2.;
619
620     //--- The 3 V shape corners of the Carbon Fiber Ladder
621     //--- the top V
622     TGeoArb8 *cfLaddTop1 = CreateLadderSide( segmentLength/2., halfTheta, -1,
623                                              fLadderLa, fLadderHa, fLadderl);
624     TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
625                                     cfLaddTop1,carbonFiberLadderStruct);
626     TGeoArb8 *cfLaddTop2 = CreateLadderSide( segmentLength/2., halfTheta, 1,
627                                              fLadderLa, fLadderHa, fLadderl);
628     TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
629                                     cfLaddTop2,carbonFiberLadderStruct);
630     TGeoTranslation *trTop1 = new TGeoTranslation(0, fLadderHeight/2+dy, 0);
631     cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
632     cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
633     vol->AddNode(cfLaddTopVol1, 1, trTop1);
634     vol->AddNode(cfLaddTopVol2, 1, trTop1);
635
636     //--- the 2 side V
637     TGeoArb8 *cfLaddSide1 = CreateLadderSide( segmentLength/2., beta, -1,
638                                               fLadderLb, fLadderHb, fLadderl);
639     TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerV1",
640                                      cfLaddSide1,carbonFiberLadderStruct);
641     TGeoArb8 *cfLaddSide2 = CreateLadderSide( segmentLength/2., beta, 1,
642                                               fLadderLb, fLadderHb, fLadderl);
643     TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerV2",
644                                      cfLaddSide2,carbonFiberLadderStruct);
645     cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
646     cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
647
648     Double_t dYTranslation = fLadderHeight/2. - 
649                       0.5*fLadderWidth*TMath::Tan(beta) - fLadderBeamRadius;
650     // because center of the triangle doesn't correspond to virtual vol. center
651     Double_t distCenterSideDown =  0.5*fLadderWidth/TMath::Cos(beta);
652     TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
653                                                alpha*TMath::RadToDeg());
654     AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+dy, 0);
655     TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,
656                                                -alpha*TMath::RadToDeg());
657     AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+dy, 0);
658     vol->AddNode(cfLaddSideVol1, 1, ctSideR);
659     vol->AddNode(cfLaddSideVol2, 1, ctSideR);
660     vol->AddNode(cfLaddSideVol1, 2, ctSideL);
661     vol->AddNode(cfLaddSideVol2, 2, ctSideL);
662
663     //--- The beams
664     // Beams on the sides
665     Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
666                 TMath::Sin(2*beta)/(TanD(fBeamSidePhi)*TanD(fBeamSidePhi))) ));
667     if(GetDebug(1))
668       cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
669     Double_t beamLength = TMath::Sqrt( fLadderHeight*fLadderHeight/
670                        ( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
671                        + fLadderWidth*fLadderWidth/4.)-fLadderLa/2-fLadderLb/2;
672     TGeoTubeSeg *sideBeam= new TGeoTubeSeg(0, fLadderBeamRadius, beamLength/2.,
673                                             0, 180);
674     TGeoVolume *cfSideBeamVol = new TGeoVolume("ITSsddCFSideBeamVol", sideBeam,
675                                                carbonFiberLadderStruct);
676     cfSideBeamVol->SetLineColor(fColorCarbonFiber);
677
678     //Euler rotation : about Z, then new X, then new Z
679     TGeoRotation *beamRot1 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
680                                  -beamPhiPrime*TMath::RadToDeg(),-90);
681     TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans( 0.5*triangleHeight*
682                                       TMath::Tan(halfTheta),
683                                       fLadderBeamRadius/2. + dy,
684                                       -3*segmentLength/8, beamRot1);
685     TGeoCombiTrans *beamTransf2 = new TGeoCombiTrans( 0.5*triangleHeight*
686                                       TMath::Tan(halfTheta),
687                                       fLadderBeamRadius/2. + dy,
688                                       segmentLength/8, beamRot1);
689     TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
690                                  beamPhiPrime*TMath::RadToDeg(), -90);
691
692     TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans(0.5*triangleHeight*
693                                       TMath::Tan(halfTheta),
694                                       fLadderBeamRadius/2. + dy,
695                                       -segmentLength/8, beamRot2);
696     TGeoCombiTrans *beamTransf4 = new TGeoCombiTrans(0.5*triangleHeight*
697                                       TMath::Tan(halfTheta),
698                                       fLadderBeamRadius/2. + dy,
699                                       3*segmentLength/8, beamRot2);
700     TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
701                                  beamPhiPrime*TMath::RadToDeg(), -90);
702
703     TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
704                                       TMath::Tan(halfTheta),
705                                       fLadderBeamRadius/2. + dy,
706                                       -3*segmentLength/8,beamRot3);
707     TGeoCombiTrans *beamTransf6 = new TGeoCombiTrans(-0.5*triangleHeight*
708                                       TMath::Tan(halfTheta),
709                                       fLadderBeamRadius/2. + dy,
710                                       segmentLength/8, beamRot3);
711     TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
712                                  -beamPhiPrime*TMath::RadToDeg(), -90);
713
714     TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
715       TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,-segmentLength/8,beamRot4);
716     TGeoCombiTrans *beamTransf8 = new TGeoCombiTrans(-0.5*triangleHeight*
717      TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,3*segmentLength/8,beamRot4);
718
719     vol->AddNode(cfSideBeamVol, 1, beamTransf1);
720     vol->AddNode(cfSideBeamVol, 2, beamTransf2);
721     vol->AddNode(cfSideBeamVol, 3, beamTransf3);
722     vol->AddNode(cfSideBeamVol, 4, beamTransf4);
723     vol->AddNode(cfSideBeamVol, 5, beamTransf5);
724     vol->AddNode(cfSideBeamVol, 6, beamTransf6);
725     vol->AddNode(cfSideBeamVol, 7, beamTransf7);
726     vol->AddNode(cfSideBeamVol, 8, beamTransf8);
727
728     //--- Beams of the bottom
729     TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fLadderBeamRadius,
730                                    fLadderWidth/2.-fLadderLb/3, 0, 180);
731     TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
732                                      bottomBeam1, carbonFiberLadderStruct);
733     bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
734
735     TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
736     TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
737                     -(fLadderHeight/2-fLadderBeamRadius)+dy,0, bottomBeamRot1);
738     TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fLadderBeamRadius,
739                                    fLadderWidth/2.-fLadderLb/3, 0, 90);
740     TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
741                                 bottomBeam2, carbonFiberLadderStruct);
742     bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
743     TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
744                                      -(fLadderHeight/2-fLadderBeamRadius)+dy,
745                                      -segmentLength/2, bottomBeamRot1);
746     TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
747     TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,
748                                         -(fLadderHeight/2 - fLadderBeamRadius)
749                                         + dy, segmentLength/2, bottomBeamRot2);
750
751     TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, fLadderBeamRadius,
752                                0.5*fLadderWidth/SinD(fBottomBeamAngle)
753                                - fLadderLb/3, 0, 180);
754     TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol",
755                                  bottomBeam3, carbonFiberLadderStruct);
756     bottomBeam3Vol->SetLineColor(fColorCarbonFiber);
757     //bottomBeam3Vol->SetLineColor(2);
758
759     // be careful on the next 2 beams : when "reading" from -z to +z and 
760     // from the bottom of the ladder, it should draw a Lambda, and not a V
761     TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, fBottomBeamAngle,
762                                                     -90);
763     TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans(0, 
764       -(fLadderHeight/2-fLadderBeamRadius)+dy,-segmentLength/4,bottomBeamRot4);
765     TGeoRotation *bottomBeamRot5 = new TGeoRotation("",-90,-fBottomBeamAngle,
766                                                     -90);
767     TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans(0,
768      -(fLadderHeight/2-fLadderBeamRadius)+dy,segmentLength/4, bottomBeamRot5);
769
770     vol->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
771     vol->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
772     vol->AddNode(bottomBeam2Vol, 2, bottomBeamTransf3);
773     vol->AddNode(bottomBeam3Vol, 1, bottomBeamTransf4);
774     vol->AddNode(bottomBeam3Vol, 2, bottomBeamTransf5);
775 };
776
777
778 //________________________________________________________________________
779 TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iSeg) {
780 // return a box containing the front-end hybrid
781 // Be careful : electronics side is at y<0, thermal bridge at y>0
782
783   Double_t volumeThick =  0.2;                                  // <===== 0.2 tmp
784   TGeoBBox *hybridBox = new TGeoBBox("",fHybridWidth/2, volumeThick/2,
785                                      (fHybridLength)/2);  // include space on each side for cables ???  
786   TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
787   TGeoVolume *VirtualHybrid = new TGeoVolume( "ITSsddHybridVol", hybridBox,
788                                               airSDD);
789   
790   TGeoBBox *sThermalBridge = new TGeoBBox( "", fHybridWidth/2,
791                                            fHybridThBridgeThick/2,
792                                            fHybridLength/2);
793   TGeoMedium *carbonFiberLadderStruct =
794     gGeoManager->GetMedium("ITSsddCarbonFiber");
795   
796   TGeoVolume *vThermalBridge = new TGeoVolume("ITSsddHybridThBridge",
797                                               sThermalBridge,
798                                               carbonFiberLadderStruct);
799   vThermalBridge->SetLineColor(fColorCarbonFiber);
800
801   TGeoTranslation *thBridgeTr = new TGeoTranslation("", 0,
802                                     volumeThick/2-fHybridThBridgeThick/2, 0);
803   VirtualHybrid->AddNode(vThermalBridge, 1, thBridgeTr);
804
805   Double_t coord[3];
806   coord[0] = 0;coord[1] = 0;coord[2] = 0;
807   cable.AddCheckPoint(VirtualHybrid, iSeg, coord);
808   VirtualHybrid->SetVisibility(kFALSE);
809   cable.GetCheckPoint( cable.GetNCheckPoints()-2, 0, 100, coord);
810   return VirtualHybrid;
811 };
812
813
814 //________________________________________________________________________
815 TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
816     // Return a box volume containing a segment of a ladder.
817
818     //***
819     Double_t tDY = -0.5; //space left on top of the ladder
820     Double_t segmentLength = fSegmentLength;
821
822     Double_t coolPipeSuppH = 0;
823     Double_t sensorCenterZPos = 0; // z in segment local coord syst.
824     if (iLay==3) {
825       coolPipeSuppH = fLay3CoolPipeSuppH;
826       sensorCenterZPos = fLay3sensorZPos[iSeg]-
827                          (fSegmentLength*fLay3Ndet/2. - 
828                           fSegmentLength/2-(iSeg)*fSegmentLength);
829     } else {
830       coolPipeSuppH = fLay4CoolPipeSuppH;
831       sensorCenterZPos = fLay4sensorZPos[iSeg]-
832                          (fSegmentLength*fLay4Ndet/2. -
833                           fSegmentLength/2-(iSeg)*fSegmentLength);
834     };
835     if(GetDebug(1)){
836       cout << "Segment ("<< iLay <<',' << iSeg 
837            << ") : sensor z shift in local segment coord.=" 
838            << sensorCenterZPos << endl;
839     };
840     //***
841
842     TGeoBBox *segBox = new TGeoBBox("ITSsddSegBox",
843                                     fLadderWidth/2+fPinSuppWidth+0.5,  // +0.5 is for include volume of hybrids !
844                                     fLadderHeight/2+TMath::Abs(tDY),
845                                     segmentLength/2);
846     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
847     TGeoVolume *virtualSeg = new TGeoVolume("ITSsddSegment",
848                                             segBox, airSDD);
849
850     //**********************************
851     // Carbon fiber structure :
852     AddLadderCFstruct(tDY, virtualSeg);
853
854     //**********************************
855     // Pine support of the sensors :
856     TGeoRotation *rotPS1 = new TGeoRotation("",0,-90,90);
857     TGeoRotation *rotPS2 = new TGeoRotation("",0,-90,-90);
858     TGeoCombiTrans *transPS1 = new TGeoCombiTrans( fPinDYOnSensor,
859                                    - fLadderHeight/2.-TMath::Abs(tDY)
860                                    + fPinSuppHeight/2.,
861                                    sensorCenterZPos + fPinDXminOnSensor,rotPS1);
862     TGeoCombiTrans *transPS2 = new TGeoCombiTrans( fPinDYOnSensor,
863                                    - fLadderHeight/2.-TMath::Abs(tDY)
864                                    + fPinSuppHeight/2.,
865                                    sensorCenterZPos + fPinDXminOnSensor + 
866                                    fPinPinDDXOnSensor, rotPS1);
867     TGeoCombiTrans *transPS3 = new TGeoCombiTrans( fPinDYOnSensor,
868                                    - fLadderHeight/2.-TMath::Abs(tDY)
869                                    + fPinSuppHeight/2.,
870                                    sensorCenterZPos-fPinDXminOnSensor,rotPS1);
871     TGeoCombiTrans *transPS4 = new TGeoCombiTrans( fPinDYOnSensor,
872                                    - fLadderHeight/2.-TMath::Abs(tDY)
873                                    + fPinSuppHeight/2.,
874                                    sensorCenterZPos-fPinDXminOnSensor -
875                                    fPinPinDDXOnSensor, rotPS1);
876     TGeoCombiTrans *transPS5 = new TGeoCombiTrans( -fPinDYOnSensor,
877                                    - fLadderHeight/2. - TMath::Abs(tDY)
878                                    + fPinSuppHeight/2.,
879                                    sensorCenterZPos+fPinDXminOnSensor,rotPS2);
880     TGeoCombiTrans *transPS6 = new TGeoCombiTrans( -fPinDYOnSensor,
881                                    - fLadderHeight/2. - TMath::Abs(tDY)
882                                    + fPinSuppHeight/2.,
883                                    sensorCenterZPos+fPinDXminOnSensor +
884                                    fPinPinDDXOnSensor, rotPS2);
885     TGeoCombiTrans *transPS7 = new TGeoCombiTrans( -fPinDYOnSensor,
886                                    - fLadderHeight/2.-TMath::Abs(tDY)
887                                    + fPinSuppHeight/2.,
888                                    sensorCenterZPos-fPinDXminOnSensor,rotPS2);
889     TGeoCombiTrans *transPS8 = new TGeoCombiTrans( -fPinDYOnSensor,
890                                    - fLadderHeight/2.-TMath::Abs(tDY)
891                                    + fPinSuppHeight/2.,
892                                    sensorCenterZPos - fPinDXminOnSensor
893                                    - fPinPinDDXOnSensor, rotPS2);
894     TGeoVolume *pinSupport = CreatePinSupport();
895     virtualSeg->AddNode(pinSupport, 1, transPS1);
896     virtualSeg->AddNode(pinSupport, 2, transPS2);
897     virtualSeg->AddNode(pinSupport, 3, transPS3);
898     virtualSeg->AddNode(pinSupport, 4, transPS4);
899     virtualSeg->AddNode(pinSupport, 5, transPS5);
900     virtualSeg->AddNode(pinSupport, 6, transPS6);
901     virtualSeg->AddNode(pinSupport, 7, transPS7);
902     virtualSeg->AddNode(pinSupport, 8, transPS8);
903
904     //**********************************
905     // Cooling pipe supports :
906     Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
907     Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
908     Double_t triangleCPaxeDist = fCoolPipeSuppAxeDist-fCoolPipeSuppWidthExt-
909                                  fCoolPipeSuppWidthIn+fLadderBeamRadius;
910
911     Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
912                              (triangleHeight+triangleCPaxeDist/
913                               TMath::Sin(halfTheta)-coolPipeSuppH);
914
915     TGeoRotation *rotCPS2 = new TGeoRotation("",-halfTheta*TMath::RadToDeg(),
916                                              -90, 90);
917     TGeoRotation *rotCPS1 = new TGeoRotation("",halfTheta*TMath::RadToDeg(),
918                                              -90, -90);
919     TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
920                                     -fLadderHeight/2.-TMath::Abs(tDY)
921                                     +coolPipeSuppH+fLadderBeamRadius,
922                                     -segmentLength/2., rotCPS1);
923     TGeoCombiTrans *transCPS2 = new TGeoCombiTrans(-coolPipeSuppL,
924                                     -fLadderHeight/2.-TMath::Abs(tDY)
925                                     +coolPipeSuppH+fLadderBeamRadius,
926                                     segmentLength/2., rotCPS2);
927     TGeoCombiTrans *transCPS3 = new TGeoCombiTrans(coolPipeSuppL,
928                                     -fLadderHeight/2.-TMath::Abs(tDY)
929                                     +coolPipeSuppH+fLadderBeamRadius,
930                                     segmentLength/2., rotCPS1);
931     TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
932                                     -fLadderHeight/2.-TMath::Abs(tDY)
933                                     +coolPipeSuppH+fLadderBeamRadius,
934                                     -segmentLength/2., rotCPS2);
935
936     TGeoVolume *coolPipeSuppLeft = CreateCoolPipeSupportL();
937     TGeoVolume *coolPipeSuppRight = CreateCoolPipeSupportR();
938     virtualSeg->AddNode(coolPipeSuppLeft,  1, transCPS1);
939     virtualSeg->AddNode(coolPipeSuppLeft,  2, transCPS2);
940     virtualSeg->AddNode(coolPipeSuppRight, 1, transCPS3);
941     virtualSeg->AddNode(coolPipeSuppRight, 2, transCPS4);
942
943     //**********************************
944     // Cooling pipes :
945     TGeoTube *coolingPipeShape = new TGeoTube( fCoolPipeInnerDiam/2,
946                                                fCoolPipeOuterDiam/2,
947                                                segmentLength/2);
948     TGeoTube *coolerShape = new TGeoTube( 0, fCoolPipeInnerDiam/2,
949                                           segmentLength/2);
950
951     //medium = phynox ?                              To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
952     //medium = water ?                               To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
953     TGeoMedium *phynoxSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
954     TGeoMedium *coolerMediumSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
955     TGeoVolume *coolingPipe = new TGeoVolume("ITSsddCoolingPipe",
956                                              coolingPipeShape, phynoxSDD );
957     coolingPipe->SetLineColor(fColorPhynox);
958     TGeoVolume *cooler = new  TGeoVolume("ITSsddCoolingLiquid",coolerShape,
959                                          coolerMediumSDD );
960
961     TGeoTranslation *pipeTr1 = new TGeoTranslation(coolPipeSuppL,
962                                   -fLadderHeight/2.-TMath::Abs(tDY)+
963                                    fLadderBeamRadius+coolPipeSuppH, 0);
964     TGeoTranslation *pipeTr2 = new TGeoTranslation(-coolPipeSuppL,
965                                   -fLadderHeight/2.-TMath::Abs(tDY)+
966                                    fLadderBeamRadius+coolPipeSuppH, 0);
967
968     virtualSeg->AddNode(coolingPipe, 1, pipeTr1);
969     virtualSeg->AddNode(coolingPipe, 2, pipeTr2);
970     if (fCoolingOn) {
971       virtualSeg->AddNode(cooler, 1, pipeTr1);
972       virtualSeg->AddNode(cooler, 2, pipeTr2);
973     };
974
975     //**********************************
976     // Bases of hybrid thermal bridges
977     Double_t hybridAngle = 46;                                           // tmp !!!
978     Double_t shiftHyb = 0.9-0.2; // shift in comparison with center of thermal Br. base // tmp !!! not clear on 0752/14-A
979     // sur 0752/14-A c'est environ 0.9
980     // en fait comme la hauteur des cooling pipes depends de la couche, ces deux variables varient probablement
981     // suivant la "layer" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
982
983     TGeoVolume *baseThermalBridge = CreateBaseThermalBridge();
984     TGeoRotation rotHybrid1("",0, 0,  -90 - hybridAngle);
985     TGeoRotation rotHybrid2("",0 ,180, 90 - hybridAngle);
986     TGeoCombiTrans *baseTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid1);
987     TGeoCombiTrans *baseTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid2);
988     virtualSeg->AddNode(baseThermalBridge, 1, baseTr1);
989     virtualSeg->AddNode(baseThermalBridge, 2, baseTr2);
990
991     //**********************************
992     // the 2 hybrids :
993     TGeoVolume *Hybrid = CreateHybrid(iSeg);
994
995     Double_t hybDy = ((TGeoBBox*)Hybrid->GetShape())->GetDY();
996     Double_t axeToHybridCenterDist = fBTBaxisAtoBase+hybDy;
997
998     Double_t hybrVolDX = ( axeToHybridCenterDist*CosD(hybridAngle) 
999                            - shiftHyb*SinD(hybridAngle) );
1000     Double_t hybrVolDY = ( axeToHybridCenterDist*SinD(hybridAngle)
1001                            + shiftHyb*CosD(hybridAngle) );
1002
1003     TGeoCombiTrans *hybTr1 = new TGeoCombiTrans(*baseTr1);
1004     AddTranslationToCombiTrans( hybTr1, -hybrVolDX, hybrVolDY, 0);
1005     TGeoCombiTrans *hybTr2 = new TGeoCombiTrans(*baseTr2);
1006     AddTranslationToCombiTrans( hybTr2, hybrVolDX, hybrVolDY, 0);
1007
1008     virtualSeg->AddNode(Hybrid, 1, hybTr1);
1009     virtualSeg->AddNode(Hybrid, 2, hybTr2);
1010
1011
1012     //**********************************
1013     virtualSeg->SetVisibility(kFALSE);
1014     return virtualSeg;
1015 };
1016
1017
1018 //________________________________________________________________________
1019 TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
1020 //
1021 // Create a pine support
1022 // axis of rotation is the cone axis, center in its middle
1023 //
1024     TGeoCone *cone = new TGeoCone("ITSsddPinSuppCone",fPinSuppHeight/2.,
1025                                   0,fPinSuppRmax,0,fPinSuppRmax-
1026                                   fPinSuppHeight*TanD(fPinSuppConeAngle) );
1027     TGeoBBox *tong = new TGeoBBox("ITSsddPinSuppTong",fPinSuppRmax,
1028                                   fPinSuppLength/2.,fPinSuppThickness/2.);
1029     TGeoTube *hole = new TGeoTube("ITSsddPinSuppHole",0,fPinR,
1030                                   fPinSuppHeight/2.);
1031     if(GetDebug(3)){// Remove compiler warning.
1032         cone->InspectShape();
1033         tong->InspectShape();
1034         hole->InspectShape();
1035     };
1036
1037     TGeoTranslation *tongTrans = new TGeoTranslation("ITSsddPinSuppTongTr",0,
1038                    fPinSuppLength/2.,-fPinSuppHeight/2.+fPinSuppThickness/2.);
1039     tongTrans->RegisterYourself();
1040     TGeoCompositeShape *pinSupportShape = new TGeoCompositeShape(
1041                "ITSssdPinSupportShape","(ITSsddPinSuppCone+"
1042                "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
1043
1044     //medium = ryton ?                           To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1045     TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
1046     TGeoVolume *pinSupport = new TGeoVolume("ITSssdPinSupport",pinSupportShape,
1047                                             rytonSDD);
1048     pinSupport->SetLineColor(fColorRyton);
1049     return pinSupport;
1050     // include the pin itself                           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1051 };
1052
1053 //________________________________________________________________________
1054 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportL() {
1055 //
1056 // Create half of the cooling pipe support (ALR-0752/3)
1057 //
1058
1059   Double_t diffX = fCoolPipeSuppHeight*TanD(fCoolPipeSuppAngle);
1060   
1061   TGeoArb8 *side1 = new TGeoArb8(fCoolPipeSuppHeight/2.);
1062   side1->SetVertex( 0, 0, -fCoolPipeSuppWidthExt/2.);
1063   side1->SetVertex( 1, fCoolPipeSuppMaxLength/2.-diffX,
1064                        -fCoolPipeSuppWidthExt/2.);
1065   side1->SetVertex( 2, fCoolPipeSuppMaxLength/2.-diffX,
1066                        fCoolPipeSuppWidthExt/2.);
1067   side1->SetVertex( 3, 0,  fCoolPipeSuppWidthExt/2.);
1068   side1->SetVertex( 4, 0, -fCoolPipeSuppWidthExt/2.);
1069   side1->SetVertex( 5, fCoolPipeSuppMaxLength/2.,
1070                        -fCoolPipeSuppWidthExt/2.);
1071   side1->SetVertex( 6, fCoolPipeSuppMaxLength/2.,
1072                        fCoolPipeSuppWidthExt/2.);
1073   side1->SetVertex( 7, 0,  fCoolPipeSuppWidthExt/2.);
1074   side1->SetName("ITSsddCPSside1");
1075
1076   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1",0,
1077                                  - fCoolPipeSuppAxeDist
1078                                  + fCoolPipeSuppWidthExt/2., 0);
1079   side1Tr->RegisterYourself();
1080   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2",0,
1081                                  - fCoolPipeSuppAxeDist
1082                                  + fCoolPipeSuppWidthExt*3/2.
1083                                  + fCoolPipeSuppWidthIn,0);
1084   side2Tr->RegisterYourself();
1085   
1086   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddle",
1087                          (fCoolPipeSuppMaxLength/2.-fCoolPipeSuppSlitL)/2.,
1088                          fCoolPipeSuppWidthIn/2., fCoolPipeSuppHeight/2.);
1089   TGeoTranslation *middleTr = 
1090     new TGeoTranslation("ITSsddCPStr3",
1091                         (fCoolPipeSuppMaxLength/2.-fCoolPipeSuppSlitL)/2.,
1092                         -fCoolPipeSuppAxeDist+fCoolPipeSuppWidthExt
1093                         +fCoolPipeSuppWidthIn/2., 0);
1094   middleTr->RegisterYourself();
1095   
1096   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBox",
1097                                   fCoolPipeSuppTongW/4.,
1098                                   (fCoolPipeSuppFulWidth
1099                                    - 2*fCoolPipeSuppWidthExt
1100                                    - fCoolPipeSuppWidthIn)/2,
1101                                   fCoolPipeSuppHeight/2.);
1102   
1103   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTr",
1104                                   fCoolPipeSuppTongW/4.,
1105                                   - fCoolPipeSuppAxeDist
1106                                   + fCoolPipeSuppFulWidth
1107                                   - axeBox->GetDY(), 0);
1108   axeBoxTr->RegisterYourself();
1109
1110   TGeoTube *axe = new TGeoTube("ITSsddCPSaxe",0,fCoolPipeSuppHoleDiam/2.,
1111                                fCoolPipeSuppTongW/4.);
1112   TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRot",90,90,0);
1113
1114   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTr",
1115                                  fCoolPipeSuppTongW/4.,0,0,axeRot);
1116   axeTrans->RegisterYourself();
1117
1118   if(GetDebug(3)){
1119     middle->InspectShape();
1120     axe->InspectShape();
1121   };
1122
1123   //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1124   TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
1125   
1126   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
1127                                         "ITSsddCoolPipeSuppShapeL",
1128                                         "ITSsddCPSmiddle:ITSsddCPStr3"
1129                                         "+ITSsddCPSside1:ITSsddCPStr1"
1130                                         "+ITSsddCPSside1:ITSsddCPStr2"
1131                                         "+ITSsddCPSaxeBox:ITSsddCPSAxBoxTr"
1132                                         "-ITSsddCPSaxe:ITSsddCPSaxeTr");
1133   TGeoVolume *coolPipeSupp = new  TGeoVolume("ITSsddCoolPipeSupportL",
1134                                              coolPipeSuppShape, rytonSDD);
1135
1136   coolPipeSupp->SetLineColor(fColorRyton);
1137   return coolPipeSupp;
1138 };
1139
1140 //________________________________________________________________________
1141 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportR() {
1142 //
1143 //Create half of the cooling pipe support (ALR-0752/3)
1144 //
1145
1146   Double_t diffX = fCoolPipeSuppHeight*TanD(fCoolPipeSuppAngle);
1147   
1148   TGeoArb8 *side1 = new TGeoArb8(fCoolPipeSuppHeight/2.);
1149   side1->SetVertex( 0, 0, -fCoolPipeSuppWidthExt/2.);
1150   side1->SetVertex( 1, -(fCoolPipeSuppMaxLength/2.-diffX),
1151                        -fCoolPipeSuppWidthExt/2.);
1152   side1->SetVertex( 2, -(fCoolPipeSuppMaxLength/2.-diffX),
1153                        fCoolPipeSuppWidthExt/2.);
1154   side1->SetVertex( 3, 0,  fCoolPipeSuppWidthExt/2.);
1155   side1->SetVertex( 4, 0, -fCoolPipeSuppWidthExt/2.);
1156   side1->SetVertex( 5, -fCoolPipeSuppMaxLength/2.,
1157                        -fCoolPipeSuppWidthExt/2.);
1158   side1->SetVertex( 6, -fCoolPipeSuppMaxLength/2.,
1159                        fCoolPipeSuppWidthExt/2.);
1160   side1->SetVertex( 7, 0,  fCoolPipeSuppWidthExt/2.);
1161   side1->SetName("ITSsddCPSside1R");
1162
1163   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1R",0,
1164                                  - fCoolPipeSuppAxeDist
1165                                  + fCoolPipeSuppWidthExt/2., 0);
1166   side1Tr->RegisterYourself();
1167   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2R",0,
1168                                  - fCoolPipeSuppAxeDist
1169                                  + fCoolPipeSuppWidthExt*3/2.
1170                                  + fCoolPipeSuppWidthIn, 0);
1171   side2Tr->RegisterYourself();
1172   
1173   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddleR",
1174                                   (fCoolPipeSuppMaxLength/2.
1175                                    - fCoolPipeSuppSlitL)/2.,
1176                                   fCoolPipeSuppWidthIn/2., 
1177                                   fCoolPipeSuppHeight/2.);
1178   TGeoTranslation *middleTr = 
1179     new TGeoTranslation("ITSsddCPStr3R",
1180                         -( fCoolPipeSuppMaxLength/2.
1181                            -fCoolPipeSuppSlitL)/2.,
1182                         -fCoolPipeSuppAxeDist + fCoolPipeSuppWidthExt
1183                         + fCoolPipeSuppWidthIn/2.,0);
1184   middleTr->RegisterYourself();
1185   
1186   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBoxR",
1187                                   fCoolPipeSuppTongW/4.,
1188                                   (fCoolPipeSuppFulWidth
1189                                    - 2*fCoolPipeSuppWidthExt
1190                                    - fCoolPipeSuppWidthIn)/2,
1191                                   fCoolPipeSuppHeight/2.);
1192   
1193   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTrR",
1194                                   - fCoolPipeSuppTongW/4.,
1195                                   - fCoolPipeSuppAxeDist
1196                                   + fCoolPipeSuppFulWidth
1197                                   - axeBox->GetDY(),0);
1198   axeBoxTr->RegisterYourself();
1199
1200   TGeoTube *axe = new TGeoTube("ITSsddCPSaxeR",0,fCoolPipeSuppHoleDiam/2.,
1201                                fCoolPipeSuppTongW/4.);
1202   TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRotR",90,90,0);
1203
1204   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTrR",
1205                                  -fCoolPipeSuppTongW/4.,0,0,axeRot);
1206   axeTrans->RegisterYourself();
1207
1208   if(GetDebug(3)){
1209     middle->InspectShape();
1210     axe->InspectShape();
1211   };
1212   
1213   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
1214                                       "ITSsddCoolPipeSuppShapeR",
1215                                       "ITSsddCPSmiddleR:ITSsddCPStr3R"
1216                                       "+ITSsddCPSside1R:ITSsddCPStr1R"
1217                                       "+ITSsddCPSside1R:ITSsddCPStr2R"
1218                                       "+ITSsddCPSaxeBoxR:ITSsddCPSAxBoxTrR"
1219                                       "-ITSsddCPSaxeR:ITSsddCPSaxeTrR");
1220
1221   //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1222   TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
1223   TGeoVolume *coolPipeSupp = new TGeoVolume( "ITSsddCoolPipeSupportR",
1224                                              coolPipeSuppShape, rytonSDD);
1225   coolPipeSupp->SetLineColor(fColorRyton);
1226
1227   return coolPipeSupp;
1228 };
1229
1230 //________________________________________________________________________
1231 TGeoVolume* AliITSv11GeometrySDD::CreateBaseThermalBridge() {
1232 // ALR 0752/8
1233
1234   Double_t dy = fBTBaxisAtoBase - fRadiusBminBTB - fBTBthick;
1235
1236   Double_t base1width = fBTBwidth - fBTBaxisAtoBottom - fRadiusBminBTB
1237                         - (fRadiusAminBTB+fBTBthick);
1238   TGeoBBox *base1 = new TGeoBBox( "ITSsddBTBbase1", base1width/2.,
1239                                   fBTBthick/2., fBTBlength/2.);
1240   TGeoTranslation *base1Tr = new TGeoTranslation("ITSsddBTBtr1",
1241                                  fBTBaxisAtoBottom-fBTBwidth+base1width/2.,
1242                                  -(fBTBaxisAtoBase-fBTBthick/2.), 0);
1243   base1Tr->RegisterYourself();
1244
1245   Double_t base2width = fBTBaxisAtoBottom - fRadiusAminBTB - fBTBthick
1246                         - fRadiusBminBTB;
1247   TGeoBBox *base2 = new TGeoBBox( "ITSsddBTBbase2", base2width/2.,
1248                                   fBTBthick/2., fBTBlength/2.);
1249   TGeoTranslation *base2Tr = new TGeoTranslation("ITSsddBTBtr2",
1250                                  fBTBaxisAtoBottom - base2width/2.,
1251                                  -(fBTBaxisAtoBase-fBTBthick/2.), 0);
1252   base2Tr->RegisterYourself();
1253
1254   TGeoBBox *side = new TGeoBBox( "ITSsddBTBside",
1255                                  fBTBthick/2., dy/2., fBTBlength/2.);
1256   TGeoTranslation *sideTr1 = new TGeoTranslation("ITSsddBTBsideTr1",
1257                                  -fRadiusAminBTB-fBTBthick/2., -dy/2., 0);
1258   TGeoTranslation *sideTr2 = new TGeoTranslation("ITSsddBTBsideTr2",
1259                                  fRadiusAminBTB+fBTBthick/2., -dy/2., 0);
1260   sideTr1->RegisterYourself();
1261   sideTr2->RegisterYourself();
1262
1263   TGeoBBox *hole = new TGeoBBox( "ITSsddBTBhole", fBTBHolewidth/2.,
1264                                  fBTBthick/2., fBTBHoleLength/2.);
1265   TGeoTranslation *holeTr1 = new TGeoTranslation("ITSsddBTBholeTr1",
1266                                  - fBTBHoleRefX + fBTBHolewidth/2.,
1267                                  - (fBTBaxisAtoBase-fBTBthick/2.),
1268                                  fBTBHoleRefY+(fBTBHoleLength-fBTBlength)/2.);
1269   TGeoTranslation *holeTr2 = new TGeoTranslation("ITSsddBTBholeTr2",
1270                                  - fBTBHoleRefX + fBTBHolewidth/2.,
1271                                  - (fBTBaxisAtoBase-fBTBthick/2.),
1272                                  - fBTBHoleRefY-(fBTBHoleLength-fBTBlength)/2.);
1273   holeTr1->RegisterYourself();
1274   holeTr2->RegisterYourself();
1275
1276   Double_t radiusAmaxBTB = fRadiusAminBTB + fBTBthick;
1277   TGeoTubeSeg *mainAxis = new TGeoTubeSeg( "ITSsddBTBmainAxis",
1278                                            fRadiusAminBTB, radiusAmaxBTB,
1279                                            fBTBlength/2., 0., 180.);
1280   TGeoTubeSeg *round1 = new TGeoTubeSeg( "ITSsddBTBround1",
1281                            fRadiusBminBTB, fRadiusBminBTB+fBTBthick,
1282                            fBTBlength/2., 270., 360.);
1283   TGeoTranslation *roundTr1 = new TGeoTranslation("ITSsddBTBround1Tr",
1284                                   -(fRadiusAminBTB+fBTBthick+fRadiusBminBTB),
1285                                   -dy, 0);
1286   roundTr1->RegisterYourself();
1287
1288   TGeoTubeSeg *round2 = new TGeoTubeSeg( "ITSsddBTBround2",
1289                            fRadiusBminBTB, fRadiusBminBTB+fBTBthick,
1290                            fBTBlength/2., 180., 270.);
1291   TGeoTranslation *roundTr2 = new TGeoTranslation("ITSsddBTBround2Tr",
1292                                   (fRadiusAminBTB+fBTBthick+fRadiusBminBTB),
1293                                   -dy, 0);
1294   roundTr2->RegisterYourself();
1295
1296   TGeoCompositeShape *sBaseThermalBridge = new TGeoCompositeShape(
1297                                       "ITSsddBaseThermalBridgeShape",
1298                                       "ITSsddBTBbase1:ITSsddBTBtr1"
1299                                       "+ ITSsddBTBbase2:ITSsddBTBtr2"
1300                                       "+ ITSsddBTBround1:ITSsddBTBround1Tr"
1301                                       "+ ITSsddBTBround2:ITSsddBTBround2Tr"
1302                                       "+ ITSsddBTBside:ITSsddBTBsideTr1"
1303                                       "+ ITSsddBTBside:ITSsddBTBsideTr2"
1304                                       "- ITSsddBTBhole:ITSsddBTBholeTr1"
1305                                       "- ITSsddBTBhole:ITSsddBTBholeTr2"
1306                                       "+ ITSsddBTBmainAxis");
1307
1308     if(GetDebug(3)){// Remove compiler warning.
1309         base1->InspectShape();
1310         base2->InspectShape();
1311         side->InspectShape();
1312         hole->InspectShape();
1313         mainAxis->InspectShape();
1314         round1->InspectShape();
1315         round2->InspectShape();
1316     };
1317
1318   TGeoMedium *carbonFiberLadderStruct = gGeoManager->GetMedium("ITSsddCarbonFiber");
1319   TGeoVolume *vBaseThermalBridge = new TGeoVolume( "ITSsddBaseThermalBridge",
1320                                                    sBaseThermalBridge,
1321                                                    carbonFiberLadderStruct);
1322
1323   vBaseThermalBridge->SetLineColor(fColorCarbonFiber);
1324   return vBaseThermalBridge;
1325 };
1326
1327
1328
1329
1330 //________________________________________________________________________
1331 TGeoVolume* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay, Int_t) {
1332     // Return a box volume containing a end of a CF ladder.
1333
1334     Double_t tDY = -0.5; //space left on top of the ladder
1335
1336     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
1337     TGeoMedium *carbonFiberLadderStruct = gGeoManager->GetMedium(
1338                                           "ITSsddCarbonFiber");
1339     Double_t length = 0;
1340     Double_t coolPipeSuppH = 0;
1341
1342      if (iLay==3) {
1343        length = (fLay3LadderLength-fLay3Ndet*fSegmentLength)/2.;
1344        coolPipeSuppH = fLay3CoolPipeSuppH;
1345      } else {
1346        length = (fLay4LadderLength-fLay4Ndet*fSegmentLength)/2.;
1347        coolPipeSuppH = fLay4CoolPipeSuppH;
1348      };
1349     
1350     Double_t segmentLength = fSegmentLength;
1351     Double_t topCornerLength = fSegmentLength/2.-fLay4LaddTopCornerEnd;
1352
1353     TGeoBBox *endBox = new TGeoBBox("ITSsddEndLaddBox",
1354                                     //(fLadderWidth+fPinSuppWidth)/2,
1355                                     (fLadderWidth)/2,
1356                                     fLadderHeight/2+TMath::Abs(tDY),
1357                                     length/2);
1358     TGeoVolume *virtualEnd = new TGeoVolume("ITSsddEnd",endBox, airSDD);
1359
1360     //**********************************
1361     // coding real matter :
1362     //**********************************
1363     Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
1364     Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
1365     Double_t beta = (TMath::Pi()-2.*halfTheta)/4.;
1366     Double_t alpha = TMath::Pi()*3./4. - halfTheta/2.;
1367
1368     //--- The 3 V shape corners of the Carbon Fiber Ladder
1369     //--- the top V
1370     TGeoArb8 *cfLaddTop1 = CreateLadderSide( topCornerLength/2., halfTheta, -1,
1371                                              fLadderLa, fLadderHa, fLadderl);
1372     TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
1373                                           cfLaddTop1,carbonFiberLadderStruct);
1374     cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
1375     TGeoArb8 *cfLaddTop2 = CreateLadderSide( topCornerLength/2., halfTheta, 1,
1376                                              fLadderLa, fLadderHa, fLadderl);
1377     TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
1378                                         cfLaddTop2,carbonFiberLadderStruct);
1379     cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
1380     TGeoTranslation *trTop1 = new TGeoTranslation(0, fLadderHeight/2+tDY,
1381                                                -(length-topCornerLength)/2.);
1382     virtualEnd->AddNode(cfLaddTopVol1, 1, trTop1);
1383     virtualEnd->AddNode(cfLaddTopVol2, 1, trTop1);
1384
1385     //--- the 2 side V
1386     TGeoArb8 *cfLaddSide1 = CreateLadderSide( length/2., beta, -1,
1387                                               fLadderLb, fLadderHb, fLadderl);
1388     TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
1389                                           cfLaddSide1,carbonFiberLadderStruct);
1390     cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
1391     TGeoArb8 *cfLaddSide2 = CreateLadderSide( length/2., beta, 1,
1392                                               fLadderLb, fLadderHb, fLadderl);
1393     TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
1394                                           cfLaddSide2,carbonFiberLadderStruct);
1395     cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
1396     Double_t dYTranslation = ( fLadderHeight/2. - 0.5*fLadderWidth*
1397                                TMath::Tan(beta) - fLadderBeamRadius );
1398
1399     // because center of the triangle doesn't correspond to virtual vol. center
1400     Double_t distCenterSideDown =  0.5*fLadderWidth/TMath::Cos(beta);
1401     TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
1402                                                alpha*TMath::RadToDeg());
1403     AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+tDY, 0);
1404     TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown, 0, 
1405                                                -alpha*TMath::RadToDeg());
1406     AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+tDY, 0);
1407     virtualEnd->AddNode(cfLaddSideVol1, 1, ctSideR);
1408     virtualEnd->AddNode(cfLaddSideVol2, 1, ctSideR);
1409     virtualEnd->AddNode(cfLaddSideVol1, 2, ctSideL);
1410     virtualEnd->AddNode(cfLaddSideVol2, 2, ctSideL);
1411
1412     //--- The beams
1413     // Beams on the sides
1414     Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
1415                 TMath::Sin(2*beta)/(TanD(fBeamSidePhi)*TanD(fBeamSidePhi))) ));
1416     if(GetDebug(3)) cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
1417      Double_t beamLength = TMath::Sqrt( fLadderHeight*fLadderHeight/
1418                            (TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
1419                            +fLadderWidth*fLadderWidth/4.)-fLadderLa/2-fLadderLb/2;
1420      TGeoTubeSeg *sideBeam = new TGeoTubeSeg( 0, fLadderBeamRadius,
1421                                               beamLength/2., 0, 180);
1422      TGeoVolume *cfSideBeamVol = new TGeoVolume("ITSsddCFSideBeamVol",
1423                                       sideBeam, carbonFiberLadderStruct);
1424      cfSideBeamVol->SetLineColor(fColorCarbonFiber);
1425
1426      //Euler rotation : about Z, then new X, then new Z
1427      TGeoRotation *beamRot1 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
1428                                   -beamPhiPrime*TMath::RadToDeg(), -90);
1429      TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
1430                                        TMath::Tan(halfTheta),
1431                                        fLadderBeamRadius/2. + tDY,
1432                                        -length/2 + segmentLength/8, beamRot1);
1433      TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
1434                                   beamPhiPrime*TMath::RadToDeg(), -90);
1435      TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans( 0.5*triangleHeight*
1436                                        TMath::Tan(halfTheta),
1437                                        fLadderBeamRadius/2.+tDY,
1438                                        -length/2 + 3*segmentLength/8, beamRot2);
1439      TGeoRotation *beamRot3 = new TGeoRotation("",90+2.*beta*TMath::RadToDeg(),
1440                                   beamPhiPrime*TMath::RadToDeg(), -90);
1441      TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
1442                                        TMath::Tan(halfTheta),
1443                                        fLadderBeamRadius/2.+tDY,
1444                                        -length/2 + segmentLength/8, beamRot3);
1445      TGeoRotation *beamRot4 = new TGeoRotation("",90 + 2.*beta*TMath::RadToDeg(),
1446                                   -beamPhiPrime*TMath::RadToDeg(), -90);
1447      TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
1448                                        TMath::Tan(halfTheta),
1449                                        fLadderBeamRadius/2. + tDY,
1450                                        -length/2+3*segmentLength/8, beamRot4);
1451      virtualEnd->AddNode(cfSideBeamVol, 1, beamTransf1);
1452      virtualEnd->AddNode(cfSideBeamVol, 2, beamTransf3);
1453      virtualEnd->AddNode(cfSideBeamVol, 3, beamTransf5);
1454      virtualEnd->AddNode(cfSideBeamVol, 4, beamTransf7);
1455
1456      //--- Beams of the bottom
1457      TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fLadderBeamRadius,
1458                                     fLadderWidth/2.-fLadderLb/3, 0, 180);
1459      TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
1460                                       bottomBeam1, carbonFiberLadderStruct);
1461      bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
1462      TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
1463      TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
1464                             -(fLadderHeight/2-fLadderBeamRadius)+tDY,
1465                             -length/2+fSegmentLength/2, bottomBeamRot1);
1466      virtualEnd->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
1467      TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fLadderBeamRadius,
1468                                     fLadderWidth/2.-fLadderLb/3, 0, 90);
1469      TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
1470                                       bottomBeam2, carbonFiberLadderStruct);
1471      bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
1472      TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
1473            -(fLadderHeight/2-fLadderBeamRadius)+tDY,-length/2, bottomBeamRot1);
1474      virtualEnd->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
1475
1476      //**********************************
1477      //the cooling pipe supports
1478      Double_t triangleCPaxeDist = fCoolPipeSuppAxeDist-fCoolPipeSuppWidthExt-
1479                                   fCoolPipeSuppWidthIn+fLadderBeamRadius;
1480
1481      Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
1482                               (triangleHeight+triangleCPaxeDist/
1483                                TMath::Sin(halfTheta) - coolPipeSuppH);
1484      TGeoRotation *rotCPS2 = new TGeoRotation("",-halfTheta*TMath::RadToDeg(),-90,90);
1485      TGeoRotation *rotCPS1 = new TGeoRotation("",halfTheta*TMath::RadToDeg(),-90,-90);
1486      TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
1487                                      -fLadderHeight/2.-TMath::Abs(tDY)+
1488                                      coolPipeSuppH+fLadderBeamRadius,
1489                                      -length/2., rotCPS1);
1490      TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
1491                                      -fLadderHeight/2.-TMath::Abs(tDY)+
1492                                      coolPipeSuppH+fLadderBeamRadius,
1493                                      -length/2., rotCPS2);
1494
1495      TGeoVolume *coolPipeSuppLeft = CreateCoolPipeSupportL();
1496      virtualEnd->AddNode(coolPipeSuppLeft, 1, transCPS1);
1497      TGeoVolume *coolPipeSuppRight = CreateCoolPipeSupportR();
1498      virtualEnd->AddNode(coolPipeSuppRight, 1, transCPS4);
1499      //**********************************
1500      virtualEnd->SetVisibility(kFALSE);
1501      return virtualEnd;
1502 };
1503
1504
1505 //________________________________________________________________________
1506 TGeoVolume* AliITSv11GeometrySDD::CreateSDDsensor() {
1507     // return a box containing the SDD sensor
1508
1509     TGeoBBox *sensorBox = new TGeoBBox("ITSsddSensorBox",
1510                                   fWaferWidth/2, fWaferThickness/2,fWaferLength/2);
1511     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
1512     TGeoVolume *virtualSensor = new TGeoVolume("ITSsddSensor",sensorBox,airSDD);
1513
1514     // the virtual volume is already following the cood convention
1515     // for the local wafer coord. system : no need for additional rotation matrix
1516     TGeoBBox *waferShape = new TGeoBBox("ITSsddWaferShape",
1517                                   fWaferWidth/2, fWaferThickness/2,fWaferLength/2);
1518
1519     //medium = silicon ?                              To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1520     TGeoMedium *siliconSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
1521     TGeoVolume *sensor = new TGeoVolume("ITSsddWafer", waferShape, siliconSDD);
1522     sensor->SetLineColor(fColorSilicon);
1523     virtualSensor->AddNode(sensor, 1, 0);
1524
1525     virtualSensor->SetVisibility(kFALSE);
1526     return virtualSensor;
1527 };
1528
1529
1530 //________________________________________________________________________
1531 TGeoVolume *AliITSv11GeometrySDD::CreateLay3Detectors() {
1532     // return a box volume containing the detectors
1533
1534     TGeoBBox *detBox = new TGeoBBox("ITSssdDetBox3",
1535                                     fWaferWidth/2,
1536                                     (fLadWaferSep + 2*fWaferThickness)/2,
1537                              fLay3LadderLength*((fLay3Ndet-0.5)/fLay3Ndet)/2);
1538     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
1539     TGeoVolume *virtualDet = new TGeoVolume("ITSsddDet3",detBox, airSDD);
1540     TGeoVolume *vSDD = CreateSDDsensor();
1541     char transName[30];
1542  
1543     Int_t iSegmentMin = 0;
1544     Int_t iSegmentMax = fLay3Ndet;
1545     if (fAddOnlySegment>=0) {
1546         iSegmentMin = fAddOnlySegment;
1547         iSegmentMax = fAddOnlySegment+1;
1548     };
1549
1550     for (Int_t i=iSegmentMin; i<iSegmentMax; i++) {
1551         Double_t localZ = fLay3sensorZPos[i];
1552         Double_t localY = fLadWaferSep/2+fWaferThickness/2;
1553         if (i%2!=0)
1554             localY = -localY;
1555         sprintf(transName, "ITSsddLay3SensorPos%i", i);
1556         TGeoTranslation *sensorPos = new TGeoTranslation(transName,0,localY,
1557                                                          localZ);
1558         virtualDet->AddNode(vSDD, i, sensorPos);
1559     }
1560     virtualDet->SetVisibility(kFALSE);
1561     return virtualDet;
1562 };
1563
1564
1565 //________________________________________________________________________
1566 void AliITSv11GeometrySDD::Layer4(TGeoVolume *Moth) {
1567     // Insert the layer 4 in the mother volume. This is a virtual volume
1568     // containing ladders of layer 4 and the supporting rings
1569
1570     TGeoTube *virtualLayer4Shape =new TGeoTube("ITSsddLayer4Shape",
1571                                         fLay4Rmin,fLay4Rmax,fLay4Length*0.5);
1572     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
1573     TGeoVolume *virtualLayer4 = new TGeoVolume("ITSsddLayer4",
1574                                           virtualLayer4Shape, airSDD);
1575     TGeoVolume *lay4Ladder = CreateLay4Ladder();
1576     TGeoVolume *lay4Detectors = CreateLay4Detectors();
1577     Double_t dPhi = 360./fLay4Nladd;
1578     Double_t detBoxThickness = fLadWaferSep + 2*fWaferThickness;
1579     // placing virtual ladder and detectors volumes following ladder 
1580     // ordering convention
1581     char rotName[20];
1582     Int_t iLaddMin = 0;
1583     Int_t iLaddMax = fLay4Nladd;
1584     if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fLay4Nladd)) {
1585         iLaddMin = fAddOnlyLadder4min;
1586         iLaddMax = fAddOnlyLadder4max+1;
1587     }
1588     for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
1589         sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
1590         Double_t minRadiusLadBox = fLay4LaddShortRadius;
1591         if (iLadd%2 != 0)
1592             minRadiusLadBox = fLay4LaddLongRadius;
1593         minRadiusLadBox += ((TGeoBBox*)lay4Ladder->GetShape())->GetDY();
1594         TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName, minRadiusLadBox,
1595                                                   0, -90+iLadd*dPhi);
1596         virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
1597         sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
1598         Double_t minRadiusDetBox = fLay4DetShortRadius;
1599         if (iLadd%2 != 0)
1600             minRadiusDetBox = fLay4DetLongRadius;
1601         minRadiusDetBox += detBoxThickness/2;
1602         TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
1603                                                  0, -90+iLadd*dPhi);
1604         virtualLayer4->AddNode(lay4Detectors, iLadd, ctDet);
1605     }
1606     virtualLayer4->SetVisibility(kFALSE);
1607     Moth->AddNode(virtualLayer4,1,0);
1608 };
1609
1610
1611 //________________________________________________________________________
1612 TGeoVolume *AliITSv11GeometrySDD::CreateLay4Ladder() {
1613     // return a box volume containing the CF ladder and all pieces on it
1614
1615     TGeoVolume *laddSegmentTemp = CreateLadderSegment(4,0);
1616     TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
1617                            ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDX(),
1618                            ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDY(),
1619                            //dX,dY = dX,dY of the segment
1620                            fLay4LadderLength/2);  
1621     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
1622     TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
1623     Double_t segmentLength = fSegmentLength;
1624     char transName[20];
1625     // placing virtual ladder segment following detector ordering convention
1626     //=======================================================================
1627     Int_t iSegmentMin = 0;
1628     Int_t iSegmentMax = fLay4Ndet;
1629     if (fAddOnlySegment>=0) {
1630         iSegmentMin = fAddOnlySegment;
1631         iSegmentMax = fAddOnlySegment+1;
1632     }
1633     for (Int_t iSegment= iSegmentMin; iSegment < iSegmentMax; iSegment++ ) {
1634
1635         TGeoVolume *laddSegment = CreateLadderSegment(4, iSegment);
1636         sprintf(transName, "ITSsddLay4LaddSeg%i", iSegment);
1637         Double_t segmentPos = segmentLength*(fLay4Ndet/2-1-iSegment) +
1638                               segmentLength/2;
1639         TGeoTranslation *segTr = new TGeoTranslation(transName,0,0,segmentPos);
1640         virtualLadder->AddNode(laddSegment, iSegment, segTr);
1641     }
1642     // putting virtual volume corresponding to the end of ladder
1643     //=======================================================================
1644     TGeoVolume *endLadder = CreateEndLadder( 4,-1 );
1645     Double_t endLength = (fLay4LadderLength-fLay4Ndet*fSegmentLength)/2.;
1646     TGeoTranslation *endTrZPos =
1647         new TGeoTranslation("ITSsddEndTrZPos",0,0,
1648                             fSegmentLength*(fLay4Ndet/2)+endLength/2.);
1649     //Euler rotation : about Z, then new X, then new Z
1650     TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
1651     TGeoCombiTrans *endTrZNeg =
1652         new TGeoCombiTrans(0,0,-fSegmentLength*(fLay4Ndet/2)-endLength/2.,
1653                            endZNegRot);
1654     if ((fAddOnlySegment==-1)||(fAddOnlySegment==0))
1655         virtualLadder->AddNode(endLadder, 1, endTrZPos);
1656     if ((fAddOnlySegment==-1)||(fAddOnlySegment==fLay4Ndet-1))
1657         virtualLadder->AddNode(endLadder, 2, endTrZNeg);
1658     virtualLadder->SetVisibility(kFALSE);
1659     return virtualLadder;
1660 };
1661
1662
1663 //________________________________________________________________________
1664 TGeoVolume *AliITSv11GeometrySDD::CreateLay4Detectors() {
1665     // return a box volume containing the detectors
1666
1667     TGeoBBox *detBox = new TGeoBBox("ITSssdDetBox4",
1668                            fWaferWidth/2,
1669                            (fLadWaferSep + 2*fWaferThickness)/2,
1670                            fLay4LadderLength*((fLay4Ndet-0.5)/fLay4Ndet)/2);
1671     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
1672     TGeoVolume *virtualDet = new TGeoVolume("ITSsddDet4",detBox, airSDD);
1673     TGeoVolume *vSDD = CreateSDDsensor();
1674     char transName[30];
1675     Int_t iSegmentMin = 0;
1676     Int_t iSegmentMax = fLay4Ndet;
1677     if (fAddOnlySegment>=0) {
1678         iSegmentMin = fAddOnlySegment;
1679         iSegmentMax = fAddOnlySegment+1;
1680     }
1681
1682     for (Int_t i=iSegmentMin; i<iSegmentMax; i++) {
1683
1684         Double_t localZ = fLay4sensorZPos[i];
1685         Double_t localY = fLadWaferSep/2+fWaferThickness/2;
1686         if (i%2==0)
1687             localY = -localY;
1688         sprintf(transName, "ITSsddLay4SensorPos%i", i);
1689         TGeoTranslation *sensorPos = new TGeoTranslation(transName, 0,
1690                                                          localY, localZ);
1691         virtualDet->AddNode(vSDD, i, sensorPos);
1692     }
1693     virtualDet->SetVisibility(kFALSE);
1694     return virtualDet;
1695 };