Another histos for lumi
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySDD.cxx
index 4cea508..31644bb 100755 (executable)
@@ -30,6 +30,7 @@
 
 
 // General Root includes
+#include <Riostream.h>
 #include <TMath.h>
 
 // Root Geometry includes
 #include <TGeoPcon.h>
 #include <TGeoTorus.h>
 
-#include "AliITSgeom.h"
-#include "AliITSgeomSDD.h"
 #include "AliITSv11GeometrySDD.h"
 #include "AliITSv11GeomCableFlat.h"
 #include "AliITSv11GeomCableRound.h"
 
-const char*    AliITSv11GeometrySDD::fgSDDsensitiveVolName3 = "ITSsddSensitivL3";
-const char*    AliITSv11GeometrySDD::fgSDDsensitiveVolName4 = "ITSsddSensitivL4";
+const char*    AliITSv11GeometrySDD::fgkSDDsensitiveVolName3 = "ITSsddSensitivL3";
+const char*    AliITSv11GeometrySDD::fgkSDDsensitiveVolName4 = "ITSsddSensitivL4";
 const Double_t AliITSv11GeometrySDD::fgkSegmentLength     = 37.21*2*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLadderWidth       = 50.0*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLadderHeight      = 30.0*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDW    =  7.5*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDH    =  7.1*fgkmm;
-const Double_t AliITSv11GeometrySDD::fgkLadderSegBoxDHCorr=  2.1*fgkmm;
 
 const Double_t AliITSv11GeometrySDD::fgkLadderBeamRadius  =  0.6*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkLadderLa          =  3.*fgkmm;
@@ -101,7 +99,7 @@ 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::fgkBTBaxisAtoBase     =  2.2*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkRadiusAminBTB      =  1. *fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkRadiusBminBTB      =  0.53 *fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkBTBHoleLength      = 15 *fgkmm;
@@ -136,7 +134,7 @@ const Double_t AliITSv11GeometrySDD::fgkEndLaddCardsShortRadiusLay4 = fgkLay4Det
 const Double_t AliITSv11GeometrySDD::fgkDistEndLaddCardsLadd = 0.*fgkmm;
 
 //hybrid 
-const Double_t AliITSv11GeometrySDD::fgkHybridAngle       = 46;           // approx !!!
+const Double_t AliITSv11GeometrySDD::fgkHybridAngle       = 48.5;           // approx !!!
 // Origine taken at the hybrid corner :
 const Double_t AliITSv11GeometrySDD::fgkHybridLength      = 65*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkHybridWidth       = 41*fgkmm;
@@ -162,9 +160,9 @@ 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::fgkHybCC2SensorLen   = 12.000*fgkmm;
+const Double_t AliITSv11GeometrySDD::fgkHybCC2SensorLen   =  9.500*fgkmm;
 const Double_t AliITSv11GeometrySDD::fgkHybCC2SensorWid   =  1.490*fgkcm; //???
-const Double_t AliITSv11GeometrySDD::fgkHybCC2SensorAng   = 40.0;
+const Double_t AliITSv11GeometrySDD::fgkHybCC2SensorAng   = 15.0;
 
 const Double_t AliITSv11GeometrySDD::fgkmu = 1*fgkmicron; // 1*fgkmicron; // can be increase for checking thin objects
 const Double_t AliITSv11GeometrySDD::fgkHybridThBridgeThick =  0.25*fgkmm;               // ???
@@ -499,11 +497,8 @@ const Double_t AliITSv11GeometrySDD::fgkSDDCableR5    =  37*fgkcm; // third part
 const Double_t AliITSv11GeometrySDD::fgkSDDCableZ5    =  65*fgkcm; // third part of "cable cone"
 
 
-
-
-
-
-
+using std::endl;
+using std::cout;
 ClassImp(AliITSv11GeometrySDD)
 
 //________________________________________________________________________
