]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSv11GeometrySDD.cxx
Replace plane by layer and chamber by stack
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySDD.cxx
index 405fb064cfd687ec6bd271ce7de425a7c07dc42f..9695bc0eec825f09be92df4c98475143e2034693 100755 (executable)
@@ -11,7 +11,7 @@
  * appear in the supporting documentation. The authors make no claims     *
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
- *********************************s*****************************************/
+ **************************************************************************/
 
 
 //*************************************************************************
@@ -42,6 +42,7 @@
 #include <TGeoCompositeShape.h>
 #include <TGeoMatrix.h>
 #include <TGeoNode.h>
+#include <TGeoPcon.h>
 
 #include "AliITSgeom.h"
 #include "AliITSgeomSDD.h"
@@ -105,8 +106,8 @@ const Double_t AliITSv11GeometrySDD::fgkBTBHolewidth       =  6 *fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkBTBHoleRefX        = 10 *fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkBTBHoleRefY        =  6.5 *fgkmm;
 
-const Double_t AliITSv11GeometrySDD::fgkLay3Rmin           = 145.*fgkmm;      // not min! Rmin virtual tube
-const Double_t AliITSv11GeometrySDD::fgkLay3Rmax           = 205.*fgkmm;      // not min! Rmax virtual tube
+const Double_t AliITSv11GeometrySDD::fgkLay3Rmin           = 145.*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLay3Rmax           = 200.*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLay3Length         = (524.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
 const Double_t AliITSv11GeometrySDD::fgkLay3LadderLength   = 524.*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLay3DetShortRadius = 146.0*fgkmm;
@@ -116,8 +117,8 @@ const Int_t    AliITSv11GeometrySDD::fgkLay3Ndet           =  6;
 const Int_t    AliITSv11GeometrySDD::fgkLay3Nladd          = 14;
 const Double_t AliITSv11GeometrySDD::fgkLay3CoolPipeSuppH  =  7.5*fgkmm;
 
-const Double_t AliITSv11GeometrySDD::fgkLay4Rmin           = 220.*fgkmm;         // not min! Rmin virtual tube
-const Double_t AliITSv11GeometrySDD::fgkLay4Rmax           = 290.*fgkmm;         // not min! Rmax virtual tube
+const Double_t AliITSv11GeometrySDD::fgkLay4Rmin           = 235.*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLay4Rmax           = 286.*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLay4Length         = (671.+0.)*fgkmm;    // ladder+supporting rings (length of the virtual tube)
 const Double_t AliITSv11GeometrySDD::fgkLay4LadderLength   = 671.*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLay4DetShortRadius = 235.0*fgkmm;
@@ -127,6 +128,10 @@ const Int_t    AliITSv11GeometrySDD::fgkLay4Ndet           = 8;
 const Int_t    AliITSv11GeometrySDD::fgkLay4Nladd          = 22;
 const Double_t AliITSv11GeometrySDD::fgkLay4CoolPipeSuppH  = 7.5*fgkmm;
 
+const Double_t AliITSv11GeometrySDD::fgkEndLaddCardsShortRadiusLay3 = fgkLay3DetShortRadius;
+const Double_t AliITSv11GeometrySDD::fgkEndLaddCardsShortRadiusLay4 = fgkLay4DetShortRadius;
+const Double_t AliITSv11GeometrySDD::fgkDistEndLaddCardsLadd = 0.*fgkmm;
+
 //hybrid 
 const Double_t AliITSv11GeometrySDD::fgkHybridAngle       = 46;           // approx !!!
 // Origine taken at the hybrid corner :
@@ -190,7 +195,8 @@ const Double_t AliITSv11GeometrySDD::fgkWaferWidth         =  72.5 *fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkWaferLength        =  87.6 *fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkWaferThickSens     = 299.8*fgkmu;
 const Double_t AliITSv11GeometrySDD::fgkWaferWidthSens     =  70.17*fgkmm;
-const Double_t AliITSv11GeometrySDD::fgkWaferLengthSens    =  74.97*fgkmm;
+// 256 anodes times 294 microns of pitch
+const Double_t AliITSv11GeometrySDD::fgkWaferLengthSens    =  256*294*fgkmicron;
 
 const Double_t AliITSv11GeometrySDD::fgkDigitCablWidth     = 18.4*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkDigitCablAlThick   = (30+30*8./10.)*fgkmicron; // will probably change
@@ -256,11 +262,11 @@ const Double_t AliITSv11GeometrySDD::fgkEndLadPipeOuterDiam   =   3.*fgkmm;
 //--- The al body of the cooling syst.of the heat exchanger :
 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZLay3    = 112.*fgkmm;   //
 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZLay4    = 125.*fgkmm;   //
-const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmX        =   4.75*fgkmm;    // the arms of the U cooling tube
+const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmX        =   4.75*fgkmm; // the arms of the U cooling tube
 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmY        =   6.8*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmBoxDY    =   1.03*fgkmm; // shift in Y of the arms from the axis
-const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmBoxDX    =   0.125*fgkmm;  // shift in X of the arms from the axis
-const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZpos     =   8.9*fgkmm; // 
+const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmBoxDX    =   0.125*fgkmm;// shift in X of the arms from the axis
+const Double_t AliITSv11GeometrySDD::fgkEndLadPipeArmZpos     =   8.9*fgkmm;  // 
 
 // LV card :
 const Double_t AliITSv11GeometrySDD::fgkLVcardX     = 26.525*fgkmm;
@@ -451,6 +457,40 @@ const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeR3   = 3.*fgkmm;  // ??
 const Double_t AliITSv11GeometrySDD::fgkConnectorCoolTubeL3   = 5 *fgkmm;  // ???
 
 
+// parameters for coding SDD cables on SDD and SSD cones
+const Double_t AliITSv11GeometrySDD::fgkSectionCuPerMod = 3*2*0.006 + 3*2*0.0005 + 2*0.002;
+//                                             copper :     LV     +  signal  +  HV(HV ???)
+const Double_t AliITSv11GeometrySDD::fgkSectionPlastPerMod = (TMath::Pi()*(3*0.36*0.36/4 + 3*0.21*0.21/4 + 2*0.115*0.115/4) 
+                                                             - fgkSectionCuPerMod);
+
+const Double_t AliITSv11GeometrySDD::fgkSectionGlassPerMod = 3*0.006; // ???
+// (sections are given in cm square)
+const Double_t AliITSv11GeometrySDD::fgkCableBendRatio = 1.3; // ??? this factor account for the bending of cables
+
+const Double_t AliITSv11GeometrySDD::fgkConeSDDr1 = 11.87574*fgkcm;
+const Double_t AliITSv11GeometrySDD::fgkConeSDDr2 = 26.07574*fgkcm;
+const Double_t AliITSv11GeometrySDD::fgkConeSDDz1 =  3.36066*fgkcm + 186.0*fgkmm + 0.5*790.0*fgkmm - 19.18934*fgkcm - 1.6;
+const Double_t AliITSv11GeometrySDD::fgkConeSDDz2 = 17.56066*fgkcm + 186.0*fgkmm + 0.5*790.0*fgkmm - 19.18934*fgkcm - 1.6;
+// These last parameters come from cone's code and define the slope
+// and position of the SDD cone end.  For some unknown reason, this doesn't
+// allow to stick on the SDD cone. This has to be checked when a correct
+// version of the cone is available ... For now 'm applying some approximative
+// corrections
+
+const Double_t AliITSv11GeometrySDD::fgkSDDCableR1    = 16*fgkcm; // ??? // part 1 of "cable cone"
+const Double_t AliITSv11GeometrySDD::fgkSDDCableR2    = 23*fgkcm; // ??? // part 1/2 of "cable cone"
+const Double_t AliITSv11GeometrySDD::fgkSDDCableR3    = 26*fgkcm; // ??? // part 2 of "cable cone"
+
+const Double_t AliITSv11GeometrySDD::fgkSDDCableDZint =  3.5*fgkcm;
+const Double_t AliITSv11GeometrySDD::fgkSDDCableR5    =  37*fgkcm; // third part of "cable cone"
+const Double_t AliITSv11GeometrySDD::fgkSDDCableZ5    =  65*fgkcm; // third part of "cable cone"
+
+
+
+
+
+
+
 ClassImp(AliITSv11GeometrySDD)
 
 //________________________________________________________________________
@@ -463,6 +503,7 @@ AliITSv11GeometrySDD::AliITSv11GeometrySDD():
   fSDDsensor4(0),
   fBaseThermalBridge(0),
   fHybrid(0),
+  fLadderFoot(0),
   fCardLVR(0),
   fCardLVL(0),
   fCardHV(0),
@@ -517,6 +558,7 @@ AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug) :
   fSDDsensor4(0),
   fBaseThermalBridge(0),
   fHybrid(0),
+  fLadderFoot(0),
   fCardLVR(0),
   fCardLVL(0),
   fCardHV(0),
@@ -570,6 +612,7 @@ AliITSv11GeometrySDD::AliITSv11GeometrySDD(const AliITSv11GeometrySDD &s) :
   fSDDsensor4(s.fSDDsensor4),
   fBaseThermalBridge(s.fBaseThermalBridge),
   fHybrid(s.fHybrid),
+  fLadderFoot(s.fLadderFoot),
   fCardLVR(s.fCardLVR),
   fCardLVL(s.fCardLVL),
   fCardHV(s.fCardHV),
@@ -750,7 +793,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
   TGeoMedium *alSDD           = GetMedium("AL$"); //ITSal
   TGeoMedium *stainless       = GetMedium("INOX$"); // for screws, what is the material ???????????
   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
-  TGeoMedium *raccordMedium   = GetMedium("inox/alum$");  // ??? material of raccordo ???
+  TGeoMedium *raccordMedium   = GetMedium("INOX$");  // ??? material of raccordo ???
 
   //********************************************************************
   // pieces of the carbon fiber structure
@@ -1080,8 +1123,8 @@ void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
   //moth->AddNode(fCardLVL,1,0);
   //moth->AddNode(fCardLVR,1,0);
 
-//    TGeoVolume* seg = CreateLadderSegment( 3, 0);
-//    moth->AddNode(seg, 1, 0);
+   TGeoVolume* seg = CreateLadderSegment( 3, 0);
+   moth->AddNode(seg, 1, 0);
 
 //   TGeoVolumeAssembly *lay3Ladder = CreateLadder(3);
 //   moth->AddNode(lay3Ladder, 1, 0);
@@ -1093,8 +1136,8 @@ void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
 //   moth->AddNode(lay3Detectors, 1, 0);
 
 
