]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSInitGeometry.cxx
modifications to satisfy the coding conventions
[u/mrichter/AliRoot.git] / ITS / AliITSInitGeometry.cxx
index 4edc0c2c7591c9e086487194bcb7ad0e1951573d..fa04684c61599cd91c32f0921c4b1178a3b3813c 100644 (file)
@@ -27,6 +27,7 @@ $Id$
 #include <TArrayF.h>
 #include <TStopwatch.h>
 #include <TGeoManager.h>
+#include <TGeoMatrix.h>
 #include <TGeoVolume.h>
 #include <TGeoShape.h>
 #include <TGeoBBox.h>
@@ -50,21 +51,20 @@ $Id$
 #include "AliITSsegmentationSPD.h"
 #include "AliITSsegmentationSDD.h"
 #include "AliITSsegmentationSSD.h"
-#include "AliITSgeom.h"
 #include "AliITSInitGeometry.h"
 #include <TDatime.h>
 
 ClassImp(AliITSInitGeometry)
 
-const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kTRUE;
+const Bool_t AliITSInitGeometry::fgkOldSPDbarrel = kFALSE;
 const Bool_t AliITSInitGeometry::fgkOldSDDbarrel = kFALSE;
 const Bool_t AliITSInitGeometry::fgkOldSSDbarrel = kFALSE;
-const Bool_t AliITSInitGeometry::fgkOldSDDcone   = kTRUE;
-const Bool_t AliITSInitGeometry::fgkOldSSDcone   = kTRUE;
-const Bool_t AliITSInitGeometry::fgkOldSPDshield = kTRUE;
+const Bool_t AliITSInitGeometry::fgkOldSDDcone   = kFALSE;
+const Bool_t AliITSInitGeometry::fgkOldSSDcone   = kFALSE;
+const Bool_t AliITSInitGeometry::fgkOldSPDshield = kFALSE;
 const Bool_t AliITSInitGeometry::fgkOldSDDshield = kTRUE;
 const Bool_t AliITSInitGeometry::fgkOldSSDshield = kTRUE;
-const Bool_t AliITSInitGeometry::fgkOldServices  = kTRUE;
+const Bool_t AliITSInitGeometry::fgkOldServices  = kFALSE;
 const Bool_t AliITSInitGeometry::fgkOldSupports  = kTRUE;
 //______________________________________________________________________
 AliITSInitGeometry::AliITSInitGeometry():
@@ -561,7 +561,7 @@ Bool_t AliITSInitGeometry::InitAliITSgeomSSD03(AliITSgeom *geom){
     return kTRUE;
 }
 //______________________________________________________________________
