]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New geometry: SDD, cables and update on V11 (L. Gaudichet)
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 9 Nov 2004 14:35:54 +0000 (14:35 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 9 Nov 2004 14:35:54 +0000 (14:35 +0000)
12 files changed:
ITS/AliITSv11.cxx
ITS/AliITSv11.h
ITS/AliITSv11GeomCable.cxx [new file with mode: 0644]
ITS/AliITSv11GeomCable.h [new file with mode: 0644]
ITS/AliITSv11GeomCableFlat.cxx [new file with mode: 0644]
ITS/AliITSv11GeomCableFlat.h [new file with mode: 0644]
ITS/AliITSv11GeomCableRound.cxx [new file with mode: 0644]
ITS/AliITSv11GeomCableRound.h [new file with mode: 0644]
ITS/AliITSv11GeometrySDD.cxx
ITS/AliITSv11GeometrySDD.h
ITS/ITSLinkDef.h
ITS/libITS.pkg

index b5fe28257ecfb1c92662c0f137a140b2da8a736c..774c4a1c677f003e0d53b577bdb809439d002efd 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
-
-//////////////////////////////////////////////////////////////////////////////
-//                                                                          //
-//  Inner Traking System version 11                                         //
-//  This class contains the base procedures for the Inner Tracking System   //
-//                                                                          //
-// Authors: R. Barbera                                                      //
-// version 6.                                                               //
-// Created  2000.                                                           //
-//                                                                          //
-//  NOTE: THIS IS THE  SYMMETRIC PPR geometry of the ITS.                   //
-// THIS WILL NOT WORK                                                       //
-// with the geometry or module classes or any analysis classes. You are     //
-// strongly encouraged to uses AliITSv5.                                    //
-//                                                                          //
-//////////////////////////////////////////////////////////////////////////////
-// See AliITSv11::StepManager().
-// General C/C++ includes
-#include <stdio.h>
-#include <stdlib.h>
-// General Root includes
-#include <Riostream.h>
-#include <TMath.h>
-#include <float.h>
-#include <TObjArray.h>
+//************************************************************************
+//                 Inner Traking System geometry v11
+//
+//  Based on ROOT geometrical modeler
+//  Set #define WITHROOT in TGeant3.h
+//
+// B. Nilsen, L. Gaudichet
+//************************************************************************
+
+
+//#include <Riostream.h>
 #include <TClonesArray.h>
 #include <TLorentzVector.h>
-#include <TObjString.h>
-// Root Geometry includes
-#include <TGeoManager.h>
-#include <TGeoVolume.h>
-#include <TGeoPcon.h>
-#include <TGeoCone.h>
-#include <TGeoTube.h> // contaings TGeoTubeSeg
-#include <TGeoArb8.h>
-#include <TGeoCompositeShape.h>
-#include <TGeoMatrix.h>
-#include <TGeoNode.h>
-#include <TGeoMaterial.h>
-#include <TGeoMedium.h>
-#include "AliITSv11GeometrySupport.h"
-// General AliRoot includes
-#include "AliRun.h"
-#include "AliMagF.h"
-#include "AliConst.h"
-// ITS specific includes
-#include "AliITSgeomSPD.h"
-#include "AliITSgeomSDD.h"
+
+#include "AliITS.h"
 #include "AliITSDetType.h"
-#include "AliITSresponseSPD.h"
+#include "AliITSGeant3Geometry.h"
+#include "AliITSgeom.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSSD.h"
+#include "AliITShit.h"
 #include "AliITSresponseSDD.h"
-#include "AliITSsegmentationSPD.h"
+#include "AliITSresponseSPD.h"
+#include "AliITSresponseSSD.h"
 #include "AliITSsegmentationSDD.h"
-#include "AliITSsimulationSPD.h"
-#include "AliITSsimulationSDD.h"
-#include "AliITSClusterFinderSSD.h"
+#include "AliITSsegmentationSPD.h"
+#include "AliITSsegmentationSSD.h"
 #include "AliITSv11.h"
-#include "AliITSv11GeometrySPD.h"
+#include "AliMagF.h"
+#include "AliRun.h"
+#include "AliTrackReference.h"
+#include "AliMC.h"
+
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoPcon.h>
+//#include "AliITSv11GeometrySPD.h"
 #include "AliITSv11GeometrySDD.h"
-#include "AliITSv11GeometrySupport.h"
+//#include "AliITSv11GeometrySupport.h"
 
-ClassImp(AliITSv11)
 
-/*
-  Some temparary #define's used untill ROOT has addoppted the proper
-  Getter in it's classes.
-  These Below are for TGeoPcon functions.
-*/
 
+ClassImp(AliITSv11)
 //______________________________________________________________________
-AliITSv11::AliITSv11() : 
-    AliITS(),
+  AliITSv11::AliITSv11() :
+    AliITS("ITS","ITS geometry v11"),
     fGeomDetOut(kFALSE),
     fGeomDetIn(kFALSE),
     fMajorVersion(11),
-    fMinorVersion(0),
-    fDet1(0.0),
-    fDet2(0.0),
-    fChip1(0.0),
-    fChip2(0.0),
-    fRails(0),
-    fFluid(1),
-    fSPDgeom(0),
-    fSupgeom(0){
-    // Standard default constructor for the ITS version 11.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   A default constructed AliITSv11 class.
+    fMinorVersion(0) {
+  //    Standard default constructor for the ITS version 11.
+  // Inputs:
+  //   none.
+  // Outputs:
+  //   none.
+  // Return:
+  //   none.
+  
+  Int_t i;
+  for(i=0;i<60;i++) fRead[i] = '\0';
+  for(i=0;i<60;i++) fWrite[i] = '\0';
+  for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
+  strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
+  SetEUCLID(kFALSE);
 
-    //fITSV = 0;
-    //fcS = 0;
-//   fcD = 0;
+//   fSPDgeom = new AliITSv11GeometrySPD();
+  fSDDgeom = new AliITSv11GeometrySDD();
+//   fSupgeom = new AliITSv11GeometrySupport();
 
-    SetEUCLID(kFALSE);
+  fIdN = 1;         
+  fIdName    = new TString[fIdN];
+  fIdName[0] = fSDDgeom->GetSenstiveVolumeMame();
+  fIdSens    = new Int_t[fIdN];
+  for(Int_t i=0; i<fIdN; i++) fIdSens[i] = 0;
 }
+
 //______________________________________________________________________
 AliITSv11::AliITSv11(Int_t debugITS,Int_t debugSPD,Int_t debugSDD,
-                     Int_t debugSSD,Int_t debugSUP) : 
-    AliITS(),
-    fGeomDetOut(kFALSE),
-    fGeomDetIn(kFALSE),
-    fMajorVersion(11),
-    fMinorVersion(0),
-    fDet1(0.0),
-    fDet2(0.0),
-    fChip1(0.0),
-    fChip2(0.0),
-    fRails(0),
-    fFluid(1),
-    fSPDgeom(0),
-    fSupgeom(0){
-    // Standard default constructor for the ITS version 11.
-    // Inputs:
-    //   Int_t    debugITS  Debug flag for ITS code (required).
-    //   Int_t    debugSPD  Debug flag for SPD geometry (default = 0).
-    //   Int_t    debugSDD  Debug flag for SDD geometry (default = 0).
-    //   Int_t    debugSSD  Debug flag for SSD geometry (default = 0).
-    //   Int_t    debugSUP  Debug flag for SUPort geometry (default = 0).
-    // Outputs:
-    //   none.
-    // Return
-    //   A Constructor for ITS geometry version 11 useful for Geometry display.
-
-    SetEUCLID(kFALSE);
-    debugSSD = debugSDD; // remove waring for unused variables.
-    SetDebug(debugITS);
-    fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
-    fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
-    fSupgeom = new AliITSv11GeometrySupport(debugSUP);
-}
-//______________________________________________________________________
-AliITSv11::AliITSv11(const char *title) : 
-    AliITS("ITS", title),
-    fGeomDetOut(kFALSE),
-    fGeomDetIn(kFALSE),
-    fMajorVersion(11),
-    fMinorVersion(0),
-    fDet1(0.0),
-    fDet2(0.0),
-    fChip1(0.0),
-    fChip2(0.0),
-    fRails(0),
-    fFluid(1),
-    fSPDgeom(0),
-    fSupgeom(0){
-    // Standard constructor for the ITS version 11.
-    // Inputs:
-    //   const char *title  The title of for this geometry.
-    // Outputs:
-    //   none.
-    // Return
-    //   A Standard constructed AliITSv11 class.
-    SetEUCLID(kFALSE);
-    fSPDgeom = new AliITSv11GeometrySPD(GetDebug());
-    fSupgeom = new AliITSv11GeometrySupport(GetDebug());
-}
-//______________________________________________________________________
-AliITSv11::~AliITSv11() {
-    // Standard destructor for the ITS version 11.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
-
-//    if(fITSV!=0) delete fITSV;
-//    if(fcS!=0) delete fcS;
-//    if(fcD!=0) delete fcD;
+                  Int_t debugSSD,Int_t debugSUP) :
+  AliITS("ITS","ITS geometry v11"),
+  fGeomDetOut(kFALSE),
+  fGeomDetIn(kFALSE),
+  fMajorVersion(11),
+  fMinorVersion(0) {
+  // Standard default constructor for the ITS version 11.
+  // Inputs:
+  //   Int_t    debugITS  Debug flag for ITS code (required).
+  //   Int_t    debugSPD  Debug flag for SPD geometry (default = 0).
+  //   Int_t    debugSDD  Debug flag for SDD geometry (default = 0).
+  //   Int_t    debugSSD  Debug flag for SSD geometry (default = 0).
+  //   Int_t    debugSUP  Debug flag for SUPort geometry (default = 0).
+  // Outputs:
+  //   none.
+  // Return
+
+  SetDensityServicesByThickness();
+
+  SetEUCLID(kFALSE);
+  fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
+  strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
+  strncpy(fRead,fEuclidGeomDet,60);
+  strncpy(fWrite,fEuclidGeomDet,60);
+  strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
+
+//   fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
+  fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
+//   fSupgeom = new AliITSv11GeometrySupport(debugSUP);
+
+  fIdN = 1;         
+  fIdName    = new TString[fIdN];
+  fIdName[0] = fSDDgeom->GetSenstiveVolumeMame();
+  fIdSens    = new Int_t[fIdN];
+  for(Int_t i=0; i<fIdN; i++) fIdSens[i] = 0;
+
+  debugITS = (debugSPD && debugSSD && debugSUP); //remove temp. warnings
 }
+
+
 //______________________________________________________________________
-AliITSv11::AliITSv11(const AliITSv11 &source) : AliITS(source){
-    //     Copy Constructor for ITS version 11.
+AliITSv11::AliITSv11(const AliITSv11 &source) :
+ AliITS(source){
+    //     Copy Constructor for ITS version 11. This function is not to be
+    // used. If any other instance of this function, other than "this" is
+    // passed, an error message is returned.
     // Inputs:
-    //   AliITSv11 &source  class to be copied from.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
+    //   const AliITSv11 &source This class
 
     if(&source == this) return;
-    Error("Copy Constructor","Not allowed to copy AliITSv11");
+    Warning("Copy Constructor","Not allowed to copy AliITSv11");
     return;
 }
+
+
 //______________________________________________________________________
-AliITSv11& AliITSv11::operator=(const AliITSv11 &source){
-    //    Assignment operator for the ITS version 11.
+AliITSv11& AliITSv11::operator=(const AliITSv11 
+                                                 &source){
+    //     Assignment operator for the ITS version 11. This function is not 
+    // to be used. If any other instance of this function, other than "this" 
+    // is passed, an error message is returned.
     // Inputs:
-    //   AliITSv11 &source  class to be copied from.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
+    //   const AliITSv11 &source This class
 
     if(&source == this) return *this;
-    Error("= operator","Not allowed to copy AliITSv11");
+    Warning("= operator","Not allowed to copy AliITSv11");
     return *this;
 }
+
+
 //______________________________________________________________________
-void AliITSv11::BuildGeometry(){
-    // This routine defines and Creates the geometry for version 11 of 
-    // the ITS for use in the simulation display routines. This is a 
-    // very simplified geometry for speed of viewing.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
-    //TVector3 t(0.0,0.0,0.0);
+AliITSv11::~AliITSv11() {
+  delete fSDDgeom;
+}
 
-    //if(fITSV==0) fITSV = new AliITSGeometryITSV(this,"ALIC");
-    //if(fcS==0) fcS = new AliITSGeometrySSDCone(this,t,"TSV",1);
 
-    //fcS->BuildDisplayGeometry();
+//______________________________________________________________________
+void AliITSv11::BuildGeometry(){
+
 }
+
+
 //______________________________________________________________________
 void AliITSv11::CreateGeometry(){
-    // This routine defines and Creates the geometry for version 11 of 
-    // the ITS. The geometry is used by the particle trasport routines,
-    // and therefore, is very detailed.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
-    TVector3 t(0.0,0.0,0.0);
-    const Double_t kcm = 1.0;
-
-    TGeoManager *mgr = gGeoManager;
-    TGeoVolume *vALIC = mgr->GetTopVolume();
-
-    TGeoPcon *sITS = new TGeoPcon("ITS Top Volume, Daughter of ALIC",
-                                  0.0,360.0,2);
-    // DefineSection(section number, Z, Rmin, Rmax).
-    sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
-    sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
-    TGeoVolume *vITS = new TGeoVolume("ITSV",sITS,0);
-    mgr->AddVolume(vITS);
-    vITS->SetVisibility(kFALSE);
-    vALIC->AddNode(vITS,1,0);
-    //
-    fSPDgeom->CenteralSPD(vITS);
-    fSDDgeom->SetGeomParameters(); // needed
-    fSDDgeom->Layer3(vITS);
-    fSDDgeom->Layer4(vITS);
-    fSupgeom->SPDCone(vITS);
-    fSupgeom->SPDThermalSheald(vITS);
-    fSupgeom->SDDCone(vITS);
-    fSupgeom->SSDCone(vITS);
-    fSupgeom->ServicesCableSupport(vITS);
+  //
+  // Create ROOT geometry
+  //
+
+  TGeoManager *geoManager = gGeoManager;
+  TGeoVolume *vALIC = geoManager->GetTopVolume();
+
+  TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
+
+  // DefineSection(section number, Z, Rmin, Rmax).
+  const Double_t kcm = 1.0;
+  sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
+  sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
+
+  TGeoMedium *air = gGeoManager->GetMedium("ITSair");
+  TGeoVolume *vITS = new TGeoVolume("vITS",sITS,air);
+  vITS->SetVisibility(kFALSE);
+  vALIC->AddNode(vITS,1,0);
+
+//   fSPDgeom->CenteralSPD(vITS);
+  fSDDgeom->Layer3(vITS);
+  fSDDgeom->Layer4(vITS);
+//     fSupgeom->SPDCone(vITS);
+//     fSupgeom->SPDThermalSheald(vITS);
+//     fSupgeom->SDDCone(vITS);
+//     fSupgeom->SSDCone(vITS);
+//     fSupgeom->ServicesCableSupport(vITS);
+
 }
+
+
 //______________________________________________________________________
 void AliITSv11::CreateMaterials(){
-    // Create ITS materials
-    //     This function defines the default materials used in the Geant
-    // Monte Carlo simulations for the geometries AliITSv11.
-    // In general it is automatically replaced by
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
-
-    //TGeoMaterial *C  = new TGeoMaterial("ITSCarbon",12.0,6.0,2.265);
-    TGeoMaterial *matAl = new TGeoMaterial("ITSAluminum",26.981539,13.0,2.07);
-    TGeoMixture *matCfiber = new TGeoMixture("ITSCarbonFiber",6,1.930);
-    TGeoMixture *matRohacell = new TGeoMixture("ITSRohacell",6,1.930);
-    TGeoMixture *matStaselite = new TGeoMixture("ITSStaselite4411w",6,1.930);
-    TGeoMixture *matAir = new TGeoMixture("ITSAir",6,1.205*1.E-3);
-    TGeoMixture *matStainless = new TGeoMixture("ITSStainless",6,1.930);
-    //
-    Double_t medSPDcone[20];
-    medSPDcone[0] = 1.0; // imat
-    medSPDcone[1] = 0.0; // isvol
-    medSPDcone[2] = gAlice->Field()->Integ(); // ifield
-    medSPDcone[3] = gAlice->Field()->Max(); // fieldm
-    medSPDcone[4] = 1.0; // tmaxfd [degrees]
-    medSPDcone[5] = 1.0; // stemax [cm]
-    medSPDcone[6] = 0.5; // deemax [fraction]
-    medSPDcone[7] = 1.0E-3; // epsil [cm]
-    medSPDcone[8] = 0.0; // stmin [cm]
-    new TGeoMedium("ITSspdCarbonFiber",1,matCfiber,medSPDcone);
-    medSPDcone[0] += 1.0;
-    new TGeoMedium("ITSspdStaselite4411w",2,matStaselite,medSPDcone);
-    medSPDcone[0] += 1.0;
-    new TGeoMedium("ITSspdRohacell50A",3,matRohacell,medSPDcone);
-    medSPDcone[0] += 1.0;
-    new TGeoMedium("ITSspdStainlesSteal",4,matStainless,medSPDcone);
-    medSPDcone[0] += 1.0;
-    new TGeoMedium("ITSspdAir",5,matAir,medSPDcone);
-    medSPDcone[0] += 1.0;
-    new TGeoMedium("ITSspdAl",6,matAl,medSPDcone);
-    //
-    Double_t medSSDcone[20];
-    medSSDcone[0] = 1.0; // imat
-    medSSDcone[1] = 0.0; // isvol
-    medSSDcone[2] = gAlice->Field()->Integ(); // ifield
-    medSSDcone[3] = gAlice->Field()->Max(); // fieldm
-    medSSDcone[4] = 1.0; // tmaxfd [degrees]
-    medSSDcone[5] = 1.0; // stemax [cm]
-    medSSDcone[6] = 0.5; // deemax [fraction]
-    medSSDcone[7] = 1.0E-3; // epsil [cm]
-    medSSDcone[8] = 0.0; // stmin [cm]
-    new TGeoMedium("ITSssdCarbonFiber",1,matCfiber,medSSDcone);
-    medSSDcone[0] += 1.0;
-    new TGeoMedium("ITSssdStaselite4411w",2,matStaselite,medSSDcone);
-    medSSDcone[0] += 1.0;
-    new TGeoMedium("ITSssdRohacell50A",3,matRohacell,medSSDcone);
-    medSSDcone[0] += 1.0;
-    new TGeoMedium("ITSssdStainlesSteal",4,matStainless,medSSDcone);
-    medSSDcone[0] += 1.0;
-    new TGeoMedium("ITSssdAir",5,matAir,medSSDcone);
-    medSSDcone[0] += 1.0;
-    new TGeoMedium("ITSssdAl",6,matAl,medSSDcone);
+  //
+  // Create ITS materials
+  // Defined media here should correspond to the one defined in galice.cuts
+  // File which is red in (AliMC*) fMCApp::Init() { ReadTransPar(); }
+  //
+
+    Int_t   ifield = gAlice->Field()->Integ();
+    Float_t fieldm = gAlice->Field()->Max();
+
+    Float_t tmaxfd = 0.1; // 1.0; // Degree
+    Float_t stemax = 1.0; // cm
+    Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
+    Float_t epsil  = 1.0E-4; // 1.0; // cm
+    Float_t stmin  = 0.0; // cm "Default value used"
+
+    Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
+    Float_t stemaxSi = 0.0075; //  .10000E+01; // cm
+    Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
+    Float_t epsilSi  = 1.0E-4;// .10000E+01;
+    Float_t stminSi  = 0.0; // cm "Default value used"
+
+    Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
+    Float_t stemaxAir = .10000E+01; // cm
+    Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
+    Float_t epsilAir  = 1.0E-4;// .10000E+01;
+    Float_t stminAir  = 0.0; // cm "Default value used"
+
+    Float_t tmaxfdServ = 1.0; // 10.0; // Degree
+    Float_t stemaxServ = 1.0; // 0.01; // cm
+    Float_t deemaxServ = 0.5; // 0.1; // Fraction of particle's energy 0<deemax<=1
+    Float_t epsilServ  = 1.0E-3; // 0.003; // cm
+    Float_t stminServ  = 0.0; //0.003; // cm "Default value used"
+
+    // Freon PerFluorobuthane C4F10 see 
+    // http://st-support-cooling-electronics.web.cern.ch/
+    //        st-support-cooling-electronics/default.htm
+    Float_t afre[2]  = { 12.011,18.9984032 };
+    Float_t zfre[2]  = { 6., 9. };
+    Float_t wfre[2]  = { 4.,10. };
+    Float_t densfre  = 1.52;
+
+
+    //CM55J
+    Float_t aCM55J[4]={12.0107,14.0067,15.9994,1.00794};
+    Float_t zCM55J[4]={6.,7.,8.,1.};
+    Float_t wCM55J[4]={0.908508078,0.010387573,0.055957585,0.025146765};
+    Float_t dCM55J = 1.63;
+
+    //ALCM55J
+    Float_t aALCM55J[5]={12.0107,14.0067,15.9994,1.00794,26.981538};
+    Float_t zALCM55J[5]={6.,7.,8.,1.,13.};
+    Float_t wALCM55J[5]={0.817657902,0.0093488157,0.0503618265,0.0226320885,0.1};
+    Float_t dALCM55J = 1.9866;
+
+    //Si Chips
+    Float_t aSICHIP[6]={12.0107,14.0067,15.9994,1.00794,28.0855,107.8682};
+    Float_t zSICHIP[6]={6.,7.,8.,1.,14., 47.};
+    Float_t wSICHIP[6]={0.039730642,0.001396798,0.01169634,
+                       0.004367771,0.844665,0.09814344903};
+    Float_t dSICHIP = 2.36436;
+
+    //Inox
+    Float_t aINOX[9]={12.0107,54.9380, 28.0855,30.9738,32.066,
+                     58.6928,55.9961,95.94,55.845};
+    Float_t zINOX[9]={6.,25.,14.,15.,16., 28.,24.,42.,26.};
+    Float_t wINOX[9]={0.0003,0.02,0.01,0.00045,0.0003,0.12,0.17,0.025,0.654};
+    Float_t dINOX = 8.03;
+
+    //SDD HV microcable
+    Float_t aHVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
+    Float_t zHVm[5]={6.,1.,7.,8.,13.};
+    Float_t wHVm[5]={0.520088819984,0.01983871336,0.0551367996,0.157399667056, 0.247536};
+    Float_t dHVm = 1.6087;
+
+    //SDD LV+signal cable
+    Float_t aLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
+    Float_t zLVm[5]={6.,1.,7.,8.,13.};
+    Float_t wLVm[5]={0.21722436468,0.0082859922,0.023028867,0.06574077612, 0.68572};
+    Float_t dLVm = 2.1035;
+
+    //SDD hybrid microcab
+    Float_t aHLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
+    Float_t zHLVm[5]={6.,1.,7.,8.,13.};
+    Float_t wHLVm[5]={0.24281879711,0.00926228815,0.02574224025,0.07348667449, 0.64869};
+    Float_t dHLVm = 2.0502;
+
+    //SDD anode microcab
+    Float_t aALVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
+    Float_t zALVm[5]={6.,1.,7.,8.,13.};
+    Float_t wALVm[5]={0.392653705471,0.0128595919215,
+                     0.041626868025,0.118832707289, 0.431909};
+    Float_t dALVm = 2.0502;
+
+    //X7R capacitors
+    Float_t aX7R[7]={137.327,47.867,15.9994,58.6928,63.5460,118.710,207.2};
+    Float_t zX7R[7]={56.,22.,8.,28.,29.,50.,82.};
+    Float_t wX7R[7]={0.251639432,0.084755042,0.085975822,
+                    0.038244751,0.009471271,0.321736471,0.2081768};
+    Float_t dX7R = 7.14567;
+
+    // AIR
+    Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
+    Float_t zAir[4]={6.,7.,8.,18.};
+    Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
+    Float_t dAir = 1.20479E-3;
+
+    // Water
+    Float_t aWater[2]={1.00794,15.9994};
+    Float_t zWater[2]={1.,8.};
+    Float_t wWater[2]={0.111894,0.888106};
+    Float_t dWater   = 1.0;
+
+    // CERAMICS
+  //     94.4% Al2O3 , 2.8% SiO2 , 2.3% MnO , 0.5% Cr2O3
+    Float_t acer[5]  = { 26.981539,15.9994,28.0855,54.93805,51.9961 };
+    Float_t zcer[5]  = {       13.,     8.,    14.,     25.,    24. };
+    Float_t wcer[5]  = {.4443408,.5213375,.0130872,.0178135,.003421};
+    Float_t denscer  = 3.6;
+
+    //G10FR4
+    Float_t zG10FR4[14] = {14.00,      20.00,  13.00,  12.00,  5.00,
+                          22.00,       11.00,  19.00,  26.00,  9.00,
+                          8.00,        6.00,   7.00,   1.00};
+    Float_t aG10FR4[14] = {28.0855000,40.0780000,26.9815380,24.3050000,
+                          10.8110000,47.8670000,22.9897700,39.0983000,
+                          55.8450000,18.9984000,15.9994000,12.0107000,
+                          14.0067000,1.0079400};
+    Float_t wG10FR4[14] = {0.15144894,0.08147477,0.04128158,0.00904554,
+                          0.01397570,0.00287685,0.00445114,0.00498089,
+                          0.00209828,0.00420000,0.36043788,0.27529426,
+                          0.01415852,0.03427566};
+    Float_t densG10FR4= 1.8;
+    
+     //--- EPOXY  --- C18 H19 O3
+      Float_t aEpoxy[3] = {15.9994, 1.00794, 12.0107} ; 
+      Float_t zEpoxy[3] = {     8.,      1.,      6.} ; 
+      Float_t wEpoxy[3] = {     3.,     19.,     18.} ; 
+      Float_t dEpoxy = 1.8 ;
+
+      // rohacell: C9 H13 N1 O2
+    Float_t arohac[4] = {12.01,  1.01, 14.010, 16.};
+    Float_t zrohac[4] = { 6.,    1.,    7.,     8.};
+    Float_t wrohac[4] = { 9.,   13.,    1.,     2.};
+    Float_t drohac    = 0.05;
+
+    // If he/she means stainless steel (inox) + Aluminium and Zeff=15.3383 then
+//
+// %Al=81.6164 %inox=100-%Al
+
+    Float_t aInAl[5] = {27., 55.847,51.9961,58.6934,28.0855 };
+    Float_t zInAl[5] = {13., 26.,24.,28.,14. };
+    Float_t wInAl[5] = {.816164, .131443,.0330906,.0183836,.000919182};
+    Float_t dInAl    = 3.075;
+
+    // Kapton
+    Float_t aKapton[4]={1.00794,12.0107, 14.010,15.9994};
+    Float_t zKapton[4]={1.,6.,7.,8.};
+    Float_t wKapton[4]={0.026362,0.69113,0.07327,0.209235};
+    Float_t dKapton   = 1.42;
+
+    //SDD ruby sph.
+    Float_t aAlOxide[2]  = { 26.981539,15.9994};
+    Float_t zAlOxide[2]  = {       13.,     8.};
+    Float_t wAlOxide[2]  = {0.4707, 0.5293};
+    Float_t dAlOxide     = 3.97;
+
+    //---------
+    AliMaterial(1,"ITSsddSi",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(1,"ITSsddSi",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+    
+    AliMixture(5,"ITSair",aAir,zAir,dAir,4,wAir);
+    AliMedium(5,"ITSair",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+    
+    AliMixture(7,"ITSsddSiChip",aSICHIP,zSICHIP,dSICHIP,6,wSICHIP);
+    AliMedium(7,"ITSsddSiChip",7,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMaterial(79,"SDD SI insensitive$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(79,"SDD SI insensitive$",79,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(11,"ITSal",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
+    AliMedium(11,"ITSal",11,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(9,"ITSsddCarbonM55J",aCM55J,zCM55J,dCM55J,4,wCM55J);
+    AliMedium(9,"ITSsddCarbonM55J",9,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(10,"SDD AIR$",aAir,zAir,dAir,4,wAir);
+    AliMedium(10,"SDD AIR$",10,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+
+    AliMixture(12, "WATER",aWater,zWater,dWater,2,wWater);
+    AliMedium(12,"WATER",12,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+     AliMixture(69,"ITSsddCAlM55J",aALCM55J,zALCM55J,dALCM55J,5,wALCM55J);
+    AliMedium(69,"ITSsddCAlM55J",69,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+  
+    AliMixture(70, "ITSsddKAPTON_POLYCH2", aKapton, zKapton, dKapton, 4, wKapton);
+    AliMedium(70,"ITSsddKAPTON_POLYCH2",70,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(77,"SDDX7Rcapacitors",aX7R,zX7R,dX7R,7,wX7R);
+    AliMedium(77,"SDDX7Rcapacitors",77,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(78,"SDD ruby sph. Al2O3$",aAlOxide,zAlOxide,dAlOxide,2,wAlOxide);
+    AliMedium(78,"SDD ruby sph. Al2O3$",78,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+
+    AliMaterial(64,"ALUMINUM$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
+    AliMedium(64,"ALUMINUM$",64,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(14,"COPPER",0.63546E+02,0.29000E+02,0.89600E+01,0.14300E+01,0.99900E+03);
+    AliMedium(14,"COPPER",14,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(2,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(2,"SPD SI CHIP$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMaterial(3,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(3,"SPD SI BUS$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMixture(4,"C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
+    AliMedium(4,"C (M55J)$",4,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(6,"GEN AIR$",aAir,zAir,dAir,4,wAir);
+    AliMedium(6,"GEN AIR$",6,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+
+    AliMixture(13,"Freon$",afre,zfre,densfre,-2,wfre);
+    AliMedium(13,"Freon$",13,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+
+    AliMixture(15,"CERAMICS$",acer,zcer,denscer,5,wcer);
+    AliMedium(15,"CERAMICS$",15,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(20,"SSD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
+    AliMedium(20,"SSD C (M55J)$",20,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(21,"SSD AIR$",aAir,zAir,dAir,4,wAir);
+    AliMedium(21,"SSD AIR$",21,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+
+    AliMixture(25,"G10FR4$",aG10FR4,zG10FR4,densG10FR4,14,wG10FR4);
+    AliMedium(25,"G10FR4$",25,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+     AliMixture(26,"GEN C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
+    AliMedium(26,"GEN C (M55J)$",26,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(27,"GEN Air$",aAir,zAir,dAir,4,wAir);
+    AliMedium(27,"GEN Air$",27,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+
+    AliMaterial(51,"SPD SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(51,"SPD SI$",51,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMaterial(52,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(52,"SPD SI CHIP$",52,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMaterial(53,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(53,"SPD SI BUS$",53,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMixture(54,"SPD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
+    AliMedium(54,"SPD C (M55J)$",54,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(55,"SPD AIR$",aAir,zAir,dAir,4,wAir);
+    AliMedium(55,"SPD AIR$",55,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
+
+    AliMixture(56, "SPD KAPTON(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
+    AliMedium(56,"SPD KAPTON(POLYCH2)$",56,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(61,"EPOXY$",aEpoxy,zEpoxy,dEpoxy,-3,wEpoxy);
+    AliMedium(61,"EPOXY$",61,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(62,"SILICON$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(62,"SILICON$",62,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
+
+    AliMixture(63, "KAPTONH(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
+    AliMedium(63,"KAPTONH(POLYCH2)$",63,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+
+    AliMixture(65,"INOX$",aINOX,zINOX,dINOX,9,wINOX);
+    AliMedium(65,"INOX$",65,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(68,"ROHACELL$",arohac,zrohac,drohac,-4,wrohac);
+    AliMedium(68,"ROHACELL$",68,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+
+     AliMaterial(71,"ITS SANDW A$",0.12011E+02,0.60000E+01,0.2115E+00,0.17479E+03,0.99900E+03);
+    AliMedium(71,"ITS SANDW A$",71,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(72,"ITS SANDW B$",0.12011E+02,0.60000E+01,0.27000E+00,0.18956E+03,0.99900E+03);
+    AliMedium(72,"ITS SANDW B$",72,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(73,"ITS SANDW C$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
+    AliMedium(73,"ITS SANDW C$",73,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(74,"HEAT COND GLUE$",0.12011E+02,0.60000E+01,0.1930E+01,0.22100E+02,0.99900E+03);
+    AliMedium(74,"HEAT COND GLUE$",74,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(75,"ELASTO SIL$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
+    AliMedium(75,"ELASTO SIL$",75,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(76,"SPDBUS(AL+KPT+EPOX)$",0.19509E+02,0.96502E+01,0.19060E+01,0.15413E+02,0.99900E+03);
+    AliMedium(76,"SPDBUS(AL+KPT+EPOX)$",76,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+               
+
+    AliMixture(80,"SDD HV microcable$",aHVm,zHVm,dHVm,5,wHVm);
+    AliMedium(80,"SDD HV microcable$",80,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(81,"SDD LV+signal cable$",aLVm,zLVm,dLVm,5,wLVm);
+    AliMedium(81,"SDD LV+signal cable$",81,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(82,"SDD hybrid microcab$",aHLVm, zHLVm,dHLVm,5,wHLVm);
+    AliMedium(82,"SDD hybrid microcab$",82,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(83,"SDD anode microcab$",aALVm,zALVm,dALVm,5,wALVm);
+    AliMedium(83,"SDD anode microcab$",83,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMaterial(84,"SDD/SSD rings$",0.123565E+02,0.64561E+01,0.18097E+01,0.229570E+02,0.99900E+03);
+    AliMedium(84,"SDD/SSD rings$",84,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+    AliMixture(85,"inox/alum$",aInAl,zInAl,dInAl,5,wInAl);
+    AliMedium(85,"inox/alum$",85,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
+
+
+    // special media to take into account services in the SDD and SSD 
+    // cones for the FMD
+
+       Float_t aA[13],zZ[13],wW[13],den;
+    // From Pierluigi Barberis calculations of 2SPD+1SDD October 2 2002.
+    zZ[0] = 1.0; aA[0] = 1.00794; // Hydrogen
+    zZ[1] = 6.0; aA[1] = 12.011; // Carbon
+    zZ[2] = 7.0; aA[2] = 14.00674; // Nitrogen
+    zZ[3] = 8.0; aA[3] = 15.9994; // Oxigen
+    zZ[4] = 14.0; aA[4] = 28.0855; // Silicon
+    zZ[5] = 24.0; aA[5] = 51.9961; //Cromium
+    zZ[6] = 25.0; aA[6] = 54.938049; // Manganese
+    zZ[7] = 26.0; aA[7] = 55.845; // Iron
+    zZ[8] = 28.0; aA[8] = 58.6934; // Nickle
+    zZ[9] = 29.0; aA[9] = 63.546; // Copper
+    zZ[10] = 13.0; aA[10] = 26.981539; // Alulminum
+    zZ[11] = 47.0; aA[11] = 107.8682; // Silver
+    zZ[12] = 27.0; aA[12] = 58.9332; // Cobolt
+    wW[0] = 0.019965;
+    wW[1] = 0.340961;
+    wW[2] = 0.041225;
+    wW[3] = 0.200352;
+    wW[4] = 0.000386;
+    wW[5] = 0.001467;
+    wW[6] = 0.000155;
+    wW[7] = 0.005113;
+    wW[8] = 0.000993;
+    wW[9] = 0.381262;
+    wW[10] = 0.008121;
+    wW[11] = 0.000000;
+    wW[12] = 0.000000;
+    if(fByThick){// New values seeITS_MatBudget_4B.xls
+       den = 1.5253276; // g/cm^3  Cell O370
+    }else{
+       den = 2.58423412; // g/cm^3 Cell L370
+    } // end if fByThick
+    //den = 6161.7/(3671.58978);//g/cm^3 Volume does not exclude holes
+    AliMixture(86,"AIRFMDSDD$",aA,zZ,den,+11,wW);
+    AliMedium(86,"AIRFMDSDD$",86,0,ifield,fieldm,tmaxfdAir,stemaxAir,
+             deemaxAir,epsilAir,stminAir);
+
+
+    wW[0] = 0.019777;
+    wW[1] = 0.325901;
+    wW[2] = 0.031848;
+    wW[3] = 0.147668;
+    wW[4] = 0.030609;
+    wW[5] = 0.013993;
+    wW[6] = 0.001479;
+    wW[7] = 0.048792;
+    wW[8] = 0.009477;
+    wW[9] = 0.350697;
+    wW[10] = 0.014546;
+    wW[11] = 0.005213;
+    wW[12] = 0.000000;
+    if(fByThick){// New values seeITS_MatBudget_4B.xls
+       den = 1.2464275; // g/cm^3   Cell O403
+    }else{
+       den = 1.28134409; // g/cm^3  Cell L403
+    } // end if fByThick
+    //den = 7666.3/(9753.553259); // volume does not exclude holes
+    AliMixture(87,"AIRFMDSSD$",aA,zZ,den,+12,wW); 
+    AliMedium(87,"AIRFMDSSD$",87,0,ifield,fieldm,tmaxfdAir,stemaxAir,
+             deemaxAir,epsilAir,stminAir);
+
+    wW[0] = 0.016302;
+    wW[1] = 0.461870;
+    wW[2] = 0.033662;
+    wW[3] = 0.163595;
+    wW[4] = 0.000315;
+    wW[5] = 0.001197;
+    wW[6] = 0.000127;
+    wW[7] = 0.004175;
+    wW[8] = 0.000811;
+    wW[9] = 0.311315;
+    wW[10] = 0.006631;
+    wW[11] = 0.000000;
+    wW[12] = 0.000000;
+    if(fByThick){// New values seeITS_MatBudget_4B.xls
+       den = 1.9353276; // g/cm^3  Cell N370
+    }else{
+       den = 3.2788626; // g/cm^3 Cell F370
+    } // end if fByThick
+    //den = 7667.1/(3671.58978); // Volume does not excludeholes
+    AliMixture(88,"ITS SANDW CFMDSDD$",aA,zZ,den,+11,wW); 
+    AliMedium(88,"ITS SANDW CFMDSDD$",88,0,ifield,fieldm,tmaxfd,stemax,
+             deemax,epsil,stmin);
+
+    wW[0] = 0.014065;
+    wW[1] = 0.520598;
+    wW[2] = 0.022650;
+    wW[3] = 0.105018;
+    wW[4] = 0.021768;
+    wW[5] = 0.009952;
+    wW[6] = 0.001051;
+    wW[7] = 0.034700;
+    wW[8] = 0.006740;
+    wW[9] = 0.249406;
+    wW[10] = 0.010345;
+    wW[11] = 0.0003707;
+    wW[12] = 0.000000;
+    if(fByThick){// New values seeITS_MatBudget_4B.xls
+       den = 1.6564275; // g/cm^3  Cell N304
+    }else{
+       den = 1.7028296; // g/cm^3  Cell F304
+    } // end if fByThick
+    //den = 1166.5/(3671.58978); // Volume does not exclude holes
+    AliMixture(89,"ITS SANDW CFMDSSD$",aA,zZ,den,+12,wW); 
+    AliMedium(89,"ITS SANDW CFMDSSD$",89,0,ifield,fieldm,tmaxfd,stemax,
+             deemax,epsil,stmin);
+
+    wW[0] = 0.005970;
+    wW[1] = 0.304704;
+    wW[2] = 0.042510;
+    wW[3] = 0.121715;
+    wW[4] = 0.001118;
+    wW[5] = 0.030948;
+    wW[6] = 0.003270;
+    wW[7] = 0.107910;
+    wW[8] = 0.020960;
+    wW[9] = 0.360895;
+    wW[10] = 0.000000;
+    wW[11] = 0.000000;
+    wW[12] = 0.000000;
+    if(fByThick){// New values seeITS_MatBudget_4B.xls
+       den = 80.31136576; // g/cm^3 Cell H329
+    }else{
+       den = 87.13062; // g/cm^3  Cell G329
+    } // end if fByThick
+    //den = 1251.3/(0.05*2.0*TMath::Pi()*(7.75*7.75 - 3.7*3.7)); // g/cm^3
+    AliMixture(97,"SPD SERVICES$",aA,zZ,den,+10,wW); 
+    AliMedium(97,"SPD SERVICES$",97,0,ifield,fieldm,tmaxfd,stemax,
+             deemax,epsil,stmin);
+
+    // Special media
+
+    AliMaterial(90,"SPD shield$", 12.011, 6., 1.93/10. , 22.1*10., 999);
+    AliMedium(90,"SPD shield$",90,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+             deemaxServ,epsilServ,stminServ);
+
+    AliMaterial(91, "SPD End ladder$", 47.0447, 21.7963, 3.6374, 4.4711, 999); 
+    AliMedium(91,"SPD End ladder$",91,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+             deemaxServ,epsilServ,stminServ);
+
+    AliMaterial(92, "SPD cone$",28.0855, 14., 2.33, 9.36, 999);    
+    AliMedium(92,"SPD cone$",92,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+             deemaxServ,epsilServ,stminServ);
+
+//     Material with fractional Z not actually used
+//     AliMaterial(93, "SDD End ladder$", 69.9298, 29.8246, 0.3824, 36.5103, 999);
+//     AliMedium(93,"SDD End ladder$",93,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+//               deemaxServ,epsilServ,stminServ);
+
+    AliMaterial(94, "SDD cone$",63.546, 29., 1.15, 1.265, 999);
+    AliMedium(94,"SDD cone$",94,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+             deemaxServ,epsilServ,stminServ);
+
+//     Material with fractional Z not actually used
+//     AliMaterial(95, "SSD End ladder$", 32.0988, 15.4021, 0.68, 35.3238, 999); 
+//     AliMedium(95,"SSD End ladder$",95,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+//     deemaxServ,epsilServ,stminServ);
+
+    AliMaterial(96, "SSD cone$",63.546, 29., 1.15, 1.265, 999);
+    AliMedium(96,"SSD cone$",96,0,ifield,fieldm,tmaxfdServ,stemaxServ,
+             deemaxServ,epsilServ,stminServ);
+
 }
+
+
 //______________________________________________________________________
 void AliITSv11::InitAliITSgeom(){
-    // Based on the geometry tree defined in Geant 3.21, this
-    // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS 
-    // geometry sturture.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
+  //
+  // Fill fITSgeom with the 3 sub-detector geometries
+  //
+
+  const Int_t knlayers = 2;             // only SDD for the moment
+  Int_t nlad[knlayers],ndet[knlayers];
+  nlad[0]=14; nlad[1]=22;
+  ndet[0]=6;  ndet[1]=8;
+  Int_t mod = nlad[0]*ndet[0]+nlad[1]*ndet[1];
+  if (fITSgeom) delete fITSgeom;
+  fITSgeom = new AliITSgeom(0,knlayers,nlad,ndet,mod);
+
+
+  //***************************************************
+  //               Set default shapes 
+  // (These default shapes won't exist anymore when all
+  //  layers are coded)
+
+  const Float_t kDxyzSPD[] = {0.6400, 0.015,   3.480};  
+  if(!(fITSgeom->IsShapeDefined(kSPD)))
+    fITSgeom->ReSetShape(kSPD,
+                        new AliITSgeomSPD425Short(3,(Float_t *)kDxyzSPD));
+
+  const Float_t kDxyzSSD[] = {3.6500, 0.0150,  2.000};
+  if(!(fITSgeom->IsShapeDefined(kSSD)))
+    fITSgeom->ReSetShape(kSSD,
+                        new AliITSgeomSSD75and275(3,(Float_t *)kDxyzSSD));
+
+  //*****************************************
+  fSDDgeom->ExportSensorGeometry(fITSgeom, +1, 0);  //SDD
+
+  return;
 }
+
+
 //______________________________________________________________________
 void AliITSv11::Init(){
-    // Initialise the ITS after it has been created.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
+  //
+  //     Initialise the ITS after it has been created.
+  //
+
+    Int_t i;
+
+    for(i=0;i<20;i++) printf("*");
+    printf( " ITSv%i.%i_Init ", fMajorVersion,fMinorVersion );
+    for(i=0;i<20;i++) printf("*"); printf("\n");
+
+    // Create geometry
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fITSgeom!=0) delete fITSgeom;
+    fITSgeom = new AliITSgeom();
+    if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
+    else this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
+
+    // Initialize AliITS
+    AliITS::Init();
+
+    for(i=0;i<40+16;i++) printf("*"); printf("\n");
 }
+
+
 //______________________________________________________________________
 void AliITSv11::SetDefaults(){
-    // Sets the default segmentation, response, digit and raw cluster 
-    // classes to be used. These defaults can be overwritten in the
-    // macros that do these later steps. Defaults are give hear for the
-    // general user.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
-}
+  //
+  // Set response ans segmentation models for SPD, SDD and SSD
+  //
+
+  printf("AliITSv11::SetDefaults :\n");
+  const Float_t kconv = 1.0e+04; // convert cm to microns
+
+  AliITSDetType *iDetType;
+  AliITSgeomSPD  *s0;
+  AliITSgeomSDD  *s1;
+  AliITSgeomSSD  *s2;
+  Int_t i;
+  Float_t bx[256],bz[280];
+
+  //================================================ SPD
+  iDetType=DetType(kSPD);
+  s0 = (AliITSgeomSPD*) fITSgeom->GetShape(kSPD);// Get shape info. Do it this way for now.
+  // If some SPD detectors have been inserted in t
+  if (s0) {
+    AliITSresponse *resp0=new AliITSresponseSPD();
+    SetResponseModel(kSPD,resp0);
+    AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD(fITSgeom);
+    seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
+                    s0->GetDz()*2.*kconv, // for now.
+                    s0->GetDy()*2.*kconv); // x,z,y full width in microns.
+    seg0->SetNPads(256,160);// Number of Bins in x and z
+    for(i=000;i<256;i++) bx[i] =  50.0; // in x all are 50 microns.
+    for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
+    for(i=160;i<280;i++) bz[i] =   0.0; // Outside of detector.
+    bz[ 31] = bz[ 32] = 625.0; // first chip boundry
+    bz[ 63] = bz[ 64] = 625.0; // first chip boundry
+    bz[ 95] = bz[ 96] = 625.0; // first chip boundry
+    bz[127] = bz[128] = 625.0; // first chip boundry
+    bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
+    seg0->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
+    SetSegmentationModel(kSPD,seg0);
+    // set digit and raw cluster classes to be used
+    const char *kData0=(iDetType->GetResponseModel())->DataType();
+    if (strstr(kData0,"real")) iDetType->ClassNames("AliITSdigit",
+                                                   "AliITSRawClusterSPD");
+    else iDetType->ClassNames("AliITSdigitSPD","AliITSRawClusterSPD");
+  };
+  
+  //================================================ SDD
+  iDetType=DetType(kSDD);
+  s1 = (AliITSgeomSDD*) fITSgeom->GetShape(kSDD);// Get shape info. Do it this way for now.
+  if (s1) {
+    AliITSresponseSDD *resp1=new AliITSresponseSDD("simulated");
+    SetResponseModel(kSDD,resp1);
+    AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD(fITSgeom,resp1);
+    seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
+                    s1->GetDz()*2.*kconv, // for now.
+                    s1->GetDy()*2.*kconv); // x,z,y full width in microns.
+    seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
+    SetSegmentationModel(kSDD,seg1);
+    const char *kData1=(iDetType->GetResponseModel())->DataType();
+    const char *kopt=iDetType->GetResponseModel()->ZeroSuppOption();
+    if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
+      iDetType->ClassNames("AliITSdigit","AliITSRawClusterSDD");
+    } else iDetType->ClassNames("AliITSdigitSDD","AliITSRawClusterSDD");
+  };
+  
+  //================================================ SSD  Layer 5
+  iDetType=DetType(kSSD);
+  s2 = (AliITSgeomSSD*) fITSgeom->GetShape(kSSD);// Get shape info. Do it this way for now.
+  if (s2) {
+    AliITSresponse *resp2=new AliITSresponseSSD("simulated");
+    SetResponseModel(kSSD,resp2);
+    AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD(fITSgeom);
+    seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
+                    s2->GetDz()*2.*kconv, // for now.
+                    s2->GetDy()*2.*kconv); // x,z,y full width in microns.
+    seg2->SetPadSize(95.,0.); // strip x pitch in microns
+    seg2->SetNPads(768,0); // number of strips on each side.
+    seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
+    seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
+    seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
+    SetSegmentationModel(kSSD,seg2); 
+    const char *kData2=(iDetType->GetResponseModel())->DataType();
+    if(strstr(kData2,"real") ) iDetType->ClassNames("AliITSdigit",
+                                                   "AliITSRawClusterSSD");
+    else iDetType->ClassNames("AliITSdigitSSD","AliITSRawClusterSSD");
+  };
+  
+  if(kNTYPES>3){
+    Warning("SetDefaults",
+           "Only the four basic detector types are initialised!");
+  }// end if
+  return;
+};
+
+
+
+
 //______________________________________________________________________
-void AliITSv11::DrawModule(){
-    // Draw a standard set of shaded view of the ITS version 11.
-    // Inputs:
-    //   none.
-    // Outputs:
-    //   none.
-    // Return
-    //   none.
+void AliITSv11::DrawModule() const{
+
 }
+
 //______________________________________________________________________
 void AliITSv11::StepManager(){
-    // Called for every step in the ITS, then calles the AliITShit class
-    // creator with the information to be recoreded about that hit.
-    //  The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
-    // printing of information to a file which can be used to create a .det
-    // file read in by the routine CreateGeometry(). If set to 0 or any other
-    // value except 1, the default behavior, then no such file is created nor
-    // is the extra variables and the like used in the printing allocated.
-}
+  //
+  //    Called for every step in the ITS, then calles the AliITShit class
+  // creator with the information to be recoreded about that hit.
+  //
+
+  Int_t         copy, id;
+  TLorentzVector position, momentum;
+  static TLorentzVector position0;
+  static Int_t stat0=0;
+    
+  if(!(this->IsActive())){
+    return;
+  } // end if !Active volume.
+
+  if(!(gMC->TrackCharge())) return;
+  
+  id=gMC->CurrentVolID(copy);
+
+  Bool_t sensvol = kFALSE;
+  for(Int_t kk = 0; kk < fIdN; kk++)
+    if(id == fIdSens[kk]) sensvol = kTRUE;
+
+  if (sensvol && (gMC->IsTrackExiting())) {
+    copy = fTrackReferences->GetEntriesFast();
+    TClonesArray &lTR = *fTrackReferences;
+    // Fill TrackReference structure with this new TrackReference.
+    new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
+  } // if Outer ITS mother Volume
+  
+  Int_t   vol[5];
+  TClonesArray &lhits = *fHits;
+  //
+  // Track status
+  vol[3] = 0;
+  vol[4] = 0;
+  // Fill hit structure.
+  if(gMC->IsTrackInside())      vol[3] +=  1;
+  if(gMC->IsTrackEntering())    vol[3] +=  2;
+  if(gMC->IsTrackExiting())     vol[3] +=  4;
+  if(gMC->IsTrackOut())         vol[3] +=  8;
+  if(gMC->IsTrackDisappeared()) vol[3] += 16;
+  if(gMC->IsTrackStop())        vol[3] += 32;
+  if(gMC->IsTrackAlive())       vol[3] += 64;
+
+  // Only entering charged tracks
+  if(!(gMC->TrackCharge())) return;
+  if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
+    fSDDgeom->GetCurrentLayLaddDet(vol[0], vol[2], vol[1]);
+    // vol[2], vol[1]) : in this order because the ladder
+    // index and the det. index are exchanged in the constructor
+    // of AliITShit ...                     ???
+
+  } else {
+    return; // not an ITS volume?
+  };
+
+  gMC->TrackPosition(position);
+  gMC->TrackMomentum(momentum);
+  vol[4] = stat0;
+  if(gMC->IsTrackEntering()){
+    position0 = position;
+    stat0 = vol[3];
+    return;
+  } // end if IsEntering
+    // Fill hit structure with this new hit.
+  new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),
+                                vol, gMC->Edep(),gMC->TrackTime(),position,
+                                position0,momentum);
+  //
+  position0 = position;
+  stat0 = vol[3];
  
+  return;
+};
index 2e4455381c1fd11ccf91a1eba1b91fe55e284bd0..1c2ff1402d430828bfbdd02a1595f940253b9e0e 100644 (file)
@@ -3,62 +3,89 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/*
-  $Id$
- */
-
-/////////////////////////////////////////////////////////////////////////
-//  Manager and hits classes for set: ITS version 11, 2003 geometry    //
-/////////////////////////////////////////////////////////////////////////
  
 #include "AliITS.h"
-class TGeoVolume;
-class TGeoPcon;
 class AliITSv11GeometrySPD;
 class AliITSv11GeometrySDD;
 class AliITSv11GeometrySupport;
+
 class AliITSv11 : public AliITS {
 
  public:
     AliITSv11();
-    AliITSv11(Int_t debugITS,Int_t debugSPD=0,Int_t debugSDD=0,
-              Int_t debugSSD=0,Int_t debugSUP=0);
-    AliITSv11(const char *title);
-    AliITSv11(const AliITSv11 &source); // copy constructor
+    AliITSv11(Int_t debugITS, Int_t debugSPD = 0, Int_t debugSDD = 0,
+            Int_t debugSSD = 0, Int_t debugSUP = 0);
+    AliITSv11(const AliITSv11 &source);            // copy constructor
     AliITSv11& operator=(const AliITSv11 &source); // assignment operator
-    virtual       ~AliITSv11();
+    virtual       ~AliITSv11() ;
     virtual void   BuildGeometry();
     virtual void   CreateGeometry();
     virtual void   CreateMaterials();
-    virtual Int_t  IsVersion() const {return 11;} // ITS version number
     virtual void   Init(); 
     virtual void   SetDefaults();
-    virtual void   DrawModule();
+    virtual void   DrawModule() const;
     virtual void   StepManager();
-    // Getters for different parts of the geometry initilization
-    virtual AliITSv11GeometrySPD*     GetSPDGeometry(){return fSPDgeom;} // SPD
-    virtual AliITSv11GeometrySupport* GetSupGeometry(){return fSupgeom;} //Sup.
-  private:
+    //virtual AliITSv11GeometrySPD*     GetSPDGeometry(){return fSPDgeom;}
+    virtual AliITSv11GeometrySDD*    GetSDDGeometry(){return fSDDgeom;}
+    //virtual AliITSv11GeometrySupport* GetSupGeometry(){return fSupgeom;}
+    virtual Int_t  IsVersion() const { return fMajorVersion;}  // ITS version number 
+    virtual Int_t  GetMajorVersion() const {// return Major Version Number
+                    return fMajorVersion;}
+    virtual Int_t  GetMinorVersion() const {// return Major Version Number
+                    return fMinorVersion;}
+
+
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v=0){ // Choose between existing minor versions
+                   fMinorVersion = v;}
+
+    virtual void SetDensityServicesByThickness(){// uses services density
+       // calculation based on the thickness of the services.
+       fByThick = kTRUE;}
+    virtual void SetDensityServicesByMass(){// uses services density
+       // calculation based on the Mass of the services.
+       fByThick = kFALSE;}
+    virtual Bool_t GetEUCLID() const {return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() const { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() const { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+
+
+ private:
     void InitAliITSgeom();
 
-    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
-    Bool_t fGeomDetOut;       // Flag to write .det file out
-    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
-    Int_t  fMajorVersion;     // Major version number == IsVersion
-    Int_t  fMinorVersion;     // Minor version number
-    Float_t  fDet1;          // thickness of detector in SPD layer 1
-    Float_t  fDet2;          // thickness of detector in SPD layer 2
-    Float_t  fChip1;         // thickness of chip in SPD layer 1   
-    Float_t  fChip2;         // thickness of chip in SPD layer 2   
-    Int_t    fRails;          // switch rails on (=1) and off (=0)
-    Int_t    fFluid;          // switch between water(=1) and freon(=0)
-    //
-    AliITSv11GeometrySPD     *fSPDgeom;  //! Pointer to SPD Geometry
-    AliITSv11GeometrySDD     *fSDDgeom;  //! Pointer to SDD Geometry
-    AliITSv11GeometrySupport *fSupgeom;  //! Pointer to ITS support Geometry
+    Bool_t   fGeomDetOut;       // Flag to write .det file out
+    Bool_t   fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Bool_t   fByThick;          // Flag to use services materials by thickness
+                                // ture, or mass false.
+    Int_t    fMajorVersion;     // Major version number == IsVersion
+    Int_t    fMinorVersion;     // Minor version number
+    char     fEuclidGeomDet[60];// file where detector transormation are define.
+    char     fRead[60];         //! file name to read .det file
+    char     fWrite[60];        //! file name to write .det file
+
+
+    //AliITSv11GeometrySPD *fSPDgeom;      //SPD Geometry
+    AliITSv11GeometrySDD *fSDDgeom;      //SDD Geometry
+    //AliITSv11GeometrySupport /fSupgeom;  //Support Geometry
 
-    ClassDef(AliITSv11,1)  //Hits manager for set:ITS version 11
+    ClassDef(AliITSv11,1)  // ITS version 11 
 };
  
 #endif
diff --git a/ITS/AliITSv11GeomCable.cxx b/ITS/AliITSv11GeomCable.cxx
new file mode 100644 (file)
index 0000000..4b457ec
--- /dev/null
@@ -0,0 +1,350 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * 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.                  *
+ **************************************************************************/
+
+
+
+// General Root includes
+//#include <Riostream.h>
+//#include <TMath.h>
+#include <TVectorD.h>
+
+// Root Geometry includes
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoNode.h>
+
+#include "AliITSv11GeomCable.h"
+
+
+
+//*************************************************************************
+//   Base class of cable classes
+//
+//
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
+
+ClassImp(AliITSv11GeomCable)
+
+//________________________________________________________________________
+AliITSv11GeomCable::AliITSv11GeomCable(const char* name) { 
+  // constructor
+  fDebug = 0;
+  fInitialNode = 0;
+  fPointArray.SetOwner(); 
+  SetName(name);
+};
+
+
+//________________________________________________________________________
+AliITSv11GeomCable::AliITSv11GeomCable(const AliITSv11GeomCable &s) :
+  TNamed(s.GetName(),s.GetTitle()),fDebug(s.fDebug),fPointArray(s.fPointArray),
+  fVolumeArray(s.fVolumeArray),fInitialNode(s.fInitialNode)
+{
+  //     Copy Constructor 
+}
+
+//________________________________________________________________________
+AliITSv11GeomCable& AliITSv11GeomCable::operator=(const AliITSv11GeomCable &s) {
+  //     Assignment operator
+  // Not fully inplemented yet !!!
+
+  if(&s == this) return *this;
+  SetName(s.GetName());
+  SetTitle(s.GetTitle());
+  fDebug = s.fDebug;
+//   fPointArray = s.fPointArray;
+//   fVolumeArray = s.fVolumeArray;
+  fInitialNode = s.fInitialNode;
+  return *this;
+}
+
+//________________________________________________________________________
+AliITSv11GeomCable::~AliITSv11GeomCable() {
+  fPointArray.Clear();
+  fVolumeArray.Clear();
+};
+
+//________________________________________________________________________
+void AliITSv11GeomCable::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
+                                       Double_t *coord)
+{
+  //
+  // Add a check point and its volume container to the cable
+  //
+
+  if (iCheckPt>=fVolumeArray.GetEntriesFast()) {
+    fVolumeArray.AddLast(vol);
+    TVectorD *point = new TVectorD(3,coord);
+    fPointArray.AddLast(point);
+
+  } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) {
+    fVolumeArray.AddAt(vol, iCheckPt);
+    TVectorD *point = new TVectorD(3,coord);
+    fPointArray.AddAt(point, iCheckPt);
+  };
+};
+
+//________________________________________________________________________
+void AliITSv11GeomCable::ResetPoints() {
+  //
+  // Remove all points to the cable
+  //
+  fPointArray.Delete();
+  fVolumeArray.Clear();
+};
+
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCable::GetPoint( Int_t iCheckPt,  Double_t *coord)
+const {
+  //
+  // Get the check point #iCheckPt
+  //
+  TVectorD *coordVector =(TVectorD *)fPointArray.UncheckedAt(iCheckPt);
+  CopyFrom(coord, coordVector->GetMatrixArray());
+  return kTRUE;
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCable::GetVect( Int_t iCheckPt,  Double_t *coord)
+const {
+  //
+  //  Get the orientation vect. related to check point #iCheckPt
+  //
+
+  TVectorD *coordVector =(TVectorD *)fPointArray.UncheckedAt(iCheckPt);
+  CopyFrom(coord, coordVector->GetMatrixArray());
+  return kTRUE;
+};
+
+//________________________________________________________________________
+TGeoVolume *AliITSv11GeomCable::GetVolume( Int_t iCheckPt ) const {
+  //
+  // Get the volume of check point #iCheckPt
+  //
+
+  if (iCheckPt >= fVolumeArray.GetEntriesFast())
+    return 0;
+  else
+    return (TGeoVolume *) fVolumeArray.UncheckedAt(iCheckPt);
+};
+
+//________________________________________________________________________
+void AliITSv11GeomCable::SetInitialNode(TGeoVolume *vol) {
+  //
+  // Set the starting node, initializing the search for the volume
+  // containing the cable check point
+  //
+  if (fInitialNode) delete fInitialNode;
+  fInitialNode = new TGeoNodeMatrix(vol,0);
+  fInitialNode->SetName("nodeInConstruction");
+};
+
+//________________________________________________________________________
+void AliITSv11GeomCable::ResetInitialNode() {
+  // Reset the initial node if it is set.
+  if (fInitialNode) delete fInitialNode;
+  fInitialNode = 0;
+};
+
+//________________________________________________________________________
+bool AliITSv11GeomCable::CheckDaughter(TGeoNode* node, Int_t i)
+{
+// Search where is the current volume in the tree of nodes
+// stop each time it find the pointer of the current volume
+// the path is recorded in fNodeInd[]
+// node is the node where the search start.
+// !!! recursive function !!!
+
+  Int_t j = fNodeInd[i];
+  if (node->GetVolume()==fCurrentVol) return kTRUE;
+  TObjArray *array = node->GetNodes();
+  if (array) {
+    Int_t nDaughters = array->GetEntriesFast();
+    if (j==-1) j++;
+    while (j<nDaughters) {
+      TGeoNode *subNode = (TGeoNode *) array->UncheckedAt(j);
+      fNodeInd[i] = j;
+      if (CheckDaughter(subNode, i+1)) return kTRUE;
+      j++;
+    };
+    fNodeInd[i] = -1;
+  };
+  return kFALSE;
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCable::
+GetCheckPoint( Int_t iCheckPt, Int_t iOccur, Int_t motherLevel,
+              Double_t *coord ) {
+// Get the coordinate of the check point number #iCheckPt, which is in the
+// #iOccur occurrence of the containing volume in the node tree. Coordinates
+// are given in the coordinate system of the #motherLevel mother level of
+// this volume
+  
+  if (iCheckPt >= fVolumeArray.GetEntriesFast()) return kFALSE;
+
+  TGeoNode *mainNode;
+  if (fInitialNode==0) {
+    TObjArray *nodes = gGeoManager->GetListOfNodes();
+    if (nodes->GetEntriesFast()==0) return kFALSE;
+    mainNode = (TGeoNode *) nodes->UncheckedAt(0);
+  } else {
+    mainNode = fInitialNode;
+  };
+
+  fCurrentVol = GetVolume(iCheckPt);
+  ResetCheckDaughter();
+  Int_t currentOccur = 0;
+
+  // loop to get the volume position in the tree of nodes
+  while ( CheckDaughter(mainNode) && (currentOccur!=iOccur) ) {
+    currentOccur++;
+    Int_t maxLevel = 0;
+    while (fNodeInd[maxLevel]!=-1) maxLevel++;
+    fNodeInd[maxLevel-1]++;
+  };
+
+  Int_t maxLevel = 0;
+  while (fNodeInd[maxLevel]!=-1) maxLevel++;
+  maxLevel--;
+  if (maxLevel<-1) return kFALSE;
+
+  TGeoNode *pathNode[fgkCableMaxNodeLevel];
+  pathNode[0] = mainNode;
+  for (Int_t i=0; i<=maxLevel; i++) {
+    pathNode[i+1] = pathNode[i]->GetDaughter(fNodeInd[i]);
+  };
+
+  Double_t localCoord[3];
+  GetPoint(iCheckPt, localCoord);
+  CopyFrom(coord, localCoord);
+
+  if (motherLevel>maxLevel+2) motherLevel = maxLevel+2;
+
+  for (Int_t i=maxLevel; i>maxLevel-motherLevel; i--) {
+    pathNode[i+1]->GetMatrix()->LocalToMaster(localCoord, coord);
+    CopyFrom(localCoord, coord);
+  };
+  return kTRUE;
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCable::GetCheckVect( Int_t iCheckPt, Int_t iOccur,
+                                       Int_t motherLevel, Double_t *coord)
+{
+// same as GetCheckPoint but with vectorial transformation ...
+
+  if (iCheckPt >= fVolumeArray.GetEntriesFast()) return kFALSE;
+
+  TGeoNode *mainNode;
+  if (fInitialNode==0) {
+    TObjArray *nodes = gGeoManager->GetListOfNodes();
+    if (nodes->GetEntriesFast()==0) return kFALSE;
+    mainNode = (TGeoNode *) nodes->UncheckedAt(0);
+  } else {
+    mainNode = fInitialNode;
+  };
+
+  fCurrentVol = GetVolume(iCheckPt);
+  ResetCheckDaughter();
+  Int_t currentOccur = 0;
+
+  // loop to get the volume position in the tree of nodes
+  while ( CheckDaughter(mainNode) && (currentOccur!=iOccur) ) {
+    currentOccur++;
+    Int_t maxLevel = 0;
+    while (fNodeInd[maxLevel]!=-1) maxLevel++;
+    fNodeInd[maxLevel-1]++;
+  };
+
+  Int_t maxLevel = 0;
+  while (fNodeInd[maxLevel]!=-1) maxLevel++;
+  maxLevel--;
+  if (maxLevel<-1) return kFALSE;
+
+  TGeoNode *pathNode[fgkCableMaxNodeLevel];
+  pathNode[0] = mainNode;
+  for (Int_t i=0; i<=maxLevel; i++) {
+    pathNode[i+1] = pathNode[i]->GetDaughter(fNodeInd[i]);
+  };
+
+  Double_t localCoord[3];
+  GetVect(iCheckPt, localCoord);
+  CopyFrom(coord, localCoord);
+
+  if (motherLevel>maxLevel+2) motherLevel = maxLevel+2;
+
+  for (Int_t i=maxLevel; i>maxLevel-motherLevel; i--) {
+    pathNode[i+1]->GetMatrix()->LocalToMasterVect(localCoord, coord);
+    CopyFrom(localCoord, coord);
+  };
+  return kTRUE;
+};
+
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCable::GetCheckVect( const Double_t *localCoord,
+                                       TGeoVolume *vol, Int_t iOccur,
+                                       Int_t motherLevel, Double_t *coord)
+{
+  //
+  // Get the global vect (in coord) correponding to the local vector (localCoord)
+  // of the volume vol. Global at the level of #motherLevel level in the node tree
+  //
+
+  TGeoNode *mainNode;
+  if (fInitialNode==0) {
+    TObjArray *nodes = gGeoManager->GetListOfNodes();
+    if (nodes->GetEntriesFast()==0) return kFALSE;
+    mainNode = (TGeoNode *) nodes->UncheckedAt(0);
+  } else {
+    mainNode = fInitialNode; };
+
+  fCurrentVol = vol;
+  Int_t currentOccur = 0;
+
+  // loop to get the volume position in the tree of nodes
+  ResetCheckDaughter();
+  while ( CheckDaughter(mainNode) && (currentOccur!=iOccur) ) {
+    currentOccur++;
+    Int_t maxLevel = 0;
+    while (fNodeInd[maxLevel]!=-1) maxLevel++;
+    fNodeInd[maxLevel-1]++;
+  };
+
+  Int_t maxLevel = 0;
+  while (fNodeInd[maxLevel]!=-1) maxLevel++;
+  maxLevel--;
+  if (maxLevel<-1) return kFALSE;
+
+  TGeoNode *pathNode[fgkCableMaxNodeLevel];
+  pathNode[0] = mainNode;
+  for (Int_t i=0; i<=maxLevel; i++) {
+    pathNode[i+1] = pathNode[i]->GetDaughter(fNodeInd[i]);
+  };
+
+  if (motherLevel>maxLevel+2) motherLevel = maxLevel+2;
+
+  Double_t tempCoord[3] = {localCoord[0], localCoord[1], localCoord[2]};
+  CopyFrom(coord, tempCoord);
+  for (Int_t i=maxLevel; i>maxLevel-motherLevel; i--) {
+    pathNode[i+1]->GetMatrix()->LocalToMasterVect(tempCoord, coord);
+    CopyFrom(tempCoord, coord);
+  };
+  return kTRUE;
+};
+
diff --git a/ITS/AliITSv11GeomCable.h b/ITS/AliITSv11GeomCable.h
new file mode 100644 (file)
index 0000000..8c1cb55
--- /dev/null
@@ -0,0 +1,89 @@
+#ifndef ALIITSV11GEOMCABLE_H
+#define ALIITSV11GEOMCABLE_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+class TGeoVolume;
+class TGeoNode;
+
+#include <TObjArray.h>
+
+//*************************************************************************
+//   Base class of cable classes
+//
+//
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
+
+
+class AliITSv11GeomCable : public TNamed {
+
+ public:
+  AliITSv11GeomCable()
+    { fInitialNode = 0; fPointArray.SetOwner(); fDebug=0; };
+  AliITSv11GeomCable(const char* name);
+  AliITSv11GeomCable(const AliITSv11GeomCable &source);
+  AliITSv11GeomCable& operator=(const AliITSv11GeomCable &source);
+
+  virtual ~AliITSv11GeomCable();
+  void SetDebug(Int_t debug = 1) {fDebug = debug;};
+
+  void  SetInitialNode(TGeoVolume *vol);
+  void  ResetInitialNode();
+
+  void  AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt, Double_t *coord);
+  virtual Int_t       GetNCheckPoints() const;
+  virtual Int_t       GetPoint(Int_t iCheckPt, Double_t *coord) const;
+  virtual Int_t       GetVect(Int_t iCheckPt, Double_t *coord) const;
+  virtual TGeoVolume* GetVolume( Int_t iCheckPt ) const;
+
+  virtual Int_t       GetCheckPoint( Int_t iCheckPt, Int_t nOccur,
+                                    Int_t motherLevel, Double_t *coord);
+  virtual Int_t       GetCheckVect( Int_t iCheckPt, Int_t nOccur,
+                                   Int_t motherLevel, Double_t *coord);
+  virtual Int_t       GetCheckVect( const Double_t *localCoord,
+                                   TGeoVolume *vol, Int_t nOccur,
+                                   Int_t motherLevel, Double_t *coord);
+  void ResetPoints();
+
+ protected:
+  bool     CheckDaughter(TGeoNode* node, Int_t i = 0);
+  void     ResetCheckDaughter();
+  void     CopyFrom(Double_t *c, const Double_t *o) const;
+  Double_t ScalProd(const Double_t *a, const Double_t *b) const;
+
+  static const Int_t fgkCableMaxNodeLevel = 50; // max. number of levels
+  static const Int_t fgkCableMaxLayer = 15;     // max. number of layers
+
+  Int_t fDebug;                         // debug flag
+  Int_t fNodeInd[fgkCableMaxNodeLevel]; // index of nodes in the node tree
+  TObjArray fPointArray;                // array of points
+  TObjArray fVolumeArray;               // volumes containing the points
+  TGeoVolume *fCurrentVol;              // volume to search in the node tree
+  TGeoNode *fInitialNode;               // initial node to start searching
+
+  ClassDef(AliITSv11GeomCable,1)
+};
+
+inline Int_t AliITSv11GeomCable::GetNCheckPoints() const{
+  return fVolumeArray.GetEntriesFast(); };
+
+inline void AliITSv11GeomCable::ResetCheckDaughter() {
+  for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) fNodeInd[i] = -1; };
+
+inline void AliITSv11GeomCable::CopyFrom(Double_t *c, const Double_t *o)
+const { *(c++)=*(o++); *(c++)=*(o++); *c=*o; };
+
+inline Double_t AliITSv11GeomCable::ScalProd(const Double_t *a,
+                                               const Double_t *b) const {
+  Double_t s = *(a++)*(*(b++)); s+=*(a++)*(*(b++)); s+=*a*(*b);
+  return s;
+};
+
+
+
+
+
+#endif
diff --git a/ITS/AliITSv11GeomCableFlat.cxx b/ITS/AliITSv11GeomCableFlat.cxx
new file mode 100644 (file)
index 0000000..725dfc3
--- /dev/null
@@ -0,0 +1,506 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * 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.                  *
+ **************************************************************************/
+
+
+//*************************************************************************
+//   Class for flat cables
+//
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
+
+
+
+// General Root includes
+//#include <Riostream.h>
+#include <TMath.h>
+#include <TVectorD.h>
+
+// Root Geometry includes
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoArb8.h>
+#include <TGeoMatrix.h>
+#include <TGeoNode.h>
+
+#include "AliITSv11GeomCableFlat.h"
+
+
+ClassImp(AliITSv11GeomCableFlat)
+
+//________________________________________________________________________
+AliITSv11GeomCableFlat::AliITSv11GeomCableFlat() : AliITSv11GeomCable()
+{
+  // constructor
+  fWidth = 0;
+  fThick = 0;
+  fNlayer = 0;
+  for (Int_t i=0; i<fgkCableMaxLayer ; i++) {
+    fLayThickness[i] = 0;
+    fTranslation[i]  = 0;
+    fLayColor[i]     = 0;
+    fLayMedia[i]     = 0;  
+ };
+};
+
+//________________________________________________________________________
+AliITSv11GeomCableFlat::
+AliITSv11GeomCableFlat(const char* name, Double_t width, Double_t thick) :
+AliITSv11GeomCable(name) {
+  // standard constructor
+  fWidth = width;
+  fThick = thick;
+  fNlayer = 0;
+  for (Int_t i=0; i<fgkCableMaxLayer ; i++) {
+    fLayThickness[i] = 0;
+    fTranslation[i]  = 0;
+    fLayColor[i]     = 0;
+    fLayMedia[i]     = 0;  
+  }; 
+};
+
+//________________________________________________________________________
+AliITSv11GeomCableFlat::AliITSv11GeomCableFlat(const AliITSv11GeomCableFlat &s) :
+  AliITSv11GeomCable(s),fWidth(s.fWidth),fThick(s.fThick),fNlayer(s.fNlayer)
+{
+  //     Copy Constructor 
+  for (Int_t i=0; i<s.fNlayer; i++) {
+    fLayThickness[i] = s.fLayThickness[i];
+    fTranslation[i] = s.fTranslation[i];
+    fLayMedia[i] = s.fLayMedia[i];
+    fLayColor[i] = s.fLayColor[i];
+  }
+}
+
+//________________________________________________________________________
+AliITSv11GeomCableFlat& AliITSv11GeomCableFlat::
+operator=(const AliITSv11GeomCableFlat &s) {
+  //     Assignment operator
+  // Not fully inplemented yet !!!
+
+  if(&s == this) return *this;
+  *this = s;
+  fWidth = s.fWidth;
+  fThick = s.fThick;
+  fNlayer = s.fNlayer;
+  for (Int_t i=0; i<s.fNlayer; i++) {
+    fLayThickness[i] = s.fLayThickness[i];
+    fTranslation[i] = s.fTranslation[i];
+    fLayMedia[i] = s.fLayMedia[i];
+    fLayColor[i] = s.fLayColor[i];
+  };
+  return *this;
+}
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableFlat::GetPoint( Int_t iCheckPt, Double_t *coord)
+  const {
+  // Get the correct point #iCheckPt
+  TVectorD *coordVector =(TVectorD *)fPointArray.At(2*iCheckPt);
+  if (coordVector) {
+    CopyFrom(coord, coordVector->GetMatrixArray());
+    return kTRUE;
+  } else {
+    return kFALSE;
+  };
+};
+
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableFlat::GetVect( Int_t iCheckPt, Double_t *coord)
+  const {
+  // Get the correct vect corresponding to point #iCheckPt
+
+  TVectorD *coordVector =(TVectorD *)fPointArray.At(2*iCheckPt+1);
+  if (coordVector) {
+    CopyFrom(coord, coordVector->GetMatrixArray());
+    return kTRUE;
+  } else {
+    return kFALSE;
+  };
+};
+
+
+//________________________________________________________________________
+void AliITSv11GeomCableFlat::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
+                                           Double_t *coord, Double_t *orthVect)
+{
+  //
+  // Add a check point. In the fPointArray, the point is at i and its vector
+  // is at i+1.
+  //
+
+//   if (iCheckPt>=fVolumeArray.GetEntriesFast()) {
+//     fVolumeArray.AddLast(vol);
+//     TVectorD *point = new TVectorD(3,coord);
+//     TVectorD *vect  = new TVectorD(3,orthVect);
+//     fPointArray.AddLast(point);
+//     fPointArray.AddLast(vect);
+
+//   } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) {
+//     fVolumeArray.AddAt(vol, iCheckPt);
+//     TVectorD *point = new TVectorD(3,coord);
+//     TVectorD *vect  = new TVectorD(3,orthVect);
+//     fPointArray.AddAt(point, iCheckPt*2  );
+//     fPointArray.AddAt(vect,  iCheckPt*2+1);
+//   };
+  fVolumeArray.AddAtAndExpand(vol, iCheckPt);
+  TVectorD *point = new TVectorD(3,coord);
+  TVectorD *vect  = new TVectorD(3,orthVect);
+  fPointArray.AddAtAndExpand(point, iCheckPt*2  );
+  fPointArray.AddAtAndExpand(vect,  iCheckPt*2+1);
+};
+
+//________________________________________________________________________
+void AliITSv11GeomCableFlat::PrintCheckPoints() const {
+  // print all check points of the cable
+  printf("  ---\n  Printing all check points of the flat cable\n");
+  for (Int_t i = 0; i<fVolumeArray.GetEntriesFast(); i++) {
+     Double_t coord[3];
+     if (GetPoint( i, coord))
+       printf("   ( %.2f, %.2f, %.2f )\n", coord[0], coord[1], coord[2]);
+  };
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2,
+                                                         Double_t rotation)
+{
+//    Creates a cable segment between points p1 and p2.
+//    Rotation is the eventual rotation of the flat cable
+//    along its length axis
+//
+// The segment volume is created inside the volume containing point2
+// Therefore this segment should be defined in this volume only.
+// I mean here that, if the previous point is in another volume,
+// it should be just at the border between the 2 volumes. Also the
+// orientation vector of the previous point should be orthogonal to
+// the surface between the 2 volumes.
+
+  TGeoNode *mainNode;
+  if (fInitialNode==0) {
+    TObjArray *nodes = gGeoManager->GetListOfNodes();
+    if (nodes->GetEntriesFast()==0) return kFALSE;
+    mainNode = (TGeoNode *) nodes->UncheckedAt(0);
+  } else {
+    mainNode = fInitialNode;
+  };
+
+  Int_t p1 = p2 - 1;
+  TGeoVolume *p2Vol = GetVolume(p2);
+  TGeoVolume *p1Vol = GetVolume(p1);
+
+  ResetCheckDaughter();
+  fCurrentVol = p1Vol;
+  if (! CheckDaughter(mainNode)) {
+    printf("Error::volume containing point is not visible in node tree!\n");
+    return kFALSE;
+  };
+
+  Double_t coord1[3], coord2[3], vect1[3], vect2[3];
+  //=================================================
+  // Get p1 position in the systeme of p2
+  if (p1Vol!=p2Vol) {
+
+    Int_t p1nodeInd[fgkCableMaxNodeLevel]; 
+    for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p1nodeInd[i]=fNodeInd[i];
+    Int_t p1volLevel = 0;
+    while (p1nodeInd[p1volLevel]!=-1) p1volLevel++;
+    p1volLevel--;
+
+    ResetCheckDaughter();
+    fCurrentVol = p2Vol;
+    if (! CheckDaughter(mainNode)) {
+      printf("Error::volume containing point is not visible in node tree!\n");
+      return kFALSE;
+    };
+    Int_t p2nodeInd[fgkCableMaxNodeLevel];
+    for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p2nodeInd[i]=fNodeInd[i];
+    Int_t commonMotherLevel = 0;
+    while (p1nodeInd[commonMotherLevel]==fNodeInd[commonMotherLevel])
+      commonMotherLevel++;
+    commonMotherLevel--;
+    Int_t p2volLevel = 0;
+    while (fNodeInd[p2volLevel]!=-1) p2volLevel++;
+    p2volLevel--;
+
+    // Get coord and vect of p1 in the common mother reference system
+    if (! GetCheckPoint(p1, 0, p1volLevel-commonMotherLevel, coord1) )
+      return kFALSE;
+    if (! GetCheckVect( p1, 0, p1volLevel-commonMotherLevel, vect1) )
+      return kFALSE;
+
+    // Translate them in the reference system of the volume containing p2    
+    TGeoNode *pathNode[fgkCableMaxNodeLevel];
+    pathNode[0] = mainNode;
+    for (Int_t i=0; i<=p2volLevel; i++) {
+      pathNode[i+1] = pathNode[i]->GetDaughter(p2nodeInd[i]);
+    };
+    Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]}; 
+    Double_t globalVect1[3]  = {vect1[0], vect1[1], vect1[2]};
+
+    for (Int_t i = commonMotherLevel+1; i <= p2volLevel; i++) {
+      pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1);
+      pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1);
+      CopyFrom(globalCoord1, coord1);
+      CopyFrom(globalVect1, vect1);
+    };
+  } else {
+    if (! GetCheckPoint(p1, 0, 0, coord1) ) return kFALSE;
+    if (! GetCheckVect(p1, 0, 0, vect1) ) return kFALSE;
+  };
+  
+  //=================================================
+  // Get p2 position in the systeme of p2
+  if (! GetCheckPoint(p2, 0, 0, coord2) ) return kFALSE;
+  if (! GetCheckVect(p2, 0, 0, vect2) ) return kFALSE;
+
+  Double_t cx = (coord1[0]+coord2[0])/2;
+  Double_t cy = (coord1[1]+coord2[1])/2;
+  Double_t cz = (coord1[2]+coord2[2])/2;
+  Double_t dx = coord2[0]-coord1[0];
+  Double_t dy = coord2[1]-coord1[1];
+  Double_t dz = coord2[2]-coord1[2];
+
+  //=================================================
+  // Positionning of the segment between the 2 points
+  if (TMath::Abs(dy)<1e-231) dy = 1e-231;
+  if (TMath::Abs(dz)<1e-231) dz = 1e-231;
+  //Double_t angleRot1 = -TMath::ATan(dx/dy);
+  //Double_t planDiagL = -TMath::Sqrt(dy*dy+dx*dx);
+  //if (dy<0) planDiagL = -planDiagL;
+  //Double_t angleRotDiag = TMath::ATan(planDiagL/dz);
+
+  Double_t angleRot1    = -TMath::ATan2(dx,dy);
+  Double_t planDiagL    =  TMath::Sqrt(dy*dy+dx*dx);
+  Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz);
+  //--- (Calculate rotation of segment on the Z axis)
+  //-- Here I'm trying to calculate the rotation to be applied in
+  //-- order to match as closer as possible this segment and the 
+  //-- previous one. 
+  //-- It seems that some times it doesn't work ...
+  Double_t angleRotZ = 0;
+  TGeoRotation rotTemp("",angleRot1*TMath::RadToDeg(),
+                      angleRotDiag*TMath::RadToDeg(), rotation);
+  Double_t localX[3] = {0,1,0};
+  Double_t globalX[3];
+  rotTemp.LocalToMasterVect(localX, globalX);
+  CopyFrom(localX, globalX);
+  GetCheckVect(localX, p2Vol, 0, fgkCableMaxNodeLevel+1, globalX);
+  Double_t orthVect[3];
+  GetCheckVect(vect1, p2Vol, 0, fgkCableMaxNodeLevel+1, orthVect);
+  if (p2>1) {
+    Double_t orthVectNorm2 = ScalProd(orthVect,orthVect);
+    Double_t alpha1 = ScalProd(fPreviousX,orthVect)/orthVectNorm2;
+    Double_t alpha2 = ScalProd(globalX,orthVect)/orthVectNorm2;
+    Double_t globalX1p[3], globalX2p[3];
+    globalX1p[0] = fPreviousX[0] - alpha1*orthVect[0];
+    globalX1p[1] = fPreviousX[1] - alpha1*orthVect[1];
+    globalX1p[2] = fPreviousX[2] - alpha1*orthVect[2];
+    globalX2p[0] = globalX[0] - alpha2*orthVect[0];
+    globalX2p[1] = globalX[1] - alpha2*orthVect[1];
+    globalX2p[2] = globalX[2] - alpha2*orthVect[2];
+    //-- now I'm searching the 3th vect which makes an orthogonal base
+    //-- with orthVect and globalX1p ...
+    Double_t nulVect[3] = {0,0,0};
+    Double_t axis3[3];
+    TMath::Normal2Plane(nulVect, orthVect, globalX1p, axis3);
+    Double_t globalX1pNorm2 = ScalProd(globalX1p, globalX1p);
+    Double_t beta = ScalProd(globalX2p, globalX1p)/globalX1pNorm2;
+    Double_t gamma = ScalProd(globalX2p, axis3);
+    angleRotZ = (TMath::ATan2(1,0) - TMath::ATan2(beta, gamma))
+                *TMath::RadToDeg();
+  };
+  //   cout << "!!!!!!!!!!!!!!!!!!!  angle = " <<angleRotZ << endl;
+  CopyFrom(fPreviousX, globalX);
+  //---
+  Double_t localVect1[3], localVect2[3];
+  TGeoRotation rot("",angleRot1*TMath::RadToDeg(),
+                  angleRotDiag*TMath::RadToDeg(),
+                  rotation);
+//                rotation-angleRotZ);
+// since angleRotZ doesn't always work, I won't use it ...
+
+  rot.MasterToLocalVect(vect1, localVect1);
+  rot.MasterToLocalVect(vect2, localVect2);
+
+  //=================================================
+  // Create the segment and add it to the mother volume
+  TGeoVolume *vCableSegB = CreateSegment(coord1, coord2,
+                                        localVect1, localVect2);
+
+  TGeoRotation rotArbSeg("", 0, 90, 0);
+  rotArbSeg.MultiplyBy(&rot, kFALSE);
+  TGeoTranslation trans("",cx, cy, cz);
+  TGeoCombiTrans  *combiB = new TGeoCombiTrans(trans, rotArbSeg);
+  p2Vol->AddNode(vCableSegB, p2, combiB);
+  //=================================================;
+
+  if (fDebug) {
+    printf("---\n  Cable segment points : ");
+    printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]);
+    printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]);
+  };
+
+//   #include <TGeoSphere.h>
+//   TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
+//   TGeoSphere *sphere = new TGeoSphere(0, 0.05);
+//   TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD);
+//   TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz);
+//   TGeoTranslation *tr1 = new TGeoTranslation("",coord1[0],
+//                                          coord1[1],coord1[2]);
+//   TGeoTranslation *tr2 = new TGeoTranslation("",coord2[0],
+//                                          coord2[1],coord2[2]);
+//   p2Vol->AddNode(vSphere, p2*3-2, trC);
+//   p2Vol->AddNode(vSphere, p2*3-1, tr1);
+//   p2Vol->AddNode(vSphere, p2*3  , tr2);
+
+  return kTRUE;
+};
+
+//________________________________________________________________________
+TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1,
+                                                     Double_t *coord2,
+                                                     Double_t *localVect1,
+                                                     Double_t *localVect2 )
+{
+
+  //=================================================
+  // Calculate segment "deformation"
+  Double_t dx = coord2[0]-coord1[0];
+  Double_t dy = coord2[1]-coord1[1];
+  Double_t dz = coord2[2]-coord1[2];
+  Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
+
+  Double_t cosTheta1 = -1./TMath::Sqrt( 1 + localVect1[0]*localVect1[0]
+                                       /localVect1[2]/localVect1[2] );
+  Double_t cosTheta2 = 1./TMath::Sqrt( 1 + localVect2[0]*localVect2[0]
+                                       /localVect2[2]/localVect2[2] );
+  if (localVect1[2]<0) cosTheta1 = -cosTheta1;
+  if (localVect2[2]<0) cosTheta2 = -cosTheta2;
+
+  Double_t dL1 = 0.5*fWidth*TMath::Tan(TMath::ACos(cosTheta1));
+  Double_t dL2 = 0.5*fWidth*TMath::Tan(TMath::ACos(cosTheta2));
+  if (localVect1[0]<0) dL1 = - dL1;
+  if (localVect2[0]<0) dL2 = - dL2;
+  //---
+  Double_t cosPhi1 = -1./TMath::Sqrt( 1 + localVect1[1]*localVect1[1]
+                                       /localVect1[2]/localVect1[2] );
+  Double_t cosPhi2 = 1./TMath::Sqrt( 1 + localVect2[1]*localVect2[1]
+                                       /localVect2[2]/localVect2[2] );
+  if (localVect1[2]<0) cosPhi1 = -cosPhi1;
+  if (localVect2[2]<0) cosPhi2 = -cosPhi2;
+
+  Double_t tanACosCosPhi1 = TMath::Tan(TMath::ACos(cosPhi1));
+  Double_t tanACosCosPhi2 = TMath::Tan(TMath::ACos(cosPhi2));
+  if (localVect1[1]<0) tanACosCosPhi1 = -tanACosCosPhi1;
+  if (localVect2[1]<0) tanACosCosPhi2 = -tanACosCosPhi2;
+
+  Double_t dl1 = 0.5*fThick*tanACosCosPhi1;
+  Double_t dl2 = 0.5*fThick*tanACosCosPhi2;
+
+  //=================================================
+  // Create the segment
+  TGeoArb8 *cableSeg = new TGeoArb8(fThick/2);
+  cableSeg->SetVertex( 0, -fWidth/2, -length/2 - dL1 + dl1);
+  cableSeg->SetVertex( 1,  fWidth/2, -length/2 + dL1 + dl1);
+  cableSeg->SetVertex( 2,  fWidth/2,  length/2 - dL2 - dl2);
+  cableSeg->SetVertex( 3, -fWidth/2,  length/2 + dL2 - dl2);
+  cableSeg->SetVertex( 4, -fWidth/2, -length/2 - dL1 - dl1);
+  cableSeg->SetVertex( 5,  fWidth/2, -length/2 + dL1 - dl1);
+  cableSeg->SetVertex( 6,  fWidth/2,  length/2 - dL2 + dl2);
+  cableSeg->SetVertex( 7, -fWidth/2,  length/2 + dL2 + dl2);
+
+  TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair");
+  TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD);
+
+  // add all cable layers
+  for (Int_t iLay=0; iLay<fNlayer; iLay++) {
+
+    Double_t dl1Lay = 0.5*fLayThickness[iLay]*tanACosCosPhi1;
+    Double_t dl2Lay = 0.5*fLayThickness[iLay]*tanACosCosPhi2;
+    Double_t ztr = -fThick/2;
+    for (Int_t i=0;i<iLay; i++) ztr+= fLayThickness[i];
+    ztr+= fLayThickness[iLay]/2;
+
+    Double_t dl1LayS = ztr*tanACosCosPhi1;
+    Double_t dl2LayS = ztr*tanACosCosPhi2;
+
+    TGeoArb8 *lay = new TGeoArb8(fLayThickness[iLay]/2);
+    lay->SetVertex( 0, -fWidth/2, -length/2 - dL1 + dl1Lay - dl1LayS);
+    lay->SetVertex( 1,  fWidth/2, -length/2 + dL1 + dl1Lay - dl1LayS);
+    lay->SetVertex( 2,  fWidth/2,  length/2 - dL2 - dl2Lay + dl2LayS);
+    lay->SetVertex( 3, -fWidth/2,  length/2 + dL2 - dl2Lay + dl2LayS);
+    lay->SetVertex( 4, -fWidth/2, -length/2 - dL1 - dl1Lay - dl1LayS);
+    lay->SetVertex( 5,  fWidth/2, -length/2 + dL1 - dl1Lay - dl1LayS);
+    lay->SetVertex( 6,  fWidth/2,  length/2 - dL2 + dl2Lay + dl2LayS);
+    lay->SetVertex( 7, -fWidth/2,  length/2 + dL2 + dl2Lay + dl2LayS);
+    TGeoVolume *vLay = new TGeoVolume("vCableSegLay", lay, fLayMedia[iLay]);
+    vLay->SetLineColor(fLayColor[iLay]);
+    
+    if (fTranslation[iLay]==0)
+      fTranslation[iLay] = new TGeoTranslation(0, 0, ztr);
+    vCableSeg->AddNode(vLay, iLay+1, fTranslation[iLay]);
+  };
+
+  vCableSeg->SetVisibility(kFALSE);
+  return vCableSeg;
+};
+
+
+//________________________________________________________________________
+void AliITSv11GeomCableFlat::SetNLayers(Int_t nLayers) {
+  // Set the number of layers
+  if((nLayers>0) &&(nLayers<=fgkCableMaxLayer)) {
+
+    fNlayer = nLayers;
+    for (Int_t i=0; i<fgkCableMaxLayer ; i++) {
+      fLayThickness[i] = 0;
+      fTranslation[i]  = 0;
+      fLayColor[i]     = 0;
+      fLayMedia[i]     = 0;  
+    }; 
+  };
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableFlat::SetLayer(Int_t nLayer, Double_t thick,
+                                         TGeoMedium *medium, Int_t color) {
+  // Set the layer number nLayer
+  if ((nLayer<0)||(nLayer>=fNlayer)) {
+    printf("Set wrong layer number of the cable\n");
+    return kFALSE;
+  };
+  if (nLayer>0)
+    if (fLayThickness[nLayer-1]<=0) {
+      printf("AliITSv11GeomCableFlat::SetLayer():"
+            " You must define cable layer %i first !",nLayer-1);
+      return kFALSE;
+    };
+
+  Double_t thickTot = 0;
+  for (Int_t i=0; i<nLayer; i++) thickTot += fLayThickness[i];
+  thickTot += thick;
+  if (thickTot-1e-10>fThick) {
+    printf("Can't add this layer, cable thickness would be higher than total\n");
+    return kFALSE;
+  };
+
+  fLayThickness[nLayer] = thick;
+  fLayMedia[nLayer] = medium;
+  fLayColor[nLayer] = color;
+  fTranslation[nLayer]  = 0;
+  return kTRUE;
+};
diff --git a/ITS/AliITSv11GeomCableFlat.h b/ITS/AliITSv11GeomCableFlat.h
new file mode 100644 (file)
index 0000000..4f8620f
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef ALIITSV11GEOMCABLEFLAT_H
+#define ALIITSV11GEOMCABLEFLAT_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+//*************************************************************************
+//   Class for flat cables
+//
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
+
+class TGeoVolume;
+class TGeoTranslation;
+//class TGeoCombiTrans;
+//class TGeoArb8;
+//class TGeoNode;
+class TGeoMedium;
+
+#include "AliITSv11GeomCable.h"
+
+class AliITSv11GeomCableFlat : public AliITSv11GeomCable {
+
+ public:
+  AliITSv11GeomCableFlat();
+  AliITSv11GeomCableFlat(const char* name, Double_t width, Double_t thick);
+  AliITSv11GeomCableFlat(const AliITSv11GeomCableFlat &source);
+  AliITSv11GeomCableFlat& operator=(const AliITSv11GeomCableFlat &source);
+  virtual ~AliITSv11GeomCableFlat() {};
+
+  void     SetNLayers(Int_t nLayers);
+  Int_t    SetLayer(Int_t nLayer,Double_t thick,TGeoMedium *medium,Int_t color=0);
+  void     AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
+                       Double_t *coord, Double_t *orthVect);
+  Int_t    CreateAndInsertCableSegment(Int_t p2, Double_t rotation=0);
+  void     SetWidth(Double_t width) { fWidth = width;};
+  void     SetThickness(Double_t thick) {fThick = thick;};
+  Double_t GetWidth() const {return fWidth;};
+  Double_t GetThickness() const {return fThick;};
+
+  virtual void  PrintCheckPoints() const;
+  virtual Int_t GetPoint(Int_t iCheckPt, Double_t *coord) const;
+  virtual Int_t GetVect(Int_t iCheckPt, Double_t *coord) const;
+
+ protected:
+  TGeoVolume *CreateSegment( Double_t *coord1,Double_t *coord2,
+                            Double_t *localVect1, Double_t *localVect2 );
+
+  Double_t  fWidth;                                 // width
+  Double_t  fThick;                                 // total thickness
+  Int_t     fNlayer;                                // number of layers
+  Double_t  fPreviousX[3];                          // used internally
+  Double_t         fLayThickness[fgkCableMaxLayer]; // layer thicknesses
+  TGeoTranslation *fTranslation[fgkCableMaxLayer];  // layer translations
+  TGeoMedium      *fLayMedia[fgkCableMaxLayer];     // layer media
+  Int_t            fLayColor[fgkCableMaxLayer];     // layer colors
+
+  ClassDef(AliITSv11GeomCableFlat,1)
+};
+
+
+#endif
diff --git a/ITS/AliITSv11GeomCableRound.cxx b/ITS/AliITSv11GeomCableRound.cxx
new file mode 100644 (file)
index 0000000..362fc6d
--- /dev/null
@@ -0,0 +1,390 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * 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.                  *
+ **************************************************************************/
+
+
+
+// General Root includes
+//#include <Riostream.h>
+#include <TMath.h>
+#include <TVectorD.h>
+
+// Root Geometry includes
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoTube.h>
+#include <TGeoMatrix.h>
+
+#include "AliITSv11GeomCableRound.h"
+
+//*************************************************************************
+//   Class for round cables
+//
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
+
+ClassImp(AliITSv11GeomCableRound)
+
+//________________________________________________________________________
+AliITSv11GeomCableRound::
+AliITSv11GeomCableRound(const char* name, Double_t radius) :
+AliITSv11GeomCable(name) {
+  // Constructor
+  fRadius = radius;
+  fNlayer = 0;
+  for (Int_t i=0; i<fgkCableMaxLayer ; i++) {
+    fLayThickness[i] = 0;
+    fLayColor[i] = 0;
+    fLayMedia[i] = 0;
+  };
+  fPhiMin = 0;
+  fPhiMax = 360;
+};
+
+//________________________________________________________________________
+AliITSv11GeomCableRound::AliITSv11GeomCableRound(const AliITSv11GeomCableRound &s) :
+  AliITSv11GeomCable(s),fRadius(s.fRadius),fNlayer(s.fNlayer),fPhiMin(s.fPhiMin),
+  fPhiMax(s.fPhiMax)
+{
+  //     Copy Constructor 
+  for (Int_t i=0; i<s.fNlayer; i++) {
+    fLayThickness[i] = s.fLayThickness[i];
+    fLayMedia[i] = s.fLayMedia[i];
+    fLayColor[i] = s.fLayColor[i];
+  }
+}
+
+//________________________________________________________________________
+AliITSv11GeomCableRound& AliITSv11GeomCableRound::
+operator=(const AliITSv11GeomCableRound &s) {
+  //     Assignment operator
+  // Not fully inplemented yet !!!
+
+  if(&s == this) return *this;
+  *this = s;
+  fRadius = s.fRadius;
+  fPhiMin = s.fPhiMin;
+  fPhiMax = s.fPhiMax;
+  fNlayer = s.fNlayer;
+  for (Int_t i=0; i<s.fNlayer; i++) {
+    fLayThickness[i] = s.fLayThickness[i];
+    fLayMedia[i] = s.fLayMedia[i];
+    fLayColor[i] = s.fLayColor[i];
+  };
+  return *this;
+}
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableRound::GetPoint( Int_t iCheckPt, Double_t *coord)
+  const {
+  // Get check point #iCheckPt
+  TVectorD *coordVector =(TVectorD *)fPointArray.UncheckedAt(2*iCheckPt);
+  CopyFrom(coord, coordVector->GetMatrixArray());
+  return kTRUE;
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableRound::GetVect( Int_t iCheckPt, Double_t *coord)
+  const {
+  //
+  // Get vector transverse to the section at point #iCheckPt
+  //
+
+  TVectorD *coordVector =(TVectorD *)fPointArray.UncheckedAt(2*iCheckPt+1);
+  CopyFrom(coord, coordVector->GetMatrixArray());
+  return kTRUE;
+};
+//________________________________________________________________________
+void AliITSv11GeomCableRound::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
+                                              Double_t *coord, Double_t *orthVect)
+{
+  //
+  // Add point #iCheckPt and its transverse vector. Point is added at (i) in
+  // fPointArray and the vector is added at (i+1)
+  //
+
+
+  if (iCheckPt>=fVolumeArray.GetEntriesFast()) {
+    fVolumeArray.AddLast(vol);
+    TVectorD *point = new TVectorD(3,coord);
+    TVectorD *vect  = new TVectorD(3,orthVect);
+    fPointArray.AddLast(point);
+    fPointArray.AddLast(vect);
+
+  } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) {
+    fVolumeArray.AddAt(vol, iCheckPt);
+    TVectorD *point = new TVectorD(3,coord);
+    TVectorD *vect  = new TVectorD(3,orthVect);
+    fPointArray.AddAt(point, iCheckPt*2  );
+    fPointArray.AddAt(vect,  iCheckPt*2+1);
+  };
+};
+
+//________________________________________________________________________
+void AliITSv11GeomCableRound::PrintCheckPoints() const {
+  // Print all check points
+
+  printf("  ---\n  Printing all check points of the round cable\n");
+  for (Int_t i = 0; i<fVolumeArray.GetEntriesFast(); i++) {
+    TVectorD *coordVector = (TVectorD *)fPointArray.UncheckedAt(i*2);
+    //TVectorD *vectVector = (TVectorD *)fPointArray.UncheckedAt(i*2+1);
+    Double_t coord[3];
+    CopyFrom(coord, coordVector->GetMatrixArray());
+
+    printf("   ( %.2f, %.2f, %.2f )\n", coord[0], coord[1], coord[2]);
+  };
+
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableRound::CreateAndInsertCableSegment(Int_t p2)
+{
+//    Creates a cable segment between points p1 and p2.
+//    Rotation is the eventual rotation of the flat cable
+//    along its length axis
+//
+// The segment volume is created inside the volume containing point2
+// Therefore this segment should be defined in this volume only.
+// I mean here that, if the previous point is in another volume,
+// it should be just at the border between the 2 volumes. Also the
+// orientation vector of the previous point should be othogonal to
+// the surface between the 2 volumes.
+
+  TGeoNode *mainNode;
+  if (fInitialNode==0) {
+    TObjArray *nodes = gGeoManager->GetListOfNodes();
+    if (nodes->GetEntriesFast()==0) return kFALSE;
+    mainNode = (TGeoNode *) nodes->UncheckedAt(0);
+  } else {
+    mainNode = fInitialNode;
+  };
+
+  Int_t p1 = p2 - 1;
+  TGeoVolume *p1Vol = GetVolume(p1);
+  TGeoVolume *p2Vol = GetVolume(p2);
+
+  ResetCheckDaughter();
+  fCurrentVol = p1Vol;
+  if (! CheckDaughter(mainNode)) {
+    printf("Error::volume containing point is not visible in node tree!\n");
+    return kFALSE;
+  };
+
+  Double_t coord1[3], coord2[3], vect1[3], vect2[3];
+  //=================================================
+  // Get p1 position in the systeme of p2
+  if (p1Vol!=p2Vol) {
+
+    Int_t p1nodeInd[fgkCableMaxNodeLevel]; 
+    for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p1nodeInd[i]=fNodeInd[i];
+    Int_t p1volLevel = 0;
+    while (p1nodeInd[p1volLevel]!=-1) p1volLevel++;
+    p1volLevel--;
+
+    ResetCheckDaughter();
+    fCurrentVol = p2Vol;
+    if (! CheckDaughter(mainNode)) {
+      printf("Error::volume containing point is not visible in node tree!\n");
+      return kFALSE;
+    };
+    Int_t p2nodeInd[fgkCableMaxNodeLevel];
+    for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p2nodeInd[i]=fNodeInd[i];
+    Int_t commonMotherLevel = 0;
+    while (p1nodeInd[commonMotherLevel]==fNodeInd[commonMotherLevel])
+      commonMotherLevel++;
+    commonMotherLevel--;
+    Int_t p2volLevel = 0;
+    while (fNodeInd[p2volLevel]!=-1) p2volLevel++;
+    p2volLevel--;
+
+    // Get coord and vect of p1 in the common mother reference system
+    GetCheckPoint(p1, 0, p1volLevel-commonMotherLevel, coord1);
+    GetCheckVect( p1, 0, p1volLevel-commonMotherLevel, vect1);
+    // Translate them in the reference system of the volume containing p2    
+    TGeoNode *pathNode[fgkCableMaxNodeLevel];
+    pathNode[0] = mainNode;
+    for (Int_t i=0; i<=p2volLevel; i++) {
+      pathNode[i+1] = pathNode[i]->GetDaughter(p2nodeInd[i]);
+    };
+    Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]}; 
+    Double_t globalVect1[3]  = {vect1[0], vect1[1], vect1[2]};
+
+    for (Int_t i = commonMotherLevel+1; i<=p2volLevel; i++) {
+      pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1);
+      pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1);
+      CopyFrom(globalCoord1, coord1);
+      CopyFrom(globalVect1, vect1);
+    };
+  } else {
+    GetCheckPoint(p1, 0, 0, coord1);
+    GetCheckVect(p1, 0, 0, vect1);
+  };
+  
+  //=================================================
+  // Get p2 position in the systeme of p2
+  GetCheckPoint(p2, 0, 0, coord2);
+  GetCheckVect(p2, 0, 0, vect2);
+
+  Double_t cx = (coord1[0]+coord2[0])/2;
+  Double_t cy = (coord1[1]+coord2[1])/2;
+  Double_t cz = (coord1[2]+coord2[2])/2;
+  Double_t dx = coord2[0]-coord1[0];
+  Double_t dy = coord2[1]-coord1[1];
+  Double_t dz = coord2[2]-coord1[2];
+
+  //=================================================
+  // Positionning of the segment between the 2 points
+  if ((dy<1e-31)&&(dy>0)) dy = 1e-31;
+  if ((dz<1e-31)&&(dz>0)) dz = 1e-31;
+  if ((dy>-1e-31)&&(dy<0)) dy = -1e-31;
+  if ((dz>-1e-31)&&(dz<0)) dz = -1e-31;
+
+  Double_t angleRot1 = -TMath::ATan2(dx,dy);
+  Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx);
+  Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz);
+  TGeoRotation *rot = new TGeoRotation("",angleRot1*TMath::RadToDeg(),
+                                      angleRotDiag*TMath::RadToDeg(),
+                                      0);
+  Double_t localVect1[3], localVect2[3];
+  rot->MasterToLocalVect(vect1, localVect1);
+  rot->MasterToLocalVect(vect2, localVect2);
+  TGeoTranslation *trans = new TGeoTranslation("",cx, cy, cz);
+
+  //=================================================
+  // Create the segment and add it to the mother volume
+  TGeoVolume *vCableSeg = CreateSegment(coord1, coord2,
+                                       localVect1, localVect2);
+
+  TGeoCombiTrans  *combi = new TGeoCombiTrans(*trans, *rot);
+  p2Vol->AddNode(vCableSeg, p2, combi);
+  //=================================================
+  delete rot;
+  delete trans;
+
+  if (fDebug) {
+    printf("---\n  Cable segment points : ");
+    printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]);
+    printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]);
+  };
+//   #include <TGeoSphere.h>
+//   TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
+//   TGeoSphere *sphere = new TGeoSphere(0, 0.15);
+//   TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD);
+//   TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz);
+//   TGeoTranslation *tr1 = new TGeoTranslation("",coord1[0],
+//                                          coord1[1],coord1[2]);
+//   TGeoTranslation *tr2 = new TGeoTranslation("",coord2[0],
+//                                          coord2[1],coord2[2]);
+//   p2Vol->AddNode(vSphere, p2*3-2, trC);
+//   p2Vol->AddNode(vSphere, p2*3-1, tr1);
+//   p2Vol->AddNode(vSphere, p2*3  , tr2);
+
+  return kTRUE;
+};
+
+//________________________________________________________________________
+TGeoVolume *AliITSv11GeomCableRound::CreateSegment( Double_t *coord1,
+                                                     Double_t *coord2,
+                                                     Double_t *localVect1,
+                                                     Double_t *localVect2 )
+{
+
+  //=================================================
+  // Calculate segment "deformation"
+  Double_t dx = coord2[0]-coord1[0];
+  Double_t dy = coord2[1]-coord1[1];
+  Double_t dz = coord2[2]-coord1[2];
+  Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
+
+  // normal vectors have to point outside the TGeoCtub :
+  if (-localVect1[2]<0) {
+    localVect1[0] = -localVect1[0];
+    localVect1[1] = -localVect1[1];
+    localVect1[2] = -localVect1[2];
+  };
+  if (localVect2[2]<0) {
+    localVect2[0] = -localVect2[0];
+    localVect2[1] = -localVect2[1];
+    localVect2[2] = -localVect2[2];
+  };
+  //=================================================
+  // Create the segment
+  TGeoCtub *cableSeg = new TGeoCtub(0., fRadius, length/2, fPhiMin, fPhiMax,
+                                   localVect1[0],localVect1[1],localVect1[2],
+                                   localVect2[0],localVect2[1],localVect2[2]);
+
+  TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair");
+  TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD);
+
+  // add all cable layers
+  Double_t layThickness[100+1];                        // 100 layers max !!!
+  layThickness[0] = 0;
+  for (Int_t iLay=0; iLay<fNlayer; iLay++) {
+    
+    layThickness[iLay+1] = fLayThickness[iLay]+layThickness[iLay];
+    TGeoCtub *lay = new TGeoCtub(layThickness[iLay], layThickness[iLay+1],
+                                length/2, fPhiMin, fPhiMax,
+                                localVect1[0],localVect1[1],localVect1[2],
+                                localVect2[0],localVect2[1],localVect2[2]);
+
+    TGeoVolume *vLay = new TGeoVolume("vCableSegLay", lay, fLayMedia[iLay]);
+    vLay->SetLineColor(fLayColor[iLay]);
+    vCableSeg->AddNode(vLay, iLay+1, 0);
+  };
+
+  vCableSeg->SetVisibility(kFALSE);
+  return vCableSeg;
+};
+
+
+//________________________________________________________________________
+void AliITSv11GeomCableRound::SetNLayers(Int_t nLayers) {
+  // Set the total number of layers
+  if((nLayers>0) &&(nLayers<=fgkCableMaxLayer)) {
+    fNlayer = nLayers;
+    for (Int_t i = 0; i<fNlayer; i++) {
+      fLayThickness[i] = 0;
+      fLayMedia[i] = 0;
+    };
+  };
+};
+
+//________________________________________________________________________
+Int_t AliITSv11GeomCableRound::SetLayer(Int_t nLayer, Double_t thick,
+                                          TGeoMedium *medium, Int_t color) {
+  // Set layer #nLayer
+  if ((nLayer<0)||(nLayer>=fNlayer)) {
+    printf("Set wrong layer number of the cable\n");
+    return kFALSE;
+  };
+  if (nLayer>0)
+    if (fLayThickness[nLayer-1]<=0) {
+      printf("You must define cable layer %i first !",nLayer-1);
+      return kFALSE;
+    };
+
+  Double_t thickTot = 0;
+  for (Int_t i=0; i<nLayer; i++) thickTot += fLayThickness[i];
+  thickTot += thick;
+  if (thickTot-1e-10>fRadius) {
+    printf("Can't add this layer, cable thickness would be higher than total\n");
+    return kFALSE;
+  };
+
+  fLayThickness[nLayer] = thick;
+  fLayMedia[nLayer] = medium;
+  fLayColor[nLayer] = color;
+
+  return kTRUE;
+};
diff --git a/ITS/AliITSv11GeomCableRound.h b/ITS/AliITSv11GeomCableRound.h
new file mode 100644 (file)
index 0000000..e5fe851
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef ALIITSV11GEOMCABLEROUND_H
+#define ALIITSV11GEOMCABLEROUND_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+
+//*************************************************************************
+//   Class for round cables
+//
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
+
+class TGeoVolume;
+class TGeoMedium;
+
+#include "AliITSv11GeomCable.h"
+
+class AliITSv11GeomCableRound : public AliITSv11GeomCable {
+
+ public:
+  AliITSv11GeomCableRound(const char* name, Double_t radius);
+  AliITSv11GeomCableRound(const AliITSv11GeomCableRound &source);
+  AliITSv11GeomCableRound& operator=(const AliITSv11GeomCableRound &source);
+  virtual ~AliITSv11GeomCableRound() {};
+
+  virtual Int_t GetPoint(Int_t iCheckPt, Double_t *coord) const;
+  virtual Int_t GetVect(Int_t iCheckPt, Double_t *coord) const;
+
+  void          AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
+                              Double_t *coord, Double_t *orthVect);
+  Int_t         CreateAndInsertCableSegment(Int_t p2);
+  void          PrintCheckPoints() const;
+
+  void          SetNLayers(Int_t nLayers);
+  Int_t         SetLayer(Int_t nLayer,Double_t thick,TGeoMedium *medium,
+                        Int_t color=0);
+  void          SetPhi(Double_t phi1, Double_t phi2)
+                      {fPhiMin=phi1; fPhiMax=phi2;};
+
+ protected:
+  TGeoVolume*   CreateSegment( Double_t *coord1,Double_t *coord2,
+                              Double_t *localVect1, Double_t *localVect2 );
+
+  Double_t   fRadius;                         // total radius
+  Int_t      fNlayer;                         // number of layers
+
+  Double_t   fPhiMin;                         // minimum phi
+  Double_t   fPhiMax;                         // maximum phi
+  Double_t   fLayThickness[fgkCableMaxLayer]; // layer thicknesses
+  Int_t      fLayColor[fgkCableMaxLayer];     // layer colors
+  TGeoMedium *fLayMedia[fgkCableMaxLayer];    // layer media
+
+  ClassDef(AliITSv11GeomCableRound,1)
+};
+
+
+#endif
index 63f7a60b91a53188f98959d14574c134d7335a34..0c30dcbfbfc61fbf6c955400cc448a44c6dfbd53 100755 (executable)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+
 //*************************************************************************
 // SDD geometry, based on ROOT geometrical modeler
 //
-// Ludovic Gaudichet (Ludovic.Gaudichet@to.infn.it)
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
 //*************************************************************************
 
 
-#include <stdio.h>
-#include <stdlib.h>
 
 // General Root includes
-#include <Riostream.h>
+//#include <Riostream.h>
 #include <TMath.h>
-#include <TVectorD.h>
 
 // Root Geometry includes
 #include <TGeoManager.h>
 #include <TGeoVolume.h>
-#include <TGeoPcon.h>
 #include <TGeoCone.h>
 #include <TGeoTube.h>
 #include <TGeoArb8.h>
 #include <TGeoCompositeShape.h>
 #include <TGeoMatrix.h>
-#include <TGeoMaterial.h>
-#include <TGeoMedium.h>
 #include <TGeoNode.h>
 
-#include "AliITSv11Geometry.h"
+#include "AliITSgeom.h"
+#include "AliITSgeomSDD.h"
 #include "AliITSv11GeometrySDD.h"
+#include "AliITSv11GeomCableFlat.h"
+#include "AliITSv11GeomCableRound.h"
+
+
+const char*    AliITSv11GeometrySDD::fgSDDsensitiveVolName = "ITSsddSensitiv";
+const Double_t AliITSv11GeometrySDD::fgkSegmentLength     = 37.2*2*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderWidth       = 50.0*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderHeight      = 30.0*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDW    =  3.5*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDH    =  3.*fgkmm;
+
+const Double_t AliITSv11GeometrySDD::fgkLadderBeamRadius  =  0.6*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderLa          =  3.*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderHa          =  0.6*fgkmm;     //total ???
+const Double_t AliITSv11GeometrySDD::fgkLadderLb          =  3.7*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLadderHb          =  0.6*fgkmm;     //total ???
+const Double_t AliITSv11GeometrySDD::fgkLadderl           =  0.25*fgkmm;
+
+const Double_t AliITSv11GeometrySDD::fgkBottomBeamAngle   = 56.5;
+const Double_t AliITSv11GeometrySDD::fgkBeamSidePhi       = 65;
+
+const Double_t AliITSv11GeometrySDD::fgkLadWaferSep       = 2*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinSuppWidth      = 2.5*fgkmm;       // ???
+const Double_t AliITSv11GeometrySDD::fgkPinSuppHeight     = 2.*fgkmm;        // ???
+const Double_t AliITSv11GeometrySDD::fgkPinSuppRmax       = 2.5/2.*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinR              = 1.5/2.*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinSuppLength     = 5.*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinSuppThickness  = 0.5*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinSuppConeAngle  = 4;
+const Double_t AliITSv11GeometrySDD::fgkPinDXminOnSensor  = (39./2.)*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinPinDDXOnSensor = 3*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkPinDYOnSensor     = (52.5/2.)*fgkmm;
 
-extern TGeoManager* gGeoManager;
-
-ClassImp(AliITSv11GeomSDDcable)
+// parameters from ALR-0752/3
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppHeight    =  3.2*fgkmm;  
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppMaxLength = 14*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppWidthExt  =  0.4*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppWidthIn   =  0.65*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppHoleDiam  =  2*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppFulWidth  =  5.15*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppTongW     =  0.8*fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppAngle     = 22.5;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppSlitL     =  4.9*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeSuppAxeDist   =  3.05*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeInnerDiam     =  1.84*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkCoolPipeOuterDiam     =  2.*fgkmm;
+
+const Double_t AliITSv11GeometrySDD::fgkBTBthick           =  0.25 *fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkBTBlength          = 55. *fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkBTBwidth           = 18*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkBTBaxisAtoBottom   =  4*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkBTBaxisAtoBase     =  1.2*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkRadiusAminBTB      =  1. *fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkRadiusBminBTB      =  0.53 *fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkBTBHoleLength      = 15 *fgkmm;
+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::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;
+const Double_t AliITSv11GeometrySDD::fgkLay3DetLongRadius  = 152.0*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLay3LaddTopCornerEnd = 15.6*fgkmm;
+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::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;
+const Double_t AliITSv11GeometrySDD::fgkLay4DetLongRadius  = 240.5*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkLay4LaddTopCornerEnd = 15.6*fgkmm;
+const Int_t    AliITSv11GeometrySDD::fgkLay4Ndet           = 8;
+const Int_t    AliITSv11GeometrySDD::fgkLay4Nladd          = 22;
+const Double_t AliITSv11GeometrySDD::fgkLay4CoolPipeSuppH  = 7.5*fgkmm;
+
+//hybrid 
+const Double_t AliITSv11GeometrySDD::fgkHybridAngle       = 46;           // approx !!!
+// Origine taken at the hybrid corner :
+const Double_t AliITSv11GeometrySDD::fgkHybridLength      = 65*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybridWidth       = 41*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybRndHoleRad     = 1.05*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybRndHoleZ       = 2.5*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybRndHoleX       = fgkHybridWidth-23.599*fgkmm;
+
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowHoleDZ    =   9.698*fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowHolePasDX =  10.754*fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowHoleAmbDX =   9.122*fgkmm;
+  // center of ships to the border
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ4    = fgkHybridLength-(4.654      )*fgkmm-fgkHybFLlowHoleDZ/2;
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ3    = fgkHybridLength-(4.654+15.  )*fgkmm-fgkHybFLlowHoleDZ/2;
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ2    = fgkHybridLength-(4.654+15.*2)*fgkmm-fgkHybFLlowHoleDZ/2;
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowChipZ1    = fgkHybridLength-(4.654+15.*3)*fgkmm-fgkHybFLlowHoleDZ/2;
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowPasX      = fgkHybridWidth-32.775*fgkmm;       
+const Double_t AliITSv11GeometrySDD::fgkHybFLlowAmbX      = fgkHybridWidth-20.791*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybChipsDZ        =  9.221*fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkHybPascalDX       = 10.245*fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkHybAmbraDX        =  8.51*fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkHybFLUpperWidth   = 15.012*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybFLUpperLength  = 59.878*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybFLUpperAlDZ    = 11.183*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybFLUpperAldx    =  2.307*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkmu = 1*fgkmicron; // can be increase for checking thin objects
+const Double_t AliITSv11GeometrySDD::fgkHybridThBridgeThick =  0.25*fgkmm;               // ???
+const Double_t AliITSv11GeometrySDD::fgkHybAlThick         =  30*fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkHybUpThick         =  20*fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkHybGlueScrnThick   =  50*fgkmu;           // ??? ?????
+const Double_t AliITSv11GeometrySDD::fgkHybGlueLowThick    =  90*fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkHybGlueUpThick     =  90*fgkmu;           // sur ?????
+const Double_t AliITSv11GeometrySDD::fgkHybAlCCThick       =  12*fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkHybUpCCThick       =  12*fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkHybChipThick       = 150*fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkHybGlueAgThick     =  50*fgkmu;          // ??? ????
+const Double_t AliITSv11GeometrySDD::fgkHybUnderNiThick    =  20*fgkmu;          // ??? ????
+const Int_t    AliITSv11GeometrySDD::fgkNHybSMD = 25;
+const Double_t AliITSv11GeometrySDD::fgkHybSMDposX[fgkNHybSMD]     = 
+          {2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,21.40*fgkmm,
+          2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,19.91*fgkmm,
+          2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,17.09*fgkmm,21.40*fgkmm,
+          2.92*fgkmm,6.5*fgkmm,10.13*fgkmm,13.59*fgkmm,19.91*fgkmm,
+          1.63*fgkmm,5.22*fgkmm,13.59*fgkmm,21.40*fgkmm};
+const Double_t AliITSv11GeometrySDD::fgkHybSMDposZ[fgkNHybSMD]     = 
+         { 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm, 2.3 *fgkmm,
+          17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,17.315*fgkmm,
+          32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,32.31*fgkmm,
+          47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,47.38*fgkmm,
+          62.68*fgkmm,62.06*fgkmm,62.06*fgkmm,62.06*fgkmm};
+const Double_t AliITSv11GeometrySDD::fgkHybSMDmiddleW      =   0.954*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybSMDmiddleL      =   0.47 *fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybSMDendW         =   1.132*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybSMDendL         =   0.925*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybSMDheight       = 400.*fgkmu;          // ??? ????!!!!!!!
+
+const Double_t AliITSv11GeometrySDD::fgkWaferThickness     = 300.*fgkmu;
+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;
+
+const Double_t AliITSv11GeometrySDD::fgkDigitCablWidth     = 18.4*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkDigitCablAlThick   = (30+30*8./10.)*fgkmicron; // will probably change
+const Double_t AliITSv11GeometrySDD::fgkDigitCablPolyThick = (20+12)*fgkmicron;        // will probably change
+
+const Double_t AliITSv11GeometrySDD::fgkWaHVcableAlThick   = 30*2./10.*fgkmu;  // will probably change // Al ratio is random !!!
+const Double_t AliITSv11GeometrySDD::fgkWaHVcablePolyThick = 175*fgkmu;        // will probably change
+const Double_t AliITSv11GeometrySDD::fgkWaHVcableLength    = 67.08*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkWaHVcableWitdh     = 17.4 *fgkmm;              //  check !!!
+const Double_t AliITSv11GeometrySDD::fgkWaHVcableDW        =  5.24*fgkmm;             //  check !!!
+
+const Double_t AliITSv11GeometrySDD::fgkSensorGlassLX      =   5.  *fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkSensorGlassLZ      =   5.  *fgkmm; 
+const Double_t AliITSv11GeometrySDD::fgkSensorGlassLY      = 150.  *fgkmu;
+const Double_t AliITSv11GeometrySDD::fgkGlassDXOnSensor    =  26.28*fgkmm;             //  check !!!
+const Double_t AliITSv11GeometrySDD::fgkGlassDZOnSensor    =  22.50*fgkmm;             //  check !!!
+
+const Double_t AliITSv11GeometrySDD::fgkTransitHVAlThick    = 30*2./10.*fgkmu; //  check // will probably change //Al ratio is random
+const Double_t AliITSv11GeometrySDD::fgkTransitHVPolyThick  = 100*fgkmu;       //  check  // will probably change
+const Double_t AliITSv11GeometrySDD::fgkTransitHVHeadLX     =  71.46*fgkmm;           //  check !!!
+const Double_t AliITSv11GeometrySDD::fgkTransitHVHeadLZ     =  21.3*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkTransitHVBondingLZ  =   3.6*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkTransitHVtailLength =  27*fgkmm;              // ???, not yet fixed ...
+const Double_t AliITSv11GeometrySDD::fgkTransitHVtailWidth  =  26*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkTransitHVtailXpos   =   8*fgkmm;              // ???, a mesurer !!!
+const Double_t AliITSv11GeometrySDD::fgkTransitHVsideLZ     =  10.34*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkTransitHVsideLeftZ  =   4.11*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkTransitHVsideRightZ =   3.5*fgkmm;           // ???, a mesurer !!!
+
+const Double_t AliITSv11GeometrySDD::fgkLongHVcablePolyThick= (20+30+125+30+20+30+125+30+20)*fgkmu; //  check  // will probably change
+const Double_t AliITSv11GeometrySDD::fgkLongHVcableAlThick  = (30+30*2/10+30)*fgkmu;                //  check  // will probably change
+const Double_t AliITSv11GeometrySDD::fgkLongHVcableSeparation = 600*fgkmicron;
 
-//----------------------------------------------------------------------
-AliITSv11GeomSDDcable::~AliITSv11GeomSDDcable() { 
-  if (fInitialNode) delete fInitialNode; };
 
+ClassImp(AliITSv11GeometrySDD)
 
-//----------------------------------------------------------------------
-void AliITSv11GeomSDDcable::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
-                                          Double_t *coord)
+//________________________________________________________________________
+ AliITSv11GeometrySDD::AliITSv11GeometrySDD(): 
+   AliITSv11Geometry(), fMotherVol(0), fAddHybrids(kTRUE), fAddSensors(kTRUE),
+   fAddHVcables(kTRUE), fAddCables(kTRUE), fAddCoolingSyst(kTRUE),
+   fCoolingOn(kTRUE),
+   fAddOnlyLadder3min(-1), fAddOnlyLadder3max(-1),
+   fAddOnlyLadder4min(-1), fAddOnlyLadder4max(-1)
 {
-  if (iCheckPt>=fVolumeArray.GetEntriesFast()) {
-    fVolumeArray.AddLast(vol);
-    TVectorD *point = new TVectorD(3,coord);
-    fPointArray.AddLast(point);
-
-  } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) {
-    fVolumeArray.AddAt(vol, iCheckPt);
-    TVectorD *point = new TVectorD(3,coord);
-    fPointArray.AddAt(point, iCheckPt);
-  };
+  //
+  // Standard constructor
+  //
+
+  fDigitCableLay3A = new AliITSv11GeomCableFlat[fgkLay3Ndet];
+  fDigitCableLay3B = new AliITSv11GeomCableFlat[fgkLay3Ndet];
+  fDigitCableLay4A = new AliITSv11GeomCableFlat[fgkLay4Ndet];
+  fDigitCableLay4B = new AliITSv11GeomCableFlat[fgkLay4Ndet];
+  SetParameters();
 };
 
 
-//----------------------------------------------------------------------
-Int_t AliITSv11GeomSDDcable::
-GetCheckPoint( Int_t iCheckPt, Int_t iOccur, Int_t motherLevel,
-              Double_t *coord ) {
-// Get the coordinate of the #i check point of the #iOccur occurrence of
-// its containing volume in the node tree. Coord. are given in the coordinate
-// system of the #motherLevel mother level of this volume
-  
-  if (iCheckPt >= fVolumeArray.GetEntriesFast()) return kFALSE;
-  fCurrentVol = (TGeoVolume *) fVolumeArray.UncheckedAt(iCheckPt);
-
-  TGeoNode *mainNode;
-  if (fInitialNode==0) {
-    TObjArray *nodes = gGeoManager->GetListOfNodes();
-    if (nodes->GetEntriesFast()==0) return kFALSE;
-    mainNode = (TGeoNode *) nodes->UncheckedAt(0);
-  } else {
-    mainNode = fInitialNode;
-  };
-
-  for (Int_t i=0; i<50; i++) fNodeInd[i]=-1;  
-  Int_t currentOccur = 0;
-
-  // loop to get the volume position in the tree of nodes
-  while ( CheckDaughter(0, mainNode) && (currentOccur!=iOccur) ) {
-    currentOccur++;
-    Int_t maxLevel = 0;
-    while (fNodeInd[maxLevel]!=-1) maxLevel++;
-    fNodeInd[maxLevel-1]++;
-  };
-
-  Int_t maxLevel = 0;
-  while (fNodeInd[maxLevel]!=-1) maxLevel++;
-  if (maxLevel==0) return kFALSE;
-
-  if (motherLevel>maxLevel) motherLevel = maxLevel;
-  TGeoNode *pathNode[50];
-  pathNode[0] = mainNode;
-  for (Int_t i=0; i<motherLevel; i++)
-    pathNode[i+1] = pathNode[i]->GetDaughter(fNodeInd[i]);
-
-
-  TVectorD *coordVector = (TVectorD *)fPointArray.UncheckedAt(iCheckPt);
-  Double_t localCoord[3], globalCoord[3];
-  localCoord[0] = (coordVector->GetMatrixArray())[0];
-  localCoord[1] = (coordVector->GetMatrixArray())[1];
-  localCoord[2] = (coordVector->GetMatrixArray())[2];
-
-//   cout << '(' << localCoord[0] << ',' << localCoord[1] << ','
-//        << localCoord[2] << ") "<< endl;
-
-  for (Int_t i=motherLevel; i>=0; i--) {
-//     cout << pathNode[i]->GetName() << " > ";
-    pathNode[i]->GetMatrix()->LocalToMaster(localCoord, globalCoord);
-    localCoord[0] = globalCoord[0];
-    localCoord[1] = globalCoord[1];
-    localCoord[2] = globalCoord[2];
-//     cout << '(' << localCoord[0] << ',' << localCoord[1] << ','
-//      << localCoord[2] << ") "<< endl;
-  };
-  coord[0] = globalCoord[0];
-  coord[1] = globalCoord[1];
-  coord[2] = globalCoord[2];
-
-  return kTRUE;
-};
-
-
-//----------------------------------------------------------------------
-void AliITSv11GeomSDDcable::SetInitialNode(TGeoVolume *vol) {
-  if (fInitialNode) delete fInitialNode;
-  fInitialNode = new TGeoNodeMatrix(vol,0);
-  fInitialNode->SetName("nodeInConstruction");
-};
-
-
-//----------------------------------------------------------------------
-void AliITSv11GeomSDDcable:: ResetInitialNode() {
-  if (fInitialNode) delete fInitialNode;
-  fInitialNode = 0;
-};
-
-
-//----------------------------------------------------------------------
-bool AliITSv11GeomSDDcable::CheckDaughter(Int_t i, TGeoNode* node) {
-// Search where is the current volume in the tree of nodes
-// stop each time it find the pointer of the current volume
-// the path is recorded in fNodeInd[]
-// !!! recursiv function !!!
-
-  Int_t j = fNodeInd[i];
-  if (node->GetVolume()==fCurrentVol) return kTRUE;
-  TObjArray *array = node->GetNodes();
-  if (array) {
-    Int_t nDaughters = array->GetEntriesFast();
-    if (j==-1) j++;
-    while (j<nDaughters) {
-      TGeoNode *subNode = (TGeoNode *) array->UncheckedAt(j);
-      //cout << "level " <<  i << "  " <<  subNode->GetName()<< endl;
-      fNodeInd[i] = j;
-      if (CheckDaughter(i+1, subNode)) return kTRUE;
-      j++;
-    };
-    fNodeInd[i] = -1;
-  };
-  return kFALSE;
-};
-
-
-
-ClassImp(AliITSv11GeomSDDcableNap)
-
-//----------------------------------------------------------------------
-//----------------------------------------------------------------------
-AliITSv11GeomSDDcableNap::
-AliITSv11GeomSDDcableNap(Double_t width, Double_t thick):AliITSv11GeomSDDcable()
+//________________________________________________________________________
+AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug) :
+  AliITSv11Geometry(debug),fMotherVol(0),fAddHybrids(kTRUE),fAddSensors(kTRUE),
+  fAddHVcables(kTRUE), fAddCables(kTRUE), fAddCoolingSyst(kTRUE),
+  fCoolingOn(kTRUE),
+  fAddOnlyLadder3min(-1), fAddOnlyLadder3max(-1),
+  fAddOnlyLadder4min(-1), fAddOnlyLadder4max(-1)
 {
-  fWidth = width;
-  fThick = thick;
-};
-
-
-#include <TGeoSphere.h>
-//----------------------------------------------------------------------
-Int_t AliITSv11GeomSDDcableNap::
-CreateAndInsertCableSegment(Int_t p1, Int_t p2, TGeoVolume *motherVol) {
-
-  Double_t coord1[3], coord2[3];
-  GetCheckPoint(p1, 0, 0, coord1);
-  GetCheckPoint(p2, 0, 0, coord2);
-  cout << coord1[0] << ','<< coord1[1] << ','<< coord1[2] << endl;
-  cout << coord2[0] << ','<< coord2[1] << ','<< coord2[2] << endl;
-  coord2[0] = 5;
-  coord2[1] = 0;
-
-  Double_t cx = (coord1[0]+coord2[0])/2;
-  Double_t cy = (coord1[1]+coord2[1])/2;
-  Double_t cz = (coord1[2]+coord2[2])/2;
-  Double_t dx = coord2[0]-coord1[0];
-  Double_t dy = coord2[1]-coord1[1];
-  Double_t dz = coord2[2]-coord1[2];
-
-  Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
-  TGeoBBox *cableSeg = new TGeoBBox("", fWidth/2,fThick/2,length/2); 
-
-  TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-  TGeoVolume *vCableSeg = new TGeoVolume("vCableSeg",cableSeg, airSDD);
-
-  TGeoTranslation *trans = new TGeoTranslation("",cx, cy, cz);
-  TGeoRotation*rot = new TGeoRotation("",-TMath::ATan(dx/dy)*TMath::RadToDeg(),
-                                     -TMath::ATan(dy/dz)*TMath::RadToDeg(),0);
-  //rot->RotateZ( -TMath::ATan(dx/dy)*TMath::RadToDeg() );
-  //rot->RotateX( -TMath::ATan(dy/dz)*TMath::RadToDeg() );
-  cout << TMath::ATan(dy/dz)*TMath::RadToDeg() << " ######### " 
-       << TMath::ATan(dx/dy)*TMath::RadToDeg() << endl;
-
-  TGeoCombiTrans *combi = new TGeoCombiTrans(*trans, *rot);
-  motherVol->AddNode(vCableSeg, 1, combi);
-
-
-
-  //------------
-  TGeoSphere *sphere = new TGeoSphere(0, 0.1);
-  TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD);
-  TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz);
-  TGeoTranslation *tr1 = new TGeoTranslation("",coord1[0],coord1[1],coord1[2]);
-  TGeoTranslation *tr2 = new TGeoTranslation("",coord2[0],coord2[1],coord2[2]);
-  motherVol->AddNode(vSphere, 1, trC);
-  motherVol->AddNode(vSphere, 2, tr1);
-  motherVol->AddNode(vSphere, 3, tr2);
-
-  return kTRUE;
+  //
+  // Constructor setting debugging level
+  //
+
+  fDigitCableLay3A = new AliITSv11GeomCableFlat[fgkLay3Ndet];
+  fDigitCableLay3B = new AliITSv11GeomCableFlat[fgkLay3Ndet];
+  fDigitCableLay4A = new AliITSv11GeomCableFlat[fgkLay4Ndet];
+  fDigitCableLay4B = new AliITSv11GeomCableFlat[fgkLay4Ndet];
+  SetParameters();
 };
 
-
-
 //________________________________________________________________________
+AliITSv11GeometrySDD::AliITSv11GeometrySDD(const AliITSv11GeometrySDD &s) :
+ AliITSv11Geometry(s.GetDebug()),fMotherVol(s.fMotherVol),
+ fAddHybrids(s.fAddHybrids),fAddSensors(s.fAddSensors),
+ fAddHVcables(s.fAddHVcables), fAddCables(s.fAddCables),
+ fAddCoolingSyst(s.fAddCoolingSyst),fCoolingOn(s.fCoolingOn),
+ fAddOnlyLadder3min(s.fAddOnlyLadder3min),fAddOnlyLadder3max(s.fAddOnlyLadder3max),
+ fAddOnlyLadder4min(s.fAddOnlyLadder4min), fAddOnlyLadder4max(s.fAddOnlyLadder4max)
+{
+  //     Copy Constructor 
+  fDigitCableLay3A = new AliITSv11GeomCableFlat[fgkLay3Ndet];
+  fDigitCableLay3B = new AliITSv11GeomCableFlat[fgkLay3Ndet];
+  fDigitCableLay4A = new AliITSv11GeomCableFlat[fgkLay4Ndet];
+  fDigitCableLay4B = new AliITSv11GeomCableFlat[fgkLay4Ndet];
+  SetParameters();
+}
 
-
-const Double_t AliITSv11GeometrySDD::fSegmentLength    = 37.2*2*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLadderWidth      = 50.0*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLadderHeight     = 30.0*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLadderBeamRadius =  0.6*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLadderLa         =  3.*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLadderHa         =  0.6*fgkmm; //total pifometer
-const Double_t AliITSv11GeometrySDD::fLadderLb         =  3.7*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLadderHb         =  0.6*fgkmm; //total pifometer
-const Double_t AliITSv11GeometrySDD::fLadderl          =  0.25*fgkmm;
-
-const Double_t AliITSv11GeometrySDD::fBottomBeamAngle  = 56.5;
-const Double_t AliITSv11GeometrySDD::fBeamSidePhi      = 65;
-
-const Double_t AliITSv11GeometrySDD::fWaferThickness   = 0.3*fgkmm;
-const Double_t AliITSv11GeometrySDD::fWaferWidth       = 72.5*fgkmm;
-const Double_t AliITSv11GeometrySDD::fWaferLength      = 87.6*fgkmm;
-
-const Double_t AliITSv11GeometrySDD::fHybridLength     = 65*fgkmm;
-const Double_t AliITSv11GeometrySDD::fHybridWidth      = 41*fgkmm;  // pifometer
-const Double_t AliITSv11GeometrySDD::fHybridThBridgeThick = 0.25*fgkmm; // pifometer
-
-const Double_t AliITSv11GeometrySDD::fLadWaferSep      = 2*fgkmm;
-const Double_t AliITSv11GeometrySDD::fPinSuppWidth     = 2.5*fgkmm; // pifometer
-const Double_t AliITSv11GeometrySDD::fPinSuppHeight    = 2.*fgkmm; // pifometer
-const Double_t AliITSv11GeometrySDD::fPinSuppRmax      = 2.5/2.*fgkmm;
-const Double_t AliITSv11GeometrySDD::fPinR             = 1.5/2.*fgkmm;
-const Double_t AliITSv11GeometrySDD::fPinSuppLength    = 5.*fgkmm;
-const Double_t AliITSv11GeometrySDD::fPinSuppThickness = 0.5*fgkmm;
-const Double_t AliITSv11GeometrySDD::fPinSuppConeAngle = 4;
-const Double_t AliITSv11GeometrySDD::fPinDXminOnSensor = (39./2.)*fgkmm; //placement of pins on sensor
-const Double_t AliITSv11GeometrySDD::fPinPinDDXOnSensor = 3*fgkmm;
-const Double_t AliITSv11GeometrySDD::fPinDYOnSensor    = (52.5/2.)*fgkmm;
-
-// parameters from ALR-0752/3
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppHeight    = 3.2*fgkmm;  
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppMaxLength = 14*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppWidthExt  = 0.4*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppWidthIn   = 0.65*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppHoleDiam  = 2*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppFulWidth  = 5.15*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppTongW     = 0.8*fgkmm; 
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppAngle     = 22.5;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppSlitL     = 4.9*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeSuppAxeDist   = 3.05*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeInnerDiam     = 1.84*fgkmm;
-const Double_t AliITSv11GeometrySDD::fCoolPipeOuterDiam     = 2.*fgkmm;
-
-const Double_t AliITSv11GeometrySDD::fBTBthick          = 0.25 *fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBlength         = 55. *fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBwidth          = 18*fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBaxisAtoBottom  = 4*fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBaxisAtoBase    = 1.2*fgkmm;
-const Double_t AliITSv11GeometrySDD::fRadiusAminBTB     = 1. *fgkmm;
-const Double_t AliITSv11GeometrySDD::fRadiusBminBTB     = 0.53 *fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBHoleLength     = 15 *fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBHolewidth      =  6 *fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBHoleRefX       = 10 *fgkmm;
-const Double_t AliITSv11GeometrySDD::fBTBHoleRefY       = 6.5 *fgkmm;
-
-const Double_t AliITSv11GeometrySDD::fLay3Rmin          = 130.*fgkmm; //not min! Rmin virtual tube
-const Double_t AliITSv11GeometrySDD::fLay3Rmax          = 190.*fgkmm; //not min! Rmax virtual tube
-const Double_t AliITSv11GeometrySDD::fLay3Length        = (524.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
-const Double_t AliITSv11GeometrySDD::fLay3LadderLength  = 524.*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLay3DetShortRadius = 146.0*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLay3DetLongRadius  = 152.0*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLay3LaddTopCornerEnd = 15.6*fgkmm;
-const Int_t    AliITSv11GeometrySDD::fLay3Ndet          = 6;
-const Int_t    AliITSv11GeometrySDD::fLay3Nladd         = 14;
-const Double_t AliITSv11GeometrySDD::fLay3CoolPipeSuppH = 7.5*fgkmm;
-
-const Double_t AliITSv11GeometrySDD::fLay4Rmin          = 220.*fgkmm; //not min! Rmin virtual tube
-const Double_t AliITSv11GeometrySDD::fLay4Rmax          = 290.*fgkmm; //not min! Rmax virtual tube
-const Double_t AliITSv11GeometrySDD::fLay4Length        = (671.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
-const Double_t AliITSv11GeometrySDD::fLay4LadderLength   = 671.*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLay4DetShortRadius = 235.0*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLay4DetLongRadius  = 240.5*fgkmm;
-const Double_t AliITSv11GeometrySDD::fLay4LaddTopCornerEnd = 15.6*fgkmm;
-const Int_t    AliITSv11GeometrySDD::fLay4Ndet           = 8;
-const Int_t    AliITSv11GeometrySDD::fLay4Nladd          = 22;
-const Double_t AliITSv11GeometrySDD::fLay4CoolPipeSuppH  = 10*fgkmm;
-
-
-ClassImp(AliITSv11GeometrySDD)
-
+//________________________________________________________________________
+AliITSv11GeometrySDD& AliITSv11GeometrySDD::
+operator=(const AliITSv11GeometrySDD &s) {
+  //     Assignment operator
+  if(&s == this) return *this;
+  fMotherVol = s.fMotherVol;
+  fAddHybrids = s.fAddHybrids;
+  fAddSensors = s.fAddSensors;
+  fAddHVcables = s.fAddHVcables;
+  fAddCables = s.fAddCables;
+  fAddCoolingSyst = s.fAddCoolingSyst;
+  fCoolingOn = s.fCoolingOn;
+  fAddOnlyLadder3min = s.fAddOnlyLadder3min;
+  fAddOnlyLadder3max = s.fAddOnlyLadder3max;
+  fAddOnlyLadder4min = s.fAddOnlyLadder4min;
+  fAddOnlyLadder4max = s.fAddOnlyLadder4max;
+  return *this;
+}
 
 //________________________________________________________________________
-AliITSv11GeometrySDD::AliITSv11GeometrySDD():AliITSv11Geometry() {
-  SetGeomParameters();
-  fCoolingOn = kTRUE;
-  fAddOnlyLadder3min = -1;
-  fAddOnlyLadder3max = -1;
-  fAddOnlyLadder4min = -1;
-  fAddOnlyLadder4max = -1;
-  fAddOnlySegment = -1;
-  fColorCarbonFiber = 4;
-  fColorRyton = 5;
-  fColorPhynox = 7;
-  fColorSilicon = 3;
+AliITSv11GeometrySDD::~AliITSv11GeometrySDD() {
+  // Look like a destructor
+  // Smell like a destructor
+  // And actually is the destructor
+  if (fDigitCableLay3A) delete [] fDigitCableLay3A;
+  if (fDigitCableLay3B) delete [] fDigitCableLay3B;
+  if (fDigitCableLay4A) delete [] fDigitCableLay4A;
+  if (fDigitCableLay4B) delete [] fDigitCableLay4B;
 };
 
-
 //________________________________________________________________________
-AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug)
-  : AliITSv11Geometry(debug) {
-  SetGeomParameters();
-  fCoolingOn = kTRUE;
-  fAddOnlyLadder3min = -1;
-  fAddOnlyLadder3max = -1;
-  fAddOnlyLadder4min = -1;
-  fAddOnlyLadder4max = -1;
-  fAddOnlySegment = -1;
+void AliITSv11GeometrySDD::SetParameters() {
+  //
+  // Define display colors and the non constant geometry parameters
+  //
+
   fColorCarbonFiber = 4;
   fColorRyton = 5;
   fColorPhynox = 7;
   fColorSilicon = 3;
-};
-
-
-//________________________________________________________________________
-void AliITSv11GeometrySDD::SetGeomParameters() {
-
-  fLay3LaddShortRadius  = fLay3DetShortRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
-  fLay3LaddLongRadius   = fLay3DetLongRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
-  fLay4LaddShortRadius  = fLay4DetShortRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
-  fLay4LaddLongRadius   = fLay4DetLongRadius-fLadderBeamRadius+(8-1)*fgkmm;  // radius from the center to the CF ladder
-
+  fColorAl = 7;
+  fColorPolyhamide = 5;
+  fColorGlass = 2;
+  fColorSMD = 12;
+  fColorSMDweld = 17;
+
+  fPinSupport = 0;
+  fCoolPipeSupportL = 0;
+  fCoolPipeSupportR = 0;
+  fSDDsensor = 0;
+  fBaseThermalBridge = 0;
+  fHybrid = 0;
+
+  Double_t detLadderDist = 8*fgkmm; 
+
+  fLay3LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
+  fLay4LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
+
+  // radius from the center to the CF ladder :
+  fLay3LaddShortRadius = (fgkLay3DetShortRadius
+                         + fgkLadWaferSep+2*fgkWaferThickness
+                         + detLadderDist); 
+  fLay3LaddLongRadius  = (fgkLay3DetLongRadius
+                         + fgkLadWaferSep+2*fgkWaferThickness
+                         + detLadderDist); 
+  fLay4LaddShortRadius = (fgkLay4DetShortRadius
+                         + fgkLadWaferSep+2*fgkWaferThickness
+                         + detLadderDist); 
+  fLay4LaddLongRadius  = (fgkLay4DetLongRadius
+                         + fgkLadWaferSep+2*fgkWaferThickness
+                         + detLadderDist); 
 
   fLay3sensorZPos[0]= (  35.8+72.4+75.8 )*fgkmm;
   fLay3sensorZPos[1]= (  35.8+72.4      )*fgkmm;
@@ -391,41 +362,252 @@ void AliITSv11GeometrySDD::SetGeomParameters() {
   fLay4sensorZPos[5] = ( -35.6-74.8           )*fgkmm;
   fLay4sensorZPos[6] = ( -35.6-74.8-72.4      )*fgkmm;
   fLay4sensorZPos[7] = ( -35.6-74.8-72.4-76.  )*fgkmm;
-
 };
 
 
 //________________________________________________________________________
-void AliITSv11GeometrySDD::CheckOverlaps(Double_t precision){
-
-  TGeoVolume *segment = CreateLadderSegment(4,1);
-  segment->CheckOverlaps(precision);
+TGeoMedium* AliITSv11GeometrySDD::GetMedium(const char* mediumName) {
+  //
+  // Called to get a medium, checks that it exists.
+  // If not, prints an error and returns 0
+  //
 
-  TGeoVolume *ladd3 = CreateLay3Ladder();
-  ladd3->CheckOverlaps(precision);
+  TGeoMedium* medium =  gGeoManager->GetMedium(mediumName);
+  if (! medium)
+    printf("Error(AliITSv11GeometrySDD)::medium %s not found !\n", mediumName);
 
-  TGeoVolume *ladd4 = CreateLay4Ladder();
-  ladd4->CheckOverlaps(precision);
-
-  TGeoVolume *endLad = CreateEndLadder(3,0);
-  endLad->CheckOverlaps(precision);
+  return medium;
+};
 
-  TGeoVolume *det3 = CreateLay3Detectors();
-  det3->CheckOverlaps(precision);
+//________________________________________________________________________
+void AliITSv11GeometrySDD::CreateBasicObjects() {
+  //
+  // Create basics objets which will be assembled together
+  // in Layer3 and Layer4 functions
+  //
+
+  fPinSupport = CreatePinSupport();
+  fCoolPipeSupportL = CreateCoolPipeSupportL();
+  fCoolPipeSupportR = CreateCoolPipeSupportR();
+  fSDDsensor = CreateSDDsensor();
+  fBaseThermalBridge = CreateBaseThermalBridge();
+  fHybrid = CreateHybrid(0);
+
+  TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
+  TGeoMedium *polyhamideSDD = GetMedium("ITSsddKAPTON_POLYCH2");
+  TGeoMedium *alSDD         = GetMedium("ITSal");
+
+  //********************************************************************
+  // pieces of the carbon fiber structure
+  //********************************************************************
+  Double_t dy             = fgkLadderSegBoxDH/2;
+  Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
+  Double_t halfTheta      = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
+  Double_t alpha          = TMath::Pi()*3./4. - halfTheta/2.;
+  Double_t beta           = (TMath::Pi() - 2.*halfTheta)/4.;
+  Double_t dYTranslation  = (fgkLadderHeight/2.
+                            -0.5*fgkLadderWidth*TMath::Tan(beta)
+                            -fgkLadderBeamRadius);
+  Double_t distCenterSideDown =  0.5*fgkLadderWidth/TMath::Cos(beta);
+
+  //--- the top V of the Carbon Fiber Ladder (segment)
+  TGeoArb8 *cfLaddTop1 = CreateLadderSide( fgkSegmentLength/2., halfTheta, 
+                         -1, fgkLadderLa, fgkLadderHa, fgkLadderl);
+  TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
+                                 cfLaddTop1,carbonFiberLadderStruct);
+  TGeoArb8 *cfLaddTop2 = CreateLadderSide( fgkSegmentLength/2., halfTheta,
+                          1, fgkLadderLa, fgkLadderHa, fgkLadderl);
+  TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerVol2",
+                                 cfLaddTop2, carbonFiberLadderStruct);
+  cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
+  cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
+  TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2-dy, 0);
+
+  //--- the 2 side V
+  TGeoArb8 *cfLaddSide1 = CreateLadderSide( fgkSegmentLength/2., beta, -1,
+                                           fgkLadderLb, fgkLadderHb, fgkLadderl);
+  TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerVol1",
+                                  cfLaddSide1,carbonFiberLadderStruct);
+  TGeoArb8 *cfLaddSide2 = CreateLadderSide( fgkSegmentLength/2., beta, 1,
+                                           fgkLadderLb, fgkLadderHb, fgkLadderl);
+  TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerVol2",
+                                  cfLaddSide2,carbonFiberLadderStruct);
+  cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
+  cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
+  TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
+                                            alpha*TMath::RadToDeg());
+  AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation-dy, 0);
+  TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,
+                                            -alpha*TMath::RadToDeg());
+  AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation-dy, 0);
+
+  //--- The beams
+  // Beams on the sides
+  Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
+          TMath::Sin(2*beta)/(TanD(fgkBeamSidePhi)*TanD(fgkBeamSidePhi))) ));
+  //cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
+  Double_t beamLength = TMath::Sqrt( fgkLadderHeight*fgkLadderHeight/
+                       ( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
+                       + fgkLadderWidth*fgkLadderWidth/4.)-fgkLadderLa/2-fgkLadderLb/2;
+  TGeoTubeSeg *sideBeamS = new TGeoTubeSeg(0, fgkLadderBeamRadius,beamLength/2.,
+                                          0, 180);
+  TGeoVolume *sideBeam = new TGeoVolume("ITSsddCFSideBeamVol", sideBeamS,
+                            carbonFiberLadderStruct);
+  sideBeam->SetLineColor(fColorCarbonFiber);
+
+  //Euler rotation : about Z, then new X, then new Z
+  TGeoRotation beamRot1("", 90-2.*beta*TMath::RadToDeg(),
+                       -beamPhiPrime*TMath::RadToDeg(),-90);
+  TGeoRotation beamRot2("", 90-2.*beta*TMath::RadToDeg(),
+                       beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation beamRot3("", 90+2.*beta*TMath::RadToDeg(),
+                       beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation beamRot4("", 90+2.*beta*TMath::RadToDeg(),
+                       -beamPhiPrime*TMath::RadToDeg(),-90);
+
+  TGeoCombiTrans *beamTransf[8];
+  beamTransf[0] = new TGeoCombiTrans( 0.5*triangleHeight*
+                                     TMath::Tan(halfTheta),
+                                     fgkLadderBeamRadius/2. - dy,
+                                     -3*fgkSegmentLength/8, &beamRot1);
+  beamTransf[1] = new TGeoCombiTrans(*beamTransf[0]);
+  AddTranslationToCombiTrans(beamTransf[1], 0, 0, fgkSegmentLength/2);
+
+  beamTransf[2] = new TGeoCombiTrans(0.5*triangleHeight*
+                                    TMath::Tan(halfTheta),
+                                    fgkLadderBeamRadius/2. - dy,
+                                    -fgkSegmentLength/8, &beamRot2);
+  beamTransf[3] = new TGeoCombiTrans(*beamTransf[2]);
+  AddTranslationToCombiTrans(beamTransf[3], 0, 0, fgkSegmentLength/2);
+
+  beamTransf[4] = new TGeoCombiTrans(-0.5*triangleHeight*
+                                    TMath::Tan(halfTheta),
+                                    fgkLadderBeamRadius/2. - dy,
+                                    -3*fgkSegmentLength/8, &beamRot3);
+  beamTransf[5] = new TGeoCombiTrans(*beamTransf[4]);
+  AddTranslationToCombiTrans(beamTransf[5], 0, 0, fgkSegmentLength/2);
+
+  beamTransf[6] = new TGeoCombiTrans(-0.5*triangleHeight*
+  TMath::Tan(halfTheta),fgkLadderBeamRadius/2.-dy, -fgkSegmentLength/8,&beamRot4);
+  beamTransf[7] = new TGeoCombiTrans(-0.5*triangleHeight*
+  TMath::Tan(halfTheta),fgkLadderBeamRadius/2.-dy,3*fgkSegmentLength/8,&beamRot4);
+
+  //--- Beams of the bottom
+  TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
+                                fgkLadderWidth/2.-fgkLadderLb/3, 0, 180);
+  TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
+                                  bottomBeam1, carbonFiberLadderStruct);
+  bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
+  TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
+                                fgkLadderWidth/2.-fgkLadderLb/3, 0, 90);
+  TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
+                               bottomBeam2, carbonFiberLadderStruct);
+  bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
+  TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
+                            0.5*fgkLadderWidth/SinD(fgkBottomBeamAngle)
+                            - fgkLadderLb/3, 0, 180);
+  TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol",
+                                  bottomBeam3, carbonFiberLadderStruct);
+  bottomBeam3Vol->SetLineColor(fColorCarbonFiber);
+  //bottomBeam3Vol->SetLineColor(2);
+
+  TGeoRotation bottomBeamRot1("", 90, 90,  90);
+  TGeoRotation bottomBeamRot2("",-90, 90, -90);
+  TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans
+    (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,0, &bottomBeamRot1);
+  TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
+                                     -(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,
+                                     -fgkSegmentLength/2, &bottomBeamRot1);
+  TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,
+                                      -(fgkLadderHeight/2 - fgkLadderBeamRadius)
+                                     - dy, fgkSegmentLength/2, &bottomBeamRot2);
+  // be careful for beams #3: when "reading" from -z to +z and 
+  // from the bottom of the ladder, it should draw a Lambda, and not a V
+  TGeoRotation bottomBeamRot4("", -90, fgkBottomBeamAngle, -90);
+  TGeoRotation bottomBeamRot5("" ,-90,-fgkBottomBeamAngle, -90);
+  TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans
+    (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,-fgkSegmentLength/4,&bottomBeamRot4);
+  TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans
+    (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,fgkSegmentLength/4, &bottomBeamRot5);
+
+  fLaddSegCommonVol[0] = cfLaddTopVol1;  fLaddSegCommonTr[0] = trTop1;
+  fLaddSegCommonVol[1] = cfLaddTopVol2;  fLaddSegCommonTr[1] = trTop1;
+  fLaddSegCommonVol[2] = cfLaddSideVol1; fLaddSegCommonTr[2] = ctSideR;
+  fLaddSegCommonVol[3] = cfLaddSideVol1; fLaddSegCommonTr[3] = ctSideL;
+  fLaddSegCommonVol[4] = cfLaddSideVol2; fLaddSegCommonTr[4] = ctSideR;
+  fLaddSegCommonVol[5] = cfLaddSideVol2; fLaddSegCommonTr[5] = ctSideL;
+  fLaddSegCommonVol[6] = sideBeam;       fLaddSegCommonTr[6] = beamTransf[0];
+  fLaddSegCommonVol[7] = sideBeam;       fLaddSegCommonTr[7] = beamTransf[1];
+  fLaddSegCommonVol[8] = sideBeam;       fLaddSegCommonTr[8] = beamTransf[2];
+  fLaddSegCommonVol[9] = sideBeam;       fLaddSegCommonTr[9] = beamTransf[3];
+  fLaddSegCommonVol[10]= sideBeam;       fLaddSegCommonTr[10]= beamTransf[4];
+  fLaddSegCommonVol[11]= sideBeam;       fLaddSegCommonTr[11]= beamTransf[5];
+  fLaddSegCommonVol[12]= sideBeam;       fLaddSegCommonTr[12]= beamTransf[6];
+  fLaddSegCommonVol[13]= sideBeam;       fLaddSegCommonTr[13]= beamTransf[7];
+  fLaddSegCommonVol[14]= bottomBeam1Vol; fLaddSegCommonTr[14]= bottomBeamTransf1;
+  fLaddSegCommonVol[15]= bottomBeam2Vol; fLaddSegCommonTr[15]= bottomBeamTransf2;
+  fLaddSegCommonVol[16]= bottomBeam2Vol; fLaddSegCommonTr[16]= bottomBeamTransf3;
+  fLaddSegCommonVol[17]= bottomBeam3Vol; fLaddSegCommonTr[17]= bottomBeamTransf4;
+  fLaddSegCommonVol[18]= bottomBeam3Vol; fLaddSegCommonTr[18]= bottomBeamTransf5;
 
-  TGeoVolume *det4 = CreateLay4Detectors();
-  det4->CheckOverlaps(precision);
+  //********************************************************************
+  // cables
+  //********************************************************************
+  char cableName[30];
+  for (Int_t i=0; i<fgkLay3Ndet; i++) {
+    sprintf(cableName, "digitCableLay3A_%i",i);
+    fDigitCableLay3A[i].SetName(cableName);
+    fDigitCableLay3A[i].SetWidth(fgkDigitCablWidth);
+    fDigitCableLay3A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
+    fDigitCableLay3A[i].SetNLayers(2);
+    fDigitCableLay3A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
+                                 fColorPolyhamide);
+    fDigitCableLay3A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
+    sprintf(cableName, "digitCableLay3B_%i",i);
+    fDigitCableLay3B[i].SetName(cableName);
+    fDigitCableLay3B[i].SetWidth(fgkDigitCablWidth);
+    fDigitCableLay3B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
+    fDigitCableLay3B[i].SetNLayers(2);
+    fDigitCableLay3B[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
+                                 fColorPolyhamide);
+    fDigitCableLay3B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
+  };
+  for (Int_t i=0; i<fgkLay4Ndet; i++) {
+    sprintf(cableName, "digitCableLay4A_%i",i);
+    fDigitCableLay4A[i].SetName(cableName);
+    fDigitCableLay4A[i].SetWidth(fgkDigitCablWidth);
+    fDigitCableLay4A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
+    fDigitCableLay4A[i].SetNLayers(2);
+    fDigitCableLay4A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
+                                 fColorPolyhamide);
+    fDigitCableLay4A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
+    sprintf(cableName, "digitCableLay4B_%i",i);
+    fDigitCableLay4B[i].SetName(cableName);
+    fDigitCableLay4B[i].SetWidth(fgkDigitCablWidth);
+    fDigitCableLay4B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
+    fDigitCableLay4B[i].SetNLayers(2);
+    fDigitCableLay4B[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
+                                 fColorPolyhamide);
+    fDigitCableLay4B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
+  };
+                                        // Well, those digit cables could also include the analog cables
+                                        // which have the same width and the same path, at least in the ladder.
+                                        // It will gain some computing ressources (less volumes) and some
+                                        // coding efforts ... !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                                        // The only thing to do is to change the names and put the correct total
+                                        // thicknesses
 
-  TGeoVolume *hyb = CreateHybrid(0);
-  hyb->CheckOverlaps(precision);
+};
 
-  TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-  TGeoBBox *layBox = new  TGeoBBox("", 300, 300, 300);
-  TGeoVolume *lay = new TGeoVolume("lay", layBox, airSDD);
-  Layer3(lay);
-  Layer4(lay);
-  lay->CheckOverlaps(precision);
 
+//________________________________________________________________________
+void AliITSv11GeometrySDD::CheckOverlaps(Double_t precision){
+  //
+  // a debugging function for checking some possible overlaps
+  //
+  if (fSDDsensor)         fSDDsensor->CheckOverlaps(precision);
+  if (fHybrid)            fHybrid->CheckOverlaps(precision);
 };
 
 
@@ -451,14 +633,11 @@ CreateCombiTrans(const char *name, Double_t dy, Double_t dz, Double_t dphi) {
 void AliITSv11GeometrySDD::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
                                                        Double_t dx,
                                                        Double_t dy,
-                                                       Double_t dz) {
-    // Add a dx,dy,dz translation to the initial TGeoCombiTrans
-    const Double_t *vect = ct->GetTranslation();
-    Double_t newVect[3];
-    newVect[0] = vect[0]+dx; 
-    newVect[1] = vect[1]+dy; 
-    newVect[2] = vect[2]+dz;
-    ct->SetTranslation(newVect);
+                                                       Double_t dz) const{
+  // Add a dx,dy,dz translation to the initial TGeoCombiTrans
+  const Double_t *vect = ct->GetTranslation();
+  Double_t newVect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
+  ct->SetTranslation(newVect);
 };
 
 
@@ -466,128 +645,381 @@ void AliITSv11GeometrySDD::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
 void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
 // for code developpment and debugging purposes
 
-//     TGeoVolume *vBaseThermalBridge = CreateBaseThermalBridge();
-//     Moth->AddNode(vBaseThermalBridge, 1, 0);
+ if (! fSDDsensor) CreateBasicObjects();
+
+//     Moth->AddNode(fBaseThermalBridge, 1, 0);
+     moth->AddNode(fHybrid,100,0);
+//     moth->AddNode(fSDDsensor, 1, 0);
 
 //   TGeoVolume* seg = CreateLadderSegment( 4, 0); //lay 4
-//   Moth->AddNode(seg, 1, 0);
+//   moth->AddNode(seg, 1, 0);
+
+
+
+
+//  TGeoBBox *box1 = new TGeoBBox("box1", 5,5,5);
+//  TGeoMedium *air = GetMedium("ITSair");
+//  TGeoVolume *vbox1 = new TGeoVolume("vbox1", box1, air);
+//  TGeoBBox *box2 = new TGeoBBox("box2", 6,6,6);
+//  TGeoVolume *vbox2 = new TGeoVolume("vbox2", box2, air);
+//  TGeoBBox *box3 = new TGeoBBox("box3", 7,7,7);
+//  TGeoVolume *vbox3 = new TGeoVolume("vbox3", box3, air);
+
+//  vbox1->AddNode(fHybrid,100,0);
+//  vbox2->AddNode(vbox1,1,0);
+//  vbox3->AddNode(vbox2,1,0);
+//  moth->AddNode(vbox3,1,0);
+
+
 
-  AliITSv11GeomSDDcableNap napCable(2.0,0.2);
-  Double_t coord1[3] = {0,0,0};
-  Double_t coord2[3] = {5,5,5};
+//   //testing cable
+//   TGeoBBox *box1 = new TGeoBBox("box1", 10,10,10);
+//   TGeoBBox *box2 = new TGeoBBox("box2", 10,10,10);
+//   TGeoBBox *box3 = new TGeoBBox("box3", 20,10,10);
+//   TGeoMedium *air = GetMedium("ITSsddAir");
+//   TGeoVolume *vbox1 = new TGeoVolume("vbox1", box1, air);
+//   TGeoVolume *vbox2 = new TGeoVolume("vbox2", box2, air);
+//   TGeoVolume *vbox3 = new TGeoVolume("vbox3", box3, air);
 
-  napCable.AddCheckPoint( moth, 0, coord1);
-  napCable.AddCheckPoint( moth, 1, coord2);
-  napCable.CreateAndInsertCableSegment( 0, 1, moth);
+//   TGeoTranslation *tr1 = new TGeoTranslation("merdeneg",-10,0,0);
+//   TGeoTranslation *tr2 = new TGeoTranslation("merdepos",10,0,0);
 
+//   AliITSv11GeomCableRound napCable(0.9);
+//   //AliITSv11GeomCableFlat napCable(2,0.9);
+//   napCable.SetNLayers(3);
+//   napCable.SetLayer(0, 0.2, air);
+//   napCable.SetLayer(1, 0.2, air);
+//   napCable.SetLayer(2, 0.5, air);
+
+//   napCable.SetInitialNode(vbox3);
+
+//   Double_t coord1[3] = {0,-2,-2};
+//   Double_t vect1[3]= {1,1,0};
+//   napCable.AddCheckPoint( vbox1, 0, coord1, vect1);
+//   Double_t coord2[3] = {10,0,0};
+//   Double_t vect2[3]= {1,0,0};
+//   napCable.AddCheckPoint( vbox1, 1, coord2, vect2);
+
+//   //Double_t coord3[3] = {7,7,7};
+//   Double_t coord3[3] = {7,-7,-7};
+//   Double_t vect3[3]= {1,0,0};
+//   napCable.AddCheckPoint( vbox3, 2, coord3, vect3);
+
+//   Double_t coord4[3] = {19,7,7};
+//   Double_t vect4[3]= {-1,0,2};
+//   napCable.AddCheckPoint( vbox3, 3, coord4, vect4);
+
+//   Double_t coord5[3] = {1,7,7};
+//   Double_t vect5[3]= {1,0,0};
+//   napCable.AddCheckPoint( vbox3, 4, coord5, vect5);
+
+//   TGeoRotation *rot = new TGeoRotation("",0,0,0);
+//   TGeoCombiTrans *combi = new TGeoCombiTrans(*tr1,*rot );
+//   //vbox3->AddNode(vbox1,1,tr1);
+//   vbox3->AddNode(vbox1,1,combi);
+//   moth->AddNode(vbox3,1,0);
+
+// //   napCable.CreateAndInsertCableSegment( 1, 135);
+// //   napCable.CreateAndInsertCableSegment( 2, 0);
+// //   napCable.CreateAndInsertCableSegment( 3, 0);
+// //   napCable.CreateAndInsertCableSegment( 4, 0);
+//   napCable.CreateAndInsertCableSegment( 1);
+//   napCable.CreateAndInsertCableSegment( 2);
+//   napCable.CreateAndInsertCableSegment( 3);
+//   napCable.CreateAndInsertCableSegment( 4);
+//   napCable.PrintCheckPoints();
 };
 
 
 //________________________________________________________________________
-void AliITSv11GeometrySDD::Layer3(TGeoVolume *Moth) {
-    // Insert the layer 3 in the mother volume. This is a virtual volume
-    // containing ladders of layer 3 and the supporting rings
-
-    TGeoTube *virtualLayer3Shape = new TGeoTube("ITSsddLayer3Shape",
-                                       fLay3Rmin,fLay3Rmax,fLay3Length*0.5);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualLayer3 = new TGeoVolume("ITSsddLayer3",
-                                               virtualLayer3Shape, airSDD);
-    TGeoVolume *lay3Ladder = CreateLay3Ladder();
-    TGeoVolume *lay3Detectors = CreateLay3Detectors();
-
-    Double_t dPhi = 360./fLay3Nladd;
-    Double_t detBoxThickness = fLadWaferSep + 2*fWaferThickness;
-    // Placing virtual ladder and detectors volumes following
-    // ladder ordering convention
-    char rotName[20];
-    Int_t iLaddMin = 0;
-    Int_t iLaddMax = fLay3Nladd;
-    if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fLay3Nladd)) {
-        iLaddMin = fAddOnlyLadder3min;
-        iLaddMax = fAddOnlyLadder3max+1;
-    }
-    for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
-        sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
-        Double_t minRadiusLadBox = fLay3LaddShortRadius;
-        if (iLadd%2 != 0) minRadiusLadBox = fLay3LaddLongRadius;
-        minRadiusLadBox += ((TGeoBBox*)lay3Ladder->GetShape())->GetDY();
-        
-        TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,
-                                                 0,-90+iLadd*dPhi);
-        virtualLayer3->AddNode(lay3Ladder,iLadd,ctLadd);
-        sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
-        Double_t minRadiusDetBox = fLay3DetShortRadius;
-        if (iLadd%2 != 0) minRadiusDetBox = fLay3DetLongRadius;
-        minRadiusDetBox += detBoxThickness/2;
-        TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
-                                                0,-90+iLadd*dPhi);
-        virtualLayer3->AddNode(lay3Detectors, iLadd, ctDet);
-    }
-    virtualLayer3->SetVisibility(kFALSE);
-    Moth->AddNode(virtualLayer3,1,0);
+void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
+  //
+  // Insert the layer 3 in the mother volume. This is a virtual volume
+  // containing ladders of layer 3 and the supporting rings
+  //
+
+  if (! moth) {
+    printf("Error::AliITSv11GeometrySDD: Can't insert layer3, mother is null!\n");
+    return;
+  };
+
+  TGeoMedium *airSDD = GetMedium("ITSair");
+
+  fMotherVol = moth;
+  if (! fSDDsensor) CreateBasicObjects();
+  
+  TGeoVolume *lay3Ladder    = CreateLadder(3);
+  TGeoVolume *lay3Detectors = CreateDetectors(3);
+  TGeoTube *virtualLayer3Shape = new TGeoTube("ITSsddLayer3Shape",
+                                    fgkLay3Rmin,fgkLay3Rmax,fgkLay3Length*0.5);
+  TGeoVolume *virtualLayer3 = new TGeoVolume("ITSsddLayer3",
+                                            virtualLayer3Shape, airSDD);
+
+  Double_t dPhi = 360./fgkLay3Nladd;
+  Double_t detectorsThick = fgkLadWaferSep + 2*fgkWaferThickness;
+  // Placing virtual ladder and detectors volumes following
+  // ladder ordering convention
+  char rotName[30];
+  Int_t iLaddMin = 0;
+  Int_t iLaddMax = fgkLay3Nladd;
+  if ((fAddOnlyLadder3min>=0)&&(fAddOnlyLadder3max<fgkLay3Nladd)) {
+    iLaddMin = fAddOnlyLadder3min;
+    iLaddMax = fAddOnlyLadder3max+1;
+  };
+
+  for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
+
+    sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
+    Double_t minRadiusLadBox = fLay3LaddShortRadius-fLay3LadderUnderSegDH;
+    if (iLadd%2 != 0)
+      minRadiusLadBox = fLay3LaddLongRadius-fLay3LadderUnderSegDH;
+    minRadiusLadBox += ((TGeoBBox*)lay3Ladder->GetShape())->GetDY();
+    TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,
+                                             0,-90+iLadd*dPhi);
+    virtualLayer3->AddNode(lay3Ladder, iLadd, ctLadd);
+    ///////////////////////////////////////////////////
+    sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
+    Double_t minRadiusDetBox = fgkLay3DetShortRadius;
+    if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
+    minRadiusDetBox += detectorsThick/2;
+    TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
+                                            0,-90+iLadd*dPhi);
+    virtualLayer3->AddNode(lay3Detectors, iLadd, ctDet);
+    ///////////////////////////////////////////////////
+  }
+
+  if(GetDebug(1)) virtualLayer3->CheckOverlaps(0.01);
+  virtualLayer3->SetVisibility(kFALSE);
+  moth->AddNode(virtualLayer3, 1, 0);
 };
 
 
 //________________________________________________________________________
-TGeoVolume *AliITSv11GeometrySDD::CreateLay3Ladder() {
-    // return a box volume containing the CF ladder
-
-    Double_t segmentLength = fSegmentLength;
-    TGeoVolume *laddSegmentTemp = CreateLadderSegment(3,0);
-    TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
-                          ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDX(),
-                           ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDY(),
-                                    //dX,dY = dX,dY of the segment
-                               fLay3LadderLength/2);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
-    cable.SetInitialNode(virtualLadder);
-
-    // placing virtual ladder segment following detector ordering convention
-    //=======================================================================
-    char transName[20];
-    Int_t iSegmentMin = 0;
-    Int_t iSegmentMax = fLay3Ndet;
-    if (fAddOnlySegment>=0) {
-        iSegmentMin = fAddOnlySegment;
-        iSegmentMax = fAddOnlySegment+1;
-    }
-    for (Int_t iSegment = iSegmentMin; iSegment < iSegmentMax; iSegment++ ) {
-
-        TGeoVolume *laddSegment = CreateLadderSegment(3, iSegment);
-        sprintf(transName, "ITSsddLay3LaddSeg%i", iSegment);
-        Double_t segmentPos = segmentLength*(fLay3Ndet/2-1-iSegment) 
-                             + segmentLength/2;
-        TGeoTranslation *segTr = new TGeoTranslation(transName,0,0,segmentPos);
-        virtualLadder->AddNode(laddSegment, iSegment, segTr);
-    }
+void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
+  //
+  // Insert the layer 4 in the mother volume. This is a virtual volume
+  // containing ladders of layer 4 and the supporting rings
+  //
+
+  if (! moth) {
+    printf("Error::AliITSv11GeometrySDD: Can't insert layer4, mother is null!\n");
+    return;
+  };
+
+  fMotherVol = moth;
+
+  if (! fSDDsensor) CreateBasicObjects();
+
+  TGeoTube *virtualLayer4Shape =new TGeoTube("ITSsddLayer4Shape",
+                                   fgkLay4Rmin,fgkLay4Rmax,fgkLay4Length*0.5);
+  TGeoMedium *airSDD = GetMedium("ITSair");
+  TGeoVolume *virtualLayer4 = new TGeoVolume("ITSsddLayer4",
+                                            virtualLayer4Shape, airSDD);
+  TGeoVolume *lay4Ladder    = CreateLadder(4);
+  TGeoVolume *lay4Detectors = CreateDetectors(4);
+  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;
+  }
+  for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
+    sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
+    Double_t minRadiusLadBox = fLay4LaddShortRadius-fLay4LadderUnderSegDH;
+    if (iLadd%2 != 0)
+      minRadiusLadBox = fLay4LaddLongRadius-fLay4LadderUnderSegDH;
+    minRadiusLadBox += ((TGeoBBox*)lay4Ladder->GetShape())->GetDY();
+    TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName, minRadiusLadBox,
+                                             0, -90+iLadd*dPhi);
+    virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
+    sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
+    Double_t minRadiusDetBox = fgkLay4DetShortRadius;
+    if (iLadd%2 != 0)
+      minRadiusDetBox = fgkLay4DetLongRadius;
+    minRadiusDetBox += detBoxThickness/2;
+    TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
+                                            0, -90+iLadd*dPhi);
+    virtualLayer4->AddNode(lay4Detectors, iLadd, ctDet);
+  }
+
+  if(GetDebug(1)) virtualLayer4->CheckOverlaps(0.01);
+  virtualLayer4->SetVisibility(kFALSE);
+  moth->AddNode(virtualLayer4,1,0);
+};
+
+
+//________________________________________________________________________
+TGeoVolume *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
+  //
+  // return a box volume containing the CF ladder
+  //
+
+  Int_t    nDetectors   = fgkLay3Ndet;
+  Double_t ladderLength = fgkLay3LadderLength;
+  Double_t underSegDH   = fLay3LadderUnderSegDH;
+  Double_t *sensorZPos  = fLay3sensorZPos;
+  AliITSv11GeomCableFlat *digitCableA = fDigitCableLay3A;
+  AliITSv11GeomCableFlat *digitCableB = fDigitCableLay3B;
+
+  if (iLay==3) {}
+  else if (iLay==4) {
+    nDetectors   = fgkLay4Ndet;
+    ladderLength = fgkLay4LadderLength;
+    digitCableA  = fDigitCableLay4A;
+    digitCableB  = fDigitCableLay4B;
+    underSegDH   = fLay4LadderUnderSegDH;
+    sensorZPos   = fLay4sensorZPos;
+  }
+  else {
+    printf("AliITSv11GeometrySDD::CreateLadder : error=wrong layer\n");
+  };
+  Double_t ladderBoxDH = fgkLadderHeight+fgkLadderSegBoxDH+underSegDH;
+  TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
+                        fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW,
+                        ladderBoxDH/2, ladderLength/2);
+  TGeoMedium *airSDD = GetMedium("ITSair");
+  TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
+  
+  // placing virtual ladder segment following detector ordering convention
+  //=======================================================================
+  char transName[30];
+
+  // adding segment this way to create cable points in the correct order ...
+  for (Int_t iSegment = nDetectors/2-1; iSegment >= 0; iSegment-- ) {
+
+    TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
+    sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
+    Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
+                          + fgkSegmentLength/2;
+    TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
+                                                underSegDH/2,segmentPos);
+    ////
+    virtualLadder->AddNode(laddSegment, iSegment, segTr);
+  };
+  for (Int_t iSegment = nDetectors/2; iSegment < nDetectors; iSegment++ ) {
+
+    TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
+    sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
+    Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
+                          + fgkSegmentLength/2;
+    TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
+                                                underSegDH/2,segmentPos);
+    ////
+    virtualLadder->AddNode(laddSegment, iSegment, segTr);
+  };
+
+  // putting virtual volume corresponding to the end of ladder
+  //=======================================================================
+  TGeoVolume *endLadder = CreateEndLadder( iLay );
+  Double_t endLength = (ladderLength - nDetectors*fgkSegmentLength)/2.;
+  TGeoTranslation *endTrZPos = new TGeoTranslation("ITSsddEndTrZPos",0,0,
+                                  fgkSegmentLength*(nDetectors/2)+endLength/2.);
+  // Euler rotation : about Z, then new X, then new Z
+  TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
+  TGeoCombiTrans *endTrZNeg = new TGeoCombiTrans(0,0,
+                 -fgkSegmentLength*(nDetectors/2)-endLength/2.,endZNegRot);
+  virtualLadder->AddNode(endLadder, 1, endTrZPos);
+  virtualLadder->AddNode(endLadder, 2, endTrZNeg);
+
+  // creating and inserting cable segments
+  //   (check points are placed while creating segments)
+  //=======================================================================
+  if (fAddCables)
+  for (Int_t iSegment = 0; iSegment < nDetectors; iSegment++ ) {
+    
+    digitCableA[iSegment].SetInitialNode(virtualLadder);
+    digitCableB[iSegment].SetInitialNode(virtualLadder);
+    
+    for (Int_t iPt=1; iPt<digitCableA[iSegment].GetNCheckPoints(); iPt++ ) {
+      Double_t rotation = 0;
+      if (iPt>1) rotation = 90-fgkHybridAngle; 
+      digitCableA[iSegment].CreateAndInsertCableSegment(iPt, rotation);
+    };
+    
+    for (Int_t iPt=1; iPt<digitCableB[iSegment].GetNCheckPoints(); iPt++ ) {
+      Double_t rotation = 0;
+      if (iPt>1) rotation = fgkHybridAngle-90; 
+      digitCableB[iSegment].CreateAndInsertCableSegment(iPt, rotation);
+    };
+  };
+  
+  // HV cable
+  //=======================================================================
+  TGeoMedium *polyhamideSDD = GetMedium("ITSsddKAPTON_POLYCH2");
+  TGeoMedium *alSDD         = GetMedium("ITSal");
+
+  AliITSv11GeomCableFlat cableHV[fgkLay4Ndet];  // temp !!!
+  char cableHVname[30];
+  for (Int_t iSegment = 0; iSegment<nDetectors; iSegment++) {
+    sprintf(cableHVname,"ITSsddHVcable%i", iSegment);
+    cableHV[iSegment].SetName(cableHVname);
+    cableHV[iSegment].SetThickness(fgkLongHVcablePolyThick+fgkLongHVcableAlThick);
+    cableHV[iSegment].SetWidth(fgkTransitHVtailWidth);
+    cableHV[iSegment].SetNLayers(2);
+    cableHV[iSegment].SetLayer(0, fgkLongHVcablePolyThick, polyhamideSDD,
+                              fColorPolyhamide);
+    cableHV[iSegment].SetLayer(1, fgkLongHVcableAlThick, alSDD, fColorAl);
+    cableHV[iSegment].SetInitialNode(virtualLadder);
+  };
+  Double_t x1[3], x2[3], x3[3],
+          vY[3] = {0,1,0}, vZ[3] = {0,0,1}, vYZ[3]={0,1,1};
+
+  x1[0] = fgkTransitHVtailXpos;
+  x2[0] = fgkTransitHVtailXpos;
+  x3[0] = fgkTransitHVtailXpos;
+  for (Int_t iSegment  = nDetectors/2-1; iSegment >= 0; iSegment-- ) {
+    Double_t cableSeparation = TMath::Abs(iSegment - (nDetectors/2-1))
+                               *fgkLongHVcableSeparation;
+    x1[1] = - ladderBoxDH/2;
+    x2[1] = - ladderBoxDH/2 + underSegDH - cableSeparation
+            - (fgkLongHVcablePolyThick+fgkLongHVcableAlThick)/2;
+    x3[1] = x2[1];
+    x1[2] = sensorZPos[iSegment]+fgkTransitHVtailLength-5*fgkmm;
+    x2[2] =  x1[2]+5*fgkmm;
+    x3[2] = ladderLength/2-endLength;
+    cableHV[iSegment].AddCheckPoint( virtualLadder, 0, x1, vY );
+    cableHV[iSegment].AddCheckPoint( virtualLadder, 1, x2, vYZ );
+    cableHV[iSegment].AddCheckPoint( virtualLadder, 2, x3, vZ );
+
+    cableHV[iSegment].CreateAndInsertCableSegment(1,0);
+    cableHV[iSegment].CreateAndInsertCableSegment(2,0);
+  };
+
+  vYZ[2] = -1;
+  for (Int_t iSegment = nDetectors/2; iSegment < nDetectors; iSegment++ ) { 
+    Double_t cableSeparation = TMath::Abs(iSegment - (nDetectors/2-1))
+                               *fgkLongHVcableSeparation;
+    x1[1] = - ladderBoxDH/2;
+    x2[1] = - ladderBoxDH/2 + underSegDH - cableSeparation
+            - (fgkLongHVcablePolyThick+fgkLongHVcableAlThick)/2;
+    x3[1] = x2[1];
+    x1[2] = sensorZPos[iSegment]-fgkTransitHVtailLength+5*fgkmm;
+    x2[2] =  x1[2]-5*fgkmm;
+    x3[2] = -ladderLength/2+endLength;
+    cableHV[iSegment].AddCheckPoint( virtualLadder, 0, x1, vY );
+    cableHV[iSegment].AddCheckPoint( virtualLadder, 1, x2, vYZ );
+    cableHV[iSegment].AddCheckPoint( virtualLadder, 2, x3, vZ );
+
+    cableHV[iSegment].CreateAndInsertCableSegment(1,0);
+    cableHV[iSegment].CreateAndInsertCableSegment(2,0);
+  };
 
-    // putting virtual volume corresponding to the end of ladder
-    //=======================================================================
-    TGeoVolume *endLadder = CreateEndLadder( 3,0 );
-    Double_t endLength = (fLay3LadderLength-fLay3Ndet*fSegmentLength)/2.;
-    TGeoTranslation *endTrZPos = new TGeoTranslation("ITSsddEndTrZPos",0,0,
-                                   fSegmentLength*(fLay3Ndet/2)+endLength/2.);
-    //Euler rotation : about Z, then new X, then new Z
-    TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
-    TGeoCombiTrans *endTrZNeg = new TGeoCombiTrans(0,0,
-                    -fSegmentLength*(fLay3Ndet/2)-endLength/2., endZNegRot);
-    if ((fAddOnlySegment==-1)||(fAddOnlySegment==0))
-        virtualLadder->AddNode(endLadder, 1, endTrZPos);
-    if ((fAddOnlySegment==-1)||(fAddOnlySegment==fLay3Ndet-1))
-        virtualLadder->AddNode(endLadder, 2, endTrZNeg);
-
-    cable.ResetInitialNode();
-
-    virtualLadder->SetVisibility(kFALSE);
-    return virtualLadder;
+  //**********************************
+  if(GetDebug(1)) virtualLadder->CheckOverlaps(0.01);
+  //virtualLadder->SetVisibility(kFALSE);
+  return virtualLadder;
 };
 
 
 //________________________________________________________________________
-TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(Double_t dz,Double_t angle,
-                          Double_t xSign,Double_t L, Double_t H, Double_t l) {
+TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(Double_t dz, Double_t angle,
+                         Double_t xSign, Double_t L, Double_t H, Double_t l) {
     // Create one half of the V shape corner of CF ladder
   
     TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
@@ -606,412 +1038,719 @@ TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(Double_t dz,Double_t angle,
 
 
 //________________________________________________________________________
-void AliITSv11GeometrySDD::AddLadderCFstruct(Double_t dy, TGeoVolume* vol) {
-    // fill a volume (segment) with the CF structure of a ladder
-
-    TGeoMedium *carbonFiberLadderStruct = 
-      gGeoManager->GetMedium("ITSsddCarbonFiber");
-    Double_t segmentLength = fSegmentLength;
-    Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
-    Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
-    Double_t beta = (TMath::Pi()-2.*halfTheta)/4.;
-    Double_t alpha = TMath::Pi()*3./4. - halfTheta/2.;
-
-    //--- The 3 V shape corners of the Carbon Fiber Ladder
-    //--- the top V
-    TGeoArb8 *cfLaddTop1 = CreateLadderSide( segmentLength/2., halfTheta, -1,
-                                            fLadderLa, fLadderHa, fLadderl);
-    TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
-                                   cfLaddTop1,carbonFiberLadderStruct);
-    TGeoArb8 *cfLaddTop2 = CreateLadderSide( segmentLength/2., halfTheta, 1,
-                                            fLadderLa, fLadderHa, fLadderl);
-    TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
-                                   cfLaddTop2,carbonFiberLadderStruct);
-    TGeoTranslation *trTop1 = new TGeoTranslation(0, fLadderHeight/2+dy, 0);
-    cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
-    cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
-    vol->AddNode(cfLaddTopVol1, 1, trTop1);
-    vol->AddNode(cfLaddTopVol2, 1, trTop1);
-
-    //--- the 2 side V
-    TGeoArb8 *cfLaddSide1 = CreateLadderSide( segmentLength/2., beta, -1,
-                                             fLadderLb, fLadderHb, fLadderl);
-    TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerV1",
-                                     cfLaddSide1,carbonFiberLadderStruct);
-    TGeoArb8 *cfLaddSide2 = CreateLadderSide( segmentLength/2., beta, 1,
-                                             fLadderLb, fLadderHb, fLadderl);
-    TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerV2",
-                                    cfLaddSide2,carbonFiberLadderStruct);
-    cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
-    cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
-
-    Double_t dYTranslation = fLadderHeight/2. - 
-                      0.5*fLadderWidth*TMath::Tan(beta) - fLadderBeamRadius;
-    // because center of the triangle doesn't correspond to virtual vol. center
-    Double_t distCenterSideDown =  0.5*fLadderWidth/TMath::Cos(beta);
-    TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
-                                               alpha*TMath::RadToDeg());
-    AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+dy, 0);
-    TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,
-                                               -alpha*TMath::RadToDeg());
-    AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+dy, 0);
-    vol->AddNode(cfLaddSideVol1, 1, ctSideR);
-    vol->AddNode(cfLaddSideVol2, 1, ctSideR);
-    vol->AddNode(cfLaddSideVol1, 2, ctSideL);
-    vol->AddNode(cfLaddSideVol2, 2, ctSideL);
-
-    //--- The beams
-    // Beams on the sides
-    Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
-                TMath::Sin(2*beta)/(TanD(fBeamSidePhi)*TanD(fBeamSidePhi))) ));
-    if(GetDebug(1))
-      cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
-    Double_t beamLength = TMath::Sqrt( fLadderHeight*fLadderHeight/
-                       ( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
-                      + fLadderWidth*fLadderWidth/4.)-fLadderLa/2-fLadderLb/2;
-    TGeoTubeSeg *sideBeam= new TGeoTubeSeg(0, fLadderBeamRadius, beamLength/2.,
-                                           0, 180);
-    TGeoVolume *cfSideBeamVol = new TGeoVolume("ITSsddCFSideBeamVol", sideBeam,
-                                               carbonFiberLadderStruct);
-    cfSideBeamVol->SetLineColor(fColorCarbonFiber);
-
-    //Euler rotation : about Z, then new X, then new Z
-    TGeoRotation *beamRot1 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
-                                -beamPhiPrime*TMath::RadToDeg(),-90);
-    TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans( 0.5*triangleHeight*
-                                     TMath::Tan(halfTheta),
-                                     fLadderBeamRadius/2. + dy,
-                                     -3*segmentLength/8, beamRot1);
-    TGeoCombiTrans *beamTransf2 = new TGeoCombiTrans( 0.5*triangleHeight*
-                                     TMath::Tan(halfTheta),
-                                     fLadderBeamRadius/2. + dy,
-                                     segmentLength/8, beamRot1);
-    TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
-                                beamPhiPrime*TMath::RadToDeg(), -90);
-
-    TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans(0.5*triangleHeight*
-                                     TMath::Tan(halfTheta),
-                                     fLadderBeamRadius/2. + dy,
-                                     -segmentLength/8, beamRot2);
-    TGeoCombiTrans *beamTransf4 = new TGeoCombiTrans(0.5*triangleHeight*
-                                     TMath::Tan(halfTheta),
-                                     fLadderBeamRadius/2. + dy,
-                                     3*segmentLength/8, beamRot2);
-    TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
-                                beamPhiPrime*TMath::RadToDeg(), -90);
-
-    TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
-                                     TMath::Tan(halfTheta),
-                                     fLadderBeamRadius/2. + dy,
-                                     -3*segmentLength/8,beamRot3);
-    TGeoCombiTrans *beamTransf6 = new TGeoCombiTrans(-0.5*triangleHeight*
-                                     TMath::Tan(halfTheta),
-                                     fLadderBeamRadius/2. + dy,
-                                     segmentLength/8, beamRot3);
-    TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),
-                                -beamPhiPrime*TMath::RadToDeg(), -90);
-
-    TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
-      TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,-segmentLength/8,beamRot4);
-    TGeoCombiTrans *beamTransf8 = new TGeoCombiTrans(-0.5*triangleHeight*
-     TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,3*segmentLength/8,beamRot4);
-
-    vol->AddNode(cfSideBeamVol, 1, beamTransf1);
-    vol->AddNode(cfSideBeamVol, 2, beamTransf2);
-    vol->AddNode(cfSideBeamVol, 3, beamTransf3);
-    vol->AddNode(cfSideBeamVol, 4, beamTransf4);
-    vol->AddNode(cfSideBeamVol, 5, beamTransf5);
-    vol->AddNode(cfSideBeamVol, 6, beamTransf6);
-    vol->AddNode(cfSideBeamVol, 7, beamTransf7);
-    vol->AddNode(cfSideBeamVol, 8, beamTransf8);
-
-    //--- Beams of the bottom
-    TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fLadderBeamRadius,
-                                  fLadderWidth/2.-fLadderLb/3, 0, 180);
-    TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
-                                     bottomBeam1, carbonFiberLadderStruct);
-    bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
-
-    TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
-    TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
-                    -(fLadderHeight/2-fLadderBeamRadius)+dy,0, bottomBeamRot1);
-    TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fLadderBeamRadius,
-                                  fLadderWidth/2.-fLadderLb/3, 0, 90);
-    TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
-                                bottomBeam2, carbonFiberLadderStruct);
-    bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
-    TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
-                                     -(fLadderHeight/2-fLadderBeamRadius)+dy,
-                                     -segmentLength/2, bottomBeamRot1);
-    TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
-    TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,
-                                        -(fLadderHeight/2 - fLadderBeamRadius)
-                                       + dy, segmentLength/2, bottomBeamRot2);
-
-    TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, fLadderBeamRadius,
-                              0.5*fLadderWidth/SinD(fBottomBeamAngle)
-                              - fLadderLb/3, 0, 180);
-    TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol",
-                                 bottomBeam3, carbonFiberLadderStruct);
-    bottomBeam3Vol->SetLineColor(fColorCarbonFiber);
-    //bottomBeam3Vol->SetLineColor(2);
-
-    // be careful on the next 2 beams : when "reading" from -z to +z and 
-    // from the bottom of the ladder, it should draw a Lambda, and not a V
-    TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, fBottomBeamAngle,
-                                                    -90);
-    TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans(0, 
-      -(fLadderHeight/2-fLadderBeamRadius)+dy,-segmentLength/4,bottomBeamRot4);
-    TGeoRotation *bottomBeamRot5 = new TGeoRotation("",-90,-fBottomBeamAngle,
-                                                    -90);
-    TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans(0,
-     -(fLadderHeight/2-fLadderBeamRadius)+dy,segmentLength/4, bottomBeamRot5);
-
-    vol->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
-    vol->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
-    vol->AddNode(bottomBeam2Vol, 2, bottomBeamTransf3);
-    vol->AddNode(bottomBeam3Vol, 1, bottomBeamTransf4);
-    vol->AddNode(bottomBeam3Vol, 2, bottomBeamTransf5);
-};
-
+TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
+  //
+  // return a box containing the front-end hybrid
+  //
+
+  Double_t roundHoleX       = -fgkHybridWidth/2+fgkHybRndHoleX;
+
+  Double_t screenTotalThick = fgkHybGlueScrnThick+fgkHybUpThick+fgkHybAlThick;
+  Double_t lowFLTotalThick  = fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick;
+//   Double_t upFLTotalThick   = fgkHybGlueUpThick +fgkHybUpThick+fgkHybAlThick;
+  Double_t chipsCCTotThick  = fgkHybUnderNiThick+fgkHybGlueAgThick
+                              +fgkHybChipThick+2*(fgkHybUpCCThick+fgkHybAlCCThick);
+  Double_t ccUpLayerTotThick = fgkHybUpCCThick+fgkHybAlCCThick+fgkHybUpCCThick;
+//   Double_t volumeThick = (fgkHybridThBridgeThick+screenTotalThick+lowFLTotalThick
+//                       + upFLTotalThick + ccUpLayerTotThick);
+  Double_t volumeThick = (fgkHybridThBridgeThick+screenTotalThick+lowFLTotalThick
+                         +fgkHybSMDheight);
+  Double_t lowLayerYmin     = -volumeThick/2+fgkHybridThBridgeThick
+                              +screenTotalThick;
+  Double_t flUpThick        = fgkHybGlueUpThick+fgkHybUpThick;
+
+  //**************************************************** media :
+  TGeoMedium *airSDD                  = GetMedium("ITSair");
+  TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
+  TGeoMedium *alSDD                   = GetMedium("ITSal");
+  TGeoMedium *alSDD80p100             = GetMedium("ITSal");                 // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *alSDD50p100             = GetMedium("ITSal");                 // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *polyhamideSDD           = GetMedium("ITSsddKAPTON_POLYCH2");
+  TGeoMedium *niSDD                   = GetMedium("COPPER");                // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *glueAG                  = GetMedium("ITSsddKAPTON_POLYCH2");  // to code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *siliconSDD              = GetMedium("ITSsddSiChip");
+  TGeoMedium *medSMD                  = GetMedium("SDDX7Rcapacitors");      //     TO CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *medSMDweld              = GetMedium("SDDX7Rcapacitors");      //    TO CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+  //**************************************************** main volume :
+  TGeoBBox *hybridBox = new TGeoBBox("",fgkHybridWidth/2, volumeThick/2,
+                                    (fgkHybridLength)/2);
+  TGeoVolume *hybrid = new TGeoVolume("ITSsddHybridVol", hybridBox,
+                                     airSDD);
+  TGeoBBox *sThermalBridge = new TGeoBBox( "", fgkHybridWidth/2,
+                                          fgkHybridThBridgeThick/2,
+                                          fgkHybridLength/2);
 
-//________________________________________________________________________
-TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iSeg) {
-// return a box containing the front-end hybrid
-// Be careful : electronics side is at y<0, thermal bridge at y>0
-
-  Double_t volumeThick =  0.2;                                  // <===== 0.2 tmp
-  TGeoBBox *hybridBox = new TGeoBBox("",fHybridWidth/2, volumeThick/2,
-                                    (fHybridLength)/2);  // include space on each side for cables ???  
-  TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-  TGeoVolume *VirtualHybrid = new TGeoVolume( "ITSsddHybridVol", hybridBox,
-                                             airSDD);
-  
-  TGeoBBox *sThermalBridge = new TGeoBBox( "", fHybridWidth/2,
-                                          fHybridThBridgeThick/2,
-                                          fHybridLength/2);
-  TGeoMedium *carbonFiberLadderStruct =
-    gGeoManager->GetMedium("ITSsddCarbonFiber");
-  
+  //**************************************************** Thermal bridge :
   TGeoVolume *vThermalBridge = new TGeoVolume("ITSsddHybridThBridge",
                                              sThermalBridge,
                                              carbonFiberLadderStruct);
   vThermalBridge->SetLineColor(fColorCarbonFiber);
+  TGeoTranslation *thBridgeTr = new TGeoTranslation(0, -volumeThick/2
+                                   +fgkHybridThBridgeThick/2, 0);
+  hybrid->AddNode(vThermalBridge, 1, thBridgeTr);
+
+  //**************************************************** Screen layer :
+  TGeoBBox *sAlScreenLayer = new TGeoBBox("sAlScreenLayer", fgkHybridWidth/2,
+                                         fgkHybAlThick/2, fgkHybridLength/2);
+  //here the upedex and glue layers are both assumed to be polyimide
+  TGeoBBox *sUpGlueScreenLayer = new TGeoBBox("sUpGlueScreenLayer",
+                                             fgkHybridWidth/2,
+                                    (fgkHybUpThick+fgkHybGlueScrnThick)/2,
+                                             fgkHybridLength/2);
+  TGeoTube *sRoundHole = new TGeoTube("sRoundHole", 0, fgkHybRndHoleRad,
+                                     (screenTotalThick+lowFLTotalThick)/2);
+
+  TGeoTranslation *upGlueScreenTr = new TGeoTranslation("upGlueScreenTr",0,
+   -volumeThick/2+fgkHybridThBridgeThick+(fgkHybUpThick+fgkHybGlueScrnThick)/2,0);
+
+  TGeoTranslation *alScreenTr = new TGeoTranslation("AlScreenTr", 0,
+   -volumeThick/2+fgkHybridThBridgeThick+fgkHybUpThick+fgkHybGlueScrnThick
+   +fgkHybAlThick/2, 0);
+
+  TGeoTranslation hybHolePos1Tr(roundHoleX,
+   -volumeThick/2+fgkHybridThBridgeThick+(screenTotalThick+lowFLTotalThick)/2,
+                               -fgkHybridLength/2+fgkHybRndHoleZ);
+  TGeoTranslation hybHolePos2Tr(roundHoleX, 
+   -volumeThick/2+fgkHybridThBridgeThick+(screenTotalThick+lowFLTotalThick)/2,
+                               fgkHybridLength/2-fgkHybRndHoleZ);
+  TGeoRotation rotHole("", 0, 90, 0);
+  TGeoCombiTrans *hybHolePos1 = new TGeoCombiTrans(hybHolePos1Tr, rotHole);
+  hybHolePos1->SetName("hybHolePos1");
+  TGeoCombiTrans *hybHolePos2 = new TGeoCombiTrans(hybHolePos2Tr, rotHole);
+  hybHolePos2->SetName("hybHolePos2");
+
+  upGlueScreenTr->RegisterYourself();
+  alScreenTr->RegisterYourself();
+  hybHolePos1->RegisterYourself();
+  hybHolePos2->RegisterYourself();
+
+  TGeoCompositeShape *sScreenAl = new TGeoCompositeShape(
+                     "sAlScreenLayer:AlScreenTr-(sRoundHole:hybHolePos1"
+                     "+sRoundHole:hybHolePos2)");
+  TGeoVolume *vScreenAl = new TGeoVolume("vScreenAl",sScreenAl, alSDD);
+  vScreenAl->SetLineColor(fColorAl);
+  TGeoCompositeShape *sScreenUpGlue = new TGeoCompositeShape(
+       "sUpGlueScreenLayer:upGlueScreenTr-(sRoundHole:hybHolePos1"
+        "+sRoundHole:hybHolePos2)");
+  TGeoVolume *vScreenUpGlue = new TGeoVolume("vScreenUpGlue",
+                                            sScreenUpGlue,polyhamideSDD);
+  vScreenUpGlue->SetLineColor(fColorPolyhamide);
+
+  hybrid->AddNode(vScreenUpGlue, 1, 0);
+  hybrid->AddNode(vScreenAl, 1, 0);
+
+  //****************************************************  FL low layer :
+  Double_t sideWidth1 = fgkHybFLlowChipZ1 - fgkHybFLlowHoleDZ/2;
+  Double_t sideWidth2 = fgkHybridLength - fgkHybFLlowChipZ4 - fgkHybFLlowHoleDZ/2;
+
+  //here the upedex and glue layers are both assumed to be polyimide
+  TGeoBBox *sUpGlueBar1 = new TGeoBBox("sUpGlueBar1", fgkHybridWidth/2,
+                                     (fgkHybGlueLowThick+fgkHybUpThick)/2,
+                                      sideWidth1/2);
+  TGeoBBox *sAlBar1 = new TGeoBBox("sAlBar1", fgkHybridWidth/2,
+                                 fgkHybAlThick/2, sideWidth1/2);
+  TGeoTranslation *upGlueBarTr1 = new TGeoTranslation("upGlueBarTr1", 0,
+                             lowLayerYmin+(fgkHybGlueLowThick+fgkHybUpThick)/2,
+                                             -(fgkHybridLength-sideWidth1)/2);
+  TGeoTranslation *alBarTr1 = new TGeoTranslation("alBarTr1", 0,
+                   lowLayerYmin+fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick/2,
+                                             -(fgkHybridLength-sideWidth1)/2);
+  upGlueBarTr1->RegisterYourself();
+  alBarTr1->RegisterYourself();
+
+  TGeoCompositeShape *sLowUpGlueBar1 = new TGeoCompositeShape(
+                    "sUpGlueBar1:upGlueBarTr1-sRoundHole:hybHolePos1");
+  TGeoCompositeShape *sLowAlBar1 = new TGeoCompositeShape(
+                     "sAlBar1:alBarTr1-sRoundHole:hybHolePos1");
+  TGeoVolume *vLowUpGlueBar1 = new TGeoVolume("vLowUpGlueBar1",
+                                             sLowUpGlueBar1, polyhamideSDD);
+  TGeoVolume *vLowAlBar1 = new TGeoVolume("vLowAlBar1",
+                                         sLowAlBar1, alSDD);
+  vLowUpGlueBar1->SetLineColor(fColorPolyhamide);
+  vLowAlBar1->SetLineColor(fColorAl);
+  hybrid->AddNode(vLowUpGlueBar1,1,0);
+  hybrid->AddNode(vLowAlBar1,1,0);
+
+  //---
+  //here the upedex and glue layers are both assumed to be polyimide
+  TGeoBBox *sUpGlueBar2 = new TGeoBBox("sUpGlueBar2", fgkHybridWidth/2,
+                                      (fgkHybGlueLowThick+fgkHybUpThick)/2,
+                                      sideWidth2/2);
+  TGeoBBox *sAlBar2 = new TGeoBBox("sAlBar2", fgkHybridWidth/2,
+                                  fgkHybAlThick/2, sideWidth2/2);
+
+ TGeoTranslation *upGlueBarTr2 = new TGeoTranslation("upGlueBarTr2", 0,
+                             lowLayerYmin+(fgkHybGlueLowThick+fgkHybUpThick)/2,
+                                              (fgkHybridLength-sideWidth2)/2);
+  TGeoTranslation *alBarTr2 = new TGeoTranslation("alBarTr2", 0,
+                   lowLayerYmin+fgkHybGlueLowThick+fgkHybUpThick+fgkHybAlThick/2,
+                                              (fgkHybridLength-sideWidth2)/2);
+  upGlueBarTr2->RegisterYourself();
+  alBarTr2->RegisterYourself();
+
+  TGeoCompositeShape *sLowUpGlueBar2 = new TGeoCompositeShape(
+                    "sUpGlueBar2:upGlueBarTr2-sRoundHole:hybHolePos2");
+  TGeoCompositeShape *sLowAlBar2 = new TGeoCompositeShape(
+                     "sAlBar2:alBarTr2-sRoundHole:hybHolePos2");
+  TGeoVolume *vLowUpGlueBar2 = new TGeoVolume("vLowUpGlueBar2",sLowUpGlueBar2,
+                                             polyhamideSDD);
+  TGeoVolume *vLowAlBar2 = new TGeoVolume("vLowAlBar2",sLowAlBar2,
+                                         alSDD);
+  vLowUpGlueBar2->SetLineColor(fColorPolyhamide);
+  vLowAlBar2->SetLineColor(fColorAl);
+  hybrid->AddNode(vLowUpGlueBar2, 1, 0);
+  hybrid->AddNode(vLowAlBar2, 1, 0);
+
+  if(GetDebug(3)){ // Remove compiler warning.
+    sAlScreenLayer->InspectShape();
+    sUpGlueScreenLayer->InspectShape();
+    sRoundHole->InspectShape();
+    sUpGlueBar1->InspectShape();
+    sUpGlueBar2->InspectShape();
+    sAlBar1->InspectShape();
+    sAlBar2->InspectShape();
+  };
+  //---
+  //using class AliITSv11GeomCableFlat to add 2-layer segments ... 
+  Double_t piece1width = fgkHybFLlowPasX-fgkHybFLlowHolePasDX/2;
+  AliITSv11GeomCableFlat lowFLpiece("lowFLpiece1",piece1width,
+                                      lowFLTotalThick);
+  lowFLpiece.SetNLayers(2);
+  lowFLpiece.SetLayer(0, fgkHybGlueLowThick+fgkHybUpThick, polyhamideSDD,
+                      fColorPolyhamide);
+  lowFLpiece.SetLayer(1, fgkHybAlThick, alSDD80p100, fColorAl);
+  // alSDD at 80% : mostly to take into account strips of piece 3
+
+  Double_t x1[3] = { -fgkHybridWidth/2 + piece1width/2,
+                    lowLayerYmin + lowFLTotalThick/2,
+                    -fgkHybridLength/2 + sideWidth1 };
+  Double_t x2[3] ={ x1[0], x1[1], fgkHybridLength/2 - sideWidth2 };
+  Double_t vZ[3] = {0,0,1};
+  lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
+  lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
+  lowFLpiece.SetInitialNode(hybrid);
+  lowFLpiece.CreateAndInsertCableSegment(1);
+  lowFLpiece.ResetPoints();
+
+  Double_t piece2width = fgkHybFLlowAmbX-fgkHybFLlowPasX
+                         -fgkHybFLlowHolePasDX/2-fgkHybFLlowHoleAmbDX/2;
+
+  lowFLpiece.SetWidth(piece2width);
+  lowFLpiece.SetName("lowFLpiece2");
+  x1[0] = piece2width/2+fgkHybFLlowPasX+fgkHybFLlowHolePasDX/2-fgkHybridWidth/2;
+  x2[0] = x1[0];
+  lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
+  lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
+  lowFLpiece.CreateAndInsertCableSegment(1);
+  lowFLpiece.ResetPoints();
+
+  Double_t piece3width = fgkHybridWidth - fgkHybFLlowAmbX 
+                         - fgkHybFLlowHoleAmbDX/2;
+
+  lowFLpiece.SetWidth(piece3width);
+  lowFLpiece.SetName("lowFLpiece3");
+  x1[0] = fgkHybridWidth/2-piece3width/2;
+  x2[0] = x1[0];
+  lowFLpiece.AddCheckPoint( hybrid, 0, x2, vZ );
+  lowFLpiece.AddCheckPoint( hybrid, 1, x1, vZ );
+  lowFLpiece.CreateAndInsertCableSegment(1);
+
+  Double_t zChips[4] = {fgkHybFLlowChipZ1,fgkHybFLlowChipZ2,
+                       fgkHybFLlowChipZ3,fgkHybFLlowChipZ4};
+  Double_t vX[3] = {1,0,0};
+  for (Int_t i=0; i<3; i++) {
+    char ch[20];
+    sprintf(ch, "lowFLpieceA%i", i+4);
+    lowFLpiece.SetName(ch);
+    lowFLpiece.SetWidth(zChips[i+1]-zChips[i]-fgkHybFLlowHoleDZ);
+
+    lowFLpiece.SetLayer(1, fgkHybAlThick, alSDD, fColorAl);
+    x1[0] = -fgkHybridWidth/2 + piece1width;
+    x2[0] = x1[0] + fgkHybFLlowHolePasDX;
+    Double_t zPiece = (zChips[i+1]+zChips[i])/2 - fgkHybridLength/2;
+    x1[2] = zPiece; x2[2] = zPiece; 
+    lowFLpiece.AddCheckPoint( hybrid, 0, x2, vX );
+    lowFLpiece.AddCheckPoint( hybrid, 1, x1, vX );
+    lowFLpiece.CreateAndInsertCableSegment(1,90);
+    lowFLpiece.ResetPoints();
+
+    sprintf(ch, "lowFLpieceB%i", i+4);
+    lowFLpiece.SetName(ch);
+    x1[0] = fgkHybridWidth/2 - piece3width;
+    x2[0] = x1[0] - fgkHybFLlowHoleAmbDX;
+    lowFLpiece.AddCheckPoint( hybrid, 0, x1, vX );
+    lowFLpiece.AddCheckPoint( hybrid, 1, x2, vX );
+    lowFLpiece.CreateAndInsertCableSegment(1,90);
+  };
+  
+  //**************************************************** chips+CC:
+  AliITSv11GeomCableFlat chip("", fgkHybChipsDZ, chipsCCTotThick);
+  chip.SetInitialNode(hybrid);
+  chip.SetNLayers(5);
+  chip.SetLayer(0, fgkHybUnderNiThick, niSDD, 2);
+  chip.SetLayer(1, fgkHybGlueAgThick, glueAG, 4);
+  chip.SetLayer(2, fgkHybChipThick, siliconSDD, fColorSilicon);
+  chip.SetLayer(3, fgkHybUpCCThick+fgkHybUpCCThick, polyhamideSDD,
+               fColorPolyhamide);
+  chip.SetLayer(4, fgkHybAlCCThick+fgkHybAlCCThick, alSDD80p100, fColorAl);
+  // Here the tho CC (low+up) are merged
+  // In fact, the last layer has a smaller surface of Al -> I put 80%
+  
+  x1[1] = lowLayerYmin + chipsCCTotThick/2;
+  x2[1] = x1[1];
+  char ch[20];
+
+  for (Int_t i=0; i<4; i++) {
+    sprintf(ch, "pascalCC%i", i);
+    chip.SetName(ch);
+    x1[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
+    x2[0] = x1[0] + fgkHybPascalDX;
+    x1[2] =  zChips[i] - fgkHybridLength/2;
+    x2[2] = x1[2];
+    chip.AddCheckPoint( hybrid, 0, x1, vX );
+    chip.AddCheckPoint( hybrid, 1, x2, vX );
+    chip.CreateAndInsertCableSegment(1,-90);
+    chip.ResetPoints();
+
+    sprintf(ch, "ambraCC%i", i);
+    chip.SetName(ch);
+    x1[0] = fgkHybFLlowAmbX - fgkHybridWidth/2 - fgkHybAmbraDX/2;
+    x2[0] = x1[0] + fgkHybAmbraDX;
+    chip.AddCheckPoint( hybrid, 0, x1, vX );
+    chip.AddCheckPoint( hybrid, 1, x2, vX );
+    chip.CreateAndInsertCableSegment(1,-90);
+    chip.ResetPoints();
+  };
 
-  TGeoTranslation *thBridgeTr = new TGeoTranslation("", 0,
-                                   volumeThick/2-fHybridThBridgeThick/2, 0);
-  VirtualHybrid->AddNode(vThermalBridge, 1, thBridgeTr);
+  //**************************************************** CC outside chips:
+  // je crois qu'il n'y a pas de 2ieme couche d'alu ici ... 
+  for (Int_t i = 0; i<4; i++) {
+    char ch[20];
+    sprintf(ch, "ccLayerA%i", i);
+
+    AliITSv11GeomCableFlat ccLayer1(ch, 6.6*fgkmm, ccUpLayerTotThick);
+    ccLayer1.SetInitialNode(hybrid);
+    ccLayer1.SetNLayers(2);
+    ccLayer1.SetLayer(0, 2*fgkHybUpCCThick, polyhamideSDD, fColorPolyhamide);
+    ccLayer1.SetLayer(1, fgkHybAlCCThick, alSDD50p100, fColorAl);
+    // Al at ~50%
+
+    x1[0] = -fgkHybridWidth/2;
+    x2[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
+    x1[1] = lowLayerYmin + fgkHybUnderNiThick + fgkHybGlueAgThick
+            + fgkHybChipThick + ccUpLayerTotThick/2;
+    x2[1] = x1[1];
+    x1[2] = zChips[i] - fgkHybridLength/2;
+    x2[2] = x1[2];
+    ccLayer1.AddCheckPoint( hybrid, 0, x1, vX );
+    ccLayer1.AddCheckPoint( hybrid, 1, x2, vX );
+    ccLayer1.CreateAndInsertCableSegment(1,-90);
+
+    sprintf(ch, "ccLayerB%i", i);
+    AliITSv11GeomCableFlat ccLayer2(ch, fgkHybChipsDZ, ccUpLayerTotThick);
+    ccLayer2.SetInitialNode(hybrid);
+    ccLayer2.SetNLayers(2);
+    ccLayer2.SetLayer(0, 2*fgkHybUpCCThick, polyhamideSDD, fColorPolyhamide);
+    ccLayer2.SetLayer(1, fgkHybAlCCThick, alSDD50p100, fColorAl);
+     // Al at ~50%
+
+    x1[0] = -fgkHybridWidth/2 + fgkHybFLlowPasX + fgkHybPascalDX/2;
+    x2[0] = -fgkHybridWidth/2 + fgkHybFLlowAmbX - fgkHybAmbraDX/2;
+    ccLayer2.AddCheckPoint( hybrid, 0, x1, vX );
+    ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
+    ccLayer2.CreateAndInsertCableSegment(1,-90);
+    ccLayer2.ResetPoints();
+    sprintf(ch, "ccLayerC%i", i);
+    ccLayer2.SetName(ch);
+    x1[0] =  -fgkHybridWidth/2 + fgkHybFLlowAmbX + fgkHybAmbraDX/2;
+    x2[0] = fgkHybridWidth/2 - fgkHybFLUpperWidth + 3*fgkmm;
+    x1[1] = lowLayerYmin + lowFLTotalThick + flUpThick + fgkHybAlThick
+             + ccUpLayerTotThick/2;
+    x2[1] = x1[1];
+
+    ccLayer2.AddCheckPoint( hybrid, 0, x1, vX );
+    ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
+    ccLayer2.CreateAndInsertCableSegment(1,-90);
+  };
 
-  Double_t coord[3];
-  coord[0] = 0;coord[1] = 0;coord[2] = 0;
-  cable.AddCheckPoint(VirtualHybrid, iSeg, coord);
-  VirtualHybrid->SetVisibility(kFALSE);
-  cable.GetCheckPoint( cable.GetNCheckPoints()-2, 0, 100, coord);
-  return VirtualHybrid;
+  //**************************************************** FL UP:
+  // (last Al layer will be a special triangular shape)
+  TGeoBBox *sFLupPolyhamide = new TGeoBBox("sFLupPolyhamide",
+                             fgkHybFLUpperWidth/2, flUpThick/2,
+                             fgkHybFLUpperLength/2);
+  TGeoVolume *vFLupPolyhamide = new TGeoVolume("vFLupPolyhamide",
+                                   sFLupPolyhamide, polyhamideSDD);
+  vFLupPolyhamide->SetLineColor(fColorPolyhamide);
+  TGeoTranslation *trFLupPolyhamide = 
+    new TGeoTranslation(fgkHybridWidth/2-fgkHybFLUpperWidth/2,
+                       lowLayerYmin+lowFLTotalThick+flUpThick/2,0);
+
+  hybrid->AddNode(vFLupPolyhamide, 1, trFLupPolyhamide);
+
+  TGeoArb8 *aluStrip = new TGeoArb8(fgkHybAlThick/2);
+  aluStrip->SetVertex( 0,-fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
+  aluStrip->SetVertex( 1, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
+  aluStrip->SetVertex( 2, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth-fgkHybFLUpperAldx);
+  aluStrip->SetVertex( 3,-fgkHybFLUpperAlDZ/2, 0);
+  aluStrip->SetVertex( 4,-fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
+  aluStrip->SetVertex( 5, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth);
+  aluStrip->SetVertex( 6, fgkHybFLUpperAlDZ/2, fgkHybFLUpperWidth-fgkHybFLUpperAldx);
+  aluStrip->SetVertex( 7,-fgkHybFLUpperAlDZ/2, 0);
+  TGeoVolume *vAluStrip = new TGeoVolume("vAluStrip",aluStrip, alSDD50p100);
+  // Al at ~50%
+
+  vAluStrip->SetLineColor(fColorAl);
+  TGeoRotation rotAluStrip("rotAluStrip",0, -90, 90);
+  Double_t yRotAluStrip = lowLayerYmin+lowFLTotalThick
+                          +flUpThick+fgkHybAlThick/2;
+  TGeoCombiTrans *aluStripTr1 = new TGeoCombiTrans(
+                                   fgkHybridWidth/2,yRotAluStrip,
+                   fgkHybridLength/2-fgkHybFLlowChipZ1+1*fgkmm, &rotAluStrip);
+  TGeoCombiTrans *aluStripTr2 = new TGeoCombiTrans(*aluStripTr1);
+  AddTranslationToCombiTrans(aluStripTr2,0,0,
+                            fgkHybFLlowChipZ1-fgkHybFLlowChipZ2);
+  TGeoCombiTrans *aluStripTr3 = new TGeoCombiTrans(*aluStripTr2);
+  AddTranslationToCombiTrans(aluStripTr3,0,0,
+                            fgkHybFLlowChipZ2-fgkHybFLlowChipZ3);
+  TGeoCombiTrans *aluStripTr4 = new TGeoCombiTrans(*aluStripTr3);
+  AddTranslationToCombiTrans(aluStripTr4,0,0,
+                            fgkHybFLlowChipZ3-fgkHybFLlowChipZ4);
+
+  hybrid->AddNode(vAluStrip, 1, aluStripTr1); 
+  hybrid->AddNode(vAluStrip, 2, aluStripTr2); 
+  hybrid->AddNode(vAluStrip, 3, aluStripTr3); 
+  hybrid->AddNode(vAluStrip, 4, aluStripTr4); 
+
+  //**************************************************** SMD:
+  TGeoBBox *hybSMD = new TGeoBBox("ITSsddSMDshape",
+                                 fgkHybSMDmiddleL/2+fgkHybSMDendL,
+                                 fgkHybSMDheight/2,fgkHybSMDendW/2);
+  TGeoVolume *vHybSMD = new TGeoVolume("ITSsddSMD",hybSMD,airSDD);
+
+  TGeoBBox *hybSMDmiddle = new TGeoBBox("ITSsddSMDmiddleShape",
+                              fgkHybSMDmiddleL/2,fgkHybSMDheight/2,
+                                       fgkHybSMDmiddleW/2);
+  TGeoVolume *vHybSMDmiddle = new TGeoVolume("ITSsddSMDmiddle",
+                                           hybSMDmiddle,medSMD);
+  vHybSMDmiddle->SetLineColor(fColorSMD);
+  TGeoBBox *hybSMDend = new TGeoBBox("ITSsddSMDendShape",
+                           fgkHybSMDendL/2,fgkHybSMDheight/2,fgkHybSMDendW/2);
+  TGeoVolume *vHybSMDend = new TGeoVolume("ITSsddSMDend",
+                                         hybSMDend,medSMDweld);
+  vHybSMDend->SetLineColor(fColorSMDweld);
+  TGeoTranslation *vHybSMDendTr1 = new TGeoTranslation("",
+                                      (fgkHybSMDmiddleL+fgkHybSMDendL)/2,0,0);
+  TGeoTranslation *vHybSMDendTr2 = new TGeoTranslation("",
+                                      -(fgkHybSMDmiddleL+fgkHybSMDendL)/2,0,0);
+  vHybSMD->AddNode(vHybSMDmiddle,1,0);
+  vHybSMD->AddNode(vHybSMDend,1,vHybSMDendTr1);
+  vHybSMD->AddNode(vHybSMDend,2,vHybSMDendTr2);
+  for (Int_t i=0; i<fgkNHybSMD; i++) {
+    TGeoTranslation *vHybSMDtr = new TGeoTranslation("",
+                                -fgkHybridWidth/2+fgkHybSMDposX[i],
+                                lowLayerYmin+lowFLTotalThick+fgkHybSMDheight/2,
+                                -fgkHybridLength/2+fgkHybSMDposZ[i]);
+    hybrid->AddNode(vHybSMD, i+1, vHybSMDtr);
+  };
+
+
+  if (iLRSide == 0) {
+  };
+
+  if(GetDebug(1)) hybrid->CheckOverlaps(0.01);
+  hybrid->SetVisibility(kFALSE);
+  return hybrid;
 };
 
 
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
-    // Return a box volume containing a segment of a ladder.
-
-    //***
-    Double_t tDY = -0.5; //space left on top of the ladder
-    Double_t segmentLength = fSegmentLength;
-
-    Double_t coolPipeSuppH = 0;
-    Double_t sensorCenterZPos = 0; // z in segment local coord syst.
-    if (iLay==3) {
-      coolPipeSuppH = fLay3CoolPipeSuppH;
-      sensorCenterZPos = fLay3sensorZPos[iSeg]-
-                        (fSegmentLength*fLay3Ndet/2. - 
-                         fSegmentLength/2-(iSeg)*fSegmentLength);
-    } else {
-      coolPipeSuppH = fLay4CoolPipeSuppH;
-      sensorCenterZPos = fLay4sensorZPos[iSeg]-
-                        (fSegmentLength*fLay4Ndet/2. -
-                         fSegmentLength/2-(iSeg)*fSegmentLength);
-    };
-    if(GetDebug(1)){
-      cout << "Segment ("<< iLay <<',' << iSeg 
-          << ") : sensor z shift in local segment coord.=" 
-          << sensorCenterZPos << endl;
-    };
-    //***
-
-    TGeoBBox *segBox = new TGeoBBox("ITSsddSegBox",
-                                    fLadderWidth/2+fPinSuppWidth+0.5,  // +0.5 is for include volume of hybrids !
-                                    fLadderHeight/2+TMath::Abs(tDY),
-                                    segmentLength/2);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualSeg = new TGeoVolume("ITSsddSegment",
-                                           segBox, airSDD);
-
-    //**********************************
-    // Carbon fiber structure :
-    AddLadderCFstruct(tDY, virtualSeg);
-
-    //**********************************
-    // Pine support of the sensors :
-    TGeoRotation *rotPS1 = new TGeoRotation("",0,-90,90);
-    TGeoRotation *rotPS2 = new TGeoRotation("",0,-90,-90);
-    TGeoCombiTrans *transPS1 = new TGeoCombiTrans( fPinDYOnSensor,
-                                  - fLadderHeight/2.-TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos + fPinDXminOnSensor,rotPS1);
-    TGeoCombiTrans *transPS2 = new TGeoCombiTrans( fPinDYOnSensor,
-                                  - fLadderHeight/2.-TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos + fPinDXminOnSensor + 
-                                  fPinPinDDXOnSensor, rotPS1);
-    TGeoCombiTrans *transPS3 = new TGeoCombiTrans( fPinDYOnSensor,
-                                  - fLadderHeight/2.-TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos-fPinDXminOnSensor,rotPS1);
-    TGeoCombiTrans *transPS4 = new TGeoCombiTrans( fPinDYOnSensor,
-                                  - fLadderHeight/2.-TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos-fPinDXminOnSensor -
-                                  fPinPinDDXOnSensor, rotPS1);
-    TGeoCombiTrans *transPS5 = new TGeoCombiTrans( -fPinDYOnSensor,
-                                  - fLadderHeight/2. - TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos+fPinDXminOnSensor,rotPS2);
-    TGeoCombiTrans *transPS6 = new TGeoCombiTrans( -fPinDYOnSensor,
-                                  - fLadderHeight/2. - TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos+fPinDXminOnSensor +
-                                   fPinPinDDXOnSensor, rotPS2);
-    TGeoCombiTrans *transPS7 = new TGeoCombiTrans( -fPinDYOnSensor,
-                                  - fLadderHeight/2.-TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos-fPinDXminOnSensor,rotPS2);
-    TGeoCombiTrans *transPS8 = new TGeoCombiTrans( -fPinDYOnSensor,
-                                  - fLadderHeight/2.-TMath::Abs(tDY)
-                                  + fPinSuppHeight/2.,
-                                  sensorCenterZPos - fPinDXminOnSensor
-                                  - fPinPinDDXOnSensor, rotPS2);
-    TGeoVolume *pinSupport = CreatePinSupport();
-    virtualSeg->AddNode(pinSupport, 1, transPS1);
-    virtualSeg->AddNode(pinSupport, 2, transPS2);
-    virtualSeg->AddNode(pinSupport, 3, transPS3);
-    virtualSeg->AddNode(pinSupport, 4, transPS4);
-    virtualSeg->AddNode(pinSupport, 5, transPS5);
-    virtualSeg->AddNode(pinSupport, 6, transPS6);
-    virtualSeg->AddNode(pinSupport, 7, transPS7);
-    virtualSeg->AddNode(pinSupport, 8, transPS8);
-
-    //**********************************
-    // Cooling pipe supports :
-    Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
-    Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
-    Double_t triangleCPaxeDist = fCoolPipeSuppAxeDist-fCoolPipeSuppWidthExt-
-                                 fCoolPipeSuppWidthIn+fLadderBeamRadius;
-
-    Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
-                             (triangleHeight+triangleCPaxeDist/
-                             TMath::Sin(halfTheta)-coolPipeSuppH);
-
-    TGeoRotation *rotCPS2 = new TGeoRotation("",-halfTheta*TMath::RadToDeg(),
-                                            -90, 90);
-    TGeoRotation *rotCPS1 = new TGeoRotation("",halfTheta*TMath::RadToDeg(),
-                                            -90, -90);
-    TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
-                                   -fLadderHeight/2.-TMath::Abs(tDY)
-                                   +coolPipeSuppH+fLadderBeamRadius,
-                                   -segmentLength/2., rotCPS1);
-    TGeoCombiTrans *transCPS2 = new TGeoCombiTrans(-coolPipeSuppL,
-                                   -fLadderHeight/2.-TMath::Abs(tDY)
-                                   +coolPipeSuppH+fLadderBeamRadius,
-                                   segmentLength/2., rotCPS2);
-    TGeoCombiTrans *transCPS3 = new TGeoCombiTrans(coolPipeSuppL,
-                                   -fLadderHeight/2.-TMath::Abs(tDY)
-                                   +coolPipeSuppH+fLadderBeamRadius,
-                                   segmentLength/2., rotCPS1);
-    TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
-                                   -fLadderHeight/2.-TMath::Abs(tDY)
-                                   +coolPipeSuppH+fLadderBeamRadius,
-                                   -segmentLength/2., rotCPS2);
-
-    TGeoVolume *coolPipeSuppLeft = CreateCoolPipeSupportL();
-    TGeoVolume *coolPipeSuppRight = CreateCoolPipeSupportR();
-    virtualSeg->AddNode(coolPipeSuppLeft,  1, transCPS1);
-    virtualSeg->AddNode(coolPipeSuppLeft,  2, transCPS2);
-    virtualSeg->AddNode(coolPipeSuppRight, 1, transCPS3);
-    virtualSeg->AddNode(coolPipeSuppRight, 2, transCPS4);
-
-    //**********************************
-    // Cooling pipes :
-    TGeoTube *coolingPipeShape = new TGeoTube( fCoolPipeInnerDiam/2,
-                                              fCoolPipeOuterDiam/2,
-                                              segmentLength/2);
-    TGeoTube *coolerShape = new TGeoTube( 0, fCoolPipeInnerDiam/2,
-                                         segmentLength/2);
-
-    //medium = phynox ?                              To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    //medium = water ?                               To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    TGeoMedium *phynoxSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
-    TGeoMedium *coolerMediumSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
-    TGeoVolume *coolingPipe = new TGeoVolume("ITSsddCoolingPipe",
-                                            coolingPipeShape, phynoxSDD );
-    coolingPipe->SetLineColor(fColorPhynox);
-    TGeoVolume *cooler = new  TGeoVolume("ITSsddCoolingLiquid",coolerShape,
-                                        coolerMediumSDD );
-
-    TGeoTranslation *pipeTr1 = new TGeoTranslation(coolPipeSuppL,
-                                 -fLadderHeight/2.-TMath::Abs(tDY)+
-                                  fLadderBeamRadius+coolPipeSuppH, 0);
-    TGeoTranslation *pipeTr2 = new TGeoTranslation(-coolPipeSuppL,
-                                 -fLadderHeight/2.-TMath::Abs(tDY)+
-                                  fLadderBeamRadius+coolPipeSuppH, 0);
-
-    virtualSeg->AddNode(coolingPipe, 1, pipeTr1);
-    virtualSeg->AddNode(coolingPipe, 2, pipeTr2);
-    if (fCoolingOn) {
-      virtualSeg->AddNode(cooler, 1, pipeTr1);
-      virtualSeg->AddNode(cooler, 2, pipeTr2);
-    };
+  //
+  // Return a box volume containing a segment of a ladder.
+  //
+
+  TGeoMedium *airSDD          = GetMedium("ITSair");
+  TGeoMedium *phynoxSDD       = GetMedium("ITSal"); // phynoxSDD To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+  TGeoMedium *coolerMediumSDD = GetMedium("WATER");
+
+  Double_t tDY = fgkLadderSegBoxDH/2; //space left on top of the ladder 
+  Double_t segmentLength = fgkSegmentLength;
+  Double_t spaceBetweenCables = 500*fgkmicron;
+  
+  //*****************************************
+  // Set parameters according to (iLay,iSeg):
+  //*****************************************
+  Int_t nDetectors          = fgkLay3Ndet;
+  Double_t coolPipeSuppH    = fgkLay3CoolPipeSuppH;
+  Double_t sensorCenterZPos = fLay3sensorZPos[iSeg]-
+                              (fgkSegmentLength*fgkLay3Ndet/2. - 
+                              fgkSegmentLength/2-(iSeg)*fgkSegmentLength);
+ // sensorCenterZPos = z in segment local coord syst.
+
+  AliITSv11GeomCableFlat *digitCableA = fDigitCableLay3A;
+  AliITSv11GeomCableFlat *digitCableB = fDigitCableLay3B;
+
+  if (iLay==3) {
+  } else if (iLay==4) {
+    nDetectors = fgkLay4Ndet;
+    coolPipeSuppH = fgkLay4CoolPipeSuppH;
+    sensorCenterZPos = fLay4sensorZPos[iSeg]-
+                       (fgkSegmentLength*fgkLay4Ndet/2. -
+                       fgkSegmentLength/2-(iSeg)*fgkSegmentLength);
+    digitCableA = fDigitCableLay4A;
+    digitCableB = fDigitCableLay4B;    
+  } else
+    printf("AliITSv11GeometrySDD::CreateLadderSegment Wrong layer index !");
+
+  Double_t cableSideSign = -1;
+  if (iSeg<nDetectors/2) cableSideSign = 1;
+  Double_t spaceForCables = spaceBetweenCables*
+           (nDetectors-TMath::Abs(nDetectors-2*iSeg-1)-1)/2
+           +0.1*fgkmicron;
+  // gives [0-1-2-2-1-0]*spaceBetweenCables
+  // or  [0-1-2-3-3-2-1-0]*spaceBetweenCables
+  Int_t iUpdateCableMin;
+  Int_t iUpdateCableMax;
+  if (cableSideSign==-1) {
+    iUpdateCableMin = nDetectors/2;
+    iUpdateCableMax = iSeg-1;
+  } else {
+    iUpdateCableMin = iSeg+1;
+    iUpdateCableMax = nDetectors/2-1;
+  };
+
+  if(GetDebug(1)){
+    cout << "Segment ("<< iLay <<',' << iSeg 
+        << ") : sensor z shift in local segment coord.=" 
+        << sensorCenterZPos << endl;
+  };
+
+  //****************************
+  // The segment volume
+  //****************************
+  TGeoBBox *segBox = new TGeoBBox("ITSsddSegBox",
+                                 fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW,
+                                 fgkLadderHeight/2+fgkLadderSegBoxDH/2,
+                                 segmentLength/2);
+  
+  TGeoVolume *virtualSeg = new TGeoVolume("ITSsddSegment",
+                                         segBox, airSDD);
+
+  //******************************
+  // Carbon fiber structure :
+  //******************************
+
+   virtualSeg->AddNode(fLaddSegCommonVol[0], 1, fLaddSegCommonTr[0]);
+  Int_t volumeIndex = 1;
+  for (Int_t i = 1; i<fgkNladdSegCommonVol;i++ ) {
+    if (fLaddSegCommonVol[i]==fLaddSegCommonVol[i-1])
+      volumeIndex++;
+    else
+      volumeIndex = 1;
+    virtualSeg->AddNode(fLaddSegCommonVol[i], volumeIndex,
+                fLaddSegCommonTr[i]);
+  };
+
+  //**********************************
+  // Pine support of the sensors :
+  //**********************************
+  TGeoRotation rotPS1("",0,-90,90);
+  TGeoRotation rotPS2("",0,-90,-90);
+  TGeoCombiTrans *transPS1 = new TGeoCombiTrans( fgkPinDYOnSensor,
+                               - fgkLadderHeight/2.-tDY
+                               + fgkPinSuppHeight/2.,
+                               sensorCenterZPos+fgkPinDXminOnSensor,&rotPS1);
+  TGeoCombiTrans *transPS2 = new TGeoCombiTrans(*transPS1);
+  AddTranslationToCombiTrans(transPS2, 0, 0, fgkPinPinDDXOnSensor);
+  TGeoCombiTrans *transPS3 = new TGeoCombiTrans(*transPS1);
+  AddTranslationToCombiTrans(transPS3, 0, 0, -2*fgkPinDXminOnSensor);
+  TGeoCombiTrans *transPS4 = new TGeoCombiTrans(*transPS3);
+  AddTranslationToCombiTrans(transPS4, 0, 0, -fgkPinPinDDXOnSensor);
+
+  TGeoCombiTrans *transPS5 = new TGeoCombiTrans( -fgkPinDYOnSensor,
+                                - fgkLadderHeight/2. - tDY
+                                + fgkPinSuppHeight/2.,
+                                sensorCenterZPos+fgkPinDXminOnSensor,&rotPS2);
+  TGeoCombiTrans *transPS6 = new TGeoCombiTrans(*transPS5);
+  AddTranslationToCombiTrans(transPS6, 0, 0, fgkPinPinDDXOnSensor);
+  TGeoCombiTrans *transPS7 = new TGeoCombiTrans(*transPS5);
+  AddTranslationToCombiTrans(transPS7, 0, 0, -2*fgkPinDXminOnSensor);
+  TGeoCombiTrans *transPS8 = new TGeoCombiTrans(*transPS7);
+  AddTranslationToCombiTrans(transPS8, 0, 0, -fgkPinPinDDXOnSensor);
+  
+  virtualSeg->AddNode(fPinSupport, 1, transPS1);
+  virtualSeg->AddNode(fPinSupport, 2, transPS2);
+  virtualSeg->AddNode(fPinSupport, 3, transPS3);
+  virtualSeg->AddNode(fPinSupport, 4, transPS4);
+  virtualSeg->AddNode(fPinSupport, 5, transPS5);
+  virtualSeg->AddNode(fPinSupport, 6, transPS6);
+  virtualSeg->AddNode(fPinSupport, 7, transPS7);
+  virtualSeg->AddNode(fPinSupport, 8, transPS8);
+  
+  //******************************
+  // Cooling pipe supports :
+  //******************************
+  Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
+  Double_t halfTheta = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
+  Double_t triangleCPaxeDist = fgkCoolPipeSuppAxeDist-fgkCoolPipeSuppWidthExt-
+                               fgkCoolPipeSuppWidthIn+fgkLadderBeamRadius;
+  
+  Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
+                           (triangleHeight+triangleCPaxeDist/
+                           TMath::Sin(halfTheta)-coolPipeSuppH);
+  if (fAddCoolingSyst) {
+  TGeoRotation rotCPS2("", -halfTheta*TMath::RadToDeg(), -90,  90);
+  TGeoRotation rotCPS1("",  halfTheta*TMath::RadToDeg(), -90, -90);
+  TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
+                                 -fgkLadderHeight/2.-TMath::Abs(tDY)
+                                 +coolPipeSuppH+fgkLadderBeamRadius,
+                                 -segmentLength/2., &rotCPS1);
+  TGeoCombiTrans *transCPS3 = new TGeoCombiTrans(*transCPS1);
+  AddTranslationToCombiTrans(transCPS3, 0, 0, segmentLength);
+  
+  TGeoCombiTrans *transCPS2 = new TGeoCombiTrans(-coolPipeSuppL,
+                                 -fgkLadderHeight/2.-tDY
+                                 +coolPipeSuppH+fgkLadderBeamRadius,
+                                 segmentLength/2., &rotCPS2);
+  TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(*transCPS2);
+  AddTranslationToCombiTrans(transCPS4, 0, 0, -segmentLength);
+  
+  virtualSeg->AddNode(fCoolPipeSupportL, 1, transCPS1);
+  virtualSeg->AddNode(fCoolPipeSupportL, 2, transCPS2);
+  virtualSeg->AddNode(fCoolPipeSupportR, 1, transCPS3);
+  virtualSeg->AddNode(fCoolPipeSupportR, 2, transCPS4);
+  };
+  
+  //************************
+  // Cooling pipes :
+  //************************
+  TGeoTranslation *pipeTr1 = new TGeoTranslation(coolPipeSuppL,
+                                -fgkLadderHeight/2. - tDY +
+                                fgkLadderBeamRadius+coolPipeSuppH, 0);
+  TGeoTranslation *pipeTr2 = new TGeoTranslation(-coolPipeSuppL,
+                                -fgkLadderHeight/2.- tDY +
+                                 fgkLadderBeamRadius+coolPipeSuppH, 0);
+
+  if (fAddCoolingSyst) {
+  TGeoTube *coolingPipeShape = new TGeoTube( fgkCoolPipeInnerDiam/2,
+                                            fgkCoolPipeOuterDiam/2,
+                                            segmentLength/2);
+  TGeoTube *coolerShape = new TGeoTube( 0, fgkCoolPipeInnerDiam/2,
+                                       segmentLength/2);
+  
+  TGeoVolume *coolingPipe = new TGeoVolume("ITSsddCoolingPipe",
+                                          coolingPipeShape, phynoxSDD );
+  coolingPipe->SetLineColor(fColorPhynox);
+  TGeoVolume *cooler = new  TGeoVolume("ITSsddCoolingLiquid",coolerShape,
+                                      coolerMediumSDD );
+
+
+  virtualSeg->AddNode(coolingPipe, 1, pipeTr1);
+  virtualSeg->AddNode(coolingPipe, 2, pipeTr2);
+  if (fCoolingOn) {
+    virtualSeg->AddNode(cooler, 1, pipeTr1);
+    virtualSeg->AddNode(cooler, 2, pipeTr2);
+  };
+  };
 
-    //**********************************
-    // Bases of hybrid thermal bridges
-    Double_t hybridAngle = 46;                                           // tmp !!!
-    Double_t shiftHyb = 0.9-0.2; // shift in comparison with center of thermal Br. base // tmp !!! not clear on 0752/14-A
-    // sur 0752/14-A c'est environ 0.9
-    // en fait comme la hauteur des cooling pipes depends de la couche, ces deux variables varient probablement
-    // suivant la "layer" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-    TGeoVolume *baseThermalBridge = CreateBaseThermalBridge();
-    TGeoRotation rotHybrid1("",0, 0,  -90 - hybridAngle);
-    TGeoRotation rotHybrid2("",0 ,180, 90 - hybridAngle);
-    TGeoCombiTrans *baseTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid1);
-    TGeoCombiTrans *baseTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid2);
-    virtualSeg->AddNode(baseThermalBridge, 1, baseTr1);
-    virtualSeg->AddNode(baseThermalBridge, 2, baseTr2);
-
-    //**********************************
-    // the 2 hybrids :
-    TGeoVolume *Hybrid = CreateHybrid(iSeg);
-
-    Double_t hybDy = ((TGeoBBox*)Hybrid->GetShape())->GetDY();
-    Double_t axeToHybridCenterDist = fBTBaxisAtoBase+hybDy;
-
-    Double_t hybrVolDX = ( axeToHybridCenterDist*CosD(hybridAngle) 
-                          - shiftHyb*SinD(hybridAngle) );
-    Double_t hybrVolDY = ( axeToHybridCenterDist*SinD(hybridAngle)
-                          + shiftHyb*CosD(hybridAngle) );
-
-    TGeoCombiTrans *hybTr1 = new TGeoCombiTrans(*baseTr1);
-    AddTranslationToCombiTrans( hybTr1, -hybrVolDX, hybrVolDY, 0);
-    TGeoCombiTrans *hybTr2 = new TGeoCombiTrans(*baseTr2);
-    AddTranslationToCombiTrans( hybTr2, hybrVolDX, hybrVolDY, 0);
-
-    virtualSeg->AddNode(Hybrid, 1, hybTr1);
-    virtualSeg->AddNode(Hybrid, 2, hybTr2);
-
-
-    //**********************************
-    virtualSeg->SetVisibility(kFALSE);
-    return virtualSeg;
+  //**********************************
+  // Bases of hybrid thermal bridges
+  //**********************************
+  Double_t shiftHyb = 1.05; // shift between thermal Bridge base and thermal bridge
+                           // approx !!! not clear on 0752/14-A
+  if (fAddCoolingSyst) {
+  TGeoRotation rotHybrid1("", 0,   0, -90 - fgkHybridAngle);
+  TGeoRotation rotHybrid2("", 0 ,180,  90 - fgkHybridAngle);
+  TGeoCombiTrans *baseTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid1);
+  TGeoCombiTrans *baseTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid2);
+  
+  virtualSeg->AddNode(fBaseThermalBridge, 1, baseTr1);
+  virtualSeg->AddNode(fBaseThermalBridge, 2, baseTr2);
+  };
+
+  //*************************
+  // the 2 hybrids :
+  //*************************
+  Double_t hybDy = ((TGeoBBox*)fHybrid->GetShape())->GetDY();
+  Double_t distAxeToHybridCenter = fgkBTBaxisAtoBase+hybDy;
+  
+  Double_t hybrVolX = ( distAxeToHybridCenter*CosD(fgkHybridAngle) 
+                        - shiftHyb*SinD(fgkHybridAngle) );
+  Double_t hybrVolY = ( distAxeToHybridCenter*SinD(fgkHybridAngle)
+                        + shiftHyb*CosD(fgkHybridAngle) );
+  if (fAddHybrids) {
+    TGeoRotation rotHybrid3("", 0,   0,  90. - fgkHybridAngle);
+    TGeoRotation rotHybrid4("", 0 ,180, -90. - fgkHybridAngle);
+    TGeoCombiTrans *hybTr1 = new TGeoCombiTrans(*pipeTr2, rotHybrid3);
+    TGeoCombiTrans *hybTr2 = new TGeoCombiTrans(*pipeTr1, rotHybrid4);
+    AddTranslationToCombiTrans( hybTr1, -hybrVolX, hybrVolY, 0);
+    AddTranslationToCombiTrans( hybTr2,  hybrVolX, hybrVolY, 0);
+    
+    virtualSeg->AddNode(fHybrid, 1, hybTr1);
+    virtualSeg->AddNode(fHybrid, 2, hybTr2);
+  };
+
+  //***********
+  // cables
+  //***********
+  if (fAddCables) {
+  // Starting from this segment
+  Double_t hybDz = ((TGeoBBox*)fHybrid->GetShape())->GetDZ();
+  Double_t hybDx = ((TGeoBBox*)fHybrid->GetShape())->GetDX();
+  Double_t posDigitCableAlongHyb = shiftHyb+ hybDx 
+                                   - digitCableA->GetWidth()/2;
+  Double_t distAxeToDigitCableCenter = distAxeToHybridCenter+hybDy
+                                       - digitCableA->GetThickness()/2;
+
+  Double_t digitCableX = ( coolPipeSuppL
+                          + distAxeToDigitCableCenter*CosD(fgkHybridAngle)
+                          - posDigitCableAlongHyb*SinD(fgkHybridAngle) );
+  Double_t digitCableY = ( - fgkLadderHeight/2.-TMath::Abs(tDY)
+                          + fgkLadderBeamRadius+coolPipeSuppH
+                          + distAxeToDigitCableCenter*SinD(fgkHybridAngle)
+                          + posDigitCableAlongHyb*CosD(fgkHybridAngle) );
+
+
+  Double_t digitCableCenterA0[3]={ -cableSideSign*digitCableX,
+                                  digitCableY, cableSideSign*hybDz };
+  Double_t digitCableCenterA1[3] = { 
+           -cableSideSign*(digitCableX+spaceForCables*CosD(fgkHybridAngle)),
+          digitCableY+spaceForCables*SinD(fgkHybridAngle),
+          cableSideSign*segmentLength/2 };
+
+  Double_t digitCableCenterB0[3]={ cableSideSign*digitCableX,
+                                  digitCableY,cableSideSign*hybDz};
+  Double_t digitCableCenterB1[3]={ 
+           cableSideSign*(digitCableX+spaceForCables*CosD(fgkHybridAngle)),
+          digitCableY+spaceForCables*SinD(fgkHybridAngle),
+          cableSideSign*segmentLength/2 };
+
+  Double_t vZ[3] = {0,0,1};
+  digitCableA[iSeg].AddCheckPoint( virtualSeg, 0, digitCableCenterA0, vZ);
+  digitCableA[iSeg].AddCheckPoint( virtualSeg, 1, digitCableCenterA1, vZ);
+  digitCableB[iSeg].AddCheckPoint( virtualSeg, 0, digitCableCenterB0, vZ);
+  digitCableB[iSeg].AddCheckPoint( virtualSeg, 1, digitCableCenterB1, vZ);
+
+  // Updating the other cables
+  for (Int_t iCable=iUpdateCableMin; iCable<=iUpdateCableMax; iCable++) {
+
+    Int_t iPoint = TMath::Abs(iCable-iSeg)+1;
+    Double_t coord[3];
+    digitCableA[iCable].GetPoint( 1, coord);
+    digitCableA[iCable].AddCheckPoint( virtualSeg, iPoint, coord, vZ);
+    digitCableB[iCable].GetPoint( 1, coord);
+    digitCableB[iCable].AddCheckPoint( virtualSeg, iPoint, coord, vZ);
+  };
+  };
+
+  //**********************************
+  if(GetDebug(1)) virtualSeg->CheckOverlaps(0.01);
+  //virtualSeg->SetVisibility(kFALSE);
+  return virtualSeg;
 };
 
 
@@ -1021,13 +1760,13 @@ TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
 // Create a pine support
 // axis of rotation is the cone axis, center in its middle
 //
-    TGeoCone *cone = new TGeoCone("ITSsddPinSuppCone",fPinSuppHeight/2.,
-                                  0,fPinSuppRmax,0,fPinSuppRmax-
-                                  fPinSuppHeight*TanD(fPinSuppConeAngle) );
-    TGeoBBox *tong = new TGeoBBox("ITSsddPinSuppTong",fPinSuppRmax,
-                                  fPinSuppLength/2.,fPinSuppThickness/2.);
-    TGeoTube *hole = new TGeoTube("ITSsddPinSuppHole",0,fPinR,
-                                  fPinSuppHeight/2.);
+    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.);
     if(GetDebug(3)){// Remove compiler warning.
         cone->InspectShape();
         tong->InspectShape();
@@ -1035,84 +1774,85 @@ TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport() {
     };
 
     TGeoTranslation *tongTrans = new TGeoTranslation("ITSsddPinSuppTongTr",0,
-                   fPinSuppLength/2.,-fPinSuppHeight/2.+fPinSuppThickness/2.);
+                   fgkPinSuppLength/2.,-fgkPinSuppHeight/2.+fgkPinSuppThickness/2.);
     tongTrans->RegisterYourself();
     TGeoCompositeShape *pinSupportShape = new TGeoCompositeShape(
-               "ITSssdPinSupportShape","(ITSsddPinSuppCone+"
+               "ITSsddPinSupportShape","(ITSsddPinSuppCone+"
                "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
 
-    //medium = ryton ?                           To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
-    TGeoVolume *pinSupport = new TGeoVolume("ITSssdPinSupport",pinSupportShape,
+    
+    TGeoMedium *rytonSDD = GetMedium("ITSsddCarbonM55J"); //medium = ryton ?  To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    TGeoVolume *pinSupport = new TGeoVolume("ITSsddPinSupport",pinSupportShape,
                                             rytonSDD);
     pinSupport->SetLineColor(fColorRyton);
     return pinSupport;
     // include the pin itself                           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 };
 
+
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportL() {
 //
 // Create half of the cooling pipe support (ALR-0752/3)
 //
 
-  Double_t diffX = fCoolPipeSuppHeight*TanD(fCoolPipeSuppAngle);
+  Double_t diffX = fgkCoolPipeSuppHeight*TanD(fgkCoolPipeSuppAngle);
   
-  TGeoArb8 *side1 = new TGeoArb8(fCoolPipeSuppHeight/2.);
-  side1->SetVertex( 0, 0, -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 1, fCoolPipeSuppMaxLength/2.-diffX,
-                      -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 2, fCoolPipeSuppMaxLength/2.-diffX,
-                      fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 3, 0,  fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 4, 0, -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 5, fCoolPipeSuppMaxLength/2.,
-                      -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 6, fCoolPipeSuppMaxLength/2.,
-                      fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 7, 0,  fCoolPipeSuppWidthExt/2.);
+  TGeoArb8 *side1 = new TGeoArb8(fgkCoolPipeSuppHeight/2.);
+  side1->SetVertex( 0, 0, -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 1, fgkCoolPipeSuppMaxLength/2.-diffX,
+                      -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 2, fgkCoolPipeSuppMaxLength/2.-diffX,
+                      fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 3, 0,  fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 4, 0, -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 5, fgkCoolPipeSuppMaxLength/2.,
+                      -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 6, fgkCoolPipeSuppMaxLength/2.,
+                      fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 7, 0,  fgkCoolPipeSuppWidthExt/2.);
   side1->SetName("ITSsddCPSside1");
 
   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1",0,
-                                - fCoolPipeSuppAxeDist
-                                + fCoolPipeSuppWidthExt/2., 0);
+                                - fgkCoolPipeSuppAxeDist
+                                + fgkCoolPipeSuppWidthExt/2., 0);
   side1Tr->RegisterYourself();
   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2",0,
-                                - fCoolPipeSuppAxeDist
-                                 + fCoolPipeSuppWidthExt*3/2.
-                                + fCoolPipeSuppWidthIn,0);
+                                - fgkCoolPipeSuppAxeDist
+                                 + fgkCoolPipeSuppWidthExt*3/2.
+                                + fgkCoolPipeSuppWidthIn,0);
   side2Tr->RegisterYourself();
   
   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddle",
-                        (fCoolPipeSuppMaxLength/2.-fCoolPipeSuppSlitL)/2.,
-                        fCoolPipeSuppWidthIn/2., fCoolPipeSuppHeight/2.);
+                        (fgkCoolPipeSuppMaxLength/2.-fgkCoolPipeSuppSlitL)/2.,
+                        fgkCoolPipeSuppWidthIn/2., fgkCoolPipeSuppHeight/2.);
   TGeoTranslation *middleTr = 
     new TGeoTranslation("ITSsddCPStr3",
-                       (fCoolPipeSuppMaxLength/2.-fCoolPipeSuppSlitL)/2.,
-                       -fCoolPipeSuppAxeDist+fCoolPipeSuppWidthExt
-                       +fCoolPipeSuppWidthIn/2., 0);
+                       (fgkCoolPipeSuppMaxLength/2.-fgkCoolPipeSuppSlitL)/2.,
+                       -fgkCoolPipeSuppAxeDist+fgkCoolPipeSuppWidthExt
+                       +fgkCoolPipeSuppWidthIn/2., 0);
   middleTr->RegisterYourself();
   
   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBox",
-                                 fCoolPipeSuppTongW/4.,
-                                 (fCoolPipeSuppFulWidth
-                                  - 2*fCoolPipeSuppWidthExt
-                                  - fCoolPipeSuppWidthIn)/2,
-                                 fCoolPipeSuppHeight/2.);
+                                 fgkCoolPipeSuppTongW/4.,
+                                 (fgkCoolPipeSuppFulWidth
+                                  - 2*fgkCoolPipeSuppWidthExt
+                                  - fgkCoolPipeSuppWidthIn)/2,
+                                 fgkCoolPipeSuppHeight/2.);
   
   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTr",
-                                 fCoolPipeSuppTongW/4.,
-                                 - fCoolPipeSuppAxeDist
-                                 + fCoolPipeSuppFulWidth
+                                 fgkCoolPipeSuppTongW/4.,
+                                 - fgkCoolPipeSuppAxeDist
+                                 + fgkCoolPipeSuppFulWidth
                                  - axeBox->GetDY(), 0);
   axeBoxTr->RegisterYourself();
 
-  TGeoTube *axe = new TGeoTube("ITSsddCPSaxe",0,fCoolPipeSuppHoleDiam/2.,
-                              fCoolPipeSuppTongW/4.);
-  TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRot",90,90,0);
+  TGeoTube *axe = new TGeoTube("ITSsddCPSaxe",0,fgkCoolPipeSuppHoleDiam/2.,
+                              fgkCoolPipeSuppTongW/4.);
+  TGeoRotation axeRot("ITSsddCPSaxeRot",90,90,0);
 
   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTr",
-                                fCoolPipeSuppTongW/4.,0,0,axeRot);
+                                fgkCoolPipeSuppTongW/4.,0,0,&axeRot);
   axeTrans->RegisterYourself();
 
   if(GetDebug(3)){
@@ -1120,8 +1860,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportL() {
     axe->InspectShape();
   };
 
-  //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
+  TGeoMedium *rytonSDD = GetMedium("ITSsddCarbonM55J"); //medium = ryton ?  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   
   TGeoCompositeShape *coolPipeSuppShape = new TGeoCompositeShape(
                                        "ITSsddCoolPipeSuppShapeL",
@@ -1143,66 +1882,65 @@ TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportR() {
 //Create half of the cooling pipe support (ALR-0752/3)
 //
 
-  Double_t diffX = fCoolPipeSuppHeight*TanD(fCoolPipeSuppAngle);
+  Double_t diffX = fgkCoolPipeSuppHeight*TanD(fgkCoolPipeSuppAngle);
   
-  TGeoArb8 *side1 = new TGeoArb8(fCoolPipeSuppHeight/2.);
-  side1->SetVertex( 0, 0, -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 1, -(fCoolPipeSuppMaxLength/2.-diffX),
-                      -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 2, -(fCoolPipeSuppMaxLength/2.-diffX),
-                      fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 3, 0,  fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 4, 0, -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 5, -fCoolPipeSuppMaxLength/2.,
-                      -fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 6, -fCoolPipeSuppMaxLength/2.,
-                      fCoolPipeSuppWidthExt/2.);
-  side1->SetVertex( 7, 0,  fCoolPipeSuppWidthExt/2.);
+  TGeoArb8 *side1 = new TGeoArb8(fgkCoolPipeSuppHeight/2.);
+  side1->SetVertex( 0, 0, -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 1, -(fgkCoolPipeSuppMaxLength/2.-diffX),
+                      -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 2, -(fgkCoolPipeSuppMaxLength/2.-diffX),
+                      fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 3, 0,  fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 4, 0, -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 5, -fgkCoolPipeSuppMaxLength/2.,
+                      -fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 6, -fgkCoolPipeSuppMaxLength/2.,
+                      fgkCoolPipeSuppWidthExt/2.);
+  side1->SetVertex( 7, 0,  fgkCoolPipeSuppWidthExt/2.);
   side1->SetName("ITSsddCPSside1R");
 
   TGeoTranslation *side1Tr = new TGeoTranslation("ITSsddCPStr1R",0,
-                                - fCoolPipeSuppAxeDist
-                                + fCoolPipeSuppWidthExt/2., 0);
+                                - fgkCoolPipeSuppAxeDist
+                                + fgkCoolPipeSuppWidthExt/2., 0);
   side1Tr->RegisterYourself();
   TGeoTranslation *side2Tr = new TGeoTranslation("ITSsddCPStr2R",0,
-                                - fCoolPipeSuppAxeDist
-                                + fCoolPipeSuppWidthExt*3/2.
-                                + fCoolPipeSuppWidthIn, 0);
+                                - fgkCoolPipeSuppAxeDist
+                                + fgkCoolPipeSuppWidthExt*3/2.
+                                + fgkCoolPipeSuppWidthIn, 0);
   side2Tr->RegisterYourself();
   
   TGeoBBox *middle = new TGeoBBox("ITSsddCPSmiddleR",
-                                 (fCoolPipeSuppMaxLength/2.
-                                  - fCoolPipeSuppSlitL)/2.,
-                                 fCoolPipeSuppWidthIn/2., 
-                                 fCoolPipeSuppHeight/2.);
+                                 (fgkCoolPipeSuppMaxLength/2.
+                                  - fgkCoolPipeSuppSlitL)/2.,
+                                 fgkCoolPipeSuppWidthIn/2., 
+                                 fgkCoolPipeSuppHeight/2.);
   TGeoTranslation *middleTr = 
     new TGeoTranslation("ITSsddCPStr3R",
-                       -( fCoolPipeSuppMaxLength/2.
-                          -fCoolPipeSuppSlitL)/2.,
-                       -fCoolPipeSuppAxeDist + fCoolPipeSuppWidthExt
-                       + fCoolPipeSuppWidthIn/2.,0);
+                       -( fgkCoolPipeSuppMaxLength/2.
+                          -fgkCoolPipeSuppSlitL)/2.,
+                       -fgkCoolPipeSuppAxeDist + fgkCoolPipeSuppWidthExt
+                       + fgkCoolPipeSuppWidthIn/2.,0);
   middleTr->RegisterYourself();
   
   TGeoBBox *axeBox = new TGeoBBox("ITSsddCPSaxeBoxR",
-                                 fCoolPipeSuppTongW/4.,
-                                 (fCoolPipeSuppFulWidth
-                                  - 2*fCoolPipeSuppWidthExt
-                                  - fCoolPipeSuppWidthIn)/2,
-                                 fCoolPipeSuppHeight/2.);
+                                 fgkCoolPipeSuppTongW/4.,
+                                 (fgkCoolPipeSuppFulWidth
+                                  - 2*fgkCoolPipeSuppWidthExt
+                                  - fgkCoolPipeSuppWidthIn)/2,
+                                 fgkCoolPipeSuppHeight/2.);
   
   TGeoTranslation *axeBoxTr = new TGeoTranslation("ITSsddCPSAxBoxTrR",
-                                 - fCoolPipeSuppTongW/4.,
-                                 - fCoolPipeSuppAxeDist
-                                 + fCoolPipeSuppFulWidth
+                                 - fgkCoolPipeSuppTongW/4.,
+                                 - fgkCoolPipeSuppAxeDist
+                                 + fgkCoolPipeSuppFulWidth
                                  - axeBox->GetDY(),0);
   axeBoxTr->RegisterYourself();
 
-  TGeoTube *axe = new TGeoTube("ITSsddCPSaxeR",0,fCoolPipeSuppHoleDiam/2.,
-                              fCoolPipeSuppTongW/4.);
-  TGeoRotation *axeRot = new TGeoRotation("ITSsddCPSaxeRotR",90,90,0);
-
+  TGeoTube *axe = new TGeoTube("ITSsddCPSaxeR",0,fgkCoolPipeSuppHoleDiam/2.,
+                              fgkCoolPipeSuppTongW/4.);
+  TGeoRotation axeRot("ITSsddCPSaxeRotR",90,90,0);
   TGeoCombiTrans *axeTrans = new TGeoCombiTrans("ITSsddCPSaxeTrR",
-                                -fCoolPipeSuppTongW/4.,0,0,axeRot);
+                                -fgkCoolPipeSuppTongW/4.,0,0,&axeRot);
   axeTrans->RegisterYourself();
 
   if(GetDebug(3)){
@@ -1217,9 +1955,8 @@ TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportR() {
                                      "+ITSsddCPSside1R:ITSsddCPStr2R"
                                      "+ITSsddCPSaxeBoxR:ITSsddCPSAxBoxTrR"
                                      "-ITSsddCPSaxeR:ITSsddCPSaxeTrR");
-
-  //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-  TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
+  
+  TGeoMedium *rytonSDD = GetMedium("ITSsddCarbonM55J"); //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   TGeoVolume *coolPipeSupp = new TGeoVolume( "ITSsddCoolPipeSupportR",
                                             coolPipeSuppShape, rytonSDD);
   coolPipeSupp->SetLineColor(fColorRyton);
@@ -1231,65 +1968,65 @@ TGeoVolume* AliITSv11GeometrySDD::CreateCoolPipeSupportR() {
 TGeoVolume* AliITSv11GeometrySDD::CreateBaseThermalBridge() {
 // ALR 0752/8
 
-  Double_t dy = fBTBaxisAtoBase - fRadiusBminBTB - fBTBthick;
+  Double_t dy = fgkBTBaxisAtoBase - fgkRadiusBminBTB - fgkBTBthick;
 
-  Double_t base1width = fBTBwidth - fBTBaxisAtoBottom - fRadiusBminBTB
-                        - (fRadiusAminBTB+fBTBthick);
+  Double_t base1width = fgkBTBwidth - fgkBTBaxisAtoBottom - fgkRadiusBminBTB
+                        - (fgkRadiusAminBTB+fgkBTBthick);
   TGeoBBox *base1 = new TGeoBBox( "ITSsddBTBbase1", base1width/2.,
-                                 fBTBthick/2., fBTBlength/2.);
+                                 fgkBTBthick/2., fgkBTBlength/2.);
   TGeoTranslation *base1Tr = new TGeoTranslation("ITSsddBTBtr1",
-                                fBTBaxisAtoBottom-fBTBwidth+base1width/2.,
-                                -(fBTBaxisAtoBase-fBTBthick/2.), 0);
+                                fgkBTBaxisAtoBottom-fgkBTBwidth+base1width/2.,
+                                -(fgkBTBaxisAtoBase-fgkBTBthick/2.), 0);
   base1Tr->RegisterYourself();
 
-  Double_t base2width = fBTBaxisAtoBottom - fRadiusAminBTB - fBTBthick
-                        - fRadiusBminBTB;
+  Double_t base2width = fgkBTBaxisAtoBottom - fgkRadiusAminBTB - fgkBTBthick
+                        - fgkRadiusBminBTB;
   TGeoBBox *base2 = new TGeoBBox( "ITSsddBTBbase2", base2width/2.,
-                                 fBTBthick/2., fBTBlength/2.);
+                                 fgkBTBthick/2., fgkBTBlength/2.);
   TGeoTranslation *base2Tr = new TGeoTranslation("ITSsddBTBtr2",
-                                fBTBaxisAtoBottom - base2width/2.,
-                                -(fBTBaxisAtoBase-fBTBthick/2.), 0);
+                                fgkBTBaxisAtoBottom - base2width/2.,
+                                -(fgkBTBaxisAtoBase-fgkBTBthick/2.), 0);
   base2Tr->RegisterYourself();
 
   TGeoBBox *side = new TGeoBBox( "ITSsddBTBside",
-                                fBTBthick/2., dy/2., fBTBlength/2.);
+                                fgkBTBthick/2., dy/2., fgkBTBlength/2.);
   TGeoTranslation *sideTr1 = new TGeoTranslation("ITSsddBTBsideTr1",
-                                -fRadiusAminBTB-fBTBthick/2., -dy/2., 0);
+                                -fgkRadiusAminBTB-fgkBTBthick/2., -dy/2., 0);
   TGeoTranslation *sideTr2 = new TGeoTranslation("ITSsddBTBsideTr2",
-                                fRadiusAminBTB+fBTBthick/2., -dy/2., 0);
+                                fgkRadiusAminBTB+fgkBTBthick/2., -dy/2., 0);
   sideTr1->RegisterYourself();
   sideTr2->RegisterYourself();
 
-  TGeoBBox *hole = new TGeoBBox( "ITSsddBTBhole", fBTBHolewidth/2.,
-                                fBTBthick/2., fBTBHoleLength/2.);
+  TGeoBBox *hole = new TGeoBBox( "ITSsddBTBhole", fgkBTBHolewidth/2.,
+                                fgkBTBthick/2., fgkBTBHoleLength/2.);
   TGeoTranslation *holeTr1 = new TGeoTranslation("ITSsddBTBholeTr1",
-                                - fBTBHoleRefX + fBTBHolewidth/2.,
-                                - (fBTBaxisAtoBase-fBTBthick/2.),
-                                fBTBHoleRefY+(fBTBHoleLength-fBTBlength)/2.);
+                                - fgkBTBHoleRefX + fgkBTBHolewidth/2.,
+                                - (fgkBTBaxisAtoBase-fgkBTBthick/2.),
+                                fgkBTBHoleRefY+(fgkBTBHoleLength-fgkBTBlength)/2.);
   TGeoTranslation *holeTr2 = new TGeoTranslation("ITSsddBTBholeTr2",
-                                - fBTBHoleRefX + fBTBHolewidth/2.,
-                                - (fBTBaxisAtoBase-fBTBthick/2.),
-                                - fBTBHoleRefY-(fBTBHoleLength-fBTBlength)/2.);
+                                - fgkBTBHoleRefX + fgkBTBHolewidth/2.,
+                                - (fgkBTBaxisAtoBase-fgkBTBthick/2.),
+                                - fgkBTBHoleRefY-(fgkBTBHoleLength-fgkBTBlength)/2.);
   holeTr1->RegisterYourself();
   holeTr2->RegisterYourself();
 
-  Double_t radiusAmaxBTB = fRadiusAminBTB + fBTBthick;
+  Double_t radiusAmaxBTB = fgkRadiusAminBTB + fgkBTBthick;
   TGeoTubeSeg *mainAxis = new TGeoTubeSeg( "ITSsddBTBmainAxis",
-                                          fRadiusAminBTB, radiusAmaxBTB,
-                                          fBTBlength/2., 0., 180.);
+                                          fgkRadiusAminBTB, radiusAmaxBTB,
+                                          fgkBTBlength/2., 0., 180.);
   TGeoTubeSeg *round1 = new TGeoTubeSeg( "ITSsddBTBround1",
-                          fRadiusBminBTB, fRadiusBminBTB+fBTBthick,
-                          fBTBlength/2., 270., 360.);
+                          fgkRadiusBminBTB, fgkRadiusBminBTB+fgkBTBthick,
+                          fgkBTBlength/2., 270., 360.);
   TGeoTranslation *roundTr1 = new TGeoTranslation("ITSsddBTBround1Tr",
-                                 -(fRadiusAminBTB+fBTBthick+fRadiusBminBTB),
+                                 -(fgkRadiusAminBTB+fgkBTBthick+fgkRadiusBminBTB),
                                  -dy, 0);
   roundTr1->RegisterYourself();
 
   TGeoTubeSeg *round2 = new TGeoTubeSeg( "ITSsddBTBround2",
-                          fRadiusBminBTB, fRadiusBminBTB+fBTBthick,
-                          fBTBlength/2., 180., 270.);
+                          fgkRadiusBminBTB, fgkRadiusBminBTB+fgkBTBthick,
+                          fgkBTBlength/2., 180., 270.);
   TGeoTranslation *roundTr2 = new TGeoTranslation("ITSsddBTBround2Tr",
-                                 (fRadiusAminBTB+fBTBthick+fRadiusBminBTB),
+                                 (fgkRadiusAminBTB+fgkBTBthick+fgkRadiusBminBTB),
                                  -dy, 0);
   roundTr2->RegisterYourself();
 
@@ -1315,7 +2052,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateBaseThermalBridge() {
         round2->InspectShape();
     };
 
-  TGeoMedium *carbonFiberLadderStruct = gGeoManager->GetMedium("ITSsddCarbonFiber");
+  TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
   TGeoVolume *vBaseThermalBridge = new TGeoVolume( "ITSsddBaseThermalBridge",
                                                   sBaseThermalBridge,
                                                   carbonFiberLadderStruct);
@@ -1325,371 +2062,639 @@ TGeoVolume* AliITSv11GeometrySDD::CreateBaseThermalBridge() {
 };
 
 
-
-
 //________________________________________________________________________
-TGeoVolume* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay, Int_t) {
-    // Return a box volume containing a end of a CF ladder.
-
-    Double_t tDY = -0.5; //space left on top of the ladder
-
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoMedium *carbonFiberLadderStruct = gGeoManager->GetMedium(
-                                          "ITSsddCarbonFiber");
-    Double_t length = 0;
-    Double_t coolPipeSuppH = 0;
-
-     if (iLay==3) {
-       length = (fLay3LadderLength-fLay3Ndet*fSegmentLength)/2.;
-       coolPipeSuppH = fLay3CoolPipeSuppH;
-     } else {
-       length = (fLay4LadderLength-fLay4Ndet*fSegmentLength)/2.;
-       coolPipeSuppH = fLay4CoolPipeSuppH;
-     };
+TGeoVolume* AliITSv11GeometrySDD::CreateEndLadder(Int_t iLay) {
+  //
+  // Return a box volume containing a end of a CF ladder.
+  //
+
+  TGeoMedium *airSDD                  = GetMedium("ITSair");
+  TGeoMedium *carbonFiberLadderStruct = GetMedium("ITSsddCarbonM55J");
+
+  Double_t length        = (fgkLay3LadderLength-fgkLay3Ndet*fgkSegmentLength)/2.;
+  Double_t coolPipeSuppH = fgkLay3CoolPipeSuppH;
+  Double_t underSegDH    = fLay3LadderUnderSegDH;
+  if (iLay==3) {
+  } else if (iLay==4) {
+    length        = (fgkLay4LadderLength-fgkLay4Ndet*fgkSegmentLength)/2.;
+    coolPipeSuppH = fgkLay4CoolPipeSuppH;
+    underSegDH    = fLay4LadderUnderSegDH;
+  } else {
+    printf("error in AliITSv11GeometrySDD::CreateEndLadder: Wrong layer");
+    return 0;
+  };
     
-    Double_t segmentLength = fSegmentLength;
-    Double_t topCornerLength = fSegmentLength/2.-fLay4LaddTopCornerEnd;
-
-    TGeoBBox *endBox = new TGeoBBox("ITSsddEndLaddBox",
-                                    //(fLadderWidth+fPinSuppWidth)/2,
-                                    (fLadderWidth)/2,
-                                    fLadderHeight/2+TMath::Abs(tDY),
-                                    length/2);
-    TGeoVolume *virtualEnd = new TGeoVolume("ITSsddEnd",endBox, airSDD);
-
-    //**********************************
-    // coding real matter :
-    //**********************************
-    Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
-    Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
-    Double_t beta = (TMath::Pi()-2.*halfTheta)/4.;
-    Double_t alpha = TMath::Pi()*3./4. - halfTheta/2.;
-
-    //--- The 3 V shape corners of the Carbon Fiber Ladder
-    //--- the top V
-    TGeoArb8 *cfLaddTop1 = CreateLadderSide( topCornerLength/2., halfTheta, -1,
-                                             fLadderLa, fLadderHa, fLadderl);
-    TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
-                                          cfLaddTop1,carbonFiberLadderStruct);
-    cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
-    TGeoArb8 *cfLaddTop2 = CreateLadderSide( topCornerLength/2., halfTheta, 1,
-                                             fLadderLa, fLadderHa, fLadderl);
-    TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
-                                        cfLaddTop2,carbonFiberLadderStruct);
-    cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
-    TGeoTranslation *trTop1 = new TGeoTranslation(0, fLadderHeight/2+tDY,
-                                               -(length-topCornerLength)/2.);
-    virtualEnd->AddNode(cfLaddTopVol1, 1, trTop1);
-    virtualEnd->AddNode(cfLaddTopVol2, 1, trTop1);
-
-    //--- the 2 side V
-    TGeoArb8 *cfLaddSide1 = CreateLadderSide( length/2., beta, -1,
-                                              fLadderLb, fLadderHb, fLadderl);
-    TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
-                                          cfLaddSide1,carbonFiberLadderStruct);
-    cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
-    TGeoArb8 *cfLaddSide2 = CreateLadderSide( length/2., beta, 1,
-                                              fLadderLb, fLadderHb, fLadderl);
-    TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
-                                          cfLaddSide2,carbonFiberLadderStruct);
-    cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
-    Double_t dYTranslation = ( fLadderHeight/2. - 0.5*fLadderWidth*
-                               TMath::Tan(beta) - fLadderBeamRadius );
-
-    // because center of the triangle doesn't correspond to virtual vol. center
-    Double_t distCenterSideDown =  0.5*fLadderWidth/TMath::Cos(beta);
-    TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
-                                               alpha*TMath::RadToDeg());
-    AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+tDY, 0);
-    TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown, 0, 
-                                               -alpha*TMath::RadToDeg());
-    AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+tDY, 0);
-    virtualEnd->AddNode(cfLaddSideVol1, 1, ctSideR);
-    virtualEnd->AddNode(cfLaddSideVol2, 1, ctSideR);
-    virtualEnd->AddNode(cfLaddSideVol1, 2, ctSideL);
-    virtualEnd->AddNode(cfLaddSideVol2, 2, ctSideL);
-
-    //--- The beams
-    // Beams on the sides
-    Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
-                TMath::Sin(2*beta)/(TanD(fBeamSidePhi)*TanD(fBeamSidePhi))) ));
-    if(GetDebug(3)) cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
-     Double_t beamLength = TMath::Sqrt( fLadderHeight*fLadderHeight/
-                          (TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
-                          +fLadderWidth*fLadderWidth/4.)-fLadderLa/2-fLadderLb/2;
-     TGeoTubeSeg *sideBeam = new TGeoTubeSeg( 0, fLadderBeamRadius,
-                                             beamLength/2., 0, 180);
-     TGeoVolume *cfSideBeamVol = new TGeoVolume("ITSsddCFSideBeamVol",
-                                      sideBeam, carbonFiberLadderStruct);
-     cfSideBeamVol->SetLineColor(fColorCarbonFiber);
-
-     //Euler rotation : about Z, then new X, then new Z
-     TGeoRotation *beamRot1 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
-                                 -beamPhiPrime*TMath::RadToDeg(), -90);
-     TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
-                                      TMath::Tan(halfTheta),
-                                      fLadderBeamRadius/2. + tDY,
-                                      -length/2 + segmentLength/8, beamRot1);
-     TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),
-                                 beamPhiPrime*TMath::RadToDeg(), -90);
-     TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans( 0.5*triangleHeight*
-                                      TMath::Tan(halfTheta),
-                                      fLadderBeamRadius/2.+tDY,
-                                      -length/2 + 3*segmentLength/8, beamRot2);
-     TGeoRotation *beamRot3 = new TGeoRotation("",90+2.*beta*TMath::RadToDeg(),
-                                 beamPhiPrime*TMath::RadToDeg(), -90);
-     TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
-                                      TMath::Tan(halfTheta),
-                                      fLadderBeamRadius/2.+tDY,
-                                      -length/2 + segmentLength/8, beamRot3);
-     TGeoRotation *beamRot4 = new TGeoRotation("",90 + 2.*beta*TMath::RadToDeg(),
-                                 -beamPhiPrime*TMath::RadToDeg(), -90);
-     TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
-                                      TMath::Tan(halfTheta),
-                                      fLadderBeamRadius/2. + tDY,
-                                      -length/2+3*segmentLength/8, beamRot4);
-     virtualEnd->AddNode(cfSideBeamVol, 1, beamTransf1);
-     virtualEnd->AddNode(cfSideBeamVol, 2, beamTransf3);
-     virtualEnd->AddNode(cfSideBeamVol, 3, beamTransf5);
-     virtualEnd->AddNode(cfSideBeamVol, 4, beamTransf7);
-
-     //--- Beams of the bottom
-     TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fLadderBeamRadius,
-                                   fLadderWidth/2.-fLadderLb/3, 0, 180);
-     TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
-                                      bottomBeam1, carbonFiberLadderStruct);
-     bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
-     TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
-     TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
-                            -(fLadderHeight/2-fLadderBeamRadius)+tDY,
-                           -length/2+fSegmentLength/2, bottomBeamRot1);
-     virtualEnd->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
-     TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fLadderBeamRadius,
-                                   fLadderWidth/2.-fLadderLb/3, 0, 90);
-     TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
-                                     bottomBeam2, carbonFiberLadderStruct);
-     bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
-     TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
-           -(fLadderHeight/2-fLadderBeamRadius)+tDY,-length/2, bottomBeamRot1);
-     virtualEnd->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
-
-     //**********************************
-     //the cooling pipe supports
-     Double_t triangleCPaxeDist = fCoolPipeSuppAxeDist-fCoolPipeSuppWidthExt-
-                                  fCoolPipeSuppWidthIn+fLadderBeamRadius;
-
-     Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
-                              (triangleHeight+triangleCPaxeDist/
-                              TMath::Sin(halfTheta) - coolPipeSuppH);
-     TGeoRotation *rotCPS2 = new TGeoRotation("",-halfTheta*TMath::RadToDeg(),-90,90);
-     TGeoRotation *rotCPS1 = new TGeoRotation("",halfTheta*TMath::RadToDeg(),-90,-90);
-     TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
-                                    -fLadderHeight/2.-TMath::Abs(tDY)+
-                                    coolPipeSuppH+fLadderBeamRadius,
-                                    -length/2., rotCPS1);
-     TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
-                                    -fLadderHeight/2.-TMath::Abs(tDY)+
-                                    coolPipeSuppH+fLadderBeamRadius,
-                                    -length/2., rotCPS2);
-
-     TGeoVolume *coolPipeSuppLeft = CreateCoolPipeSupportL();
-     virtualEnd->AddNode(coolPipeSuppLeft, 1, transCPS1);
-     TGeoVolume *coolPipeSuppRight = CreateCoolPipeSupportR();
-     virtualEnd->AddNode(coolPipeSuppRight, 1, transCPS4);
-     //**********************************
-     virtualEnd->SetVisibility(kFALSE);
-     return virtualEnd;
+  Double_t tDY = (- fgkLadderSegBoxDH/2       //space left on top of the ladder
+                 + underSegDH/2);          //space under ladder segment
+        // here tDY is not the same as for the segment because the end ladder
+        // does not have a space under it, inside the general ladder volume.
+  Double_t segmentLength   = fgkSegmentLength;
+  Double_t topCornerLength = fgkSegmentLength/2.-fgkLay4LaddTopCornerEnd;
+
+  TGeoBBox *endBox = new TGeoBBox("ITSsddEndLaddBox",
+                        (fgkLadderWidth)/2,
+                        fgkLadderHeight/2+fgkLadderSegBoxDH/2+underSegDH/2,
+                        length/2);
+  TGeoVolume *virtualEnd = new TGeoVolume("ITSsddEnd",endBox, airSDD);
+  
+  //**********************************
+  // coding real matter :
+  //**********************************
+  Double_t triangleHeight = fgkLadderHeight - fgkLadderBeamRadius;
+  Double_t halfTheta   = TMath::ATan( 0.5*fgkLadderWidth/triangleHeight );
+  Double_t beta        = (TMath::Pi()-2.*halfTheta)/4.;
+  Double_t alpha       = TMath::Pi()*3./4. - halfTheta/2.;
+  
+  //--- The 3 V shape corners of the Carbon Fiber Ladder
+  //--- the top V
+  TGeoArb8 *cfLaddTop1 = CreateLadderSide(topCornerLength/2., halfTheta, -1,
+                                         fgkLadderLa, fgkLadderHa, fgkLadderl);
+  TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
+                                 cfLaddTop1,carbonFiberLadderStruct);
+  cfLaddTopVol1->SetLineColor(fColorCarbonFiber);
+  TGeoArb8 *cfLaddTop2 = CreateLadderSide( topCornerLength/2., halfTheta, 1,
+                                          fgkLadderLa, fgkLadderHa, fgkLadderl);
+  TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
+                                 cfLaddTop2,carbonFiberLadderStruct);
+  cfLaddTopVol2->SetLineColor(fColorCarbonFiber);
+  TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2+tDY,
+                                               -(length-topCornerLength)/2.);
+  virtualEnd->AddNode(cfLaddTopVol1, 1, trTop1);
+  virtualEnd->AddNode(cfLaddTopVol2, 1, trTop1);
+
+  //--- the 2 side V
+  TGeoArb8 *cfLaddSide1 = CreateLadderSide( length/2., beta, -1,
+                                           fgkLadderLb, fgkLadderHb, fgkLadderl);
+  TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
+                                  cfLaddSide1,carbonFiberLadderStruct);
+  cfLaddSideVol1->SetLineColor(fColorCarbonFiber);
+  TGeoArb8 *cfLaddSide2 = CreateLadderSide( length/2., beta, 1,
+                                           fgkLadderLb, fgkLadderHb, fgkLadderl);
+  TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
+                                  cfLaddSide2,carbonFiberLadderStruct);
+  cfLaddSideVol2->SetLineColor(fColorCarbonFiber);
+  Double_t dYTranslation = ( fgkLadderHeight/2. - 0.5*fgkLadderWidth*
+                            TMath::Tan(beta) - fgkLadderBeamRadius );
+  
+  // because center of the triangle doesn't correspond to virtual vol. center
+  Double_t distCenterSideDown =  0.5*fgkLadderWidth/TMath::Cos(beta);
+  TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
+                                            alpha*TMath::RadToDeg());
+  AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation+tDY, 0);
+  TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown, 0, 
+                                            -alpha*TMath::RadToDeg());
+  AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation+tDY, 0);
+  virtualEnd->AddNode(cfLaddSideVol1, 1, ctSideR);
+  virtualEnd->AddNode(cfLaddSideVol2, 1, ctSideR);
+  virtualEnd->AddNode(cfLaddSideVol1, 2, ctSideL);
+  virtualEnd->AddNode(cfLaddSideVol2, 2, ctSideL);
+  
+  //--- The beams
+  // Beams on the sides
+  Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
+                 TMath::Sin(2*beta)/(TanD(fgkBeamSidePhi)*TanD(fgkBeamSidePhi))) ));
+
+  //Euler rotation : about Z, then new X, then new Z
+  TGeoRotation beamRot1("", 90-2.*beta*TMath::RadToDeg(),
+                       -beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation beamRot2("", 90-2.*beta*TMath::RadToDeg(),
+                       beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation beamRot3("", 90+2.*beta*TMath::RadToDeg(),
+                       beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoRotation beamRot4("", 90+2.*beta*TMath::RadToDeg(),
+                       -beamPhiPrime*TMath::RadToDeg(), -90);
+  TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
+                                                  TMath::Tan(halfTheta),
+                                             fgkLadderBeamRadius/2. + tDY,
+                                -length/2 + segmentLength/8, &beamRot1);
+  TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans( 0.5*triangleHeight*
+                                                   TMath::Tan(halfTheta),
+                                                fgkLadderBeamRadius/2.+tDY,
+                               -length/2 + 3*segmentLength/8, &beamRot2);
+  TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
+                                                  TMath::Tan(halfTheta),
+                                               fgkLadderBeamRadius/2.+tDY,
+                                -length/2 + segmentLength/8, &beamRot3);
+  TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
+                                                  TMath::Tan(halfTheta),
+                                             fgkLadderBeamRadius/2. + tDY,
+                                -length/2+3*segmentLength/8, &beamRot4);
+
+  virtualEnd->AddNode(fLaddSegCommonVol[6], 1, beamTransf1);
+  virtualEnd->AddNode(fLaddSegCommonVol[6], 2, beamTransf3);
+  virtualEnd->AddNode(fLaddSegCommonVol[6], 3, beamTransf5);
+  virtualEnd->AddNode(fLaddSegCommonVol[6], 4, beamTransf7);
+
+  //--- Beams of the bottom
+  TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
+                                fgkLadderWidth/2.-fgkLadderLb/3, 0, 180);
+  TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
+                                  bottomBeam1, carbonFiberLadderStruct);
+  bottomBeam1Vol->SetLineColor(fColorCarbonFiber);
+
+  TGeoRotation bottomBeamRot1("",90, 90, 90);
+  TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
+                            -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY,
+                           -length/2+fgkSegmentLength/2, &bottomBeamRot1);
+  virtualEnd->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
+  TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fgkLadderBeamRadius,
+                                fgkLadderWidth/2.-fgkLadderLb/3, 0, 90);
+  TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
+                                  bottomBeam2, carbonFiberLadderStruct);
+  bottomBeam2Vol->SetLineColor(fColorCarbonFiber);
+  TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
+     -(fgkLadderHeight/2-fgkLadderBeamRadius)+tDY,-length/2,&bottomBeamRot1);
+  virtualEnd->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
+
+  //**********************************
+  //the cooling pipe supports
+  Double_t triangleCPaxeDist = fgkCoolPipeSuppAxeDist-fgkCoolPipeSuppWidthExt-
+    fgkCoolPipeSuppWidthIn+fgkLadderBeamRadius;
+
+  Double_t coolPipeSuppL = TMath::Tan(halfTheta)*
+    (triangleHeight+triangleCPaxeDist/
+     TMath::Sin(halfTheta) - coolPipeSuppH);
+  
+  if (fAddCoolingSyst) {
+  TGeoRotation rotCPS2("",-halfTheta*TMath::RadToDeg(),-90, 90);
+  TGeoRotation rotCPS1("", halfTheta*TMath::RadToDeg(),-90,-90);
+  TGeoCombiTrans *transCPS1 = new TGeoCombiTrans(coolPipeSuppL,
+                                 -fgkLadderHeight/2.-TMath::Abs(tDY)+
+                                 coolPipeSuppH+fgkLadderBeamRadius,
+                                 -length/2., &rotCPS1);
+  TGeoCombiTrans *transCPS4 = new TGeoCombiTrans(-coolPipeSuppL,
+                                 -fgkLadderHeight/2.-TMath::Abs(tDY)+
+                                 coolPipeSuppH+fgkLadderBeamRadius,
+                                 -length/2., &rotCPS2);
+
+  virtualEnd->AddNode(fCoolPipeSupportL, 1, transCPS1);
+  virtualEnd->AddNode(fCoolPipeSupportR, 1, transCPS4);
+  };
+
+  //**********************************
+  if(GetDebug(1)) virtualEnd->CheckOverlaps(0.01);
+  //virtualEnd->SetVisibility(kFALSE);
+  return virtualEnd;
 };
 
 
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeometrySDD::CreateSDDsensor() {
-    // return a box containing the SDD sensor
-
-    TGeoBBox *sensorBox = new TGeoBBox("ITSsddSensorBox",
-                                 fWaferWidth/2, fWaferThickness/2,fWaferLength/2);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualSensor = new TGeoVolume("ITSsddSensor",sensorBox,airSDD);
-
-    // the virtual volume is already following the cood convention
-    // for the local wafer coord. system : no need for additional rotation matrix
+  //
+  // return a box containing the SDD sensor
+  //
+
+  TGeoMedium *airSDD        = GetMedium("ITSair");
+  TGeoMedium *siliconSDD    = GetMedium("ITSsddSi");
+  TGeoMedium *alSDD         = GetMedium("ITSal");
+  TGeoMedium *polyhamideSDD = GetMedium("ITSsddKAPTON_POLYCH2");
+  TGeoMedium *glassSDD      = GetMedium("ITSsddSi");       //  To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+  Double_t rWraping = fgkWaferThickness/2+fgkWaHVcableAlThick+fgkWaHVcablePolyThick;
+  Double_t witdhCableBox = (fgkWaHVcableWitdh - TMath::Pi()*rWraping)/2;
+
+  Double_t sensoxBoxLength = ( fgkWaferLength +
+                              2*(rWraping+witdhCableBox-fgkWaHVcableDW) );
+  // Makes life easier to include the space for the WA HV cable on both sides 
+  Double_t sensoxBoxThick = fgkWaferThickness +
+                            2*(fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
+
+  TGeoBBox *box = new TGeoBBox("ITSsddSensorBox",
+                     fgkWaferWidth/2, sensoxBoxThick/2, sensoxBoxLength/2);
+  TGeoVolume *virtualSensor = new TGeoVolume("ITSsddSensor",box,airSDD);
+
+  //****************************
+  // silicon wafer
+  //****************************
+  if (fAddSensors) {
     TGeoBBox *waferShape = new TGeoBBox("ITSsddWaferShape",
-                                 fWaferWidth/2, fWaferThickness/2,fWaferLength/2);
-
-    //medium = silicon ?                              To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-    TGeoMedium *siliconSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
-    TGeoVolume *sensor = new TGeoVolume("ITSsddWafer", waferShape, siliconSDD);
-    sensor->SetLineColor(fColorSilicon);
-    virtualSensor->AddNode(sensor, 1, 0);
+                          fgkWaferWidth/2, fgkWaferThickness/2, fgkWaferLength/2);
+    TGeoVolume *wafer = new TGeoVolume("ITSsddWafer", waferShape, siliconSDD);
+    wafer->SetLineColor(fColorSilicon);
+    TGeoBBox *sensBox = new TGeoBBox("ITSsddSensorSensBox",
+                       fgkWaferWidthSens/2,fgkWaferThickSens/2,fgkWaferLengthSens/2);
+    TGeoVolume *sensVol=new TGeoVolume(fgSDDsensitiveVolName,sensBox,siliconSDD);
+    sensVol->SetLineColor(fColorSilicon);
+    
+    wafer->AddNode(sensVol, 1, 0);
+    virtualSensor->AddNode(wafer, 1, 0);
+  };
+  
+  //****************************
+  // glass
+  //****************************
+  TGeoBBox *glass = new TGeoBBox("ITSsddGlassBox", fgkSensorGlassLX/2,
+                                fgkSensorGlassLY/2, fgkSensorGlassLZ/2);
+  TGeoVolume *vGlass  = new  TGeoVolume("ITSsddGlass",glass, glassSDD);
+  vGlass->SetLineColor(fColorGlass);
+  TGeoTranslation *glassTr1 = new TGeoTranslation("",fgkGlassDXOnSensor,
+                                 fgkWaferThickness/2+fgkSensorGlassLY/2,
+                                 fgkGlassDZOnSensor);
+  TGeoTranslation *glassTr2 = new TGeoTranslation("",-fgkGlassDXOnSensor,
+                                 fgkWaferThickness/2+fgkSensorGlassLY/2,
+                                 fgkGlassDZOnSensor);
+  TGeoTranslation *glassTr3 = new TGeoTranslation("",fgkGlassDXOnSensor,
+                                 fgkWaferThickness/2+fgkSensorGlassLY/2,
+                                 -fgkGlassDZOnSensor);
+  TGeoTranslation *glassTr4 = new TGeoTranslation("",-fgkGlassDXOnSensor,
+                                 fgkWaferThickness/2+fgkSensorGlassLY/2,
+                                 -fgkGlassDZOnSensor);
+  virtualSensor->AddNode(vGlass, 1, glassTr1);
+  virtualSensor->AddNode(vGlass, 2, glassTr2);
+  virtualSensor->AddNode(vGlass, 3, glassTr3);
+  virtualSensor->AddNode(vGlass, 4, glassTr4);
+
+  //****************************
+  // Wrap-around cable
+  //****************************
+  if (fAddHVcables) {
+  AliITSv11GeomCableFlat waHVCable("ITSsddWaHVCableU",witdhCableBox,
+                                     fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
+  waHVCable.SetNLayers(2);
+  waHVCable.SetLayer(0, fgkWaHVcablePolyThick,polyhamideSDD,fColorPolyhamide);
+  waHVCable.SetLayer(1, fgkWaHVcableAlThick, alSDD, fColorAl);
+  waHVCable.SetInitialNode(virtualSensor);
+
+  Double_t x1[3], x2[3], vX[3] = {1,0,0};
+  x1[0] = -fgkWaHVcableLength/2;
+  x2[0] = -x1[0];
+  x1[1] = (fgkWaferThickness + waHVCable.GetThickness())/2;
+  x2[1] = x1[1];
+  x1[2] = fgkWaferLength/2+waHVCable.GetWidth()/2-fgkWaHVcableDW;
+  x2[2] = x1[2];
+
+  waHVCable.AddCheckPoint(virtualSensor, 0, x1, vX);
+  waHVCable.AddCheckPoint(virtualSensor, 1, x2, vX);
+  waHVCable.CreateAndInsertCableSegment(1,-90);
+  x1[1] = -x1[1];
+  x2[1] = x1[1];
+  waHVCable.SetName("ITSsddWaHVCableD");
+  waHVCable.ResetPoints();
+  waHVCable.AddCheckPoint(virtualSensor, 0, x1, vX);
+  waHVCable.AddCheckPoint(virtualSensor, 1, x2, vX);
+  waHVCable.CreateAndInsertCableSegment(1, 90);
+
+  AliITSv11GeomCableRound waHVCableFold("ITSsddWaHVCableFold",
+                                          rWraping);
+  waHVCableFold.SetPhi(180,360);
+  waHVCableFold.SetNLayers(2);
+  waHVCableFold.SetLayer(0, fgkWaferThickness/2+fgkWaHVcablePolyThick,
+                        polyhamideSDD, fColorPolyhamide);
+  waHVCableFold.SetLayer(1, fgkWaHVcableAlThick, alSDD, fColorAl);
+  waHVCableFold.SetInitialNode(virtualSensor);
+  x1[1] = 0;
+  x2[1] = 0;
+  x1[2] = fgkWaferLength/2-fgkWaHVcableDW+witdhCableBox;
+  x2[2] = x1[2];
+  waHVCableFold.AddCheckPoint(virtualSensor, 0, x1, vX);
+  waHVCableFold.AddCheckPoint(virtualSensor, 1, x2, vX);
+  waHVCableFold.CreateAndInsertCableSegment(1);
+
+  //****************************
+  // transition cable
+  //****************************
+  Double_t headRadius = (fgkTransitHVHeadLX*fgkTransitHVHeadLX/4.+
+                        fgkTransitHVHeadLZ*fgkTransitHVHeadLZ)
+                        /(2.*fgkTransitHVHeadLZ);
+  Double_t theta = TMath::ATan2(fgkTransitHVHeadLX/2,
+                               headRadius-fgkTransitHVHeadLZ)
+                   *TMath::RadToDeg();
+
+  TGeoTubeSeg *headPoly = new TGeoTubeSeg(0,headRadius,
+                                         fgkTransitHVPolyThick/2,
+                                         90-theta,90+theta);
+  headPoly->SetName("headPoly");
+  TGeoTranslation *headPolyTr = new TGeoTranslation(0,0,
+                                   -fgkTransitHVPolyThick/2);
+  headPolyTr->SetName("headPolyTr");
+  headPolyTr->RegisterYourself();
+
+  TGeoTubeSeg *headAl = new TGeoTubeSeg(0,headRadius,
+                                       fgkTransitHVAlThick/2,
+                                       90-theta,90+theta);
+  headAl->SetName("headAl");
+  TGeoTranslation *headAlTr = new TGeoTranslation(0,0,
+                                 -fgkTransitHVPolyThick
+                                 -fgkTransitHVAlThick/2);
+  headAlTr->SetName("headAlTr");
+  headAlTr->RegisterYourself();
+
+  TGeoBBox *cache = new TGeoBBox(fgkTransitHVHeadLX/2,
+                                (headRadius-fgkTransitHVHeadLZ)/2,
+                      (fgkTransitHVPolyThick+fgkTransitHVAlThick)/2);
+  cache->SetName("cache");
+
+  TGeoTranslation *headCacheTr = new TGeoTranslation(0,
+                               (headRadius-fgkTransitHVHeadLZ)/2,
+                                -(fgkTransitHVPolyThick
+                                  +fgkTransitHVAlThick)/2);
+  headCacheTr->SetName("cacheTr");
+  headCacheTr->RegisterYourself();
+
+  TGeoCompositeShape *headPolyComp = new TGeoCompositeShape(
+                     "headPoly:headPolyTr-cache:cacheTr");
+  TGeoVolume *vHeadPolyComp = new TGeoVolume(
+              "ITSsddHVtransitHeadPoly",headPolyComp, polyhamideSDD);
+  vHeadPolyComp->SetLineColor(fColorPolyhamide);
+  TGeoCompositeShape *headAlComp = new TGeoCompositeShape(
+                                      "headAl:headAlTr-cache:cacheTr");
+  TGeoVolume *vHeadAlComp = new TGeoVolume(
+              "ITSsddHVtransitHeadAl",headAlComp, alSDD);
+  vHeadAlComp->SetLineColor(fColorAl);
+
+
+  TGeoRotation rotHead("",0,90,0);
+  TGeoCombiTrans *rotHeadTr = new TGeoCombiTrans(0,fgkWaferThickness/2,
+                 -headRadius+fgkTransitHVHeadLZ+fgkTransitHVBondingLZ/2,
+                                                &rotHead);
+  virtualSensor->AddNode(vHeadPolyComp,1,rotHeadTr);
+  virtualSensor->AddNode(vHeadAlComp,1,rotHeadTr);
+
+  //---
+  AliITSv11GeomCableFlat transitHVCable("ITSsddHVtransitCenter",
+                                       fgkTransitHVBondingLZ,
+                           fgkTransitHVPolyThick+fgkTransitHVAlThick);
+  transitHVCable.SetNLayers(2);
+  transitHVCable.SetLayer(0, fgkTransitHVPolyThick,polyhamideSDD,
+                         fColorPolyhamide);
+  transitHVCable.SetLayer(1, fgkTransitHVAlThick, alSDD, fColorAl);
+  transitHVCable.SetInitialNode(virtualSensor);
+
+  x1[0] = -fgkTransitHVHeadLX/2;
+  x2[0] = -x1[0];
+  x1[1] = (fgkWaferThickness+fgkTransitHVPolyThick+fgkTransitHVAlThick)/2;
+  x2[1] = x1[1];
+  x1[2] = 0;
+  x2[2] = 0;
+  transitHVCable.AddCheckPoint(virtualSensor, 0, x1, vX);
+  transitHVCable.AddCheckPoint(virtualSensor, 1, x2, vX);
+  transitHVCable.CreateAndInsertCableSegment(1,-90);
+  transitHVCable.ResetPoints();
+  transitHVCable.SetName("ITSsddHVtransitTail");
+  transitHVCable.SetWidth(fgkTransitHVtailWidth);
+  x1[0] = fgkTransitHVtailXpos;
+  x2[0] = fgkTransitHVtailXpos;
+  x1[2] = -fgkTransitHVBondingLZ/2;
+  x2[2] = -fgkTransitHVBondingLZ/2-fgkTransitHVtailLength;
+  Double_t vZ[3] = {0,0,1};
+  transitHVCable.AddCheckPoint(virtualSensor, 0, x1, vZ);
+  transitHVCable.AddCheckPoint(virtualSensor, 1, x2, vZ);
+  transitHVCable.CreateAndInsertCableSegment(1,0);
+
+  //---
+  TGeoArb8 *sideLeft = new TGeoArb8( fgkTransitHVPolyThick/2 );
+  sideLeft->SetVertex(0, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
+  sideLeft->SetVertex(1, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
+                     fgkTransitHVsideLZ);
+  sideLeft->SetVertex(2, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
+  sideLeft->SetVertex(3, fgkTransitHVHeadLX/2, 0);
+  sideLeft->SetVertex(4, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
+  sideLeft->SetVertex(5, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
+                     fgkTransitHVsideLZ);
+  sideLeft->SetVertex(6, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
+  sideLeft->SetVertex(7, fgkTransitHVHeadLX/2, 0);
+
+  TGeoArb8 *sideLeftAl = new TGeoArb8( fgkTransitHVAlThick/2 );
+  sideLeftAl->SetVertex(0, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
+  sideLeftAl->SetVertex(1, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
+                       fgkTransitHVsideLZ);
+  sideLeftAl->SetVertex(2, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
+  sideLeftAl->SetVertex(3, fgkTransitHVHeadLX/2, 0);
+  sideLeftAl->SetVertex(4, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,0);
+  sideLeftAl->SetVertex(5, fgkTransitHVtailXpos+fgkTransitHVtailWidth/2,
+                       fgkTransitHVsideLZ);
+  sideLeftAl->SetVertex(6, fgkTransitHVHeadLX/2, fgkTransitHVsideLeftZ);
+  sideLeftAl->SetVertex(7, fgkTransitHVHeadLX/2, 0);
+
+  TGeoArb8 *sideRight = new TGeoArb8( fgkTransitHVPolyThick/2 );
+  sideRight->SetVertex(0, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,0);
+  sideRight->SetVertex(1, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,
+                      fgkTransitHVsideLZ);
+  sideRight->SetVertex(2, -fgkTransitHVHeadLX/2, fgkTransitHVsideRightZ);
+  sideRight->SetVertex(3, -fgkTransitHVHeadLX/2, 0);
+  sideRight->SetVertex(4, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,0);
+  sideRight->SetVertex(5, fgkTransitHVtailXpos-fgkTransitHVtailWidth/2,
+                      fgkTransitHVsideLZ);
+  sideRight->SetVertex(6, -fgkTransitHVHeadLX/2, fgkTransitHVsideRightZ);
+  sideRight->SetVertex(7, -fgkTransitHVHeadLX/2, 0);
+
+  TGeoRotation rotSide("",0,-90,0);
+  TGeoCombiTrans *sideRightTr = new TGeoCombiTrans(0,
+                               (fgkWaferThickness+fgkTransitHVPolyThick)/2,
+                               -fgkTransitHVBondingLZ/2,&rotSide);
+  TGeoCombiTrans *sideLeftTr = new TGeoCombiTrans(0,
+                              (fgkWaferThickness+fgkTransitHVPolyThick)/2,
+                              -fgkTransitHVBondingLZ/2, &rotSide);
+  TGeoCombiTrans *sideLeftAlTr = new TGeoCombiTrans(0,
+                 fgkTransitHVPolyThick+(fgkWaferThickness+fgkTransitHVAlThick)/2,
+                 -fgkTransitHVBondingLZ/2, &rotSide);
+
+  TGeoVolume *vSideLeft = new TGeoVolume("ITSsddHVtransitSideLeft",
+                                        sideLeft,polyhamideSDD);
+  vSideLeft->SetLineColor(fColorPolyhamide);
+  TGeoVolume *vSideLeftAl = new TGeoVolume("ITSsddHVtransitSideLeftAl",
+                                          sideLeftAl,alSDD);
+  vSideLeftAl->SetLineColor(fColorAl);
+  TGeoVolume *vSideRight = new TGeoVolume("ITSsddHVtransitSideRight",
+                                         sideRight,polyhamideSDD);
+  vSideRight->SetLineColor(fColorPolyhamide);
+
+  virtualSensor->AddNode(vSideLeft,   1, sideLeftTr);
+  virtualSensor->AddNode(vSideLeftAl, 1, sideLeftAlTr);
+  virtualSensor->AddNode(vSideRight,  1, sideRightTr);
+  };
 
-    virtualSensor->SetVisibility(kFALSE);
-    return virtualSensor;
+  //****************************
+  if(GetDebug(1)) virtualSensor->CheckOverlaps(0.01);
+  virtualSensor->SetVisibility(kFALSE);
+  return virtualSensor;
 };
 
 
 //________________________________________________________________________
-TGeoVolume *AliITSv11GeometrySDD::CreateLay3Detectors() {
-    // return a box volume containing the detectors
-
-    TGeoBBox *detBox = new TGeoBBox("ITSssdDetBox3",
-                                    fWaferWidth/2,
-                                    (fLadWaferSep + 2*fWaferThickness)/2,
-                             fLay3LadderLength*((fLay3Ndet-0.5)/fLay3Ndet)/2);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualDet = new TGeoVolume("ITSsddDet3",detBox, airSDD);
-    TGeoVolume *vSDD = CreateSDDsensor();
-    char transName[30];
-    Int_t iSegmentMin = 0;
-    Int_t iSegmentMax = fLay3Ndet;
-    if (fAddOnlySegment>=0) {
-        iSegmentMin = fAddOnlySegment;
-        iSegmentMax = fAddOnlySegment+1;
-    };
+TGeoVolume *AliITSv11GeometrySDD::CreateDetectors(Int_t iLay) {
+  //
+  // return a box volume containing the detectors
+  //
+
+  TGeoMedium *airSDD = GetMedium("ITSair");
 
-    for (Int_t i=iSegmentMin; i<iSegmentMax; i++) {
-        Double_t localZ = fLay3sensorZPos[i];
-        Double_t localY = fLadWaferSep/2+fWaferThickness/2;
-        if (i%2!=0)
-            localY = -localY;
-        sprintf(transName, "ITSsddLay3SensorPos%i", i);
-        TGeoTranslation *sensorPos = new TGeoTranslation(transName,0,localY,
-                                                         localZ);
-        virtualDet->AddNode(vSDD, i, sensorPos);
+  Int_t    nDetectors   = fgkLay3Ndet;
+  Double_t ladderLength = fgkLay3LadderLength;
+  Double_t *sensorZPos  = fLay3sensorZPos;
+  
+  if (iLay==3) {}
+  else if (iLay==4) {
+    nDetectors   = fgkLay4Ndet;
+    ladderLength = fgkLay4LadderLength;
+    sensorZPos   = fLay4sensorZPos;
+  } else {
+    printf("AliITSv11GeometrySDD::CreateLay3Detectors: Error : Wrong layer");
+  };
+
+  char name[30];
+  Double_t volThickness = ( fgkLadWaferSep + 2*fgkWaferThickness +
+                           2*(fgkWaHVcableAlThick+fgkWaHVcablePolyThick));
+  
+  sprintf(name,"ITSsddDetBox%i",iLay);
+  TGeoBBox *detBox = new TGeoBBox(name, fgkWaferWidth/2, volThickness/2,
+                        ladderLength*((nDetectors-0.5)/nDetectors)/2);
+  TGeoVolume *virtualDet = new TGeoVolume("ITSsddLadd",detBox, airSDD);
+    for (Int_t i=0; i<nDetectors; i++) {
+        Double_t localZ = sensorZPos[i];
+        Double_t localY = fgkLadWaferSep/2+fgkWaferThickness/2;
+        if (iLay==3) if (i%2!=0) localY = -localY;
+       if (iLay==4) if (i%2==0) localY = -localY;
+        sprintf(name, "ITSsddLay%iSensorPos%i",iLay, i);
+       Double_t rotationY = 180;
+       if (i >= nDetectors/2) rotationY = 0;
+       TGeoRotation rotSensor("",0, rotationY, 0);
+       TGeoCombiTrans *sensorPos = new TGeoCombiTrans(0,localY,
+                                                      localZ,&rotSensor);
+       sensorPos->SetName(name);
+        virtualDet->AddNode(fSDDsensor, i, sensorPos);
     }
-    virtualDet->SetVisibility(kFALSE);
+
+    if(GetDebug(1)) virtualDet->CheckOverlaps(0.01);
+    //virtualDet->SetVisibility(kFALSE);
     return virtualDet;
 };
 
 
+
 //________________________________________________________________________
-void AliITSv11GeometrySDD::Layer4(TGeoVolume *Moth) {
-    // Insert the layer 4 in the mother volume. This is a virtual volume
-    // containing ladders of layer 4 and the supporting rings
-
-    TGeoTube *virtualLayer4Shape =new TGeoTube("ITSsddLayer4Shape",
-                                        fLay4Rmin,fLay4Rmax,fLay4Length*0.5);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualLayer4 = new TGeoVolume("ITSsddLayer4",
-                                          virtualLayer4Shape, airSDD);
-    TGeoVolume *lay4Ladder = CreateLay4Ladder();
-    TGeoVolume *lay4Detectors = CreateLay4Detectors();
-    Double_t dPhi = 360./fLay4Nladd;
-    Double_t detBoxThickness = fLadWaferSep + 2*fWaferThickness;
-    // placing virtual ladder and detectors volumes following ladder 
-    // ordering convention
-    char rotName[20];
-    Int_t iLaddMin = 0;
-    Int_t iLaddMax = fLay4Nladd;
-    if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fLay4Nladd)) {
-        iLaddMin = fAddOnlyLadder4min;
-        iLaddMax = fAddOnlyLadder4max+1;
-    }
-    for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
-        sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
-        Double_t minRadiusLadBox = fLay4LaddShortRadius;
-        if (iLadd%2 != 0)
-            minRadiusLadBox = fLay4LaddLongRadius;
-        minRadiusLadBox += ((TGeoBBox*)lay4Ladder->GetShape())->GetDY();
-        TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName, minRadiusLadBox,
-                                                  0, -90+iLadd*dPhi);
-        virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
-        sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
-        Double_t minRadiusDetBox = fLay4DetShortRadius;
-        if (iLadd%2 != 0)
-            minRadiusDetBox = fLay4DetLongRadius;
-        minRadiusDetBox += detBoxThickness/2;
-        TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
-                                                 0, -90+iLadd*dPhi);
-        virtualLayer4->AddNode(lay4Detectors, iLadd, ctDet);
-    }
-    virtualLayer4->SetVisibility(kFALSE);
-    Moth->AddNode(virtualLayer4,1,0);
-};
+Int_t AliITSv11GeometrySDD::ExportSensorGeometry(AliITSgeom *geom, Int_t iLaySDD,
+                                                Int_t startMod) {
+  //
+  // export the geometry in a AliITSgeom object
+  //
+
+  if (! geom) {
+    printf("error:Try to fill null (AliITSgeom *) object");
+    return kFALSE;
+  };
+  if (! fMotherVol) {
+    printf("error:Try to set sensor geometry while geometry is not defined\n");
+    return kFALSE;
+  };
 
+  Int_t firstSDDmod = startMod;
+  const Float_t kDxyz[3] = {fgkWaferWidthSens, fgkWaferThickSens, fgkWaferLengthSens};
+
+  if(!(geom->IsShapeDefined(kSDD)))
+    geom->ReSetShape(kSDD, new AliITSgeomSDD256(3, kDxyz));
+
+  char layerName[30];
+  char ladderName[30];
+  char sensorName[30];
+  char senstivName[30];
+  const Int_t kNLay = 2;
+  const Int_t kNLadd[2] = {fgkLay3Nladd, fgkLay4Nladd};
+  const Int_t kNDet[2]  = {fgkLay3Ndet,  fgkLay4Ndet};
+
+  if (GetDebug(1))
+    printf("AliITSv11GeometrySDD::SetSensorGeometry(), nodes found :\n");
+
+  for (Int_t iLay=0; iLay<kNLay; iLay++) {
+    /////////////////////////////////////////
+    sprintf(layerName, "ITSsddLayer%i_1",iLay+3);
+    TGeoNode *layNode = fMotherVol->GetNode(layerName);
+    if (layNode) {
+      if (GetDebug(1)) printf("%s\n",layNode->GetName());
+      TGeoVolume *layVolume = layNode->GetVolume();
+      TGeoHMatrix layMatrix(*layNode->GetMatrix());
+
+      for (Int_t iLadd=0; iLadd<kNLadd[iLay]; iLadd++) {
+       /////////////////////////////////////////
+       sprintf(ladderName, "ITSsddLadd_%i", iLadd);
+       TGeoNode *laddNode = layVolume->GetNode(ladderName);
+       if (laddNode) {
+         if (GetDebug(1)) printf("|   %s\n",laddNode->GetName());
+         TGeoVolume *laddVolume = laddNode->GetVolume();
+         TGeoHMatrix laddMatrix(layMatrix);
+         laddMatrix.Multiply(laddNode->GetMatrix());
+
+         for (Int_t iDet=0; iDet<kNDet[iLay]; iDet++) {
+           /////////////////////////////////////////
+           sprintf(sensorName, "ITSsddSensor_%i",iDet);
+           TGeoNode *detNode = laddVolume->GetNode(sensorName);
+           if (detNode) {
+             if (GetDebug(1)) printf("|   |   %s\n",detNode->GetName());
+             TGeoVolume *detVolume = detNode->GetVolume();
+             TGeoHMatrix detMatrix(laddMatrix);
+             detMatrix.Multiply(detNode->GetMatrix());
+
+             TGeoNode *wafNode = detVolume->GetNode("ITSsddWafer_1");
+             if (wafNode) {
+               TGeoVolume *wafVolume = wafNode->GetVolume();
+               TGeoHMatrix wafMatrix(detMatrix);
+               detMatrix.Multiply(wafNode->GetMatrix());
+               //--------------------------------------------------------
+               sprintf(senstivName, "%s%s", fgSDDsensitiveVolName,"_1");
+               TGeoNode *sensitivNode = wafVolume->GetNode(senstivName);
+             if (sensitivNode) {
+               TGeoHMatrix sensMatrix(wafMatrix);
+               sensMatrix.Multiply(sensitivNode->GetMatrix());
+
+               Double_t *trans = sensMatrix.GetTranslation();
+               Double_t *r     = sensMatrix.GetRotationMatrix();
+               Double_t rot[10] = {r[0],r[1],r[2],
+                                   r[3],r[4],r[5],
+                                   r[6],r[7],r[8], 0.0};
+               //rot[9]=0.0 => not a unity matrix
+               geom->CreatMatrix(startMod,iLay+iLaySDD,iLadd+1,iDet+1,
+                                 kSDD,trans,rot);
+               // iLadd+1, iDet+1 because ladd. and det. start at +1
+               // elsewhere
+               startMod++;
+             } else
+               printf("Error (ExportSensorGeometry) %s not found !\n",
+                      senstivName);
+             } else
+               printf("Error (ExportSensorGeometry) %s not found !\n",
+                      "ITSsddWafer_1");
+           } else
+             printf("Error (ExportSensorGeometry) %s not found !\n",
+                    sensorName);
+         };
+       } else 
+         printf("Error (ExportSensorGeometry) %s not found !\n",
+                ladderName);
+      };  
+    } else
+      printf("Error (ExportSensorGeometry) %s not found !\n",
+            layerName);
+  };
 
-//________________________________________________________________________
-TGeoVolume *AliITSv11GeometrySDD::CreateLay4Ladder() {
-    // return a box volume containing the CF ladder and all pieces on it
-
-    TGeoVolume *laddSegmentTemp = CreateLadderSegment(4,0);
-    TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
-                           ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDX(),
-                          ((TGeoBBox*)laddSegmentTemp->GetShape())->GetDY(),
-                          //dX,dY = dX,dY of the segment
-                          fLay4LadderLength/2);  
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
-    Double_t segmentLength = fSegmentLength;
-    char transName[20];
-    // placing virtual ladder segment following detector ordering convention
-    //=======================================================================
-    Int_t iSegmentMin = 0;
-    Int_t iSegmentMax = fLay4Ndet;
-    if (fAddOnlySegment>=0) {
-        iSegmentMin = fAddOnlySegment;
-        iSegmentMax = fAddOnlySegment+1;
-    }
-    for (Int_t iSegment= iSegmentMin; iSegment < iSegmentMax; iSegment++ ) {
-
-        TGeoVolume *laddSegment = CreateLadderSegment(4, iSegment);
-        sprintf(transName, "ITSsddLay4LaddSeg%i", iSegment);
-        Double_t segmentPos = segmentLength*(fLay4Ndet/2-1-iSegment) +
-                             segmentLength/2;
-        TGeoTranslation *segTr = new TGeoTranslation(transName,0,0,segmentPos);
-        virtualLadder->AddNode(laddSegment, iSegment, segTr);
-    }
-    // putting virtual volume corresponding to the end of ladder
-    //=======================================================================
-    TGeoVolume *endLadder = CreateEndLadder( 4,-1 );
-    Double_t endLength = (fLay4LadderLength-fLay4Ndet*fSegmentLength)/2.;
-    TGeoTranslation *endTrZPos =
-        new TGeoTranslation("ITSsddEndTrZPos",0,0,
-                            fSegmentLength*(fLay4Ndet/2)+endLength/2.);
-    //Euler rotation : about Z, then new X, then new Z
-    TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
-    TGeoCombiTrans *endTrZNeg =
-        new TGeoCombiTrans(0,0,-fSegmentLength*(fLay4Ndet/2)-endLength/2.,
-                           endZNegRot);
-    if ((fAddOnlySegment==-1)||(fAddOnlySegment==0))
-        virtualLadder->AddNode(endLadder, 1, endTrZPos);
-    if ((fAddOnlySegment==-1)||(fAddOnlySegment==fLay4Ndet-1))
-        virtualLadder->AddNode(endLadder, 2, endTrZNeg);
-    virtualLadder->SetVisibility(kFALSE);
-    return virtualLadder;
+  return (startMod-firstSDDmod);
 };
 
 
-//________________________________________________________________________
-TGeoVolume *AliITSv11GeometrySDD::CreateLay4Detectors() {
-    // return a box volume containing the detectors
-
-    TGeoBBox *detBox = new TGeoBBox("ITSssdDetBox4",
-                           fWaferWidth/2,
-                           (fLadWaferSep + 2*fWaferThickness)/2,
-                           fLay4LadderLength*((fLay4Ndet-0.5)/fLay4Ndet)/2);
-    TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
-    TGeoVolume *virtualDet = new TGeoVolume("ITSsddDet4",detBox, airSDD);
-    TGeoVolume *vSDD = CreateSDDsensor();
-    char transName[30];
-    Int_t iSegmentMin = 0;
-    Int_t iSegmentMax = fLay4Ndet;
-    if (fAddOnlySegment>=0) {
-        iSegmentMin = fAddOnlySegment;
-        iSegmentMax = fAddOnlySegment+1;
-    }
+Int_t AliITSv11GeometrySDD::
+GetCurrentLayLaddDet(Int_t &lay, Int_t &ladd, Int_t&det) const {
+  //
+  // Function which gives the layer, ladder and det.
+  // index of the current volume. To be used in
+  // AliITS::StepManager()
+  //
 
-    for (Int_t i=iSegmentMin; i<iSegmentMax; i++) {
+  if (gGeoManager->GetLevel()<3) return kFALSE;
+  // Get the det index :
+  TGeoNode *node = gGeoManager->GetMother(2);
+  if (!node) return kFALSE;
+  det = node->GetNumber()+1;
 
-        Double_t localZ = fLay4sensorZPos[i];
-        Double_t localY = fLadWaferSep/2+fWaferThickness/2;
-        if (i%2==0)
-            localY = -localY;
-        sprintf(transName, "ITSsddLay4SensorPos%i", i);
-        TGeoTranslation *sensorPos = new TGeoTranslation(transName, 0,
-                                                        localY, localZ);
-        virtualDet->AddNode(vSDD, i, sensorPos);
-    }
-    virtualDet->SetVisibility(kFALSE);
-    return virtualDet;
+  // Get the ladder index :
+  node = gGeoManager->GetMother(3);
+  if (!node) return kFALSE;
+  ladd = node->GetNumber()+1;
+
+ // Get the layer index :
+  if (node->GetNdaughters()==fgkLay3Ndet)
+    lay = 1;
+  else lay = 2;
+
+  return kTRUE;
 };
index b15d98065382e63530ee69b19a0463ea54ece078..b2268abf8b6f731566b2390d091719a439aae933 100755 (executable)
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-// Ludovic Gaudichet (Ludovic.Gaudichet@to.infn.it)
+//*************************************************************************
+// class AliITSv11GeometrySDD
+// Ludovic Gaudichet                                   gaudichet@to.infn.it
+//*************************************************************************
 
 class TGeoVolume;
+class TGeoTranslation;
 class TGeoCombiTrans;
 class TGeoArb8;
 class TGeoNode;
+class TGeoMedium;
+class TGeoMatrix;
+class AliITSgeom;
+class AliITSv11GeomCableFlat;
 
-#include <TObjArray.h>
-
-//----------------------------------------------------------------------
-class AliITSv11GeomSDDcable: public TObject {
- public:
-  AliITSv11GeomSDDcable():TObject(){fInitialNode = 0; fPointArray.SetOwner(); };
-  virtual ~AliITSv11GeomSDDcable();
-  void AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt, Double_t *coord);
-  Int_t GetNCheckPoints() {return fVolumeArray.GetEntriesFast();};
-  Int_t GetCheckPoint( Int_t iCheckPt, Int_t nOccur, Int_t motherLevel,
-                      Double_t *coord);
-  void SetInitialNode(TGeoVolume *vol);
-  void ResetInitialNode();
-
- protected:
-  bool CheckDaughter(Int_t i, TGeoNode* node);
-
-  Int_t fNodeInd[50];
-  TObjArray fVolumeArray;
-  TObjArray fPointArray;
-  TGeoVolume *fCurrentVol;
-  TGeoNode *fInitialNode;
-
-  ClassDef(AliITSv11GeomSDDcable,1) // ITS v11 SDD cable geometry
-};
-
-
-
-//----------------------------------------------------------------------
-class AliITSv11GeomSDDcableNap : public AliITSv11GeomSDDcable {
- public:
-  AliITSv11GeomSDDcableNap(Double_t width, Double_t thick);
-  virtual ~AliITSv11GeomSDDcableNap() {};
-  Int_t CreateAndInsertCableSegment(Int_t p1, Int_t p2, TGeoVolume *motherVol);
- protected:
-  Double_t fWidth;
-  Double_t fThick;
-
-  ClassDef(AliITSv11GeomSDDcableNap,1) // ITS v11 SDD cable Nap geometry
-};
+#include "AliITSv11Geometry.h"
 
 
-
-//----------------------------------------------------------------------
 class AliITSv11GeometrySDD : public AliITSv11Geometry {
 
  public:
   AliITSv11GeometrySDD();
   AliITSv11GeometrySDD(Int_t debug);
-  virtual ~AliITSv11GeometrySDD(){};
+  AliITSv11GeometrySDD(const AliITSv11GeometrySDD &source);
+  AliITSv11GeometrySDD& operator=(const AliITSv11GeometrySDD &source);
+  virtual ~AliITSv11GeometrySDD();
 
   // Main functions
-  virtual void Layer3(TGeoVolume *Moth);
-  virtual void Layer4(TGeoVolume *Moth);
+  virtual void  Layer3(TGeoVolume *moth);
+  virtual void  Layer4(TGeoVolume *moth);
+  virtual Int_t ExportSensorGeometry(AliITSgeom *geom, Int_t iLaySDD,
+                                     Int_t startMod);
+  virtual Int_t GetCurrentLayLaddDet(Int_t &lay, Int_t &ladd, Int_t&det) const;
 
   // Functions for coding, testing, debugging 
-  void ShowOnePiece(TGeoVolume *Moth);
-  void CheckOverlaps(Double_t precision = 0.01);
-  void AddOnlySegment(Int_t i) { fAddOnlySegment=i; };
-  void AddOnlyLay3Ladder(Int_t min,Int_t max){
-    fAddOnlyLadder3min = min; fAddOnlyLadder3max = max; };
-  void AddOnlyLay4Ladder(Int_t min,Int_t max) {
-    fAddOnlyLadder4min = min; fAddOnlyLadder4max = max;};
-
-  virtual void SetGeomParameters();
-
-
-  AliITSv11GeomSDDcable cable;
+  void          AddHybrids(bool b)     {fAddHybrids    = b;};
+  void          AddSensors(bool b)     {fAddSensors    = b;};
+  void          AddHVcables(bool b)    {fAddHVcables   = b;};
+  void          AddCables(bool b)      {fAddCables     = b;};
+  void          AddCoolingSyst(bool b) {fAddCoolingSyst= b;};
+
+  void          CheckOverlaps(Double_t precision = 0.01);
+  void          AddOnlyLay3Ladder(Int_t min,Int_t max){
+                  fAddOnlyLadder3min = min; fAddOnlyLadder3max = max; };
+  void          AddOnlyLay4Ladder(Int_t min,Int_t max) {
+                  fAddOnlyLadder4min = min; fAddOnlyLadder4max = max;};
+  void          ShowOnePiece(TGeoVolume *Moth);
+
+  virtual void  SetParameters();
+  TGeoVolume*   GetMotherVolume() const { return fMotherVol;};
+  const char*   GetSenstiveVolumeMame() const {return fgSDDsensitiveVolName;};
 
   private:
 
-  // Create ladder virtual volumes and its detectors (inside layers 3 and 4)
-  virtual TGeoVolume* CreateLay3Ladder();
-  virtual TGeoVolume* CreateLay3Detectors();
-  virtual TGeoVolume* CreateLay4Ladder();
-  virtual TGeoVolume* CreateLay4Detectors();
-
+  // Create ladder virtual volumes and its detectors
+  virtual TGeoVolume*  CreateLadder(Int_t iLay);
+  virtual TGeoVolume*  CreateDetectors(Int_t iLay);
   // Create virtual volumes inside a ladder volume
-  virtual TGeoVolume* CreateLadderSegment(Int_t iLay, Int_t iSeg);
-  virtual TGeoVolume* CreateEndLadder(Int_t iLay, Int_t);
-  virtual TGeoVolume* CreateHybrid(Int_t iSeg);
-
-
-  // Create a TGeoCombiTrans : general rotation in phi and (dy,dz) translation 
+  virtual TGeoVolume*  CreateLadderSegment(Int_t iLay, Int_t iSeg);
+  virtual TGeoVolume*  CreateEndLadder(Int_t iLay);
+  // Create some basic objects  
+  virtual TGeoVolume*  CreateHybrid(Int_t iLRSide);
+  virtual TGeoVolume*  CreatePinSupport();
+  virtual TGeoVolume*  CreateCoolPipeSupportL();
+  virtual TGeoVolume*  CreateCoolPipeSupportR();
+  virtual TGeoVolume*  CreateSDDsensor();
+  virtual TGeoVolume*  CreateBaseThermalBridge();
+  void                 CreateBasicObjects();
+
+
+  // Check that the nedium exists
+  virtual TGeoMedium* GetMedium(const char* mediumName);
+
+  // Create a TGeoCombiTrans: general rotation in phi and (dy,dz) translation 
   TGeoCombiTrans* CreateCombiTrans( const char *name,
                                    Double_t dy, Double_t dz, Double_t dphi);
 
   // add (dx,dy,dz) translation to a initial TGeoCombiTrans
   void AddTranslationToCombiTrans( TGeoCombiTrans* ct,
-                                   Double_t dx=0, Double_t dy=0, Double_t dz=0);
+                         Double_t dx=0, Double_t dy=0, Double_t dz=0) const;
 
   // Create one side of the CF corner of the CF structure
   TGeoArb8* CreateLadderSide( Double_t dz, Double_t angle, Double_t xSign,
                              Double_t L, Double_t H, Double_t l);
 
-  // Create de CF structure in the ladder segment
-  void AddLadderCFstruct(Double_t dy, TGeoVolume* vol);
-
-  // Create a pin support object
-  virtual TGeoVolume* CreatePinSupport();
-
-  virtual TGeoVolume* CreateCoolPipeSupportL();
-  virtual TGeoVolume* CreateCoolPipeSupportR();
-
-  // Create a SDD detector object
-  virtual TGeoVolume* CreateSDDsensor();
-
-  // Create the base of the thermal bridge, supporting hybrids on ladder
-  virtual TGeoVolume* CreateBaseThermalBridge();
-
-  //**************************************************
-
-  Int_t fAddOnlyLadder3min;
-  Int_t fAddOnlyLadder3max;
-  Int_t fAddOnlyLadder4min;
-  Int_t fAddOnlyLadder4max;
-  Int_t fAddOnlySegment;
-  Int_t fColorCarbonFiber;
-  Int_t fColorRyton;
-  Int_t fColorPhynox;
-  Int_t fColorSilicon;
-
-  bool fCoolingOn;
-
-  // parameters of the SDD geometry :
-  static const Double_t fLay3Rmin;
-  static const Double_t fLay3Rmax;
-  static const Double_t fLay3Length;
-  static const Double_t fLay3LadderLength;
-  static const Double_t fLay3DetLongRadius;
-  static const Double_t fLay3LaddTopCornerEnd;
-  static const Double_t fLay3ZPlusEndLength;
-  static const Int_t    fLay3Nladd;
-  static const Int_t    fLay3Ndet;
-  static const Double_t fLay3DetShortRadius;
-
-  static const Double_t fLay4Rmin;
-  static const Double_t fLay4Rmax;
-  static const Double_t fLay4Length;
-  static const Double_t fLay4LadderLength;
-  static const Double_t fLay4LaddTopCornerEnd;
-  static const Double_t fLay4ZPlusEndLength;
-  static const Int_t    fLay4Nladd;
-  static const Int_t    fLay4Ndet;
-  static const Double_t fLay4DetShortRadius;
-  static const Double_t fLay4DetLongRadius;
-
-  static const Double_t fSegmentLength;
-  static const Double_t fLadderWidth;
-  static const Double_t fLadderHeight;
-  static const Double_t fLadderBeamRadius;
-  static const Double_t fLadderLa;
-  static const Double_t fLadderHa;
-  static const Double_t fLadderLb;
-  static const Double_t fLadderHb;
-  static const Double_t fLadderl;
-
-  static const Double_t fBottomBeamAngle;
-  static const Double_t fBeamSidePhi;
-
-  static const Double_t fWaferThickness;
-  static const Double_t fWaferWidth;
-  static const Double_t fWaferLength;
-  
-  static const Double_t fHybridLength;
-  static const Double_t fHybridWidth;
-  static const Double_t fHybridThBridgeThick;
-
-  static const Double_t fLadWaferSep;
-  static const Double_t fPinSuppWidth;
-  static const Double_t fPinSuppHeight;
-  static const Double_t fPinSuppRmax;
-  static const Double_t fPinR;
-  static const Double_t fPinSuppLength;
-  static const Double_t fPinSuppThickness;
-  static const Double_t fPinSuppConeAngle;
-  static const Double_t fPinDXminOnSensor;
-  static const Double_t fPinPinDDXOnSensor;
-  static const Double_t fPinDYOnSensor;
-
-  static const Double_t fCoolPipeInnerDiam;
-  static const Double_t fCoolPipeOuterDiam;
-  static const Double_t fCoolPipeSuppHeight;
-  static const Double_t fCoolPipeSuppMaxLength;
-  static const Double_t fCoolPipeSuppWidthExt;
-  static const Double_t fCoolPipeSuppWidthIn;
-  static const Double_t fCoolPipeSuppHoleDiam;
-  static const Double_t fCoolPipeSuppFulWidth;
-  static const Double_t fCoolPipeSuppTongW;
-  static const Double_t fCoolPipeSuppAngle;
-  static const Double_t fCoolPipeSuppSlitL;
-  static const Double_t fCoolPipeSuppAxeDist;
-  static const Double_t fLay3CoolPipeSuppH;
-  static const Double_t fLay4CoolPipeSuppH;
-
-  static const Double_t fBTBthick;
-  static const Double_t fBTBlength;
-  static const Double_t fBTBwidth;
-  static const Double_t fBTBaxisAtoBottom;
-  static const Double_t fBTBaxisAtoBase;
-  static const Double_t fRadiusAminBTB;
-  static const Double_t fRadiusBminBTB;
-  static const Double_t fBTBHoleLength;
-  static const Double_t fBTBHolewidth;
-  static const Double_t fBTBHoleRefX;
-  static const Double_t fBTBHoleRefY;
-
-  Double_t fLay3LaddShortRadius;
-  Double_t fLay3LaddLongRadius;
-
-  Double_t fLay4LaddShortRadius;
-  Double_t fLay4LaddLongRadius;
-
-  Double_t fLay3sensorZPos[6];
-  Double_t fLay4sensorZPos[8];
-
+  //----------------------------
+  TGeoVolume* fPinSupport;        //!  pins glued to sensors
+  TGeoVolume* fCoolPipeSupportL;  //!  half of cooling pipe support
+  TGeoVolume* fCoolPipeSupportR;  //!  half of cooling pipe support
+  TGeoVolume* fSDDsensor;         //!  sensor and HV cables on it
+  TGeoVolume* fBaseThermalBridge; //!  Base of hybrid thermal bridge
+  TGeoVolume* fHybrid;            //!  hybrid volume
+
+  static const Int_t fgkNladdSegCommonVol = 19;       //  Number of vol.
+  TGeoVolume* fLaddSegCommonVol[fgkNladdSegCommonVol];//! volumes in ladder
+  TGeoMatrix* fLaddSegCommonTr[fgkNladdSegCommonVol]; //! their transf.
+
+  AliITSv11GeomCableFlat *fDigitCableLay3A; // layer 3 cables, side A
+  AliITSv11GeomCableFlat *fDigitCableLay3B; // layer 3 cables, side A
+  AliITSv11GeomCableFlat *fDigitCableLay4A; // layer 4 cables, side B
+  AliITSv11GeomCableFlat *fDigitCableLay4B; // layer 4 cables, side B
+
+  TGeoVolume *fMotherVol;    //! mother volume given in LayerX() funct.
+  bool  fAddHybrids;         //  Insert hybrids ?   (default TRUE)
+  bool  fAddSensors;         //  Insert sensors ?   (default TRUE)
+  bool  fAddHVcables;        //  Insert HV cables ? (default TRUE)
+  bool  fAddCables;          //  Insert cables ?    (default TRUE)
+  bool  fAddCoolingSyst;     //  Insert cooling system ? (default TRUE)
+  bool  fCoolingOn;          //  Insert cooling fluid ?  (default TRUE)
+  Int_t fAddOnlyLadder3min;  //  first ladder index
+  Int_t fAddOnlyLadder3max;  //  last  ladder index
+  Int_t fAddOnlyLadder4min;  //  first ladder index
+  Int_t fAddOnlyLadder4max;  //  last  ladder index
+  Int_t fColorCarbonFiber;   //  display colors
+  Int_t fColorRyton;         //  ===
+  Int_t fColorPhynox;        //  ===
+  Int_t fColorSilicon;       //  ===
+  Int_t fColorAl;            //  ===
+  Int_t fColorPolyhamide;    //  ===
+  Int_t fColorGlass;         //  ===
+  Int_t fColorSMD;           //  ===
+  Int_t fColorSMDweld;       //  ===
+
+  //--------------------------------------  parameters for the SDD geometry
+
+  static const char* fgSDDsensitiveVolName;       // name of sensitive vol
+
+  static const Int_t    fgkLay3Nladd;             // 14
+  static const Int_t    fgkLay3Ndet;              //  6
+  static const Double_t fgkLay3Rmin;              // min. radius of tube
+  static const Double_t fgkLay3Rmax;              // max. radius of tube
+  static const Double_t fgkLay3Length;            // length of layer 3 tube
+  static const Double_t fgkLay3LadderLength;      // tot. length of ladder
+  static const Double_t fgkLay3DetShortRadius;    // radius from beam axis
+  static const Double_t fgkLay3DetLongRadius;     // radius from beam axis
+  static const Double_t fgkLay3LaddTopCornerEnd;  // Ends of ladder 3
+  static const Double_t fgkLay3ZPlusEndLength;    // ===
+
+  static const Int_t    fgkLay4Nladd;             // 22
+  static const Int_t    fgkLay4Ndet;              //  8
+  static const Double_t fgkLay4Rmin;              // min. radius of tube
+  static const Double_t fgkLay4Rmax;              // max. radius of tube
+  static const Double_t fgkLay4Length;            // length of layer 4 tube
+  static const Double_t fgkLay4LadderLength;      // tot. length of ladder
+  static const Double_t fgkLay4DetShortRadius;    // radius from beam axis
+  static const Double_t fgkLay4DetLongRadius;     // radius from beam axis
+  static const Double_t fgkLay4LaddTopCornerEnd;  // Ends of ladder 3
+  static const Double_t fgkLay4ZPlusEndLength;    // ===
+
+  static const Double_t fgkSegmentLength;         // length of 1 ladder seg.
+  static const Double_t fgkLadderWidth;           // carbon fiber structure 
+  static const Double_t fgkLadderHeight;          // including bottom beam
+  static const Double_t fgkLadderSegBoxDW;        // To include hybrids in box
+  static const Double_t fgkLadderSegBoxDH;        // To include hybrids in box
+
+  static const Double_t fgkLadderBeamRadius;      // carbon fiber beam radius
+  static const Double_t fgkLadderLa;              // parameters defining
+  static const Double_t fgkLadderHa;              //   the V side shape
+  static const Double_t fgkLadderLb;              //   of the carbon
+  static const Double_t fgkLadderHb;              //   fiber ladder
+  static const Double_t fgkLadderl;               //   ============
+
+  static const Double_t fgkBottomBeamAngle;       // bottom beam angle
+  static const Double_t fgkBeamSidePhi;           // side beam angle
+
+  static const Double_t fgkWaferThickness;        // sensor thickness (Y)
+  static const Double_t fgkWaferWidth;            // width (X)
+  static const Double_t fgkWaferLength;           // length (Z)
+  static const Double_t fgkWaferThickSens;        // sensitive volume thich
+  static const Double_t fgkWaferWidthSens;        // sens. volume width
+  static const Double_t fgkWaferLengthSens;       // sens. volume length
+
+  static const Double_t fgkSensorGlassLX;         // dimensions of glass
+  static const Double_t fgkSensorGlassLZ;         //  (on which pins are
+  static const Double_t fgkSensorGlassLY;         //   glued)
+  static const Double_t fgkGlassDXOnSensor;       // Position of glass
+  static const Double_t fgkGlassDZOnSensor;       //   on sensor
+
+  static const Double_t fgkLadWaferSep;           // ladder-sensor dist.
+  static const Double_t fgkPinR;                  // pins radius
+  static const Double_t fgkPinSuppWidth;          // ===
+  static const Double_t fgkPinSuppHeight;         // ===
+  static const Double_t fgkPinSuppRmax;           // Parameters for pin
+  static const Double_t fgkPinSuppLength;         //   supports on
+  static const Double_t fgkPinSuppThickness;      //   carbon fiber
+  static const Double_t fgkPinSuppConeAngle;      //   ladder
+  static const Double_t fgkPinDXminOnSensor;      // ===
+  static const Double_t fgkPinPinDDXOnSensor;     // ===
+  static const Double_t fgkPinDYOnSensor;         // ===
+
+  static const Double_t fgkCoolPipeInnerDiam;     // Water cooling
+  static const Double_t fgkCoolPipeOuterDiam;     //   pipe
+  static const Double_t fgkLay3CoolPipeSuppH;     // Heights of water
+  static const Double_t fgkLay4CoolPipeSuppH;     //   pipes on ladders
+  static const Double_t fgkCoolPipeSuppHeight;    // ===
+  static const Double_t fgkCoolPipeSuppMaxLength; // ===
+  static const Double_t fgkCoolPipeSuppWidthExt;  // Parameters for
+  static const Double_t fgkCoolPipeSuppWidthIn;   //  cooling pipes
+  static const Double_t fgkCoolPipeSuppHoleDiam;  //  on carbon fiber
+  static const Double_t fgkCoolPipeSuppFulWidth;  //  ladder 
+  static const Double_t fgkCoolPipeSuppTongW;     // ===
+  static const Double_t fgkCoolPipeSuppAngle;     // ===
+  static const Double_t fgkCoolPipeSuppSlitL;     // ===
+  static const Double_t fgkCoolPipeSuppAxeDist;   // ===
+
+  static const Double_t fgkBTBthick;              // BTB for :
+  static const Double_t fgkBTBlength;             // Base of Thermal Bridge
+  static const Double_t fgkBTBwidth;              // =====================
+  static const Double_t fgkBTBaxisAtoBottom;      // axis A is the same as
+  static const Double_t fgkBTBaxisAtoBase;        // the cooling pipe axis
+  static const Double_t fgkRadiusAminBTB;         // ===
+  static const Double_t fgkRadiusBminBTB;         // ===
+  static const Double_t fgkBTBHoleLength;         // ===
+  static const Double_t fgkBTBHolewidth;          // ===
+  static const Double_t fgkBTBHoleRefX;           // ===
+  static const Double_t fgkBTBHoleRefY;           // ===
+
+  static const Double_t fgkHybridLength;          // Hybrid parameters :
+  static const Double_t fgkHybridWidth;           // ===
+  static const Double_t fgkHybridAngle;           // Hybrid on ladder in phi
+
+  static const Double_t fgkHybRndHoleRad;         // ===
+  static const Double_t fgkHybRndHoleZ;           // ===
+  static const Double_t fgkHybRndHoleX;           // ===
+
+  static const Double_t fgkHybFLlowHoleDZ;        // FLlow : low flex
+  static const Double_t fgkHybFLlowHolePasDX;     // ===
+  static const Double_t fgkHybFLlowHoleAmbDX;     // ===
+  // (center of ships to the border)
+  static const Double_t fgkHybFLlowChipZ4;        // Z1 to Z4 : position
+  static const Double_t fgkHybFLlowChipZ3;        //   in z of the chip
+  static const Double_t fgkHybFLlowChipZ2;        //   centers
+  static const Double_t fgkHybFLlowChipZ1;        // ===
+  static const Double_t fgkHybFLlowPasX;          // Pascal center X pos
+  static const Double_t fgkHybFLlowAmbX;          // Ambra center X pos
+  static const Double_t fgkHybChipsDZ;            // Z dimension of chips
+  static const Double_t fgkHybPascalDX;           // X dimension of Pascal
+  static const Double_t fgkHybAmbraDX;            // X dimension of Ambra
+  static const Double_t fgkHybFLUpperWidth;       // bFLUpper : upper flex
+  static const Double_t fgkHybFLUpperLength;      // ===
+  static const Double_t fgkHybFLUpperAlDZ;        // ===
+  static const Double_t fgkHybFLUpperAldx;        // ===
+
+  static const Double_t fgkHybridThBridgeThick;   // Thicknesses :
+  static const Double_t fgkHybAlThick;            // ===
+  static const Double_t fgkHybUpThick;            // ===
+  static const Double_t fgkHybGlueScrnThick;      // ===
+  static const Double_t fgkHybGlueLowThick;       // ===
+  static const Double_t fgkHybGlueUpThick;        // ===
+  static const Double_t fgkHybAlCCThick;          // ===
+  static const Double_t fgkHybUpCCThick;          // ===
+  static const Double_t fgkHybChipThick;          // ===
+  static const Double_t fgkHybGlueAgThick;        // ===
+  static const Double_t fgkHybUnderNiThick;       // ===
+  static const Int_t    fgkNHybSMD;               // Number of SMD
+  static const Double_t fgkHybSMDposX[25];        // X pos. of SMD
+  static const Double_t fgkHybSMDposZ[25];        // Z pos. of SMD
+  static const Double_t fgkHybSMDmiddleW;         // SMD width
+  static const Double_t fgkHybSMDmiddleL;         // SMD length
+  static const Double_t fgkHybSMDendW;            // end SMD witdh
+  static const Double_t fgkHybSMDendL;            // end SMD length
+  static const Double_t fgkHybSMDheight;          // SMD height
+
+  static const Double_t fgkDigitCablWidth;        // Digital
+  static const Double_t fgkDigitCablAlThick;      // cables
+  static const Double_t fgkDigitCablPolyThick;    // ===
+
+  //HV cables
+  static const Double_t fgkWaHVcableAlThick;      // Wrap-around
+  static const Double_t fgkWaHVcablePolyThick;    //   High Voltage
+  static const Double_t fgkWaHVcableLength;       //   cables
+  static const Double_t fgkWaHVcableWitdh;        //   (on sensor)
+  static const Double_t fgkWaHVcableDW;           // ===
+
+  static const Double_t fgkTransitHVAlThick;      // Transition
+  static const Double_t fgkTransitHVPolyThick;    //   High Voltage
+  static const Double_t fgkTransitHVHeadLX;       //   cables
+  static const Double_t fgkTransitHVHeadLZ;       //   (on sensor)
+  static const Double_t fgkTransitHVBondingLZ;    // ===
+  static const Double_t fgkTransitHVtailLength;   // ===
+  static const Double_t fgkTransitHVtailWidth;    // ===
+  static const Double_t fgkTransitHVtailXpos;     // ===
+  static const Double_t fgkTransitHVsideLZ;       // ===
+  static const Double_t fgkTransitHVsideLeftZ;    // ===
+  static const Double_t fgkTransitHVsideRightZ;   // ===
+
+  static const Double_t fgkLongHVcablePolyThick;  // Long High
+  static const Double_t fgkLongHVcableAlThick;    //   Voltage
+  static const Double_t fgkLongHVcableSeparation; //   cables
+
+  static const Double_t fgkmu;  // 1 micron, or more for debugging
+
+  // calculated parameters
+  Double_t fLay3LadderUnderSegDH;  // To include HVcables in box
+  Double_t fLay4LadderUnderSegDH;  // To include HVcables in box
+  Double_t fLay3LaddShortRadius;   // ladder 3 to beam axis radius
+  Double_t fLay3LaddLongRadius;    // ladder 3 to beam axis radius
+  Double_t fLay4LaddShortRadius;   // ladder 4 to beam axis radius
+  Double_t fLay4LaddLongRadius;    // ladder 4 to beam axis radius
+
+  // parameters that be modified
+  Double_t fLay3sensorZPos[6];     // Z pos of sensors in layer 3
+  Double_t fLay4sensorZPos[8];     // Z pos of sensors in layer 4
 
   ClassDef(AliITSv11GeometrySDD,1) // ITS v11 SDD geometry
 };
 
 
-
-
-
 #endif
index dffd0ba209d96851a53065840b051d0f03dd3bf1..e0945d22b67c9a4afe1571742f8027d062278d9e 100644 (file)
 #pragma link C++ class  AliITSvSPD02+;
 #pragma link C++ class  AliITSvSDD03+;
 #pragma link C++ class  AliITSvSSD03+;
-//#pragma link C++ class  AliITSv11+;
-//#pragma link C++ class  AliITSv11Geometry+;
+#pragma link C++ class  AliITSv11+;
+#pragma link C++ class  AliITSv11GeomCable+;
+#pragma link C++ class  AliITSv11GeomCableFlat+;
+#pragma link C++ class  AliITSv11GeomCableRound+;
+#pragma link C++ class  AliITSv11Geometry+;
 //#pragma link C++ class  AliITSv11GeometrySupport+;
 //#pragma link C++ class  AliITSv11GeometrySPD+;
-//#pragma link C++ class  AliITSv11GeometrySDD+;
+#pragma link C++ class  AliITSv11GeometrySDD+;
 //#pragma link C++ class  AliITSv11GeomSDDcable+;
 //#pragma link C++ class  AliITSv11GeomSDDcableNap+;
 //
index d641623c60f4cb08b4f98be21b1f76e85ec9ca45..46e980151150678f4ac7bf6b88c02ac2e209ecdf 100644 (file)
@@ -95,11 +95,14 @@ SRCS =      AliITS.cxx \
                AliITSRawClusterSPD.cxx \
                AliITSRawClusterSDD.cxx \
                AliITSRawClusterSSD.cxx\
-          AliITSspdTestBeam.cxx \
+                AliITSspdTestBeam.cxx \
                AliITSReconstructor.cxx \
-
-#          AliITSv11.cxx \
-#          AliITSv11Geometry.cxx \
+                AliITSv11.cxx \
+                AliITSv11GeomCable.cxx \
+                AliITSv11GeomCableFlat.cxx \
+                AliITSv11GeomCableRound.cxx \
+                AliITSv11Geometry.cxx \
+                AliITSv11GeometrySDD.cxx \
 #          AliITSv11GeometrySupport.cxx \
 #          AliITSv11GeometrySPD.cxx \
 #          AliITSv11GeometrySDD.cxx \