-  TGeoVolumeAssembly *endLadder = CreateEndLadder( 4 );
-  moth->AddNode(endLadder, 1, 0);
+//   TGeoVolumeAssembly *endLadder = CreateEndLadder( 4 );
+//   moth->AddNode(endLadder, 1, 0);
 
 //   TGeoVolumeAssembly *highVCard = CreateHVCard( 4 );
 //   moth->AddNode(highVCard, 1, 0);
@@ -1102,11 +1145,54 @@ void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
 //   TGeoVolumeAssembly *supportRing = CreateSupportRing( 4 );
 //   moth->AddNode(supportRing, 1, 0);
 
-//   TGeoVolumeAssembly *endLadderCards = CreateEndLadderCards( 4 );
+//   TGeoVolume *endLadderCards = CreateEndLadderCardsV( 4 );
 //   moth->AddNode(endLadderCards, 1, 0);
 
 //   TGeoVolumeAssembly *carlosCard = CreateCarlosCard( 4 );
 //   moth->AddNode(carlosCard, 1, 0);
+
+
+
+  /*
+  //==================================
+  //--- test of flat cable curvature
+  //==================================
+
+  double angle = 90;
+  AliITSv11GeomCableFlat cable("test", 3, 0.3);
+  cable.SetNLayers(1);
+  cable.SetNLayers(2);
+  cable.SetLayer(0, 0.2, coolerMediumSDD, 2);
+  cable.SetLayer(1, 0.1, coolerMediumSDD, 3);
+  cable.SetInitialNode(endLadderCards);
+
+  Double_t p1[3], p2[3], vX[3] = {1,0,0},vY[3] = {0,5,0};
+
+  p1[0] = -3;
+  p1[1] = 1;
+  p1[2] = 10;
+
+  p2[0] = 0;
+  p2[1] = 1;
+  p2[2] = 10;
+  cable.AddCheckPoint(endLadderCards, 0, p1, vX);
+  cable.AddCheckPoint(endLadderCards, 1, p2, vX);
+  cable.CreateAndInsertBoxCableSegment(1,angle);
+
+  Double_t p3[3], p4[3];
+
+  p3[0] = 2;
+  p3[1] = 3;
+  p3[2] = 10;
+  cable.AddCheckPoint(endLadderCards, 2, p3, vY);
+  cable.CreateAndInsertCableCylSegment(2,angle);
+
+  p4[0] = 2;
+  p4[1] = 6;
+  p4[2] = 10;
+  cable.AddCheckPoint(endLadderCards, 3, p4, vY);
+  cable.CreateAndInsertCableSegment(3,angle);
+  */
 }
 
 
@@ -1190,23 +1276,33 @@ void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
     ///////////////////////////////////////////////////
   }
 
+  /*
   //====================================
   // Then the forward rapidity pieces
   // (cooling, Carlos, LV, HV ...)
   //====================================
 
-  Double_t fgkForwardLay3Length = 200*fgkmm;  // this has to be tune !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  Double_t fgkForwardLay3Rmin = fgkLay3Rmin-10*fgkmm;
-  Double_t fgkForwardLay3Rmax = fgkLay3Rmax;
+  Double_t fgkForwardLay3Length = fgkEndLadPipeUlengthLay3+10*fgkmm;  // this has to be tune
+  Double_t fgkForwardLay3Rmin = fgkLay3Rmin-7*fgkmm;
+  Double_t fgkForwardLay3Rmax = fgkLay3Rmax-5*fgkmm;
 
   TGeoVolumeAssembly* lay3EndLadder = CreateEndLadderCards(3);
   TGeoTube *virtualForward3Shape = new TGeoTube("virtualForward3Shape",
                                                fgkForwardLay3Rmin, fgkForwardLay3Rmax,
                                                fgkForwardLay3Length/2.);
+
+//   TGeoPcon *virtualForward3Shape = new TGeoPcon("virtualForward3Shape",0,360,2);
+// // virtualForward3Shape->DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax);
+//   virtualForward3Shape->DefineSection(0, Double_t z, Double_t rmin, Double_t rmax);
+
+
   TGeoVolume *virtualForward3Pos = new TGeoVolume("ITSsddForward3Pos",
                                                  virtualForward3Shape, airSDD);
   TGeoVolume *virtualForward3Neg = new TGeoVolume("ITSsddForward3Neg",
                                                  virtualForward3Shape, airSDD);
+//   TGeoVolume *virtualForward3Neg = new TGeoVolumeAssembly("ITSsddForward3Neg");
+//   TGeoVolume *virtualForward3Pos = new TGeoVolumeAssembly("ITSsddForward3Pos");
+
   TGeoTranslation *virtualForward3TrPos = new TGeoTranslation("virtualForward3TrPos",0,0,
                                          fgkLay3Length/2+fgkForwardLay3Length/2);
   TGeoTranslation *virtualForward3TrNeg = new TGeoTranslation("virtualForward3TrNeg",0,0,
@@ -1230,22 +1326,171 @@ void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
     virtualForward3Neg->AddNode(lay3EndLadder, iLadd*2, ctEndLaddNeg);
   }
 
+  */
+
+
   if(GetDebug(1)) {
     virtualLayer3->CheckOverlaps(0.01);
-    virtualForward3Pos->CheckOverlaps(0.01);
-    virtualForward3Neg->CheckOverlaps(0.01);
+    //virtualForward3Pos->CheckOverlaps(0.01);
+    //virtualForward3Neg->CheckOverlaps(0.01);
   }
 
   virtualLayer3->SetVisibility(kFALSE);
-  virtualForward3Pos->SetVisibility(kFALSE);
-  virtualForward3Neg->SetVisibility(kFALSE);
+  //virtualForward3Pos->SetVisibility(kFALSE);
+  //virtualForward3Neg->SetVisibility(kFALSE);
+
 
   moth->AddNode(virtualLayer3, 1, 0);
-  moth->AddNode(virtualForward3Pos, 1, virtualForward3TrPos);
-  moth->AddNode(virtualForward3Neg, 1, virtualForward3TrNeg);
+  //moth->AddNode(virtualForward3Pos, 1, virtualForward3TrPos);
+  //moth->AddNode(virtualForward3Neg, 1, virtualForward3TrNeg);
 }
 
 
+// //________________________________________________________________________
+// void AliITSv11GeometrySDD::ForwardLayer3(TGeoVolume *moth) {
+//   //
+//   // Insert the forward pieces of layer 3 in the mother volume. 
+//   // (cooling, Carlos, LV, HV ...)
+//   //
+
+//   if (! moth) {
+//     printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
+//     return;
+//   };
+
+//   TGeoMedium *airSDD = GetMedium("SDD AIR$");
+
+//   if (! fSDDsensor3) CreateBasicObjects();
+
+//   Double_t dPhi = 360./fgkLay3Nladd;
+//   Double_t detectorsThick = fgkLadWaferSep + 2*fgkWaferThickness;
+//   Int_t iLaddMin = 0;
+//   Int_t iLaddMax = fgkLay3Nladd;
+//   if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
+//     iLaddMin = fAddOnlyLadder3min;
+//     iLaddMax = fAddOnlyLadder3max+1;
+//   };
+//   char rotName[30];
+
+
+//   //=================
+
+//   Double_t fgkForwardLay3Length = fgkEndLadPipeUlengthLay3+10*fgkmm;  // this has to be tune
+//   Double_t fgkForwardLay3Rmin = fgkLay3Rmin-7*fgkmm;
+//   Double_t fgkForwardLay3Rmax = fgkLay3Rmax-5*fgkmm;
+
+//   TGeoVolumeAssembly* lay3EndLadder = CreateEndLadderCards(3);
+//   TGeoTube *virtualForward3Shape = new TGeoTube("virtualForward3Shape",
+//                                             fgkForwardLay3Rmin, fgkForwardLay3Rmax,
+//                                             fgkForwardLay3Length/2.);
+
+// //   TGeoPcon *virtualForward3Shape = new TGeoPcon("virtualForward3Shape",0,360,2);
+// // // virtualForward3Shape->DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax);
+// //   virtualForward3Shape->DefineSection(0, Double_t z, Double_t rmin, Double_t rmax);
+
+
+//   TGeoVolume *virtualForward3Pos = new TGeoVolume("ITSsddForward3Pos",
+//                                               virtualForward3Shape, airSDD);
+//   TGeoVolume *virtualForward3Neg = new TGeoVolume("ITSsddForward3Neg",
+//                                               virtualForward3Shape, airSDD);
+// //   TGeoVolume *virtualForward3Neg = new TGeoVolumeAssembly("ITSsddForward3Neg");
+// //   TGeoVolume *virtualForward3Pos = new TGeoVolumeAssembly("ITSsddForward3Pos");
+
+//   TGeoTranslation *virtualForward3TrPos = new TGeoTranslation("virtualForward3TrPos",0,0,
+//                                       fgkLay3Length/2+fgkForwardLay3Length/2);
+//   TGeoTranslation *virtualForward3TrNeg = new TGeoTranslation("virtualForward3TrNeg",0,0,
+//                                       -fgkLay3Length/2-fgkForwardLay3Length/2);
+
+//   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
+
+//     Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
+//     Double_t minRadiusDetBox = fgkLay3DetShortRadius;
+//     if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
+//     minRadiusDetBox += detectorsThick/2;
+
+//     sprintf(rotName, "ITSsddLay3EndLadd%i",iLadd);
+
+//     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
+//                                -fgkForwardLay3Length/2, ladderPhi, kTRUE);
+//     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
+//                                fgkForwardLay3Length/2, ladderPhi, kFALSE);
+
+//     virtualForward3Pos->AddNode(lay3EndLadder, iLadd*2, ctEndLaddPos);
+//     virtualForward3Neg->AddNode(lay3EndLadder, iLadd*2, ctEndLaddNeg);
+//   }
+
+//   if(GetDebug(1)) {
+//     virtualForward3Pos->CheckOverlaps(0.01);
+//     virtualForward3Neg->CheckOverlaps(0.01);
+//   }
+
+//   virtualForward3Pos->SetVisibility(kFALSE);
+//   virtualForward3Neg->SetVisibility(kFALSE);
+
+//   moth->AddNode(virtualForward3Pos, 1, virtualForward3TrPos);
+//   moth->AddNode(virtualForward3Neg, 1, virtualForward3TrNeg);
+// }
+
+
+
+//________________________________________________________________________
+void AliITSv11GeometrySDD::ForwardLayer3(TGeoVolume *moth) {
+  //
+  // Insert the end-ladder of layer 3 in the mother volume. 
+  // (cooling, Carlos, LV, HV ...)
+  //
+
+  if (! moth) {
+    printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
+    return;
+  };
+
+  if (! fSDDsensor3) CreateBasicObjects();
+
+  Int_t iLaddMin = 0;
+  Int_t iLaddMax = fgkLay3Nladd;
+  if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
+    iLaddMin = fAddOnlyLadder3min;
+    iLaddMax = fAddOnlyLadder3max+1;
+  };
+
+  TGeoVolume *virtualForward3Neg = new TGeoVolumeAssembly("ITSsddForward3Neg");
+  TGeoVolume *virtualForward3Pos = new TGeoVolumeAssembly("ITSsddForward3Pos");
+
+  char rotName[30];
+  Double_t dPhi = 360./fgkLay3Nladd;
+  TGeoVolume* lay3EndLadder = CreateEndLadderCardsV(3);
+
+  for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
+
+    Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
+    Double_t dR = 0;
+    if (iLadd%2 != 0) dR = fgkLay3DetLongRadius-fgkLay3DetShortRadius;
+
+    sprintf(rotName, "ITSsddLay3EndLadd%i",iLadd);
+
+    TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, dR,
+                                   fgkLay3Length/2, ladderPhi, kTRUE);
+    TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, dR,
+                                  -fgkLay3Length/2, ladderPhi, kFALSE);
+
+    virtualForward3Pos->AddNode(lay3EndLadder, iLadd*2, ctEndLaddPos);
+    virtualForward3Neg->AddNode(lay3EndLadder, iLadd*2, ctEndLaddNeg);
+  }
+
+  if(GetDebug(1)) {
+    virtualForward3Pos->CheckOverlaps(0.01);
+    virtualForward3Neg->CheckOverlaps(0.01);
+  }
+
+  // 180deg Y rotation to compensate the cancellation of ITSD volume
+  // (idortm[199] in AliITSv11Hybrid : z--->  -z;   x ---> -x;   y ---> y)
+  TGeoRotation *y180 = new TGeoRotation();
+  y180->SetAngles( 90.,180., 90., 90.,180.,  0.);
+  moth->AddNode(virtualForward3Pos, 1, y180);
+  moth->AddNode(virtualForward3Neg, 1, y180);
+}
+
 //________________________________________________________________________
 void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
   //