-Bool_t AliITSInitGeometry::InitAliITSgeomITS04(AliITSgeom *geom){
+Bool_t AliITSInitGeometry::InitAliITSgeomITS04(AliITSgeom *geom) const{
     // Initilizes the geometry transformation class AliITSgeom
     // to values appropreate to this specific geometry. Now that
     // the segmentation is part of AliITSgeom, the detector
@@ -712,8 +712,10 @@ Bool_t AliITSInitGeometry::InitAliITSgeomPPRasymmFMD(AliITSgeom *geom){
         "%sIT34_1/I005_%d/I402_%d/ITS4_%d/", // lay=4
         "%sIT56_1/I565_%d/I562_%d/ITS5_%d/", // lay=5
         "%sIT56_1/I569_%d/I566_%d/ITS6_%d/"},// lay=6
-       {"%sIT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
-        "%sIT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
+//     {"%sIT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
+//      "%sIT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
+       {"%sIT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1",//lay=1
+        "%sIT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1",//lay=2
         "%sIT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
         "%sIT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
         "%sIT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
@@ -726,7 +728,7 @@ Bool_t AliITSInitGeometry::InitAliITSgeomPPRasymmFMD(AliITSgeom *geom){
       {34,22, 1},// lay=5
       {38,25, 1}};//lay=6
     */
-    Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2;
+    Int_t mod,nmods=0,lay,lad,det,cpn0,cpn1,cpn2, cpnHS;
     Double_t tran[3]={0.0,0.0,0.0},rot[10]={9*0.0,1.0};
     TArrayD shapePar;
     TString path,shapeName;
@@ -741,8 +743,19 @@ Bool_t AliITSInitGeometry::InitAliITSgeomPPRasymmFMD(AliITSgeom *geom){
         DecodeDetectorLayers(mod,lay,lad,det); // Write
         geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
         RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
-        path.Form(kNames[fMinorVersion-1][lay-1].Data(),
-                  kPathbase.Data(),cpn0,cpn1,cpn2);
+
+       if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because 
+                                  // of the half-stave
+         if (det<3) cpnHS = 0; else cpnHS = 1;
+         path.Form(kNames[fMinorVersion-1][lay-1].Data(),kPathbase.Data(),
+                   cpn0,cpn1,cpnHS,cpn2);
+       } else {
+         path.Form(kNames[fMinorVersion-1][lay-1].Data(),kPathbase.Data(),
+                   cpn0,cpn1,cpn2);
+       };
+//         path.Form(kNames[fMinorVersion-1][lay-1].Data(),
+//                   kPathbase.Data(),cpn0,cpn1,cpn2);
+
         geom->GetGeomMatrix(mod)->SetPath(path);
         GetTransformation(path.Data(),matrix);
         geom->SetTrans(mod,matrix.GetTranslation());
@@ -785,8 +798,17 @@ Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
   const Int_t kdetectors[klayers] = {4,4,6,8,22,25};// number of detector/lad
   const AliITSDetector kIdet[6]   = {kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
   const TString kPathbase = "/ALIC_1/ITSV_1/";
-  
-  char *pathSDDsens1, *pathSDDsens2;
+
+  const char *pathSPDsens1, *pathSPDsens2;
+  if (SPDIsTGeoNative()) {
+    pathSPDsens1="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay1-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay1-Ladder_%d/ITSSPDlay1-sensor_1";
+    pathSPDsens2="%sITSSPD_1/ITSSPDCarbonFiberSectorV_%d/ITSSPDSensitiveVirtualvolumeM0_1/ITSSPDlay2-Stave_%d/ITSSPDhalf-Stave%d_1/ITSSPDlay2-Ladder_%d/ITSSPDlay2-sensor_1";
+  } else{
+    pathSPDsens1 = "%sITSD_1/IT12_1/I12B_%d/I10B_%d/L1H-STAVE%d_1/I107_%d/I101_1/ITS1_1";
+    pathSPDsens2 = "%sITSD_1/IT12_1/I12B_%d/I20B_%d/L2H-STAVE%d_1/I1D7_%d/I1D1_1/ITS2_1";
+  }
+
+  const char *pathSDDsens1, *pathSDDsens2;
   if (SDDIsTGeoNative()) {
     pathSDDsens1 = "%sITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor3_%d/ITSsddWafer3_%d/ITSsddSensitivL3_1";
     pathSDDsens2 = "%sITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor4_%d/ITSsddWafer4_%d/ITSsddSensitivL4_1";
@@ -795,24 +817,24 @@ Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
     pathSDDsens2 = "%sITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d";
   }
 
-  char *pathSSDsens1, *pathSSDsens2;
+  const char *pathSSDsens1, *pathSSDsens2;
   if (SSDIsTGeoNative()) {
-    pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSsddSensor5_%d/ITSsddSensitivL5_1";
-    pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSsddSensor6_%d/ITSsddSensitivL6_1";
+    pathSSDsens1 = "%sITSssdLayer5_1/ITSssdLay5Ladd_%d/ITSssdSensor5_%d/ITSssdSensitivL5_1";
+    pathSSDsens2 = "%sITSssdLayer6_1/ITSssdLay6Ladd_%d/ITSssdSensor6_%d/ITSssdSensitivL6_1";
   } else{
     pathSSDsens1 = "%sITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d";
     pathSSDsens2 = "%sITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d";
   }
 
   const TString kNames[klayers] = {
-    "%sITSD_1/IT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
-    "%sITSD_1/IT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
+    pathSPDsens1, // lay=1
+    pathSPDsens2, // lay=2
     pathSDDsens1, // lay=3
     pathSDDsens2, // lay=4
     pathSSDsens1, // lay=5
     pathSSDsens2};// Lay=6
   
-  Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2;
+  Int_t mod,nmods=0, lay, lad, det, cpn0, cpn1, cpn2, cpnHS=1;
   Double_t tran[3]={0.,0.,0.}, rot[10]={9*0.0,1.0};
   TArrayD shapePar;
   TString path, shapeName;
@@ -825,30 +847,38 @@ Bool_t AliITSInitGeometry::InitAliITSgeomV11Hybrid(AliITSgeom *geom){
   for(mod=0;mod<klayers;mod++) nmods += kladders[mod]*kdetectors[mod];
   geom->Init(kItype,klayers,kladders,kdetectors,nmods);
 
-  for(mod=0;mod<nmods;mod++) {
+  for(mod=0; mod<nmods; mod++) {
 
-//     DecodeDetectorLayers(mod,lay,lad,det); // Write
-//     geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
-//     RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
-    DecodeDetectorLayers(mod,lay,lad,det); // Write
+    DecodeDetectorLayers(mod,lay,lad,det);
     geom->CreateMatrix(mod,lay,lad,det,kIdet[lay-1],tran,rot);
-    RecodeDetector(mod,cpn0,cpn1,cpn2); // Write reusing lay,lad,det.
-
-    if (SDDIsTGeoNative())
-      if (kIdet[lay-1]==kSDD) {
-       cpn0 = lad-1;
-       cpn1 = det-1;
-       cpn2 = 1;
-      }
-    if (SSDIsTGeoNative())
-      if (kIdet[lay-1]==kSSD) {
-       cpn0 = lad-1;
-       cpn1 = det-1;
-       cpn2 = 1;
-      }
+    RecodeDetectorv11Hybrid(mod,cpn0,cpn1,cpn2);
+
+//     if (SPDIsTGeoNative())
+//       if (kIdet[lay-1]==kSPD) {
+//     cpn0 = lad-1;
+//     cpn1 = det-1;
+//     cpn2 = 1;
+//       }
+//     if (SDDIsTGeoNative())
+//       if (kIdet[lay-1]==kSDD) {
+//     cpn0 = lad-1;
+//     cpn1 = det-1;
+//     cpn2 = 1;
+//       }
+//     if (SSDIsTGeoNative())
+//       if (kIdet[lay-1]==kSSD) {
+//     cpn0 = lad-1;
+//     cpn1 = det-1;
+//     cpn2 = 1;
+//       }
+
+    if (kIdet[lay-1]==kSPD) { // we need 1 more copy number because of the half-stave
+      if (det<3) cpnHS = 0; else cpnHS = 1;
+      path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpnHS,cpn2);
+    } else {
+      path.Form(kNames[lay-1].Data(),kPathbase.Data(),cpn0,cpn1,cpn2);
+    };
 
-    path.Form(kNames[lay-1].Data(),
-             kPathbase.Data(),cpn0,cpn1,cpn2);
     geom->GetGeomMatrix(mod)->SetPath(path);
     GetTransformation(path.Data(),matrix);
     geom->SetTrans(mod,matrix.GetTranslation());
@@ -973,15 +1003,16 @@ Bool_t AliITSInitGeometry::InitGeomShapePPRasymmFMD(AliITSDetector idet,
        initSeg[idet] = kTRUE;
        AliITSgeomSPD *geomSPD = new AliITSgeomSPD425Short();
        Float_t bx[256],bz[280];
-       for(i=000;i<256;i++) bx[i] =  50.0*kmicron2cm; // in x all are 50 microns.
-       for(i=000;i<160;i++) bz[i] = 425.0*kmicron2cm; // most are 425 microns
+       for(i=000;i<256;i++) bx[i] = 50.0*kmicron2cm;//in x all are 50 microns.
+       for(i=000;i<160;i++) bz[i] =425.0*kmicron2cm; // most are 425 microns
        // except below
        for(i=160;i<280;i++) bz[i] =   0.0*kmicron2cm; // Outside of detector.
        bz[ 31] = bz[ 32] = 625.0*kmicron2cm; // first chip boundry
        bz[ 63] = bz[ 64] = 625.0*kmicron2cm; // first chip boundry
        bz[ 95] = bz[ 96] = 625.0*kmicron2cm; // first chip boundry
        bz[127] = bz[128] = 625.0*kmicron2cm; // first chip boundry
-       bz[160] = 425.0*kmicron2cm;// Set so that there is no zero pixel size for fNz.
+       bz[160] = 425.0*kmicron2cm;// Set so that there is no zero 
+                                   // pixel size for fNz.
        geomSPD->ReSetBins(shapeParF[1],256,bx,160,bz);
        geom->ReSetShape(idet,geomSPD);
     }break;
@@ -1065,8 +1096,6 @@ Bool_t AliITSInitGeometry::InitSegmentationPPRasymmFMD(AliITSDetector idet,
        segSSD->SetPadSize(95.,0.); // strip x pitch in microns
        segSSD->SetNPads(768,2); // number of strips on each side, sides.
        segSSD->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
-       segSSD->SetAnglesLay5(0.0075,0.0275);//strip angels rad P and N
-       segSSD->SetAnglesLay6(0.0275,0.0075);//strip angels rad P and N
        geom->ReSetShape(idet,segSSD);
     }break;
     default:{// Others, Note no kSDDp or kSSDp in this geometry.
@@ -1523,7 +1552,7 @@ void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
 
     // This is a FIXED switch yard function. I (Bjorn Nilsen) Don't 
     // like them but I see not better way for the moment.
-    switch (fMajorVersion){
+    switch (fMajorVersion) {
     case kvtest:{
         if(GetMinorVersion()==1) 
             return DecodeDetectorLayersvPPRasymmFMD(mod,layer,lad,det);
@@ -1533,7 +1562,7 @@ void AliITSInitGeometry::DecodeDetectorLayers(Int_t mod,Int_t &layer,
                 "Geometry is kvtest minor version=%d is not defined",
                 GetMinorVersion());
         return;
-    }break;
+    } break;
     case kvDefault:{
         Error("DecodeDetectorLayers",
               "Major version = kvDefault, not supported");
@@ -1595,7 +1624,7 @@ void AliITSInitGeometry::DecodeDetectorvSPD02(
 }
 //______________________________________________________________________
 void AliITSInitGeometry::RecodeDetectorvSPD02(Int_t mod,Int_t &cpn0,
-                                        Int_t &cpn1,Int_t &cpn2){
+                                        Int_t &cpn1,Int_t &cpn2) const {
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose.
@@ -1625,7 +1654,7 @@ void AliITSInitGeometry::RecodeDetectorvSPD02(Int_t mod,Int_t &cpn0,
 }
 //______________________________________________________________________
 void AliITSInitGeometry::DecodeDetectorLayersvSPD02(Int_t mod,Int_t &lay,
-                                                    Int_t &lad,Int_t &det){
+                                            Int_t &lad,Int_t &det) const{
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose. Note, this use of layer ladder
@@ -1675,7 +1704,7 @@ void AliITSInitGeometry::DecodeDetectorvSDD03(
 }
 //______________________________________________________________________
 void AliITSInitGeometry::RecodeDetectorvSDD03(Int_t mod,Int_t &cpn0,
-                                        Int_t &cpn1,Int_t &cpn2){
+                                        Int_t &cpn1,Int_t &cpn2) const{
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose.
@@ -1698,7 +1727,7 @@ void AliITSInitGeometry::RecodeDetectorvSDD03(Int_t mod,Int_t &cpn0,
 }
 //______________________________________________________________________
 void AliITSInitGeometry::DecodeDetectorLayersvSDD03(Int_t mod,Int_t &lay,
-                                                    Int_t &lad,Int_t &det){
+                                                 Int_t &lad,Int_t &det) const{
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose. Note, this use of layer ladder
@@ -1745,7 +1774,7 @@ void AliITSInitGeometry::DecodeDetectorvSSD03(
 }
 //______________________________________________________________________
 void AliITSInitGeometry::RecodeDetectorvSSD03(Int_t mod,Int_t &cpn0,
-                                        Int_t &cpn1,Int_t &cpn2){
+                                        Int_t &cpn1,Int_t &cpn2) const {
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose.
@@ -1768,7 +1797,7 @@ void AliITSInitGeometry::RecodeDetectorvSSD03(Int_t mod,Int_t &cpn0,
 }
 //______________________________________________________________________
 void AliITSInitGeometry::DecodeDetectorLayersvSSD03(Int_t mod,Int_t &lay,
-                                                    Int_t &lad,Int_t &det){
+                                                Int_t &lad,Int_t &det) const {
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose. Note, this use of layer ladder
@@ -1812,7 +1841,7 @@ void AliITSInitGeometry::DecodeDetectorvITS04(
 }
 //______________________________________________________________________
 void AliITSInitGeometry::RecodeDetectorvITS04(Int_t mod,Int_t &cpn0,
-                                        Int_t &cpn1,Int_t &cpn2){
+                                        Int_t &cpn1,Int_t &cpn2) const {
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose.
@@ -1845,7 +1874,7 @@ void AliITSInitGeometry::RecodeDetectorvITS04(Int_t mod,Int_t &cpn0,
 }
 //______________________________________________________________________
 void AliITSInitGeometry::DecodeDetectorLayersvITS04(Int_t mod,Int_t &lay,
-                                                    Int_t &lad,Int_t &det){
+                                             Int_t &lad,Int_t &det) const{
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose. Note, this use of layer ladder
@@ -1883,8 +1912,8 @@ void AliITSInitGeometry::DecodeDetectorLayersvITS04(Int_t mod,Int_t &lay,
     return;
 }
 //______________________________________________________________________
-void AliITSInitGeometry::DecodeDetectorvPPRasymmFMD(Int_t &mod,Int_t layer,Int_t cpn0,
-                                        Int_t cpn1,Int_t cpn2) const {
+void AliITSInitGeometry::DecodeDetectorvPPRasymmFMD(Int_t &mod,Int_t layer,
+                                    Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
     // decode geometry into detector module number. There are two decoding
     // Scheams. Old which does not follow the ALICE coordinate system
     // requirements, and New which dose.
@@ -2136,8 +2165,8 @@ void AliITSInitGeometry::DecodeDetectorLayersvPPRasymmFMD(Int_t mod,Int_t &lay,
     return;
 }
 //______________________________________________________________________
-void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,Int_t cpn0,
-                                        Int_t cpn1,Int_t cpn2) const {
+void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,
+                                 Int_t cpn0,Int_t cpn1,Int_t cpn2) const {
     // decode geometry into detector module number
     // Inputs:
     //    Int_t layer    The ITS layer
@@ -2152,12 +2181,17 @@ void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,Int_t cp
   const Int_t kDetPerLadderSPD[2]={2,4};
   const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
   const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
-  Int_t lad=-1,det=-1,i;
+  Int_t lad=-1,det=-1;
   
   switch(layer) {
   case 1: case 2:{
-    lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
-    det = cpn2;
+    if (SPDIsTGeoNative()) {
+      lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
+      det = cpn2;
+    } else {
+      lad = cpn1+kDetPerLadderSPD[layer-1]*(cpn0-1);
+      det = cpn2;
+    }
   } break;
   case 3: case 4:{
     if (SDDIsTGeoNative()) {
@@ -2181,10 +2215,12 @@ void AliITSInitGeometry::DecodeDetectorv11Hybrid(Int_t &mod,Int_t layer,Int_t cp
   } break;
   } // end switch
   mod = 0;
-  for(i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
+  for(Int_t i=0;i<layer-1;i++) mod += kLadPerLayer[i]*kDetPerLadder[i];
   mod += kDetPerLadder[layer-1]*(lad-1)+det-1;// module start at zero.
   return;
 }
+
+/*
 //______________________________________________________________________
 void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
                                         Int_t &cpn1,Int_t &cpn2) {
@@ -2207,12 +2243,10 @@ void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
                                          {34,22, 1},// lay=5
                                          {38,25, 1}};//lay=6
     const Int_t kDetPerLadderSPD[2]={2,4};
-    //    const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
-    //    const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
     Int_t lay,lad,det;
 
     cpn0 = cpn1 = cpn2 = 0;
-    DecodeDetectorLayers(mod,lay,lad,det);
+    DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
     // Old encoding
     switch (lay){
     case 1: case 2:{
@@ -2239,48 +2273,136 @@ void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
               cpn0,cpn1,cpn2,mod,lay,lad,det);
     return;
 }
-//______________________________________________________________________
-void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
-                                              Int_t &lad,Int_t &det) {
+*/
+
 
-    // decode geometry into detector module number for v11Hybrid
+//______________________________________________________________________
+void AliITSInitGeometry::RecodeDetectorv11Hybrid(Int_t mod,Int_t &cpn0,
+                                        Int_t &cpn1,Int_t &cpn2) {
+    // decode geometry into detector module number. There are two decoding
+    // Scheams. Old which does not follow the ALICE coordinate system
+    // requirements, and New which does.
     // Inputs:
     //    Int_t mod      The module number assoicated with this set
     //                   of copy numbers.
     // Output:
-    //    Int_t lay     The layer number
-    //    Int_t lad     The ladder number
-    //    Int_t det     the dettector number
+    //    Int_t cpn0     The lowest copy number  (SPD sector or SDD/SSD ladder)
+    //    Int_t cpn1     The middle copy number  (SPD stave or SDD/SSD module)
+    //    Int_t cpn2     the highest copy number (SPD ladder or 1 for SDD/SSD)
     // Return:
     //    none.
+    const Int_t kDetPerLadderSPD[2]={2,4};
+    Int_t lay,lad,det;
 
-    const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
-    const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
-    Int_t mod2;
+    DecodeDetectorLayersv11Hybrid(mod,lay,lad,det);
+    if (lay<3) { // SPD
+        cpn2 = det;     // Detector 1-4
+        cpn0 = (lad+kDetPerLadderSPD[lay-1]-1)/kDetPerLadderSPD[lay-1];
+        cpn1 = (lad+kDetPerLadderSPD[lay-1]-1)%kDetPerLadderSPD[lay-1] + 1;
+        //if (SPDIsTGeoNative()) {
+        //    cpn2--;
+        //    cpn1--;
+        //}
+    } else { // SDD and SSD
+        cpn2 = 1;
+        cpn1 = det;
+        cpn0 = lad;
+        if (lay<5) { // SDD
+            if (SDDIsTGeoNative()) {
+                cpn1--;
+                cpn0--;
+            } // end if SDDIsTGeoNative()
+        } else { //SSD
+            if (SSDIsTGeoNative()) {
+                cpn1--;
+                cpn0--;
+            }// end if SSDIsTGeoNative()
+        } // end if Lay<5/else
+    } // end if lay<3/else
+    /*printf("AliITSInitGeometry::RecodeDetectorv11Hybrid:"
+           "mod=%d lay=%d lad=%d det=%d cpn0=%d cpn1=%d cpn2=%d\n",
+           mod,lay,lad,det,cpn0,cpn1,cpn2);*/
+}
+// //______________________________________________________________________
+// void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
+//                                               Int_t &lad,Int_t &det) {
+
+//     // decode module number into detector indices for v11Hybrid
+//     // Inputs:
+//     //    Int_t mod      The module number associated with this set
+//     //                   of copy numbers.
+//     // Output:
+//     //    Int_t lay     The layer number
+//     //    Int_t lad     The ladder number
+//     //    Int_t det     the dettector number
+//     // Return:
+//     //    none.
+
+//     const Int_t kDetPerLadder[6]={4,4,6,8,22,25};
+//     const Int_t kLadPerLayer[6]={20,40,14,22,34,38};
+//     Int_t mod2 = 0;
+//     det  = 0;
+//     lad  = 0;
+//     lay  = 0;
+
+//     do{
+//         mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
+//         lay++;
+//     } while(mod2<=mod); // end while
+//     if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
+//     mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
+//     do{
+//         lad++;
+//         mod2 += kDetPerLadder[lay-1];
+//     } while(mod2<=mod); // end while
+//     if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
+//             "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
+//                                             kLadPerLayer[lay-1],mod,mod2);
+//     mod2 -= kDetPerLadder[lay-1];
+//     det = mod-mod2+1;
+//     if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
+//            "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
+//                                   lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
+//     return;
+// }
 
-    det  = 0;
-    lad  = 0;
-    lay  = 0;
-    mod2 = 0;
-    do{
-        mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
-        lay++;
-    } while(mod2<=mod); // end while
-    if(lay>6||lay<1) Error("DecodeDetectorLayers","0<lay=%d>6",lay);
-    mod2 -= kLadPerLayer[lay-1]*kDetPerLadder[lay-1];
-    do{
-        lad++;
-        mod2 += kDetPerLadder[lay-1];
-    } while(mod2<=mod); // end while
-    if(lad>kLadPerLayer[lay-1]||lad<1) Error("DecodeDetectorLayers",
-            "lad=%d>kLadPerLayer[lay-1=%d]=%d mod=%d mod2=%d",lad,lay-1,
-                                            kLadPerLayer[lay-1],mod,mod2);
-    mod2 -= kDetPerLadder[lay-1];
-    det = mod-mod2+1;
-    if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
-           "det=%d>detPerLayer[lay-1=%d]=%d mod=%d mod2=%d lad=%d",det,
-                                  lay-1,kDetPerLadder[lay-1],mod,mod2,lad);
-    return;
+//______________________________________________________________________
+void AliITSInitGeometry::DecodeDetectorLayersv11Hybrid(Int_t mod,Int_t &lay,
+                                              Int_t &lad,Int_t &det) {
+
+  // decode module number into detector indices for v11Hybrid
+  // mod starts from 0
+  // lay, lad, det start from 1
+
+  // Inputs:
+  //    Int_t mod      The module number associated with this set
+  //                   of copy numbers.
+  // Output:
+  //    Int_t lay     The layer number
+  //    Int_t lad     The ladder number
+  //    Int_t det     the dettector number
+
+  const Int_t kDetPerLadder[6] = {4,4,6,8,22,25};
+  const Int_t kLadPerLayer[6]  = {20,40,14,22,34,38};
+  
+  Int_t mod2 = 0;
+  lay  = 0;
+  
+  do {
+    mod2 += kLadPerLayer[lay]*kDetPerLadder[lay];
+    lay++;
+  } while(mod2<=mod); // end while
+  if(lay>6) Error("DecodeDetectorLayers","lay=%d>6",lay);
+
+  mod2 = kLadPerLayer[lay-1]*kDetPerLadder[lay-1] - mod2+mod;
+  lad = mod2/kDetPerLadder[lay-1];
+
+  if(lad>=kLadPerLayer[lay-1]||lad<0) Error("DecodeDetectorLayers",
+                                     "lad=%d not in the correct range",lad);
+  det = (mod2 - lad*kDetPerLadder[lay-1])+1;
+  if(det>kDetPerLadder[lay-1]||det<1) Error("DecodeDetectorLayers",
+                                     "det=%d not in the correct range",det);
+  lad++;
 }
 
 //______________________________________________________________________
@@ -2304,9 +2426,25 @@ Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
     //                        and will be set to zero
     // Return:
     //   kTRUE if no errors
+    Char_t cvslikedate[30];
     Int_t i,n,cvsDateLength,cvsRevisionLength;
 
     cvsDateLength = (Int_t)strlen(cvsDate);
+    if(cvsDateLength>30){ // svn string, make a cvs like string
+        i=0;n=0;
+        do{
+            cvslikedate[i] = cvsDate[i];
+            if(cvsDate[i]=='+' || cvsDate[i++]=='-'){
+                n++; // count number of -
+                cvslikedate[i-1] = '/'; // replace -'s by /'s.
+            } // end if
+        } while(n<3&&i<30); // once additonal - of time zone reach exit
+        cvslikedate[i-1] = '$'; // put $ at end then zero.
+        for(;i<30;i++) cvslikedate[i]=0;// i starts wher do loop left off.
+    }else{
+        for(i=0;i<cvsDateLength&&i<30;i++) cvslikedate[i]=cvsDate[i];
+    }// end if
+    cvsDateLength = (Int_t)strlen(cvslikedate);
     cvsRevisionLength = (Int_t)strlen(cvsRevision);
     i = (Int_t)maj;
     n = 50+(Int_t)(TMath::Log10(TMath::Abs((Double_t)i)))+1+
@@ -2314,7 +2452,7 @@ Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
         +cvsDateLength-6+cvsRevisionLength-10;
     if(GetDebug()>1) printf("AliITSInitGeometry::WriteVersionString:"
                         "length=%d major=%d minor=%d cvsDate=%s[%d] "
-                        "cvsRevision=%s[%d] n=%d\n",length,i,min,cvsDate,
+                        "cvsRevision=%s[%d] n=%d\n",length,i,min,cvslikedate,
                         cvsDateLength,cvsRevision,cvsRevisionLength,n);
     if(i<0) n++;
     if(min<0) n++;
@@ -2329,14 +2467,16 @@ Bool_t AliITSInitGeometry::WriteVersionString(Char_t *str,Int_t length,
         if(10+i<cvsRevisionLength-1)
             cvsrevision[i] = cvsRevision[10+i]; else cvsrevision[i] = 0;
     for(i=0;i<cvsDateLength-6;i++) if(6+i<cvsDateLength-1)
-        cvsdate[i] = cvsDate[6+i]; else cvsdate[i] = 0;
+        cvsdate[i] = cvslikedate[6+i]; else cvsdate[i] = 0;
     for(i=0;i<length;i++) str[i] = 0; // zero it out for now.
     i = (Int_t)maj;
     sprintf(str,"Major Version= %d Minor Version= %d Revision: %s Date: %s",
             i,min,cvsrevision,cvsdate);
+    /* this gives compilation warnings on some compilers: descriptor zu
     if(GetDebug()>1)printf("AliITSInitGeometry::WriteVersionString: "
                        "n=%d str=%s revision[%zu] date[%zu]\n",
                        n,str,strlen(cvsrevision),strlen(cvsdate));
+    */
     delete[] cvsrevision;
     delete[] cvsdate;
     return kTRUE;
@@ -2378,8 +2518,8 @@ Bool_t AliITSInitGeometry::ReadVersionString(const Char_t *str,Int_t length,
     ok = m==3;
     if(!ok) return !ok;
     dt.Set(year,month,day,hours,minuits,seconds);
-    if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d min=%d "
-                       "cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
+    if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: i=%d "
+                     "min=%d cvsRevision=%s cvsDate=%s cvsTime=%s m=%d\n",
                        i,min,cvsRevision,cvsDate,cvsTime,m);
     if(GetDebug()>1)printf("AliITSInitGeometry::ReadVersionString: year=%d"
                        " month=%d day=%d hours=%d minuits=%d seconds=%d\n",