@@ -728,7 +723,7 @@ void AliITSv11GeometrySDD::SetParameters() {
   // Define display colors and the non constant geometry parameters
   //
 
-  Double_t detLadderDist = 8*fgkmm; 
+  Double_t detLadderDist = 8.4*fgkmm; 
 
   fLay3LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
   fLay4LadderUnderSegDH = detLadderDist - (fgkWaHVcableAlThick+fgkWaHVcablePolyThick);
@@ -773,7 +768,7 @@ TGeoMedium* AliITSv11GeometrySDD::GetMedium(const char* mediumName) {
   //
 
   char ch[30];
-  sprintf(ch, "ITS_%s",mediumName);
+  snprintf(ch, 30, "ITS_%s",mediumName);
   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
   if (! medium)
     printf("Error(AliITSv11GeometrySDD)::medium %s not found !\n", mediumName);
@@ -831,6 +826,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
   TGeoMedium *stainless       = GetMedium("AISI304L$"); // for screws
   TGeoMedium *coolerMediumSDD = GetMedium("WATER$");
   TGeoMedium *raccordMedium   = GetMedium("INOX$");  // same as AISI 316-L
+  TGeoMedium *copperMedium    = GetMedium("COPPER$");
 
   //********************************************************************
   // pieces of the carbon fiber structure
@@ -981,6 +977,14 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
   TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans
     (0,-(fgkLadderHeight/2-fgkLadderBeamRadius)-dy,fgkSegmentLength/4, bottomBeamRot5);
 
+  // The ground wire running on the top vertex - M.S. 12 nov 2013
+  TGeoTube *groundWire = new TGeoTube(0, fgkEndLadderEarthCableR, fgkSegmentLength/2);
+  TGeoVolume *groundWireVol = new TGeoVolume("ITSsddGroundWire", groundWire,
+                                            copperMedium);
+  groundWireVol->SetLineColor(41); // should be something brown-ish
+  TGeoTranslation *trGroundWire = new TGeoTranslation(0,
+                              fgkLadderHeight/2-5*fgkEndLadderEarthCableR, 0);
+
   fLaddSegCommonVol[0] = cfLaddTopVol1;  fLaddSegCommonTr[0] = trTop1;
   fLaddSegCommonVol[1] = cfLaddTopVol2;  fLaddSegCommonTr[1] = trTop1;
   fLaddSegCommonVol[2] = cfLaddSideVol1; fLaddSegCommonTr[2] = ctSideR;
@@ -1000,6 +1004,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
   fLaddSegCommonVol[16]= bottomBeam2Vol; fLaddSegCommonTr[16]= bottomBeamTransf3;
   fLaddSegCommonVol[17]= bottomBeam3Vol; fLaddSegCommonTr[17]= bottomBeamTransf4;
   fLaddSegCommonVol[18]= bottomBeam3Vol; fLaddSegCommonTr[18]= bottomBeamTransf5;
+  fLaddSegCommonVol[19]= groundWireVol;  fLaddSegCommonTr[19]= trGroundWire;
 
  
   //********************************************************************
@@ -1007,7 +1012,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
   //********************************************************************
   char cableName[30];
   for (Int_t i=0; i<fgkLay3Ndet; i++) {
-    sprintf(cableName, "digitCableLay3A_%i",i);
+    snprintf(cableName, 30, "digitCableLay3A_%i",i);
     fDigitCableLay3A[i].SetName(cableName);
     fDigitCableLay3A[i].SetWidth(fgkDigitCablWidth);
     fDigitCableLay3A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
@@ -1015,7 +1020,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
     fDigitCableLay3A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
                                  fColorPolyhamide);
     fDigitCableLay3A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
-    sprintf(cableName, "digitCableLay3B_%i",i);
+    snprintf(cableName, 30, "digitCableLay3B_%i",i);
     fDigitCableLay3B[i].SetName(cableName);
     fDigitCableLay3B[i].SetWidth(fgkDigitCablWidth);
     fDigitCableLay3B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
@@ -1025,7 +1030,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
     fDigitCableLay3B[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
   };
   for (Int_t i=0; i<fgkLay4Ndet; i++) {
-    sprintf(cableName, "digitCableLay4A_%i",i);
+    snprintf(cableName, 30, "digitCableLay4A_%i",i);
     fDigitCableLay4A[i].SetName(cableName);
     fDigitCableLay4A[i].SetWidth(fgkDigitCablWidth);
     fDigitCableLay4A[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
@@ -1033,7 +1038,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
     fDigitCableLay4A[i].SetLayer( 0, fgkDigitCablPolyThick, polyhamideSDD,
                                  fColorPolyhamide);
     fDigitCableLay4A[i].SetLayer(1, fgkDigitCablAlThick, alSDD, fColorAl);
-    sprintf(cableName, "digitCableLay4B_%i",i);
+    snprintf(cableName, 30, "digitCableLay4B_%i",i);
     fDigitCableLay4B[i].SetName(cableName);
     fDigitCableLay4B[i].SetWidth(fgkDigitCablWidth);
     fDigitCableLay4B[i].SetThickness(fgkDigitCablPolyThick+fgkDigitCablAlThick);
@@ -1061,7 +1066,7 @@ void AliITSv11GeometrySDD::CreateBasicObjects() {
 
   fLadderFoot = CreateLadderFoot();
   CreateLVCard();
-  fCardHV     = CreateHVCard(0);
+  fCardHV     = CreateHVCard();
   fCardCarlos = CreateCarlosCard(0);
 
   //==================
@@ -1183,7 +1188,7 @@ void AliITSv11GeometrySDD::ShowOnePiece(TGeoVolume *moth) {
 //   TGeoVolumeAssembly *highVCard = CreateHVCard( 4 );
 //   moth->AddNode(highVCard, 1, 0);
 
-//   TGeoVolumeAssembly *supportRing = CreateSupportRing( 4 );
+//   TGeoVolumeAssembly *supportRing = CreateSupportRing();
 //   moth->AddNode(supportRing, 1, 0);
 
 //   TGeoVolume *endLadderCards = CreateEndLadderCardsV( 4 );
@@ -1282,7 +1287,7 @@ void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
 
     Double_t ladderPhi = -3*dPhi+iLadd*dPhi;
-    sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
+    snprintf(rotName, 30, "ITSsddLay3Ladd%i",iLadd);
     Double_t minRadiusLadBox = fLay3LaddShortRadius-fLay3LadderUnderSegDH;
     if (iLadd%2 != 0)
       minRadiusLadBox = fLay3LaddLongRadius-fLay3LadderUnderSegDH;
@@ -1302,7 +1307,7 @@ void AliITSv11GeometrySDD::Layer3(TGeoVolume *moth) {
                                0, ladderPhi, kFALSE);
     virtualLayer3->AddNode(lay3Ladder, iLadd, ctLadd);
     ///////////////////////////////////////////////////
-    sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
+    snprintf(rotName, 30, "ITSsddLay3DetBox%i",iLadd);
     Double_t minRadiusDetBox = fgkLay3DetShortRadius;
     if (iLadd%2 != 0) minRadiusDetBox = fgkLay3DetLongRadius;
     minRadiusDetBox += detectorsThick/2;
@@ -1509,7 +1514,7 @@ void AliITSv11GeometrySDD::ForwardLayer3(TGeoVolume *moth) {
     Double_t dR = 0;
     if (iLadd%2 != 0) dR = fgkLay3DetLongRadius-fgkLay3DetShortRadius;
 
-    sprintf(rotName, "ITSsddLay3EndLadd%i",iLadd);
+    snprintf(rotName, 30, "ITSsddLay3EndLadd%i",iLadd);
 
     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, dR,
                                    fgkLay3Length/2, ladderPhi, kTRUE);
@@ -1568,7 +1573,7 @@ void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
 
   // placing virtual ladder and detectors volumes following ladder 
   // ordering convention
-  char rotName[20];
+  char rotName[30];
   Int_t iLaddMin = 0;
   Int_t iLaddMax = fgkLay4Nladd;
   if ((fAddOnlyLadder4min >= 0)&&(fAddOnlyLadder4max < fgkLay4Nladd)) {
@@ -1578,7 +1583,7 @@ void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
   for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
 
     Double_t ladderPhi = -5*dPhi + iLadd*dPhi;
-    sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
+    snprintf(rotName, 30, "ITSsddLay4Ladd%i",iLadd);
     Double_t minRadiusLadBox = fLay4LaddShortRadius-fLay4LadderUnderSegDH;
     if (iLadd%2 != 0)
       minRadiusLadBox = fLay4LaddLongRadius-fLay4LadderUnderSegDH;
@@ -1587,7 +1592,7 @@ void AliITSv11GeometrySDD::Layer4(TGeoVolume *moth) {
                                              0, ladderPhi, kTRUE);
     virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
     ///////////////////////////////////////////////////
-    sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
+    snprintf(rotName, 30, "ITSsddLay4DetBox%i",iLadd);
     Double_t minRadiusDetBox = fgkLay4DetShortRadius;
     if (iLadd%2 != 0)
       minRadiusDetBox = fgkLay4DetLongRadius;
@@ -1769,7 +1774,7 @@ void AliITSv11GeometrySDD::ForwardLayer4(TGeoVolume *moth) {
     if (iLadd%2 != 0)
       dR = fgkLay4DetLongRadius-fgkLay4DetShortRadius;
 
-    sprintf(rotName, "ITSsddLay4EndLadd%i",iLadd);
+    snprintf(rotName, 30, "ITSsddLay4EndLadd%i",iLadd);
 
     TGeoCombiTrans *ctEndLaddPos = CreateCombiTrans(rotName, dR,
                                   fgkLay4Length/2, ladderPhi, kTRUE);
@@ -1825,7 +1830,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
 
     //TGeoVolumeAssembly *laddSegment = CreateLadderSegment(iLay, iSegment);
     TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
-    sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
+    snprintf(transName, 30, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
     Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
                           + fgkSegmentLength/2;
     TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
@@ -1837,7 +1842,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
 
     TGeoVolume *laddSegment = CreateLadderSegment(iLay, iSegment);
     //TGeoVolumeAssembly *laddSegment = CreateLadderSegment(iLay, iSegment);
-    sprintf(transName, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
+    snprintf(transName, 30, "ITSsddLay%iLaddSeg%i", iLay, iSegment);
     Double_t segmentPos = fgkSegmentLength*(nDetectors/2-1-iSegment) 
                           + fgkSegmentLength/2;
     TGeoTranslation *segTr = new TGeoTranslation(transName, 0,
@@ -1897,7 +1902,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateLadder(Int_t iLay) {
   AliITSv11GeomCableFlat cableHV[fgkLay4Ndet];  // temp !!!
   char cableHVname[30];
   for (Int_t iSegment = 0; iSegment<nDetectors; iSegment++) {
-    sprintf(cableHVname,"ITSsddHVcable%i", iSegment);
+    snprintf(cableHVname,30,"ITSsddHVcable%i", iSegment);
     cableHV[iSegment].SetName(cableHVname);
     cableHV[iSegment].SetThickness(fgkLongHVcablePolyThick+fgkLongHVcableAlThick);
     cableHV[iSegment].SetWidth(fgkTransitHVtailWidth);
@@ -2243,7 +2248,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
   Double_t vX[3] = {1,0,0};
   for (Int_t i=0; i<3; i++) {
     char ch[20];
-    sprintf(ch, "lowFLpieceA%i", i+4);
+    snprintf(ch, 20, "lowFLpieceA%i", i+4);
     lowFLpiece.SetName(ch);
     lowFLpiece.SetWidth(zChips[i+1]-zChips[i]-fgkHybFLlowHoleDZ);
 
@@ -2257,7 +2262,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
     lowFLpiece.CreateAndInsertBoxCableSegment(1,90);
     lowFLpiece.ResetPoints();
 
-    sprintf(ch, "lowFLpieceB%i", i+4);
+    snprintf(ch, 20, "lowFLpieceB%i", i+4);
     lowFLpiece.SetName(ch);
     x1[0] = fgkHybridWidth/2 - piece3width;
     x2[0] = x1[0] - fgkHybFLlowHoleAmbDX;
@@ -2284,7 +2289,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
   char ch[20];
 
   for (Int_t i=0; i<4; i++) {
-    sprintf(ch, "pascalCC%i", i);
+    snprintf(ch, 20, "pascalCC%i", i);
     chip.SetName(ch);
     x1[0] = fgkHybFLlowPasX - fgkHybridWidth/2 - fgkHybPascalDX/2;
     x2[0] = x1[0] + fgkHybPascalDX;
@@ -2295,7 +2300,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
     chip.CreateAndInsertBoxCableSegment(1,-90);
     chip.ResetPoints();
 
-    sprintf(ch, "ambraCC%i", i);
+    snprintf(ch, 20, "ambraCC%i", i);
     chip.SetName(ch);
     x1[0] = fgkHybFLlowAmbX - fgkHybridWidth/2 - fgkHybAmbraDX/2;
     x2[0] = x1[0] + fgkHybAmbraDX;
@@ -2308,7 +2313,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
   //**************************************************** CC outside chips:
   // I don't think there is a second aluminium layer here ...
   for (Int_t i = 0; i<4; i++) {
-    sprintf(ch, "ccLayerA%i", i);
+    snprintf(ch, 20, "ccLayerA%i", i);
 
     AliITSv11GeomCableFlat ccLayer1(ch, 6.6*fgkmm, ccUpLayerTotThick);
     ccLayer1.SetInitialNode(hybrid);
@@ -2328,7 +2333,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
     ccLayer1.AddCheckPoint( hybrid, 1, x2, vX );
     ccLayer1.CreateAndInsertBoxCableSegment(1,-90);
 
-    sprintf(ch, "ccLayerB%i", i);
+    snprintf(ch, 20, "ccLayerB%i", i);
     AliITSv11GeomCableFlat ccLayer2(ch, fgkHybChipsDZ, ccUpLayerTotThick);
     ccLayer2.SetInitialNode(hybrid);
     ccLayer2.SetNLayers(2);
@@ -2342,7 +2347,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
     ccLayer2.AddCheckPoint( hybrid, 1, x2, vX );
     ccLayer2.CreateAndInsertBoxCableSegment(1,-90);
     ccLayer2.ResetPoints();
-    sprintf(ch, "ccLayerC%i", i);
+    snprintf(ch, 20, "ccLayerC%i", i);
     ccLayer2.SetName(ch);
     x1[0] =  -fgkHybridWidth/2 + fgkHybFLlowAmbX + fgkHybAmbraDX/2;
     x2[0] = fgkHybridWidth/2 - fgkHybFLUpperWidth + 3*fgkmm;
@@ -2356,35 +2361,41 @@ TGeoVolume* AliITSv11GeometrySDD::CreateHybrid(Int_t iLRSide) {
 
   //**************************************************** CC to sensors:
   // (alas, we cannot use GeomCableFlat here because section is not constant)
-    Double_t xcc[6],ycc[6];
+    Double_t xcc[8],ycc[8];
     xcc[0] = -0.5*ccLayer1.GetWidth();
     ycc[0] =  0;
     xcc[1] =  0.5*ccLayer1.GetWidth();
     ycc[1] =  0;
     xcc[2] = xcc[1];
-    ycc[2] = -fgkHybCC2SensorLen;
-    xcc[3] = xcc[2] - fgkHybCC2SensorWid;
+    ycc[2] = -fgkHybCC2SensorLen*0.8;
+    xcc[3] = xcc[2] + 0.1*fgkHybCC2SensorWid;
     ycc[3] = ycc[2];
     xcc[4] = xcc[3];
-    ycc[4] = 0.8*ycc[3];
-    xcc[5] = xcc[0];
-    ycc[5] = 0.2*ycc[3];
+    ycc[4] = -fgkHybCC2SensorLen;
+    xcc[5] = xcc[4] - fgkHybCC2SensorWid;
+    ycc[5] = ycc[4];
+    xcc[6] = xcc[5];
+    ycc[6] = 0.8*ycc[5];
+    xcc[7] = xcc[0];
+    ycc[7] = 0.2*ycc[5];
 
     TGeoXtru* ccToSensPoliSh = new TGeoXtru(2);
-    ccToSensPoliSh->DefinePolygon(6, xcc, ycc);
+    ccToSensPoliSh->DefinePolygon(8, xcc, ycc);
     ccToSensPoliSh->DefineSection(0, 0.);
     ccToSensPoliSh->DefineSection(1, ccLayer1.GetThickness());
 
-    sprintf(ch, "ccToSens%i", i);
+    snprintf(ch, 20, "ccToSens%i", i);
     TGeoVolume* ccToSensPoliVol = new TGeoVolume(ch, ccToSensPoliSh, polyhamideSDD);
     ccToSensPoliVol->SetLineColor(fColorPolyhamide);
 
     TGeoXtru* ccToSensAlSh = new TGeoXtru(2);
-    ccToSensAlSh->DefinePolygon(6, xcc, ycc);
+    xcc[6] += 0.001;
+    ycc[7] -= 0.001;
+    ccToSensAlSh->DefinePolygon(8, xcc, ycc);
     ccToSensAlSh->DefineSection(0, 0.);
     ccToSensAlSh->DefineSection(1, fgkHybAlCCThick);
 
-    sprintf(ch, "ccToSensAl%i", i);
+    snprintf(ch, 20, "ccToSensAl%i", i);
     TGeoVolume* ccToSensAlVol = new TGeoVolume(ch, ccToSensAlSh, alSDD50p100);
     ccToSensAlVol->SetLineColor(fColorAl);
 
@@ -2567,25 +2578,26 @@ TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
   TGeoXtru *segBox = new TGeoXtru(2);
   segBox->SetName("ITSsddSegBox");
 
-  Double_t xseg[8],yseg[8];
-  xseg[0] = -(fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW);
-  yseg[0] =  fgkLadderHeight/2+fgkLadderSegBoxDH/2;
-  xseg[1] =  xseg[0];
-  yseg[1] = -yseg[0];
-  xseg[2] = -xseg[1];
-  yseg[2] =  yseg[1];
-  xseg[3] =  xseg[2];
-  yseg[3] =  yseg[0];
-  xseg[4] =  0.35*xseg[3];
-  yseg[4] =  yseg[3];
-  xseg[5] =  xseg[4];
-  yseg[5] =  yseg[4] + fgkLadderSegBoxDHCorr;
-  xseg[6] = -xseg[4];
-  yseg[6] =  yseg[5];
-  xseg[7] =  xseg[6];
-  yseg[7] =  yseg[0];
-
-  segBox->DefinePolygon(8, xseg, yseg);
+  Double_t xseg[12],yseg[12];
+  xseg[ 0] = -(fgkLadderWidth/2+fgkPinSuppWidth+fgkLadderSegBoxDW);
+  yseg[ 0] =  fgkLadderHeight/2+fgkLadderSegBoxDH/2;
+  xseg[ 1] =  xseg[0];
+  yseg[ 1] = -yseg[0];
+  xseg[ 2] =  0.87*xseg[1];
+  yseg[ 2] =  yseg[1];
+  xseg[ 3] =  0.77*xseg[1];
+  yseg[ 3] = -yseg[0] - 0.62*fgkHybCC2SensorLen;
+  xseg[ 4] =  0.72*xseg[1];
+  yseg[ 4] =  yseg[3];
+  xseg[ 5] =  0.83*xseg[1];
+  yseg[ 5] =  yseg[1];
+
+  for (Int_t j=0; j<6; j++) {
+    xseg[6+j] = -xseg[5-j];
+    yseg[6+j] =  yseg[5-j];
+  }
+
+  segBox->DefinePolygon(12, xseg, yseg);
   segBox->DefineSection(0,-segmentLength/2);
   segBox->DefineSection(1, segmentLength/2);
 
@@ -2799,7 +2811,7 @@ TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment(Int_t iLay, Int_t iSeg) {
   //*************************
   // the 2 hybrids :
   //*************************
-  Double_t hybDy = ((TGeoBBox*)fHybrid->GetShape())->GetDY();
+  Double_t hybDy = ((TGeoXtru*)fHybrid->GetShape())->GetY(2);
   Double_t distAxeToHybridCenter = fgkBTBaxisAtoBase+hybDy;
   
   Double_t hybrVolX = ( distAxeToHybridCenter*CosD(fgkHybridAngle) 
@@ -3699,23 +3711,23 @@ TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateCarlosCard(Int_t iLay) {
   Double_t screw1z = ( aaa*sin(TMath::DegToRad()*fgkCarlosSuppAngle) + 
                       bbb*cos(TMath::DegToRad()*fgkCarlosSuppAngle) )-0.07;
 
-  TGeoRotation *CarlosSuppRot = (TGeoRotation *)fCommonTr[0];  
+  TGeoRotation *carlosSuppRot = (TGeoRotation *)fCommonTr[0];  
 
   TGeoCombiTrans* lScrewTr1 = new TGeoCombiTrans((fgkCarlosSuppX1+
                              fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
-                             screw1y,screw1z, CarlosSuppRot);
+                             screw1y,screw1z, carlosSuppRot);
 
   TGeoCombiTrans* lScrewTr2 = new TGeoCombiTrans((fgkCarlosSuppX1+
                              fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
-                             screw1z,screw1y, CarlosSuppRot);
+                             screw1z,screw1y, carlosSuppRot);
 
   TGeoCombiTrans *lScrewTr3 = new TGeoCombiTrans(-(fgkCarlosSuppX1+
                              fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
-                             screw1y,screw1z, CarlosSuppRot);
+                             screw1y,screw1z, carlosSuppRot);
 
   TGeoCombiTrans *lScrewTr4 = new TGeoCombiTrans(-(fgkCarlosSuppX1+
                              fgkCarlosSuppX2+fgkCarlosSuppX3)/2,
-                             screw1z,screw1y, CarlosSuppRot);
+                             screw1z,screw1y, carlosSuppRot);
 
   assemblySupCarlos->AddNode(fCommonVol[0], 1, lScrewTr1);
   assemblySupCarlos->AddNode(fCommonVol[0], 2, lScrewTr2);
@@ -4140,11 +4152,10 @@ Int_t AliITSv11GeometrySDD::CreateLVCard() {
 }
 
 //________________________________________________________________________
-TGeoVolumeAssembly*  AliITSv11GeometrySDD::CreateHVCard(Int_t iLay){
+TGeoVolumeAssembly*  AliITSv11GeometrySDD::CreateHVCard(){
   // 
   // return an assembly containing the HV card
   //
-  iLay = iLay;
 
   TGeoMedium *ceramic          = GetMedium("CERAMICS$"); // ceramicHVcard
   TGeoMedium *medSMDcapaMiddle = GetMedium("SDD X7R capacitors$"); // check if different
@@ -4422,7 +4433,6 @@ TGeoVolumeAssembly*  AliITSv11GeometrySDD::CreateHVCard(Int_t iLay){
   return highVCard;
 }
 
-
 //________________________________________________________________________
 TGeoVolumeAssembly*  AliITSv11GeometrySDD::CreateEndLadderCards(Int_t iLay) {
 // 
@@ -4931,13 +4941,12 @@ TGeoVolume*  AliITSv11GeometrySDD::CreateEndLadderCardsV(Int_t iLay) {
 }
 
 //________________________________________________________________________
-TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateSupportRing(Int_t iLay) {
+TGeoVolumeAssembly* AliITSv11GeometrySDD::CreateSupportRing() {
 //
 // return an assembly of the support rings, attaching the ladders to the cone 
 //
 
 
-  iLay = iLay;
 
   TGeoMedium *stainless = GetMedium("INOX$"); // To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   TGeoVolumeAssembly *supportRing = new TGeoVolumeAssembly("supportRing");
@@ -5081,7 +5090,7 @@ void AliITSv11GeometrySDD::CreateSDDsensor() {
     wafer3->SetLineColor(fColorSilicon);
     TGeoBBox *sensBox3 = new TGeoBBox("ITSsddSensorSensBox3",
                        fgkWaferWidthSens/2, fgkWaferThickSens/2, fgkWaferLengthSens/2);
-    TGeoVolume *sensVol3 = new TGeoVolume(fgSDDsensitiveVolName3,sensBox3, siliconSDDsens);
+    TGeoVolume *sensVol3 = new TGeoVolume(fgkSDDsensitiveVolName3,sensBox3, siliconSDDsens);
     sensVol3->SetLineColor(fColorSilicon+5);
     wafer3->AddNode(sensVol3, 1, 0);
     fSDDsensor3->AddNode(wafer3, 1, 0);
@@ -5090,7 +5099,7 @@ void AliITSv11GeometrySDD::CreateSDDsensor() {
     wafer4->SetLineColor(fColorSilicon);
     TGeoBBox *sensBox4 = new TGeoBBox("ITSsddSensorSensBox4",
                        fgkWaferWidthSens/2, fgkWaferThickSens/2, fgkWaferLengthSens/2);
-    TGeoVolume *sensVol4 = new TGeoVolume(fgSDDsensitiveVolName4,sensBox4, siliconSDDsens);
+    TGeoVolume *sensVol4 = new TGeoVolume(fgkSDDsensitiveVolName4,sensBox4, siliconSDDsens);
     sensVol4->SetLineColor(fColorSilicon+5);
     wafer4->AddNode(sensVol4, 1, 0);
     fSDDsensor4->AddNode(wafer4, 1, 0);
@@ -5447,7 +5456,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateDetectorsAssembly(Int_t iLay) {
   };
 
   char name[30];
-  sprintf(name,"ITSsddDetBox%i",iLay);
+  snprintf(name,30,"ITSsddDetBox%i",iLay);
   
   TGeoVolumeAssembly  *virtualDet = new TGeoVolumeAssembly("ITSsddLadd");
 
@@ -5456,7 +5465,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateDetectorsAssembly(Int_t iLay) {
     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);
+    snprintf(name, 30, "ITSsddLay%iSensorPos%i",iLay, i);
  
     if (i >= nDetectors/2) {
       TGeoTranslation *sensorPos = new TGeoTranslation(0,localY,localZ);
@@ -5491,7 +5500,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateDetectorsAssemblyLadd2() {
   TGeoVolume *sensorSDD = fSDDsensor3;
 
   char name[30];
-  sprintf(name,"ITSsddDetBoxLadd2");
+  snprintf(name,30,"ITSsddDetBoxLadd2");
   
   TGeoVolumeAssembly  *virtualDet = new TGeoVolumeAssembly("ITSsddLadd");
 
@@ -5499,7 +5508,7 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateDetectorsAssemblyLadd2() {
     Double_t localZ = (-1.)*sensorZPos[nDetectors-1-i];
     Double_t localY = fgkLadWaferSep/2+fgkWaferThickness/2;
     if (i%2==0) localY = -localY;
-    sprintf(name, "ITSsddLayLadd2SensorPos%i", i);
+    snprintf(name, 30, "ITSsddLayLadd2SensorPos%i", i);
  
     if (i >= nDetectors/2) {
       TGeoTranslation *sensorPos = new TGeoTranslation(0,localY,localZ);
@@ -5521,125 +5530,6 @@ TGeoVolumeAssembly *AliITSv11GeometrySDD::CreateDetectorsAssemblyLadd2() {
 
 
 //________________________________________________________________________
-Int_t AliITSv11GeometrySDD::ExportSensorGeometry(AliITSgeom *geom, Int_t iLaySDD,
-                                                Int_t startMod) {
-//
-// export the geometry in a AliITSgeom object
-// Obsolete
-//
-
-  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;
-  };
-
-  const Float_t kDxyz[3] = {fgkWaferWidthSens/2., fgkWaferThickSens/2.,
-                           fgkWaferLengthSens/2.};
-  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[kNLay] = {fgkLay3Nladd, fgkLay4Nladd};
-  const Int_t kNDet[kNLay]  = {fgkLay3Ndet,  fgkLay4Ndet};
-
-  if (GetDebug(1))
-    printf("AliITSv11GeometrySDD::SetSensorGeometry(), nodes found :\n");
-
-  Int_t firstSDDmod = startMod;
-  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", fgSDDsensitiveVolName3,"_1");
-               TGeoNode *sensitivNode = wafVolume->GetNode(senstivName);
-             if (sensitivNode) {
-               TGeoHMatrix sensMatrix(wafMatrix);
-               sensMatrix.Multiply(sensitivNode->GetMatrix());
-
-               // Sticking to the convention for local wafer coordinate
-               // in AliITSgeom :
-               if (iDet >= kNDet[iLay]/2) {
-                 //              TGeoRotation rotY("",0,180,0);
-                 TGeoRotation rotY("",-180,-180,0);
-                 sensMatrix.Multiply(&rotY);
-               };
-               // Creating the matrix in AliITSgeom for
-               // this sensitive volume :
-               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], 1.0};
-               //rot[9]!=0.0 => not a unity matrix
-               geom->CreateMatrix(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);
-  };
-
-  return (startMod-firstSDDmod);
-}
-
-
-//________________________________________________________________________
 Int_t AliITSv11GeometrySDD::
 GetCurrentLayLaddDet(Int_t &lay, Int_t &ladd, Int_t&det) const {
 //
@@ -5661,7 +5551,7 @@ GetCurrentLayLaddDet(Int_t &lay, Int_t &ladd, Int_t&det) const {
 
  // Get the layer index :
   if (node->GetNdaughters()==fgkLay3Ndet)
-    lay = 3;            // this has to be equal to the iLaySDD argument given to ExportSensorGeometry() !!!
+    lay = 3;
   else lay = 4;
 
   return kTRUE;
@@ -5709,7 +5599,7 @@ TGeoPcon* AliITSv11GeometrySDD::CreateConeConstSection(Double_t r1max, Double_t
 
 //________________________________________________________________________
 Double_t AliITSv11GeometrySDD::GetConeZ(Double_t r, Double_t refR1, Double_t refR2, 
-                                       Double_t refZ1, Double_t refZ2) {
+                                       Double_t refZ1, Double_t refZ2) const {
   // just a helping function
   return refZ1+(refZ2-refZ1)*(r-refR1)/(refR2-refR1);
 }
@@ -5728,7 +5618,7 @@ Int_t AliITSv11GeometrySDD::CreateAndInsetConeCablePart(TGeoVolume *mother, Doub
   TGeoMedium *opticalFiber = GetMedium("SDD OPTICFIB$");
 
   char titleCable[30];
-  sprintf(titleCable,"cableSDDport%i",(Int_t)angle);
+  snprintf(titleCable,30,"cableSDDport%i",(Int_t)angle);
 
   //---
   Double_t section = (fgkSectionCuPerMod+fgkSectionPlastPerMod+fgkSectionGlassPerMod)*(nLay3+nLay4);