@@ -1311,14 +1556,15 @@ void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
     ///////////////////////////////////////////////////
   }
 
+  /*
   //====================================
   // Then the pieces at forward rapidity
   // (cooling, Carlos, LV, HV ...)
   //====================================
 
-  Double_t fgkForwardLay4Length = 200*fgkmm;  // this has to be tuned !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  Double_t fgkForwardLay4Rmin = fgkLay4Rmin-10*fgkmm;
-  Double_t fgkForwardLay4Rmax = fgkLay4Rmax;
+  Double_t fgkForwardLay4Length = fgkEndLadPipeUlengthLay4+10*fgkmm;  // this has to be tuned
+  Double_t fgkForwardLay4Rmin = fgkLay4Rmin-9*fgkmm;
+  Double_t fgkForwardLay4Rmax = fgkLay4Rmax-5*fgkmm;
 
   TGeoVolumeAssembly* lay4EndLadder = CreateEndLadderCards(4);
   TGeoTube *virtualForward4Shape = new TGeoTube("virtualForward3Shape",
@@ -1328,6 +1574,9 @@ void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
                                                  virtualForward4Shape, airSDD);
   TGeoVolume *virtualForward4Neg = new TGeoVolume("ITSsddForward4Neg",
                                                  virtualForward4Shape, airSDD);
+//   TGeoVolume *virtualForward4Pos = new TGeoVolumeAssembly("ITSsddForward4Pos");
+//   TGeoVolume *virtualForward4Neg = new TGeoVolumeAssembly("ITSsddForward4Neg");
+
   TGeoTranslation *virtualForward4TrPos = new TGeoTranslation("virtualForward4TrPos",0,0,
                                          fgkLay4Length/2+fgkForwardLay4Length/2);
   TGeoTranslation *virtualForward4TrNeg = new TGeoTranslation("virtualForward4TrNeg",0,0,
@@ -1350,16 +1599,150 @@ void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
     virtualForward4Pos->AddNode(lay4EndLadder, iLadd*2, ctEndLaddPos);
     virtualForward4Neg->AddNode(lay4EndLadder, iLadd*2+1, ctEndLaddNeg);
   }
+  */
 
   if(GetDebug(1)) virtualLayer4->CheckOverlaps(0.01);
 
   virtualLayer4->SetVisibility(kFALSE);
-  virtualForward4Pos->SetVisibility(kFALSE);
-  virtualForward4Neg->SetVisibility(kFALSE);
+  //virtualForward4Pos->SetVisibility(kFALSE);
+  //virtualForward4Neg->SetVisibility(kFALSE);
 
   moth->AddNode(virtualLayer4,1,0);
-  moth->AddNode(virtualForward4Pos, 1, virtualForward4TrPos);
-  moth->AddNode(virtualForward4Neg, 1, virtualForward4TrNeg);
+  //moth->AddNode(virtualForward4Pos, 1, virtualForward4TrPos);
+  //moth->AddNode(virtualForward4Neg, 1, virtualForward4TrNeg);
+}
+
+
+// //________________________________________________________________________
+// void AliITSv11GeometrySDD::ForwardLayer4(TGeoVolume *moth) {
+//   //
+//   // Insert the layer 4 in the mother volume. This is a virtual volume
+//   // containing ladders of layer 4 and the supporting rings
+//   // (cooling, Carlos, LV, HV ...)
+//   //
+
+//   if (! moth) {
+//     printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
+//     return;
+//   };
+
+//   TGeoMedium *airSDD = GetMedium("SDD AIR$");
+
+//   if (! fSDDsensor3) CreateBasicObjects();
+
+//   Double_t dPhi = 360./fgkLay4Nladd;
+//   Double_t detBoxThickness = fgkLadWaferSep + 2*fgkWaferThickness;
+
+//   // placing virtual ladder and detectors volumes following ladder 
+//   // ordering convention
+//   char rotName[20];
+//   Int_t iLaddMin = 0;
+//   Int_t iLaddMax = fgkLay4Nladd;
+//   if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
+//     iLaddMin = fAddOnlyLadder4min;
+//     iLaddMax = fAddOnlyLadder4max+1;
+//   }
+
+//   //=================
+//   Double_t fgkForwardLay4Length = fgkEndLadPipeUlengthLay4+10*fgkmm;  // this has to be tuned
+//   Double_t fgkForwardLay4Rmin = fgkLay4Rmin-9*fgkmm;
+//   Double_t fgkForwardLay4Rmax = fgkLay4Rmax-5*fgkmm;
+
+//   TGeoVolumeAssembly* lay4EndLadder = CreateEndLadderCards(4);
+//   TGeoTube *virtualForward4Shape = new TGeoTube("virtualForward3Shape",
+//                                             fgkForwardLay4Rmin, fgkForwardLay4Rmax,
+//                                             fgkForwardLay4Length/2.);
+//   TGeoVolume *virtualForward4Pos = new TGeoVolume("ITSsddForward4Pos",
+//                                               virtualForward4Shape, airSDD);
+//   TGeoVolume *virtualForward4Neg = new TGeoVolume("ITSsddForward4Neg",
+//                                               virtualForward4Shape, airSDD);
+// //   TGeoVolume *virtualForward4Pos = new TGeoVolumeAssembly("ITSsddForward4Pos");
+// //   TGeoVolume *virtualForward4Neg = new TGeoVolumeAssembly("ITSsddForward4Neg");
+
+//   TGeoTranslation *virtualForward4TrPos = new TGeoTranslation("virtualForward4TrPos",0,0,
+//                                       fgkLay4Length/2+fgkForwardLay4Length/2);
+//   TGeoTranslation *virtualForward4TrNeg = new TGeoTranslation("virtualForward4TrNeg",0,0,
+//                                       -fgkLay4Length/2-fgkForwardLay4Length/2);
+
+//   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
+
+//     Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
+//     Double_t minRadiusDetBox = fgkLay4DetShortRadius;
+//     if (iLadd%2 != 0)
+//       minRadiusDetBox = fgkLay4DetLongRadius;
+//     minRadiusDetBox += detBoxThickness/2;
+
+//     sprintf(rotName, "ITSsddLay4EndLadd%i",iLadd);
+
+//     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
+//                                -fgkForwardLay4Length/2, ladderPhi, kTRUE);
+//     TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, minRadiusDetBox-0.1,
+//                                 fgkForwardLay4Length/2, ladderPhi, kFALSE);
+//     virtualForward4Pos->AddNode(lay4EndLadder, iLadd*2, ctEndLaddPos);
+//     virtualForward4Neg->AddNode(lay4EndLadder, iLadd*2+1, ctEndLaddNeg);
+//   }
+
+//   virtualForward4Pos->SetVisibility(kFALSE);
+//   virtualForward4Neg->SetVisibility(kFALSE);
+
+//   moth->AddNode(virtualForward4Pos, 1, virtualForward4TrPos);
+//   moth->AddNode(virtualForward4Neg, 1, virtualForward4TrNeg);
+// }
+
+
+//________________________________________________________________________
+void AliITSv11GeometrySDD::ForwardLayer4(TGeoVolume *moth) {
+  //
+  // Insert the end-ladder of layer 4 in the mother volume.
+  // (cooling, Carlos, LV, HV ...)
+  //
+
+  if (! moth) {
+    printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
+    return;
+  };
+
+  if (! fSDDsensor3) CreateBasicObjects();
+
+  // placing virtual ladder and detectors volumes following ladder 
+  // ordering convention
+  Int_t iLaddMin = 0;
+  Int_t iLaddMax = fgkLay4Nladd;
+  if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
+    iLaddMin = fAddOnlyLadder4min;
+    iLaddMax = fAddOnlyLadder4max+1;
+  }
+
+  TGeoVolume *virtualForward4Pos = new TGeoVolumeAssembly("ITSsddForward4Pos");
+  TGeoVolume *virtualForward4Neg = new TGeoVolumeAssembly("ITSsddForward4Neg");
+
+  char rotName[30];
+  Double_t dPhi = 360./fgkLay4Nladd;
+  TGeoVolume* lay4EndLadder = CreateEndLadderCardsV(4);
+
+  for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
+
+    Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
+    Double_t dR = 0;
+    if (iLadd%2 != 0)
+      dR = fgkLay4DetLongRadius-fgkLay4DetShortRadius;
+
+    sprintf(rotName, "ITSsddLay4EndLadd%i",iLadd);
+
+    TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, dR,
+                                  fgkLay4Length/2, ladderPhi, kTRUE);
+    TGeoCombiTrans *ctEndLaddNeg = CreateCombiTrans(rotName, dR,
+                                  -fgkLay4Length/2, ladderPhi, kFALSE);
+    virtualForward4Pos->AddNode(lay4EndLadder, iLadd*2, ctEndLaddPos);
+    virtualForward4Neg->AddNode(lay4EndLadder, iLadd*2, ctEndLaddNeg);
+  }
+
+  // 180deg Y rotation to compensate the cancellation of ITSD volume
+  // (idortm[199] in AliITSv11Hybrid : z--->  -z;   x ---> -x;   y ---> y)
+  TGeoRotation *y180 = new TGeoRotation();
+  y180->SetAngles( 90.,180., 90., 90.,180.,  0.);
+  moth->AddNode(virtualForward4Pos, 1, y180);
+  moth->AddNode(virtualForward4Neg, 1, y180);
 }
 
 
@@ -1449,7 +1832,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
        rotation = 90-fgkHybridAngle; 
        digitCableA[iSegment].CreateAndInsertCableSegment(iPt, rotation);
       } else
-       digitCableA[iSegment].CreateAndInsertBoxCableSegment(iPt);
+       digitCableA[iSegment].CreateAndInsertCableSegment(iPt);
 
     };
     
@@ -1459,7 +1842,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
        rotation = fgkHybridAngle-90; 
        digitCableB[iSegment].CreateAndInsertCableSegment(iPt, rotation);
       } else
-       digitCableB[iSegment].CreateAndInsertBoxCableSegment(iPt);
+       digitCableB[iSegment].CreateAndInsertCableSegment(iPt);
     };
   };
   
@@ -1853,7 +2236,6 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
   //**************************************************** CC outside chips:
   // I don't think there is a second aluminium layer here ...
   for (Int_t i = 0; i<4; i++) {
-    char ch[20];
     sprintf(ch, "ccLayerA%i", i);
 
     AliITSv11GeomCableFlat ccLayer1(ch, 6.6*fgkmm, ccUpLayerTotThick);
@@ -1996,7 +2378,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
   // Return a TGeoVolume* containing a segment of a ladder.
   //
 
-  TGeoMedium *phynoxSDD       = GetMedium("inox/alum$"); // phynoxSDD To code ??? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *phynoxSDD       = GetMedium("INOX$");
   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
   TGeoMedium *airSDD          = GetMedium("SDD AIR$");
 
@@ -2148,7 +2530,43 @@ TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
   virtualSeg->AddNode(fPinSupport, 6, transPS6);
   virtualSeg->AddNode(fPinSupport, 7, transPS7);
   virtualSeg->AddNode(fPinSupport, 8, transPS8);
-  
+
+  TGeoMedium *pinMed   = GetMedium("SDDKAPTON (POLYCH2)$");  // medium ???
+  Double_t fgkPinHeight = 4.5*fgkmm;
+  TGeoTube *pineS = new TGeoTube("ITSsddPin",0,fgkPinR,
+                               fgkPinHeight/2.);
+  TGeoVolume *pineV = new TGeoVolume("ITSsddPinVol", pineS, pinMed);
+
+  TGeoCombiTrans *transPS2b = new TGeoCombiTrans( fgkPinDYOnSensor,
+                               - fgkLadderHeight/2.-tDY
+                               + fgkPinHeight/2.,
+                               sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
+  AddTranslationToCombiTrans(transPS2b, 0, 0, fgkPinPinDDXOnSensor);
+  virtualSeg->AddNode(pineV, 1, transPS2b);
+
+  TGeoCombiTrans *transPS6b = new TGeoCombiTrans( -fgkPinDYOnSensor,
+                                - fgkLadderHeight/2. - tDY
+                                + fgkPinHeight/2.,
+                                sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
+  AddTranslationToCombiTrans(transPS6b, 0, 0, fgkPinPinDDXOnSensor);
+  virtualSeg->AddNode(pineV, 2, transPS6b);
+
+  TGeoCombiTrans *transPS4b = new TGeoCombiTrans( fgkPinDYOnSensor,
+                               - fgkLadderHeight/2.-tDY
+                               + fgkPinHeight/2.,
+                               sensorCenterZPos+fgkPinDXminOnSensor,rotPS1);
+  AddTranslationToCombiTrans(transPS4b, 0, 0, -2*fgkPinDXminOnSensor-fgkPinPinDDXOnSensor);
+  virtualSeg->AddNode(pineV, 3, transPS4b);
+
+  TGeoCombiTrans *transPS8b = new TGeoCombiTrans( -fgkPinDYOnSensor,
+                                - fgkLadderHeight/2. - tDY
+                                + fgkPinHeight/2.,
+                                sensorCenterZPos+fgkPinDXminOnSensor,rotPS2);
+  AddTranslationToCombiTrans(transPS8b, 0, 0, -2*fgkPinDXminOnSensor-fgkPinPinDDXOnSensor);
+  virtualSeg->AddNode(pineV, 4, transPS8b);
+
+
   //******************************
   // Cooling pipe supports :
   //******************************
@@ -2322,16 +2740,20 @@ TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
 //
-// Create a pine support
+// Create a pine support and its pine
 // axis of rotation is the cone axis, center in its middle
 //
+    TGeoMedium *rytonSDD = GetMedium("SDD C AL (M55J)$"); //medium = ryton ?
+
     TGeoCone *cone = new TGeoCone("ITSsddPinSuppCone",fgkPinSuppHeight/2.,
                                   0,fgkPinSuppRmax,0,fgkPinSuppRmax-
                                   fgkPinSuppHeight*TanD(fgkPinSuppConeAngle) );
     TGeoBBox *tong = new TGeoBBox("ITSsddPinSuppTong",fgkPinSuppRmax,
                                   fgkPinSuppLength/2.,fgkPinSuppThickness/2.);
     TGeoTube *hole = new TGeoTube("ITSsddPinSuppHole",0,fgkPinR,
-                                  fgkPinSuppHeight/2.);
+                                  fgkPinSuppHeight/2.+0.00001);
+    // 0.00001 is for seing the actual hole (avoid viewer artefact)
+
     if(GetDebug(3)){// Remove compiler warning.
         cone->InspectShape();
         tong->InspectShape();
@@ -2343,15 +2765,13 @@ TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
     tongTrans->RegisterYourself();
     TGeoCompositeShape *pinSupportShape = new TGeoCompositeShape(
                "ITSsddPinSupportShape","(ITSsddPinSuppCone+"
-               "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
+              "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
 
-    
-    TGeoMedium *rytonSDD = GetMedium("SDD C AL (M55J)$"); //medium = ryton ?  To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    TGeoVolume *pinSupport = new TGeoVolume("ITSsddPinSupport",pinSupportShape,
+    TGeoVolume *pinSupport = new TGeoVolume("ITSsddPinSupport", pinSupportShape,
                                             rytonSDD);
     pinSupport->SetLineColor(fColorRyton);
+
     return pinSupport;
-    // include the pin itself                           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 }
 
 
@@ -2641,8 +3061,8 @@ TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay) {
   //
 
   TGeoMedium *carbonFiberLadderStruct = GetMedium("SDD C AL (M55J)$"); // ITSsddCarbonM55J
-  TGeoMedium *stesalite       = GetMedium("EPOXY$");         /// To code ??? !!!!!!!!!!!!!!!!
-  TGeoMedium *phynoxSDD       = GetMedium("inox/alum$"); // phynoxSDD To code ??? !!!!!!!!!!!
+  TGeoMedium *stesalite       = GetMedium("G10FR4$");
+  TGeoMedium *phynoxSDD       = GetMedium("INOX$");
   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
 
   Double_t length        = (fgkLay3LadderLength-fgkLay3Ndet*fgkSegmentLength)/2.;
@@ -2859,7 +3279,7 @@ TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay) {
 
   TGeoBBox* guideHVbox = new TGeoBBox("guideHVbox",fgkHVguideX1/2,
                                      fgkHVguideY1/2,fgkHVguideZ1/2);
-  TGeoVolume *guideHV = new TGeoVolume("guideHV",guideHVbox,stesalite);  // material ?
+  TGeoVolume *guideHV = new TGeoVolume("guideHV",guideHVbox,stesalite);
 
   TGeoTranslation* guideHVtr = new TGeoTranslation(fgkHVguideDX,
      -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY-fgkHVguideY1/2,
@@ -2896,7 +3316,7 @@ TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateLadderFoot() {
   // the really small level difference of 0.3mm on the bottom
 
 
-  TGeoMedium *stesalite = GetMedium("EPOXY$");     /// To code ??? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *stesalite = GetMedium("G10FR4$");
 
   TGeoVolumeAssembly *virtualFoot = new TGeoVolumeAssembly("ITSsddFoot");
 
@@ -3826,8 +4246,8 @@ TGeoVolumeAssembly*  AliITSv11GeometrySDD::CreateEndLadderCards(Int_t iLay) {
 // and their cooling system 
 //
 
-  TGeoMedium *alCu12SDD       = GetMedium("AL$"); // ITSsddAlCu12 : to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  TGeoMedium *phynoxSDD       = GetMedium("AL$"); // phynoxSDD To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *alCu12SDD       = GetMedium("AL$"); // ITSsddAlCu12 : to code !!!!!!!!!!!!!!
+  TGeoMedium *phynoxSDD       = GetMedium("INOX$");
   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
 
   TGeoVolumeAssembly *endLadderCards = new TGeoVolumeAssembly("endLadderCards");
@@ -4013,53 +4433,295 @@ TGeoVolumeAssembly*  AliITSv11GeometrySDD::CreateEndLadderCards(Int_t iLay) {
     endLadderCards->AddNode(assemblySupCarlos, iCard, carlosPos);
   }
 
+  return endLadderCards;
+}
 
 
-  
+//________________________________________________________________________
+TGeoVolume*  AliITSv11GeometrySDD::CreateEndLadderCardsV(Int_t iLay) {
+// 
+// return an Pcon containing the LV, HV and Carlos cards of one ladder
+// and their cooling system 
+// This is the code actually used for the end ladder cards
+//
 
-  /*
-  //==================================
-  //--- test of flat cable curvature
-  //==================================
+  TGeoMedium *alCu12SDD       = GetMedium("AL$"); // ITSsddAlCu12 : to code !!!!!!!!!!!!!!
+  TGeoMedium *phynoxSDD       = GetMedium("INOX$");
+  TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
+  TGeoMedium *copper          = GetMedium("COPPER$");
+  TGeoMedium *plastic         = GetMedium("SDDKAPTON (POLYCH2)$");  // ???
+  TGeoMedium *airSDD          = GetMedium("SDD AIR$");
+  TGeoMedium *opticalFiber    = GetMedium("SDD SI insensitive$");  //  To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
-  double angle = 90;
-  AliITSv11GeomCableFlat cable("test", 3, 0.3);
-  cable.SetNLayers(1);
-  cable.SetNLayers(2);
-  cable.SetLayer(0, 0.2, coolerMediumSDD, 2);
-  cable.SetLayer(1, 0.1, coolerMediumSDD, 3);
-  cable.SetInitialNode(endLadderCards);
+  Double_t endLadPipeUlength = fgkEndLadPipeUlengthLay3;
+  Double_t endLadPipeArmZ    = fgkEndLadPipeArmZLay3;
+  Int_t    nCards = 3;
+  Double_t rREF   = fgkEndLaddCardsShortRadiusLay3;
+  // reference radius corresponding to local y=0
 
-  Double_t p1[3], p2[3], vX[3] = {1,0,0},vY[3] = {0,5,0};
+  if (iLay==4) {
+    endLadPipeUlength = fgkEndLadPipeUlengthLay4;
+    endLadPipeArmZ = fgkEndLadPipeArmZLay4;
+    nCards = 4;
+    rREF = fgkEndLaddCardsShortRadiusLay4;
+  }
 
-  p1[0] = -3;
-  p1[1] = 1;
-  p1[2] = 10;
+  Double_t cardLVxShift = (fgkEndLadPipeUwidth/2-fgkEndLadPipeArmX/2
+                          +fgkEndLadPipeArmBoxDX);
+  Double_t cardLVyShift = (-fgkLVcoolPosY-fgkLVcoolY1+fgkLVcoolY3
+                          +fgkEndLadPipeArmY/2+fgkEndLadPipeArmBoxDY);
 
-  p2[0] = 0;
-  p2[1] = 1;
-  p2[2] = 10;
-  cable.AddCheckPoint(endLadderCards, 0, p1, vX);
-  cable.AddCheckPoint(endLadderCards, 1, p2, vX);
-  cable.CreateAndInsertBoxCableSegment(1,angle);
+  Double_t rMin   = rREF + cardLVyShift;
+  // (The LV card is defining rMin because it is the lower object)
 
-  Double_t p3[3], p4[3];
+  Double_t thickTotCable = 0.5;
 
-  p3[0] = 2;
-  p3[1] = 3;
-  p3[2] = 10;
-  cable.AddCheckPoint(endLadderCards, 2, p3, vY);
-  cable.CreateAndInsertCableCylSegment(2,angle);
+  //==================================
+  //--- The Pcon container
+
+  // minimum angle of the Pcon :
+  Double_t tanDPhi = ((fgkEndLadPipeUwidth/2+fgkEndLadPipeArmX/2) /
+                    (rREF-fgkEndLadPipeArmY/2) );
+  Double_t dphi = 2*TMath::ATan(tanDPhi)*TMath::RadToDeg();
+  Double_t phi0 = 90-dphi/2;
+  Double_t coolUzPos = fgkEndLadPipeOuterDiam/2 + fgkDistEndLaddCardsLadd; // it is the z coord of the axis
+                                                        // of the U colling pipe in its center
+  Double_t zMax = endLadPipeUlength+coolUzPos;
+  Double_t rMax = rMin + fgkLVcardY;
+  rMax = TMath::Sqrt(rMax*rMax + cardLVxShift*cardLVxShift);
+  Double_t cablesRadius  = rMax-0.5;
+
+  TGeoPcon *containerShape = new TGeoPcon("EndLadderCcontainerShape", phi0, dphi, 10);
+   //DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax);
+  // hard coded numbers are fine tuning to avoid overlaps with other volume in the old geometry
+  containerShape->DefineSection(0, fgkDistEndLaddCardsLadd, rREF-fgkEndLadPipeOuterDiam/2-0.2, rMax);
+  containerShape->DefineSection(1, fgkDistEndLaddCardsLadd+1.4, rREF-fgkEndLadPipeOuterDiam/2-0.2, rMax);
+  containerShape->DefineSection(2,  fgkDistEndLaddCardsLadd+1.4, rMin, rMax);
+  containerShape->DefineSection(3,  endLadPipeArmZ+2*fgkEndLadPipeRadius, rMin, rMax);
+  containerShape->DefineSection(4,  endLadPipeArmZ+2*fgkEndLadPipeRadius, rREF-1.*fgkmm, rMax);
+  containerShape->DefineSection(5,  zMax, rREF-1.*fgkmm, rMax);
+  // the following is quite dirty but works for the moment ...
+  containerShape->DefineSection(6,  zMax,  rREF+fgkCarlosCardZ1/2, rMax);
+  containerShape->DefineSection(7, zMax+1, cablesRadius-thickTotCable/2, rMax);
+
+  // The next parameters define the shape of the Pcon at its end and where cables
+  // are escaping...
+  Double_t cableSectionR1 = cablesRadius-thickTotCable/2;
+  Double_t cableSectionR2 = rMax;
+  Double_t cableSectionZ1 = zMax + 6.3*fgkmm + 2.5*fgkcm;
+  Double_t cableSectionZ2 = zMax + 7.3*fgkmm + 4*fgkcm;
+  // Those 6.3 and 7.3 are to be fixed to stick the maximum to the SDD cone
+  // (I'm waiting for the new cone)
+
+  containerShape->DefineSection(8, cableSectionZ1, cableSectionR1, rMax);
+  containerShape->DefineSection(9, cableSectionZ2, cableSectionR2, rMax);
+
+  TGeoVolume *endLadderCards = new TGeoVolume("endLadderCards",containerShape,airSDD);
+  //endLadderCards->SetVisibility(kFALSE);
 
-  p4[0] = 2;
-  p4[1] = 6;
-  p4[2] = 10;
-  cable.AddCheckPoint(endLadderCards, 3, p4, vY);
-  cable.CreateAndInsertCableSegment(3,angle);
-  */
+  //=*********************************
+  //--- The rounded pipe for the end ladder card cooling
 
-  return endLadderCards;
-}
+  AliITSv11GeomCableRound endLadderPipe("endLadderPipe", fgkEndLadPipeOuterDiam/2);
+  endLadderPipe.SetNLayers(2); 
+  endLadderPipe.SetLayer(0, fgkEndLadPipeInnerDiam/2, coolerMediumSDD, 4);
+  endLadderPipe.SetLayer(1, (fgkEndLadPipeOuterDiam-fgkEndLadPipeInnerDiam)/2, phynoxSDD, fColorPhynox);
+
+  Double_t coordA[3] = { fgkEndLadPipeUwidth/2, rREF, endLadPipeUlength+coolUzPos};
+  Double_t vectA[3]  = {0,0,1};
+
+  Double_t coordB[3] = { fgkEndLadPipeUwidth/2,rREF, fgkEndLadPipeRadius+coolUzPos};
+  Double_t vectB[3]  = {0,0,1};
+
+  Double_t coordC[3] = { fgkEndLadPipeUwidth/2-fgkEndLadPipeRadius, rREF, coolUzPos};
+  Double_t vectC[3]  = {1,0,0};
+
+  Double_t coordD[3] = {-fgkEndLadPipeUwidth/2+fgkEndLadPipeRadius, rREF, coolUzPos};
+  Double_t vectD[3]  = {-1,0,0};
+
+  Double_t coordE[3] = {-fgkEndLadPipeUwidth/2, rREF, fgkEndLadPipeRadius+coolUzPos};
+  Double_t vectE[3]  = {0,0,-1};
+
+  Double_t coordF[3] = {-fgkEndLadPipeUwidth/2,rREF, endLadPipeUlength+coolUzPos};
+  Double_t vectF[3]  = {0,0,-1};
+
+  endLadderPipe.AddCheckPoint( (TGeoVolume *) endLadderCards, 0, coordA, vectA);
+  endLadderPipe.AddCheckPoint( (TGeoVolume *) endLadderCards, 1, coordB, vectB);
+  endLadderPipe.AddCheckPoint( (TGeoVolume *) endLadderCards, 2, coordC, vectC);
+  endLadderPipe.AddCheckPoint( (TGeoVolume *) endLadderCards, 3, coordD, vectD);
+  endLadderPipe.AddCheckPoint( (TGeoVolume *) endLadderCards, 4, coordE, vectE);
+  endLadderPipe.AddCheckPoint( (TGeoVolume *) endLadderCards, 5, coordF, vectF);
+
+  endLadderPipe.SetInitialNode((TGeoVolume *) endLadderCards); //Set the root node
+  //endLadderPipe.CreateAndInsertCableSegment( 1);
+  endLadderPipe.CreateAndInsertTubeSegment( 1);
+  //endLadderPipe.CreateAndInsertCableSegment( 2);
+  endLadderPipe.CreateAndInsertTorusSegment( 2);
+  //endLadderPipe.CreateAndInsertCableSegment( 3);
+  endLadderPipe.CreateAndInsertTubeSegment( 3);
+  //endLadderPipe.CreateAndInsertCableSegment( 4);
+  endLadderPipe.CreateAndInsertTorusSegment( 4);
+  //endLadderPipe.CreateAndInsertCableSegment( 5);
+  endLadderPipe.CreateAndInsertTubeSegment( 5);
+
+  TGeoBBox *endLadPipeArmBox = new TGeoBBox("endLadPipeArmBox",fgkEndLadPipeArmX/2,
+                                        fgkEndLadPipeArmY/2, endLadPipeArmZ/2);
+  TGeoTube *endLadPipeArmTube = new TGeoTube("endLadPipeArmTube", 0,
+                                   fgkEndLadPipeOuterDiam/2, endLadPipeArmZ/2);
+
+  TGeoTranslation *endLadPipeArmBoxDY1 = new TGeoTranslation("endLadPipeArmBoxDY1",
+                                                           - fgkEndLadPipeArmBoxDX,
+                                                            fgkEndLadPipeArmBoxDY,0);
+  TGeoTranslation *endLadPipeArmBoxDY2 = new TGeoTranslation("endLadPipeArmBoxDY2",
+                                                           fgkEndLadPipeArmBoxDX,
+                                                           fgkEndLadPipeArmBoxDY,0);
+  endLadPipeArmBoxDY1->RegisterYourself();
+  endLadPipeArmBoxDY2->RegisterYourself();
+
+  if(GetDebug(3)) { // Remove compiler warning.
+    endLadPipeArmBox->InspectShape();
+    endLadPipeArmTube->InspectShape();
+  }
+
+  TGeoCompositeShape *endLadPipeArm1 = new TGeoCompositeShape("ITSsddEndLadPipeArm1",
+                                          "endLadPipeArmBox:endLadPipeArmBoxDY1"
+                                          "- endLadPipeArmTube");
+  TGeoCompositeShape *endLadPipeArm2 = new TGeoCompositeShape("ITSsddEndLadPipeArm2",
+                                          "endLadPipeArmBox:endLadPipeArmBoxDY2"
+                                          "- endLadPipeArmTube");
+
+  TGeoVolume *vEndLadPipeArm1 = new TGeoVolume("ITSsddVolEndLadPipeArm1",
+                                              endLadPipeArm1, alCu12SDD);
+  TGeoVolume *vEndLadPipeArm2 = new TGeoVolume("ITSsddVolEndLadPipeArm2",
+                                              endLadPipeArm2, alCu12SDD);
+  vEndLadPipeArm1->SetLineColor(2);
+  vEndLadPipeArm2->SetLineColor(2);
+
+  Double_t armZ = (coolUzPos-fgkEndLadPipeOuterDiam/2+endLadPipeArmZ/2
+                  +fgkEndLadPipeArmZpos);
+
+  TGeoTranslation *trEndLadPipeArm1 = new TGeoTranslation("trEndLadPipeArm1",
+                                         -fgkEndLadPipeUwidth/2,rREF,armZ);
+  TGeoTranslation *trEndLadPipeArm2 = new TGeoTranslation("trEndLadPipeArm2",
+                                          fgkEndLadPipeUwidth/2,rREF,armZ);
+
+  endLadderCards->AddNode(vEndLadPipeArm1, 1, trEndLadPipeArm1);
+  endLadderCards->AddNode(vEndLadPipeArm2, 1, trEndLadPipeArm2);
+
+  //=*********************************
+  //--- LV cards
+  TGeoVolumeAssembly *cardLVassemblyR = fCardLVR;
+  TGeoVolumeAssembly *cardLVassemblyL = fCardLVL;
+
+  Double_t spaceBetweenCards = 0.2*fgkmm; 
+
+
+  Double_t alLVcoolZ3 = (fgkLVcardCuZ+fgkLVcardZ+2.*(fgkLVChip0SiZ+fgkLVChip0Z)
+                         +fgkLVcoolZ1*2.);
+
+  Double_t firstLVCardZ = fgkEndLadPipeArmZpos-fgkEndLadPipeOuterDiam/2.+alLVcoolZ3/2
+                          +coolUzPos+1.25*fgkmm;
+  // Position in z of the first LVB with respect to the start of the cooling
+  // rectangular arm, coming  (from inside of the ladder)
+  // The cards are added one after the other
+
+  for (Int_t iCard=0; iCard<nCards; iCard++) {
+
+    Double_t cardLVzShift = firstLVCardZ + 
+      Double_t(iCard)*(alLVcoolZ3 + 2.*spaceBetweenCards+fgkHVCardCool3Z);
+
+    TGeoTranslation *trCardLVassemblyR = new TGeoTranslation(cardLVxShift,
+                                            cardLVyShift+rREF, cardLVzShift);
+    TGeoTranslation *trCardLVassemblyL = new TGeoTranslation(-cardLVxShift,
+                                            cardLVyShift+rREF, cardLVzShift);
+
+    endLadderCards->AddNode(cardLVassemblyR, iCard+1, trCardLVassemblyR);
+    endLadderCards->AddNode(cardLVassemblyL, iCard+1, trCardLVassemblyL);
+  }
+
+  //=*********************************
+  //--- HV cards
+  TGeoVolumeAssembly *cardHV = fCardHV;
+
+  Double_t coolHVdy = (fgkHVCardCoolDY + fgkHVCardCool3Y
+                      + fgkEndLadPipeArmY/2 + fgkEndLadPipeArmBoxDY);
+  // shift of the HV card in local y w.r.t the local y=0 (center of cooling tube)
+
+  Double_t coolHVCenterShift = (fgkHVCardCool3Z/2-fgkHVCardCool2Z
+                               -(fgkHVCardCeramZ)/2); 
+
+  for (Int_t iCard=0; iCard<nCards; iCard++) {
+
+    Double_t fact = iCard*2.+1.;
+    Double_t coolHVdz = (firstLVCardZ + alLVcoolZ3*fact/2 + spaceBetweenCards*fact
+                        + fgkHVCardCool3Z*fact/2. + coolHVCenterShift);
+    TGeoTranslation *trCardHV = new TGeoTranslation(0,coolHVdy+rREF, coolHVdz);
+    endLadderCards->AddNode(cardHV, iCard+1, trCardHV);
+  }
+
+  //=*********************************
+  //--- Carlos card
+
+  TGeoVolumeAssembly *assemblySupCarlos = fCardCarlos;
+//   TGeoRotation *carlosSupRot1 = new TGeoRotation("carlosSuppAngle",
+//                                              0, -fgkCarlosSuppAngle, 0);
+
+  Double_t spaceBetweenCarlsoCards = 0.1*fgkmm;
+  Double_t firstCarlosCardZ = (firstLVCardZ - alLVcoolZ3/2 + alLVcoolZ3*4 +
+                              fgkHVCardCool3Z*4 + spaceBetweenCards*7 + 2*fgkmm);
+  // position in z of the first Carlos board, coming  from inside of the ladder
+
+  Double_t coolCarlosDy = (fgkCarlosSuppY3/2 + fgkEndLadPipeArmY/2 + 
+                          fgkEndLadPipeArmBoxDY);
+
+  for (Int_t iCard=0; iCard<nCards; iCard++) {
+
+    Double_t carloszPos = ( firstCarlosCardZ + fgkCarlosSuppZ3/2 +
+                           iCard*(fgkCarlosSuppZ3+spaceBetweenCarlsoCards) );
+    TGeoCombiTrans *carlosPos = new TGeoCombiTrans(0,coolCarlosDy+rREF,carloszPos,
+                                                  (TGeoRotation*) fCommonTr[0]);
+
+    endLadderCards->AddNode(assemblySupCarlos, iCard, carlosPos);
+  }
+
+
+  //=*********************************
+  //--- Cables
+
+
+  Double_t sectionV   = (fgkSectionCuPerMod+fgkSectionPlastPerMod
+                        + fgkSectionGlassPerMod)*nCards;
+  // We fix thickness, then width is calculated accordingly
+   Double_t width      = sectionV/thickTotCable;
+  Double_t thickCu    = thickTotCable*fgkSectionCuPerMod
+              / (fgkSectionCuPerMod+fgkSectionPlastPerMod+fgkSectionGlassPerMod);
+  Double_t thickPlast = thickTotCable*fgkSectionPlastPerMod
+              / (fgkSectionCuPerMod+fgkSectionPlastPerMod+fgkSectionGlassPerMod);
+  Double_t thickGlass = thickTotCable - thickCu - thickPlast;
+
+  AliITSv11GeomCableFlat cable("SDDcableEndLadder",width,thickTotCable);
+  cable.SetNLayers(3);
+  cable.SetLayer(0, thickCu, copper, kRed);
+  cable.SetLayer(1, thickPlast, plastic, kYellow);
+  cable.SetLayer(2, thickGlass, opticalFiber, kGreen);
+
+  Double_t zVect[3]={0,0,1};
+  Double_t xMinCable = firstCarlosCardZ+nCards*(fgkCarlosSuppZ3
+                      +spaceBetweenCarlsoCards)/2 + 2.9;
+  // the 2.9cm is for taking into account carlos card angle...
+
+  Double_t zEndCable = GetConeZ(cablesRadius-thickTotCable/2, cableSectionR1,
+                               cableSectionR2,cableSectionZ1,cableSectionZ2);
+
+  Double_t pos1[3] = {0, cablesRadius, xMinCable};
+  Double_t pos2[3] = {0, cablesRadius, zEndCable};
+  cable.AddCheckPoint( endLadderCards, 0, pos1, zVect );
+  cable.AddCheckPoint( endLadderCards, 1, pos2, zVect );
+  cable.SetInitialNode(endLadderCards);
+  cable.CreateAndInsertCableSegment(1);
+
+  return endLadderCards;
+}
 
 //________________________________________________________________________
 TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateSupportRing(Int_t iLay) {
@@ -4754,3 +5416,455 @@ GetCurrentLayLaddDet(Int_t &lay, Int_t &ladd, Int_t&det) const {
 
   return kTRUE;
 }
+
+
+//________________________________________________________________________
+TGeoPcon* AliITSv11GeometrySDD::CreateConeConstSection(Double_t r1max, Double_t z1,
+                                                      Double_t r2max, Double_t z2,
+                                                      Double_t section, Int_t nDiv)
+{
+  // Creates a cone along z where the section is approximately constant
+  // with z. This is for simulation of cables, because a cone with a constant
+  // radius difference would show a quantity of matter increasing with z...
+  // The max radius of the created Pcon is evolving linearly, the min radius
+  // is calculated at several steps (nDiv).
+  // z2 > z1 (required by the Pcon)
+
+  TGeoPcon *myPcon = new TGeoPcon(0, 360, 1+nDiv);
+  
+  Double_t dr = (r2max-r1max)/nDiv;
+  Double_t dz = (z2-z1)/nDiv;
+  Double_t r1minI, r2minI, r1maxI, r2maxI;
+  Double_t z1I, z2I;
+
+  Double_t lZ = TMath::Sqrt((r2max-r1max)*(r2max-r1max) + (z2-z1)*(z2-z1));
+  Double_t cosAlpha = (z2-z1)/lZ;
+
+  r1minI = TMath::Sqrt(r1max*r1max-section/(TMath::Pi()*cosAlpha));
+  myPcon->DefineSection(0, z1, r1minI, r1max);
+
+  for (Int_t i=0; i<nDiv; i++) {
+    
+    z1I = z1 + i*dz;
+    z2I = z1I + dz;
+    r1maxI = r1max + i*dr;
+    r2maxI = r1maxI + dr;
+
+    r2minI =  TMath::Sqrt(r2maxI*r2maxI-section/(TMath::Pi()*cosAlpha));
+    myPcon->DefineSection(i+1, z2I, r2minI, r2maxI);
+  }
+  return myPcon;
+}
+
+
+//________________________________________________________________________
+Double_t AliITSv11GeometrySDD::GetConeZ(Double_t r, Double_t refR1, Double_t refR2, 
+                                       Double_t refZ1, Double_t refZ2) {
+  // just a helping function
+  return refZ1+(refZ2-refZ1)*(r-refR1)/(refR2-refR1);
+}
+
+//________________________________________________________________________
+Int_t AliITSv11GeometrySDD::CreateAndInsetConeCablePart(TGeoVolume *mother, Double_t angle,
+                                                       Int_t nLay3, Int_t nLay4,
+                                                       Double_t r1, Double_t z1,
+                                                       Double_t r2, Double_t z2) {
+  
+  // Create some cables portions from SDD modules grouped
+  // and attached at the border of the SSD cone
+
+  TGeoMedium *copper     = GetMedium("COPPER$");
+  TGeoMedium *plastic    = GetMedium("SDDKAPTON (POLYCH2)$");
+  TGeoMedium *opticalFiber = GetMedium("SDD OPTICFIB$");
+
+  char titleCable[30];
+  sprintf(titleCable,"cableSDDport%i",(Int_t)angle);
+
+  //---
+  Double_t section = (fgkSectionCuPerMod+fgkSectionPlastPerMod+fgkSectionGlassPerMod)*(nLay3+nLay4);
+  Double_t thickness = 1.; // let's fix the thickness, then calculate the width
+  Double_t width     = section/thickness;
+  Double_t thickCu   = thickness*fgkSectionCuPerMod/(fgkSectionCuPerMod+fgkSectionPlastPerMod
+                                                    +fgkSectionGlassPerMod);
+
+  Double_t thickPlast = thickness*fgkSectionPlastPerMod/(fgkSectionCuPerMod+fgkSectionPlastPerMod
+                                                        +fgkSectionGlassPerMod);
+
+  Double_t thickGlass = thickness*fgkSectionGlassPerMod/(fgkSectionCuPerMod+fgkSectionPlastPerMod
+                                                        +fgkSectionGlassPerMod);
+
+  Double_t hypothenus   = TMath::Sqrt( (r2-r1)*(r2-r1) + (z2-z1)*(z2-z1) );
+  Double_t cosAlpha     = (z2-z1)/hypothenus;
+  Double_t radius1Cable = TMath::Sqrt(r1*r1 - width*width/4) - 0.5*thickness/cosAlpha;
+  Double_t radius2Cable = TMath::Sqrt(r2*r2 - width*width/4) - 0.5*thickness/cosAlpha;
+  angle *= TMath::DegToRad();
+  Double_t x1 = radius1Cable*TMath::Cos(angle), y1 = radius1Cable*TMath::Sin(angle);
+  Double_t x2 = radius2Cable*TMath::Cos(angle), y2 = radius2Cable*TMath::Sin(angle);
+  Double_t pos1[3] = {x1,y1,z1};
+  Double_t pos2[3] = {x2,y2,z2};
+  Double_t zVect[3] = {0,0,1};
+
+  AliITSv11GeomCableFlat cable(titleCable,width,thickness);
+  cable.SetNLayers(3);
+  cable.SetLayer(0, thickPlast, plastic, kYellow);
+  cable.SetLayer(1, thickCu, copper, kRed);
+  cable.SetLayer(2, thickGlass, opticalFiber, kGreen);
+
+  cable.AddCheckPoint( mother, 0, pos1, zVect );
+  cable.AddCheckPoint( mother, 1, pos2, zVect );
+  cable.SetInitialNode(mother);
+  cable.CreateAndInsertCableSegment(1);
+
+  return kTRUE;
+}
+
+
+
+//________________________________________________________________________
+void AliITSv11GeometrySDD::SDDCables(TGeoVolume *moth)
+{
+//
+// Creates and inserts the SDD cables running on SDD and SSD cones
+//
+// Input:
+//         moth : the TGeoVolume owing the volume structure
+// Output:
+//
+// Created:         ???       Ludovic Gaudichet
+// Updated:      15 Mar 2008  Mario Sitta
+// Updated:      14 Apr 2008  Mario Sitta            Overlap fixes
+// Updated:      09 May 2008  Mario Sitta            SSD overlap fixes
+//
+
+  TGeoMedium *copper       = GetMedium("COPPER$");
+  TGeoMedium *plastic      = GetMedium("SDDKAPTON (POLYCH2)$");
+  TGeoMedium *opticalFiber = GetMedium("SDD OPTICFIB$");
+  TGeoMedium *airSDD       = GetMedium("SDD AIR$");
+
+
+  //==================================
+  //  
+  //==================================
+
+  Double_t nModLay3 = fgkLay3Nladd*fgkLay3Ndet;
+  Double_t nModLay4 = fgkLay4Nladd*fgkLay4Ndet;
+
+  Double_t sectionLay3Cu      = fgkCableBendRatio*fgkSectionCuPerMod*nModLay3/2;
+  Double_t sectionLay3Plastic = fgkCableBendRatio*fgkSectionPlastPerMod*nModLay3/2;
+  Double_t sectionLay3Glass   = fgkCableBendRatio*fgkSectionGlassPerMod*nModLay3/2;
+
+  Double_t sectionLay4Cu      = fgkCableBendRatio*fgkSectionCuPerMod*nModLay4/2;
+  Double_t sectionLay4Plastic = fgkCableBendRatio*fgkSectionPlastPerMod*nModLay4/2;
+  Double_t sectionLay4Glass   = fgkCableBendRatio*fgkSectionGlassPerMod*nModLay4/2;
+
+  // Do not use hardcoded numbers, get them from real shapes - M.S. 15/03/08
+  TGeoVolume *sddCone = gGeoManager->GetVolume("SDDCarbonFiberCone");
+  TGeoPcon *sddConeShape = (TGeoPcon*)sddCone->GetShape();
+
+  TGeoVolume *sddCylinder = gGeoManager->GetVolume("SDDCarbonFiberCylinder");
+  TGeoTube *sddCylinderShape = (TGeoTube*)sddCylinder->GetShape();
+
+  // (were fgkConeSDDr1, fgkConeSDDr2, fgkConeSDDz1, fgkConeSDDz2 hardcoded)
+  Double_t coneSDDr1 = sddConeShape->GetRmin(5);
+  Double_t coneSDDr2 = sddConeShape->GetRmin(3);
+
+  Double_t coneSDDz1 = sddConeShape->GetZ(9) - sddConeShape->GetZ(5) +
+                      sddCylinderShape->GetDz();
+  Double_t coneSDDz2 = sddConeShape->GetZ(9) - sddConeShape->GetZ(3) +
+                      sddCylinderShape->GetDz();
+
+  // Calculate z1, z2 thanks to R1 and R2
+  Double_t sddCableZ1 = GetConeZ(fgkSDDCableR1, coneSDDr1, coneSDDr2,
+                                               coneSDDz1, coneSDDz2);
+  Double_t sddCableZ2 = GetConeZ(fgkSDDCableR2, coneSDDr1, coneSDDr2,
+                                               coneSDDz1, coneSDDz2);
+  Double_t sddCableZ3 = GetConeZ(fgkSDDCableR3, coneSDDr1, coneSDDr2,
+                                               coneSDDz1, coneSDDz2);
+
+  TGeoRotation *rotCableSDD = new TGeoRotation("rotCableSDD",0,180,0);
+
+  //==================================
+  //  first set of cones : cables from layer 3
+  //==================================
+
+  TGeoPcon* pcon1all = CreateConeConstSection(fgkSDDCableR1, sddCableZ1,
+                                             fgkSDDCableR2, sddCableZ2,
+                 sectionLay3Plastic+sectionLay3Cu+sectionLay3Glass, 1);
+
+  TGeoPcon* pcon1container = new TGeoPcon(0,360,2);
+  pcon1container->DefineSection(0, sddCableZ1, pcon1all->GetRmin(0),
+                                              pcon1all->GetRmax(0));
+
+  Double_t drMax = pcon1all->GetRmax(0)- pcon1all->GetRmin(0);
+  pcon1container->DefineSection(1, sddCableZ2, pcon1all->GetRmax(1)-drMax,
+                                              pcon1all->GetRmax(1));
+
+  TGeoVolume *vpcon1container = new TGeoVolume("vpcon1container",
+                                              pcon1container, airSDD);
+  vpcon1container->SetVisibility(kFALSE);
+
+  TGeoPcon* pcon1plast = CreateConeConstSection(fgkSDDCableR1, sddCableZ1,
+                                               fgkSDDCableR2, sddCableZ2,
+                                               sectionLay3Plastic, 3);
+
+  TGeoVolume *vpcon1plast = new TGeoVolume("ITScablesSDDpcon1Plast",
+                                          pcon1plast, plastic);
+  vpcon1plast->SetLineColor(kYellow);
+  vpcon1container->AddNode(vpcon1plast, 0);
+
+  Double_t dr1a = fgkSDDCableR1 - pcon1plast->GetRmin(0);
+  TGeoPcon* pcon1Cu = CreateConeConstSection(fgkSDDCableR1 - dr1a, sddCableZ1,
+                                            fgkSDDCableR2 - dr1a, sddCableZ2,
+                                            sectionLay3Cu, 3);
+
+  TGeoVolume *vpcon1Cu = new TGeoVolume("ITScablesSDDpcon1Cu",
+                                       pcon1Cu, copper);
+  vpcon1Cu->SetLineColor(kRed);
+  vpcon1container->AddNode(vpcon1Cu, 0);
+
+  Double_t dr1b = pcon1Cu->GetRmax(0) - pcon1Cu->GetRmin(0);
+  TGeoPcon* pcon1glass = CreateConeConstSection(fgkSDDCableR1-dr1a-dr1b, sddCableZ1,
+                                               fgkSDDCableR2-dr1a-dr1b, sddCableZ2,
+                                               sectionLay3Glass, 3);
+
+  TGeoVolume *vpcon1glass = new TGeoVolume("ITScablesSDDpcon1glass",
+                                          pcon1glass, opticalFiber);
+  vpcon1glass->SetLineColor(kGreen);
+  vpcon1container->AddNode(vpcon1glass, 0);
+
+  moth->AddNode(vpcon1container, 1);
+  moth->AddNode(vpcon1container, 2, rotCableSDD);
+
+  //==================================
+  //  2nd set of cones : cables from layer 3 and layer 4
+  //==================================
+
+  TGeoPcon* pcon2all = CreateConeConstSection(fgkSDDCableR2, sddCableZ2,
+                                             fgkSDDCableR3, sddCableZ3,
+                                     sectionLay3Plastic+sectionLay4Plastic+
+                                     sectionLay3Cu+sectionLay4Cu+
+                                     sectionLay3Glass+sectionLay4Glass, 1);
+
+  TGeoPcon* pcon2container = new TGeoPcon(0,360,2);
+  pcon2container->DefineSection(0, sddCableZ2, pcon2all->GetRmin(0),
+                                              pcon2all->GetRmax(0));
+
+  drMax = pcon2all->GetRmax(0)- pcon2all->GetRmin(0);
+  pcon2container->DefineSection(1, sddCableZ3, pcon2all->GetRmax(1)-drMax,
+                                              pcon2all->GetRmax(1));
+
+
+  TGeoVolume *vpcon2container = new TGeoVolume("vpcon2container",
+                                              pcon2container, airSDD);
+  vpcon2container->SetVisibility(kFALSE);
+
+  TGeoPcon* pcon2plast = CreateConeConstSection(fgkSDDCableR2, sddCableZ2,
+                                               fgkSDDCableR3, sddCableZ3,
+                                               sectionLay3Plastic+
+                                               sectionLay4Plastic, 3);
+
+  TGeoVolume *vpcon2plast = new TGeoVolume("ITScablesSDDpcon2Plast",
+                                          pcon2plast, plastic);
+  vpcon2plast->SetLineColor(kYellow);
+  vpcon2container->AddNode(vpcon2plast, 0);
+
+  Double_t dr2a = fgkSDDCableR2 - pcon2plast->GetRmin(0);
+  TGeoPcon* pcon2Cu = CreateConeConstSection(fgkSDDCableR2 - dr2a, sddCableZ2,
+                                            fgkSDDCableR3 - dr2a, sddCableZ3,
+                                            sectionLay3Cu+sectionLay4Cu, 3);
+
+  TGeoVolume *vpcon2Cu = new TGeoVolume("ITScablesSDDpcon2Cu",
+                                       pcon2Cu, copper);
+  vpcon2Cu->SetLineColor(kRed);
+  vpcon2container->AddNode(vpcon2Cu, 0);
+
+  Double_t dr2b = pcon2Cu->GetRmax(0) - pcon2Cu->GetRmin(0);
+  TGeoPcon* pcon2glass = CreateConeConstSection(fgkSDDCableR2-dr2a-dr2b, sddCableZ2,
+                                               fgkSDDCableR3-dr2a-dr2b, sddCableZ3,
+                                               sectionLay3Glass+
+                                               sectionLay4Glass, 3);
+
+  TGeoVolume *vpcon2glass = new TGeoVolume("ITScablesSDDpcon2glass",
+                                          pcon2glass, opticalFiber);
+  vpcon2glass->SetLineColor(kGreen);
+  vpcon2container->AddNode(vpcon2glass, 0);
+
+  moth->AddNode(vpcon2container, 1);
+  moth->AddNode(vpcon2container, 2, rotCableSDD);
+
+  //==================================
+  //  intermediate cylinder
+  //==================================
+
+  // (was fgkSDDCableDZint hardcoded)
+  Double_t sddCableDZint = (sddConeShape->GetZ(9) - sddConeShape->GetZ(0) +
+                           sddCylinderShape->GetDz()) - sddCableZ3;
+
+  TGeoTube *interCyl = new TGeoTube("sddCableInterCyl",
+                                   pcon2container->GetRmin(1),
+                                   pcon2container->GetRmax(1),
+                                   sddCableDZint/2);
+
+  TGeoVolume *vInterCyl = new TGeoVolume("vSddCableInterCyl",
+                                        interCyl, airSDD);
+  vInterCyl->SetVisibility(kFALSE);
+
+  Double_t rmaxCylPlast = pcon2container->GetRmax(1);
+  Double_t rminCylPlast = TMath::Sqrt(rmaxCylPlast*rmaxCylPlast - 
+                       (sectionLay3Plastic+sectionLay4Plastic)/TMath::Pi() );
+
+  TGeoTube *interCylPlast = new TGeoTube("sddCableInterCylPlast", rminCylPlast,
+                                        rmaxCylPlast, sddCableDZint/2);
+
+  TGeoVolume *vInterCylPlast = new TGeoVolume("vSddCableInterCylPlast",
+                                             interCylPlast, plastic);
+  vInterCylPlast->SetLineColor(kYellow);
+  vInterCyl->AddNode(vInterCylPlast, 0);
+
+  Double_t rmaxCylCu = pcon2Cu->GetRmax(3);
+  Double_t rminCylCu = TMath::Sqrt(rmaxCylCu*rmaxCylCu - 
+                      (sectionLay3Cu+sectionLay4Cu)/TMath::Pi() );
+
+  TGeoTube *interCylCu = new TGeoTube("sddCableInterCylCu", rminCylCu,
+                                     rmaxCylCu, sddCableDZint/2);
+
+  TGeoVolume *vInterCylCu = new TGeoVolume("vSddCableInterCylCu",
+                                          interCylCu, copper);
+  vInterCylCu->SetLineColor(kRed);
+  vInterCyl->AddNode(vInterCylCu, 0);
+
+  Double_t rmaxCylGlass = pcon2glass->GetRmax(3);
+  Double_t rminCylGlass = TMath::Sqrt(rmaxCylGlass*rmaxCylGlass - 
+                         (sectionLay3Glass+sectionLay4Glass)/TMath::Pi() );
+
+  TGeoTube *interCylGlass = new TGeoTube("sddCableInterCylGlass", rminCylGlass,
+                                        rmaxCylGlass, sddCableDZint/2);
+
+  TGeoVolume *vInterCylGlass = new TGeoVolume("vSddCableInterCylGlass",
+                                             interCylGlass,opticalFiber);
+  vInterCylGlass->SetLineColor(kGreen);
+  vInterCyl->AddNode(vInterCylGlass, 0);
+
+  moth->AddNode(vInterCyl, 1, new TGeoTranslation(0, 0,
+                             sddCableZ3+sddCableDZint/2));
+  moth->AddNode(vInterCyl, 2, new TGeoTranslation(0, 0,
+                            -sddCableZ3-sddCableDZint/2));
+
+  //==================================
+  // cable cone on the SSD cone
+  //==================================
+
+  Double_t sddCableR4 = rmaxCylPlast;
+  Double_t sddCableZ4 = sddCableZ3 + sddCableDZint;
+
+  TGeoPcon* pcon3all = CreateConeConstSection(sddCableR4, sddCableZ4,
+                                             fgkSDDCableR5, fgkSDDCableZ5,
+                                             sectionLay3Plastic+
+                                             sectionLay4Plastic+
+                                             sectionLay3Cu+sectionLay4Cu+
+                                             sectionLay3Glass+sectionLay4Glass, 1);
+
+  TGeoPcon* pcon3container = new TGeoPcon(0,360,2);
+  pcon3container->DefineSection(0, sddCableZ4, pcon3all->GetRmin(0),
+                                              pcon3all->GetRmax(0));
+
+  drMax = pcon3all->GetRmax(0) - pcon3all->GetRmin(0);
+  pcon3container->DefineSection(1, fgkSDDCableZ5, pcon3all->GetRmax(1)-drMax,
+                                              pcon3all->GetRmax(1));
+
+
+  TGeoVolume *vpcon3container = new TGeoVolume("vpcon3container",
+                                              pcon3container, airSDD);
+  vpcon3container->SetVisibility(kFALSE);
+
+  TGeoPcon* pcon3plast = CreateConeConstSection(sddCableR4, sddCableZ4,
+                                               fgkSDDCableR5, fgkSDDCableZ5,
+                                               sectionLay3Plastic+
+                                               sectionLay4Plastic, 3);
+
+  TGeoVolume *vpcon3plast = new TGeoVolume("ITScablesSDDpcon3Plast",
+                                          pcon3plast, plastic);
+  vpcon3plast->SetLineColor(kYellow);
+  vpcon3container->AddNode(vpcon3plast, 0);
+
+  Double_t dr3a = sddCableR4 - pcon3plast->GetRmin(0);
+  TGeoPcon* pcon3Cu = CreateConeConstSection(sddCableR4 - dr3a, sddCableZ4,
+                                            fgkSDDCableR5 - dr3a, fgkSDDCableZ5,
+                                            sectionLay3Cu+sectionLay4Cu, 3);
+
+  TGeoVolume *vpcon3Cu = new TGeoVolume("ITScablesSDDpcon3Cu",
+                                       pcon3Cu, copper);
+  vpcon3Cu->SetLineColor(kRed);
+  vpcon3container->AddNode(vpcon3Cu, 0);
+
+  Double_t dr3b = pcon3Cu->GetRmax(0) - pcon3Cu->GetRmin(0);
+  TGeoPcon* pcon3glass = CreateConeConstSection(sddCableR4-dr3a-dr3b, sddCableZ4,
+                                               fgkSDDCableR5-dr3a-dr3b, fgkSDDCableZ5,
+                                               sectionLay3Glass+sectionLay4Glass, 3);
+
+  TGeoVolume *vpcon3glass = new TGeoVolume("ITScablesSDDpcon3glass",
+                                          pcon3glass,opticalFiber);
+  vpcon3glass->SetLineColor(kGreen);
+  vpcon3container->AddNode(vpcon3glass, 0);
+
+  moth->AddNode(vpcon3container, 1);
+  moth->AddNode(vpcon3container, 2, rotCableSDD);
+
+  //==================================
+  // cables that are grouped at the end of SSD cones
+  //==================================
+
+  Double_t fgkSDDCableR6 = fgkSDDCableR5+9;
+  Double_t fgkSDDCableZ6 = fgkSDDCableZ5+8.8;
+
+  TGeoVolumeAssembly *endConeSDDCable = new TGeoVolumeAssembly("endConeSDDCable");
+
+  // Add some hardcoded shifts to avoid overlaps with SSD pathc panels
+  CreateAndInsetConeCablePart(endConeSDDCable, 40, 1*3,2*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6+0.7,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 60, 1*3,1*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6+0.6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 85, 2*3,1*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 95, 0*3,1*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 110, 2*3,3*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6+0.9,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 146, 0*3,3*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6+0.7,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 176.1, 0*3,1*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 190, 2*3,0*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 220, 1*3,2*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 240, 1*3,2*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 290.1, 2*3,2*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 315, 1*3,1*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6+0.6,fgkSDDCableZ6);
+
+  CreateAndInsetConeCablePart(endConeSDDCable, 353, 1*3,3*4, fgkSDDCableR5,
+                             fgkSDDCableZ5,fgkSDDCableR6,fgkSDDCableZ6);
+
+  moth->AddNode(endConeSDDCable, 1, 0);
+
+  TGeoRotation* reflect = new TGeoRotation("reflectEndConeSDDCable");
+  reflect->ReflectZ(kTRUE);
+  moth->AddNode(endConeSDDCable, 2, reflect);
+
+
+  return;
+}