]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSvPPRasymmFMD.cxx
first steps to set the covariance matrix from the errors calculated in conformal...
[u/mrichter/AliRoot.git] / ITS / AliITSvPPRasymmFMD.cxx
index 7ebc189237c9c8ef43ee8327b7056d2180e1569b..aaf72a7de7ae503fd224c0a1400646a2d076c681 100644 (file)
@@ -33,6 +33,7 @@
 #include <TGeometry.h>
 #include <TLorentzVector.h>
 #include <TGeoMatrix.h>
+#include <TGeoPhysicalNode.h>
 #include <TArrayD.h>
 #include <TArrayF.h>
 #include <TString.h>
@@ -44,7 +45,6 @@
 
 #include "AliITS.h"
 #include "AliITSDetTypeSim.h"
-//#include "AliITSGeant3Geometry.h"
 #include "AliITSgeom.h"
 #include "AliITSgeomSDD.h"
 #include "AliITSgeomSPD.h"
@@ -63,6 +63,7 @@
 #include "AliMagF.h"
 #include "AliRun.h"
 #include "AliTrackReference.h"
+#include "AliGeomManager.h"
 
 
 #define GEANTGEOMETRY kTRUE
 ClassImp(AliITSvPPRasymmFMD)
  
 //______________________________________________________________________
-AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(): AliITS(),
-fGeomDetOut(kFALSE),
-fGeomDetIn(kFALSE),
-fByThick(kTRUE),
-fMajorVersion(IsVersion()),
-fMinorVersion(-1),
-fDet1(0),
-fDet2(0),
-fChip1(0),
-fChip2(0),
-fRails(0),
-fFluid(0),
-fIDMother(0)
+AliITSvPPRasymmFMD::AliITSvPPRasymmFMD():
+AliITS(),                    // Default AliITS Constructor
+fGeomDetOut(kFALSE),         // Flag to write .det file out
+fGeomDetIn(kFALSE),          // Flag to read .det file or directly from Geat.
+fByThick(kTRUE),             // Flag to use services materials by thickness
+                             // ture, or mass false.
+fMajorVersion(IsVersion()),  // Major version number == IsVersion
+fMinorVersion(2),           // Minor version number
+fEuclidGeomDet("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det"),// file where detector transormation are define.
+fRead("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm.det"),//! file name to read .det file
+fWrite("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det"),//! file name to write .det file
+fDet1(200.0),     // thickness of detector in SPD layer 1 [microns]
+fDet2(200.0),     // thickness of detector in SPD layer 2 [microns]
+fChip1(150.0),    // thickness of chip in SPD layer 1 [microns]
+fChip2(150.0),    // thickness of chip in SPD layer 2 [microns]
+fRails(0),         // flag to switch rails on (=1) and off (=0)
+fFluid(1),         // flag to switch between water (=1)& freon (=0)
+fIDMother(0),      //! ITS Mother Volume id.
+fIgm((AliITSVersion_t)fMajorVersion,fMinorVersion)//! Get access to decoding 
+                                               // and AliITSgeom init functions
  {
     //    Standard default constructor for the ITS version 10.
     // Inputs:
@@ -91,27 +99,81 @@ fIDMother(0)
     //   none.
     // Return:
     //   none.
+    fIgm.SetGeometryName("");
+}
+
+//______________________________________________________________________
+AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const Char_t *title):
+AliITS(title),               // Standard AliITS Constructor
+fGeomDetOut(kFALSE),         // Flag to write .det file out
+fGeomDetIn(kFALSE),          // Flag to read .det file or directly from Geat.
+fByThick(kTRUE),             // Flag to use services materials by thickness
+                             // ture, or mass false.
+fMajorVersion(IsVersion()),  // Major version number == IsVersion
+fMinorVersion(2),            // Minor version number
+fEuclidGeomDet("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det"),// file where detector transormation are define.
+fRead("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm.det"),//! file name to read .det file
+fWrite("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det"),//! file name to write .det file
+fDet1(200.0),     // thickness of detector in SPD layer 1 [microns]
+fDet2(200.0),     // thickness of detector in SPD layer 2 [microns]
+fChip1(150.0),    // thickness of chip in SPD layer 1 [microns]
+fChip2(150.0),    // thickness of chip in SPD layer 2 [microns]
+fRails(0),         // flag to switch rails on (=1) and off (=0)
+fFluid(1),         // flag to switch between water (=1)& freon (=0)
+fIDMother(0),      //! ITS Mother Volume id.
+fIgm((AliITSVersion_t)fMajorVersion,fMinorVersion)//! Get access to decoding 
+                                               // and AliITSgeom init functions
+{
+    //    Standard constructor for the ITS version 10.
+    // Inputs:
+    //   const Char_t * title  Arbitrary title
+    // 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);
+
+    fIgm.SetDecoding(kFALSE);// Use Alice compliant naming/numbering system
+    fIgm.SetTiming(kFALSE);// default no timing
+    fIgm.SetSegGeom(kFALSE);// use AliITSgeomS?D classes instead 
+                            // of segmentation AliITSsegmentationS?D class
+    fIgm.SetGeometryName("ITS PPR aymmetric services with course"
+                         " cables on cones");
+    // Set some AliITS class veriables.
+    fIdN = 6;
+    fIdName = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for(i=0;i<fIdN;i++) fIdSens[i] = 0;
 }
+
 //______________________________________________________________________
-AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const char *name, const char *title) 
-  : AliITS("ITS", title),
-    fGeomDetOut(kFALSE),
-    fGeomDetIn(kFALSE),
-    fByThick(kTRUE),
-    fMajorVersion(IsVersion()),
-    fMinorVersion(2),
-    fDet1(0),
-    fDet2(0),
-    fChip1(0),
-    fChip2(0),
-    fRails(0),
-    fFluid(0),
-    fIDMother(0) {
+AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const char *name, const char *title):
+AliITS(name,title),          // Extended AliITS Constructor
+fGeomDetOut(kFALSE),         // Flag to write .det file out
+fGeomDetIn(kFALSE),          // Flag to read .det file or directly from Geat.
+fByThick(kTRUE),             // Flag to use services materials by thickness
+                             // ture, or mass false.
+fMajorVersion(IsVersion()),  // Major version number == IsVersion
+fMinorVersion(2),            // Minor version number
+fEuclidGeomDet("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det"),// file where detector transormation are define.
+fRead("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm.det"),//! file name to read .det file
+fWrite("$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det"),//! file name to write .det file
+fDet1(200.0),     // thickness of detector in SPD layer 1 [microns]
+fDet2(200.0),     // thickness of detector in SPD layer 2 [microns]
+fChip1(150.0),    // thickness of chip in SPD layer 1 [microns]
+fChip2(150.0),    // thickness of chip in SPD layer 2 [microns]
+fRails(0),         // flag to switch rails on (=1) and off (=0)
+fFluid(1),         // flag to switch between water (=1)& freon (=0)
+fIDMother(0),      //! ITS Mother Volume id.
+fIgm((AliITSVersion_t)fMajorVersion,fMinorVersion)//! Get access to decoding 
+                                               // and AliITSgeom init functions
+{
     //    Standard constructor for the ITS version 10.
     // Inputs:
     //   const char * name   Ignored, set to "ITS"
@@ -120,11 +182,18 @@ AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const char *name, const char *title)
     //   none.
     // Return:
     //   none.
+
     Int_t i;
 
+    fIgm.SetDecoding(kFALSE);// Use Alice compliant naming/numbering system
+    fIgm.SetTiming(kFALSE);// default no timing
+    fIgm.SetSegGeom(kFALSE);// use AliITSgeomS?D classes instead 
+                            // of segmentation AliITSsegmentationS?D class
+    fIgm.SetGeometryName("ITS PPR aymmetric services with course"
+                         " cables on cones");
+    // Set some AliITS class veriables.
     fIdN = 6;
     fIdName = new TString[fIdN];
-    fIdName[0] = name; // removes warning message
     fIdName[0] = "ITS1";
     fIdName[1] = "ITS2";
     fIdName[2] = "ITS3";
@@ -133,33 +202,39 @@ AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const char *name, const char *title)
     fIdName[5] = "ITS6";
     fIdSens    = new Int_t[fIdN];
     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
+
     SetThicknessDet1();
     SetThicknessDet2();
     SetThicknessChip1();
     SetThicknessChip2();
     SetDensityServicesByThickness();
-
-    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);
 }
+
 //______________________________________________________________________
-AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const AliITSvPPRasymmFMD &source) :
- AliITS(source),
- fGeomDetOut(kFALSE),
- fGeomDetIn(kFALSE),
- fByThick(kTRUE),
- fMajorVersion(IsVersion()),
- fMinorVersion(2),
- fDet1(0),
- fDet2(0),
- fChip1(0),
- fChip2(0),
- fRails(0),
- fFluid(0),
- fIDMother(0) {
+AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const AliITSvPPRasymmFMD &source):
+AliITS(source.GetName(),source.GetTitle()),// Extended AliITS Constructor
+fGeomDetOut(source.GetWriteDet()),// Flag to write .det file out
+fGeomDetIn(source.GetReadDet()),  // Flag to read .det file or directly 
+                                  // from Geat.
+fByThick(source.IsDensityServicesByThickness()),// Flag to use services 
+                                                // materials by thickness
+                                                // ture, or mass false.
+fMajorVersion(source.IsVersion()),  // Major version number == IsVersion
+fMinorVersion(source.GetMinorVersion()),// Minor version number
+fEuclidGeomDet(source.GetEuclidFile()),// file where detector transormation 
+                                       // are define.
+fRead(source.GetReadDetFileName()),  //! file name to read .det file
+fWrite(source.GetWriteDetFileName()),//! file name to write .det file
+fDet1(source.GetThicknessDet1()),//thickness of detector in SPD layer 1[micron]
+fDet2(source.GetThicknessDet2()),//thickness of detector in SPD layer 2[micron]
+fChip1(source.GetThicknessChip1()),//thickness of chip in SPD layer 1 [microns]
+fChip2(source.GetThicknessChip2()),//thickness of chip in SPD layer 2 [microns]
+fRails(source.GetRails()),         // flag to switch rails on (=1) and off (=0)
+fFluid(source.GetCoolingFluid()),// flag to switch between water (1)& freon (0)
+fIDMother(source.GetMotherID()),      //! ITS Mother Volume id.
+fIgm(source.GetGeomInit())//! Get access to decoding 
+                          // and AliITSgeom init functions
+{
     //     Copy Constructor for ITS version 10. This function is not to be
     // used. If any other instance of this function, other than "this" is
     // passed, an error message is returned.
@@ -174,6 +249,7 @@ AliITSvPPRasymmFMD::AliITSvPPRasymmFMD(const AliITSvPPRasymmFMD &source) :
     Warning("Copy Constructor","Not allowed to copy AliITSvPPRasymmFMD");
     return;
 }
+
 //______________________________________________________________________
 AliITSvPPRasymmFMD& AliITSvPPRasymmFMD::operator=(const AliITSvPPRasymmFMD 
                                                  &source){
@@ -189,8 +265,9 @@ AliITSvPPRasymmFMD& AliITSvPPRasymmFMD::operator=(const AliITSvPPRasymmFMD
 
     if(&source == this) return *this;
     Warning("= operator","Not allowed to copy AliITSvPPRasymmFMD");
-    return *this;
+    return *this; // return null pointer, copy not allowed.
 }
+
 //______________________________________________________________________
 AliITSvPPRasymmFMD::~AliITSvPPRasymmFMD() {
     //    Standard destructor for the ITS version 10.
@@ -206,9 +283,15 @@ AliITSvPPRasymmFMD::~AliITSvPPRasymmFMD() {
 void AliITSvPPRasymmFMD::AddAlignableVolumes() const
 {
   //
-  // Create entries for alignable volumes associating the symbolic volume
+  // Creates entries for alignable volumes associating the symbolic volume
   // name with the corresponding volume path.
   // 
+  // Records in the alignable entries the transformation matrices converting
+  // TGeo local coordinates (in the RS of alignable volumes) to the tracking
+  // system
+  // For this, this function has to run before the misalignment because we
+  // are using the ideal positions in the AliITSgeom object.
+
   AliInfo("Add ITS alignable volumes");
 
   if (!gGeoManager) {
@@ -216,130 +299,210 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
     return;
   }
 
+  AliGeomManager::ELayerID layerId;
+  Int_t modUID, modnum;
+
   if( !gGeoManager->SetAlignableEntry("ITS","ALIC_1/ITSV_1") )
     AliFatal("Unable to set alignable entry!!");    
 
+  Double_t al, *gtrans, rotMatrix[9];
+
   TString strSPD = "ITS/SPD";
   TString strSDD = "ITS/SDD";
   TString strSSD = "ITS/SSD";
   TString strStave = "/Stave";
+  TString strHalfStave = "/HalfStave";
   TString strLadder = "/Ladder";
   TString strSector = "/Sector";
   TString strSensor = "/Sensor";
   TString strEntryName1;
   TString strEntryName2;
   TString strEntryName3;
+  TString strEntryName4;
 
   //===== SPD layer1 =====
   {
+    layerId = AliGeomManager::kSPD1;
+    modnum = 0;
     TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_";
     TString str1 = "/I10B_";
+    TString str1Bis = "/L1H-STAVE";
+    TString str1Tierce = "_1";
     TString str2 = "/I107_";
-  
+    
     TString sector;
     TString stave;
+    TString halfStave;
     TString module;
-
-    for(Int_t c1 = 1; c1<=10; c1++){
-
+    
+    for(Int_t cSect = 0; cSect<10; cSect++)
+    {
       sector = str0;
-      sector += c1; // this is one full sector
+      sector += cSect+1; // this is one full sector
       strEntryName1 = strSPD;
       strEntryName1 += 0;
       strEntryName1 += strSector;
-      strEntryName1 += (c1-1);
+      strEntryName1 += cSect;
+      //printf("%s   ==   %s\n",strEntryName1.Data(),sector.Data());
       if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),sector.Data()))
        AliFatal("Unable to set alignable entry!!");    
-      //printf("%s   ==   %s\n",strEntryName1.Data(),sector.Data());
       
-      for(Int_t c2 =1; c2<=2; c2++){
-       
+      for(Int_t cStave = 0; cStave<2; cStave++)
+      {
        stave = sector;
        stave += str1;
-       stave += c2;
+       stave += cStave+1;
        strEntryName2 = strEntryName1;
        strEntryName2 += strStave;
-       strEntryName2 += (c2-1);
-       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),stave.Data()))
-         AliFatal("Unable to set alignable entry!!");    
+       strEntryName2 += cStave;
        //printf("%s   ==   %s\n",strEntryName2.Data(),stave.Data()); // this is a stave
 
-       for(Int_t c3 =1; c3<=4; c3++){
-         
-         module = stave;
-         module += str2;
-         module += c3;
+       for(Int_t cHS=0; cHS<2; cHS++)
+       {
+         halfStave = stave;
+         halfStave += str1Bis;
+         halfStave += cHS;
+         halfStave += str1Tierce;
          strEntryName3 = strEntryName2;
-         strEntryName3 += strLadder;
-         strEntryName3 += (c3-1);
-         if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),module.Data()))
+         strEntryName3 += strHalfStave;
+         strEntryName3 += cHS;
+         //printf("%s   ==   %s\n",strEntryName3.Data(),halfStave.Data()); // this is a half-stave
+         if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),halfStave.Data()))
            AliFatal("Unable to set alignable entry!!");    
-         //printf("%s   ==   %s\n",strEntryName3.Data(),module.Data());
+
+         for(Int_t cLadder = 0; cLadder<2; cLadder++)
+         {
+           modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+           module = halfStave;
+           module += str2;
+           module += cLadder+cHS*2+1;
+           strEntryName4 = strEntryName3;
+           strEntryName4 += strLadder;
+           strEntryName4 += cLadder+cHS*2;
+           //printf("%s   ==   %s\n",strEntryName4.Data(),module.Data());
+           if(!gGeoManager->SetAlignableEntry(strEntryName4.Data(),module.Data(),modUID))
+             AliFatal("Unable to set alignable entry!!");    
+
+           // Creates the TGeo Local to Tracking transformation matrix ...
+           TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+           TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+           gtrans = globMatrix->GetTranslation();
+           memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+           al = TMath::ATan2(rotMatrix[1],rotMatrix[0]);
+           TGeoHMatrix *matLtoT = new TGeoHMatrix;
+           matLtoT->SetDx( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) ); // translation
+           al += TMath::Pi()/2;
+
+           matLtoT->SetDy(-fChip1*0.0001/2.);
+           matLtoT->SetDz(-gtrans[2]);
+           rotMatrix[0]= 0;  rotMatrix[1]=-1;  rotMatrix[2]= 0; // + rotation
+           rotMatrix[3]=-1;  rotMatrix[4]= 0;  rotMatrix[5]= 0; // ! flip in y for the SPD1 only
+           rotMatrix[6]= 0;  rotMatrix[7]= 0;  rotMatrix[8]=-1;
+           TGeoRotation rot;
+           rot.SetMatrix(rotMatrix);
+           matLtoT->MultiplyLeft(&rot);
+           TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+           delete matLtoT;
+           alignableEntry->SetMatrix(matTtoL);
+         }
        }
       }
     }
-  }
-
-  //===== SPD layer2 =====
-  {
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_";
-    TString str1 = "/I20B_";
-    TString str2 = "/I1D7_";
-  
-    TString sector;
-    TString stave;
-    TString module;
-
-    for(Int_t c1 = 1; c1<=10; c1++){
-
+    
+    //===== SPD layer2 =====
+    layerId = AliGeomManager::kSPD2;
+    modnum = 0;
+    str1Bis = "/L2H-STAVE";
+    str1 = "/I20B_";
+    str2 = "/I1D7_";
+    
+    for(Int_t cSect = 0; cSect<10; cSect++)
+    {
       sector = str0;
-      sector += c1; // this is one full sector
+      sector += cSect+1; // this is one full sector
       strEntryName1 = strSPD;
       strEntryName1 += 1;
       strEntryName1 += strSector;
-      strEntryName1 += (c1-1);
-      if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),sector.Data()))
-       AliFatal("Unable to set alignable entry!!");    
-      //printf("%s   ==   %s\n",strEntryName1.Data(),sector.Data());
+      strEntryName1 += cSect;
+      //       if(!gGeoManager->SetAlignableEntry(strEntryName1.Data(),sector.Data()))
+      //       AliFatal("Unable to set alignable entry!!");    
+      // we don't need the previous lines because the whole sector is already define
+      // with first layer ...
       
-      for(Int_t c2 =1; c2<=4; c2++){
-       
+      for(Int_t cStave =0; cStave<4; cStave++)
+      {
        stave = sector;
        stave += str1;
-       stave += c2;
+       stave += cStave+1;
        strEntryName2 = strEntryName1;
        strEntryName2 += strStave;
-       strEntryName2 += (c2-1);
-       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),stave.Data()))
-         AliFatal("Unable to set alignable entry!!");    
-       //printf("%s   ==   %s\n",strEntryName2.Data(),stave.Data()); // this is a stave
-
-       for(Int_t c3 =1; c3<=4; c3++){
-         
-         module = stave;
-         module += str2;
-         module += c3;
+       strEntryName2 += cStave;
+       
+       for(Int_t cHS=0; cHS<2; cHS++)
+       {
+         halfStave = stave;
+         halfStave += str1Bis;
+         halfStave += cHS;
+         halfStave += str1Tierce;
          strEntryName3 = strEntryName2;
-         strEntryName3 += strLadder;
-         strEntryName3 += (c3-1);
-         if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),module.Data()))
-           AliFatal("Unable to set alignable entry!!");
-         //printf("%s   ==   %s\n",strEntryName3.Data(),module.Data());
+         strEntryName3 += strHalfStave;
+         strEntryName3 += cHS;
+         //printf("%s   ==   %s\n",strEntryName3.Data(),halfStave.Data()); // this is a half-stave
+         if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),halfStave.Data()))
+           AliFatal("Unable to set alignable entry!!");    
+         
+         for(Int_t cLad =0; cLad<2; cLad++)
+         {
+           modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
+           module = halfStave;
+           module += str2;
+           module += cLad+cHS*2+1;
+           strEntryName4 = strEntryName3;
+           strEntryName4 += strLadder;
+           strEntryName4 += cLad+cHS*2;
+           //printf("%s   ==   %s\n",strEntryName4.Data(),module.Data());
+           if(!gGeoManager->SetAlignableEntry(strEntryName4.Data(),module.Data(),modUID))
+             AliFatal("Unable to set alignable entry!!");
+           
+           // Creates the TGeo Local to Tracking transformation matrix ...
+           TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+           TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+           gtrans = globMatrix->GetTranslation();
+           memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+           al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+           TGeoHMatrix *matLtoT = new TGeoHMatrix;
+           matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+           al += TMath::Pi()/2;
+
+           matLtoT->SetDy(-fChip2*0.0001/2.);
+           matLtoT->SetDz(-gtrans[2]);
+           rotMatrix[0]= 0;  rotMatrix[1]= 1;  rotMatrix[2]= 0; // + rotation
+           rotMatrix[3]= 1;  rotMatrix[4]= 0;  rotMatrix[5]= 0;
+           rotMatrix[6]= 0;  rotMatrix[7]= 0;  rotMatrix[8]=-1;
+           TGeoRotation rot;
+           rot.SetMatrix(rotMatrix);
+           matLtoT->MultiplyLeft(&rot);
+           TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+           delete matLtoT;
+           alignableEntry->SetMatrix(matTtoL);
+         }
        }
       }
     }
   }
-
+  
   //===== SDD layer1 =====
   {
+    layerId = AliGeomManager::kSDD1;
+    modnum = 0;
     TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_";
     TString str1 = "/I302_";
 
     TString ladder;
     TString wafer;
 
-    for(Int_t c1 = 1; c1<=14; c1++){
-
+    for(Int_t c1 = 1; c1<=14; c1++)
+    {
       ladder = str0;
       ladder += c1; // the set of wafers from one ladder
       strEntryName1 = strSDD;
@@ -350,32 +513,56 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
        AliFatal("Unable to set alignable entry!!");    
       //printf("%s    ==    %s\n",strEntryName1.Data(),ladder.Data());
 
-      for(Int_t c2 =1; c2<=6; c2++){
-
+      for(Int_t c2 =1; c2<=6; c2++)
+      {
+       modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
        wafer = ladder;
        wafer += str1;
        wafer += c2;    // one wafer
        strEntryName2 = strEntryName1;
        strEntryName2 += strSensor;
        strEntryName2 += (c2-1);
-       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data()))
+       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
 
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+       TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       rotMatrix[0]=0;  rotMatrix[1]=1;  rotMatrix[2]=0; // + rotation
+       rotMatrix[3]=1;  rotMatrix[4]=0;  rotMatrix[5]=0;
+       rotMatrix[6]=0;  rotMatrix[7]=0;  rotMatrix[8]=-1;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
 
   //===== SDD layer2 =====
   {
+    layerId = AliGeomManager::kSDD2;
+    modnum = 0;
     TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_";
     TString str1 = "/I402_";
 
     TString ladder;
     TString wafer;
 
-    for(Int_t c1 = 1; c1<=22; c1++){
-
+    for(Int_t c1 = 1; c1<=22; c1++)
+    {
       ladder = str0;
       ladder += c1; // the set of wafers from one ladder
       strEntryName1 = strSDD;
@@ -386,31 +573,56 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
        AliFatal("Unable to set alignable entry!!");    
       //printf("%s    ==    %s\n",strEntryName1.Data(),ladder.Data());
 
-      for(Int_t c2 =1; c2<=8; c2++){
-
+      for(Int_t c2 =1; c2<=8; c2++)
+      {
+       modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
        wafer = ladder;
        wafer += str1;
        wafer += c2;    // one wafer
        strEntryName2 = strEntryName1;
        strEntryName2 += strSensor;
        strEntryName2 += (c2-1);
-       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data()))
+       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
+
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+       TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       rotMatrix[0]=0;  rotMatrix[1]=1;  rotMatrix[2]=0; // + rotation
+       rotMatrix[3]=1;  rotMatrix[4]=0;  rotMatrix[5]=0;
+       rotMatrix[6]=0;  rotMatrix[7]=0;  rotMatrix[8]=-1;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
 
   //===== SSD layer1 =====
   {
+    layerId = AliGeomManager::kSSD1;
+    modnum = 0;
     TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_";
     TString str1 = "/I562_";
 
     TString ladder;
     TString wafer;
 
-    for(Int_t c1 = 1; c1<=34; c1++){
-
+    for(Int_t c1 = 1; c1<=34; c1++)
+    {
       ladder = str0;
       ladder += c1; // the set of wafers from one ladder
       strEntryName1 = strSSD;
@@ -421,31 +633,56 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
        AliFatal("Unable to set alignable entry!!");    
       //printf("%s    ==    %s\n",strEntryName1.Data(),ladder.Data());
 
-      for(Int_t c2 = 1; c2<=22; c2++){
-
+      for(Int_t c2 = 1; c2<=22; c2++)
+      {
+       modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
        wafer = ladder;
        wafer += str1;
        wafer += c2;     // one wafer
        strEntryName2 = strEntryName1;
        strEntryName2 += strSensor;
        strEntryName2 += (c2-1);
-       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data()))
+       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
+
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+       TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       rotMatrix[0]=0;  rotMatrix[1]=1;  rotMatrix[2]=0; // + rotation
+       rotMatrix[3]=1;  rotMatrix[4]=0;  rotMatrix[5]=0;
+       rotMatrix[6]=0;  rotMatrix[7]=0;  rotMatrix[8]=-1;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
 
   //===== SSD layer2 =====
   {
+    layerId = AliGeomManager::kSSD2;
+    modnum = 0;
     TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_";
     TString str1 = "/I566_";
 
     TString ladder;
     TString wafer;
 
-    for(Int_t c1 = 1; c1<=38; c1++){
-
+    for(Int_t c1 = 1; c1<=38; c1++)
+    {
       ladder = str0;
       ladder += c1; // the set of wafers from one ladder
       strEntryName1 = strSSD;
@@ -456,23 +693,45 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
        AliFatal("Unable to set alignable entry!!");    
       //printf("%s    ==    %s\n",strEntryName1.Data(),ladder.Data());
 
-      for(Int_t c2 = 1; c2<=25; c2++){
-
+      for(Int_t c2 = 1; c2<=25; c2++)
+      {
+       modUID = AliGeomManager::LayerToVolUID(layerId,modnum++);
        wafer = ladder;
        wafer += str1;
        wafer += c2;     // one wafer
        strEntryName2 = strEntryName1;
        strEntryName2 += strSensor;
        strEntryName2 += (c2-1);
-       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data()))
+       if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data(),modUID))
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
 
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(modUID);
+       TGeoHMatrix *globMatrix = alignableEntry->GetGlobalOrig();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       rotMatrix[0]=0;  rotMatrix[1]=1;  rotMatrix[2]=0; // + rotation
+       rotMatrix[3]=1;  rotMatrix[4]=0;  rotMatrix[5]=0;
+       rotMatrix[6]=0;  rotMatrix[7]=0;  rotMatrix[8]=-1;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
+}
 
-} 
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::BuildGeometry(){
     //    Geometry builder for the ITS version 10. Event Display geometry.
@@ -529,6 +788,7 @@ void AliITSvPPRasymmFMD::BuildGeometry(){
     node->SetLineColor(kColorITS);
     fNodes->Add(node);
 }
+
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::CreateGeometry(){
     //    This routine defines and Creates the geometry for version 10 of 
@@ -604,6 +864,11 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
 
     Float_t dbus=300.;      // total bus thickness on both layers (micron)
 
+    // These constant character strings are set by cvs during commit
+    // do not change them unless you know what you are doing!
+    const Char_t *cvsDate="$Date$";
+    const Char_t *cvsRevision="$Revision$";
+
     ddet1 = GetThicknessDet1();
     ddet2 = GetThicknessDet2();
     dchip1 = GetThicknessChip1();
@@ -654,14 +919,14 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
     }// end if
 
 
-    AliInfo(Form("Detector thickness on layer 1 is set to %f microns",ddet1));
-    AliInfo(Form("Chip thickness on layer 1 is set to %f microns",dchip1));
-    AliInfo(Form("Detector thickness on layer 2 is set to %f microns",ddet2));
-    AliInfo(Form("Chip thickness on layer 2 is set to %f microns",dchip2));
+    AliDebug(1,Form("Detector thickness on layer 1 is set to %f microns",ddet1));
+    AliDebug(1,Form("Chip thickness on layer 1 is set to %f microns",dchip1));
+    AliDebug(1,Form("Detector thickness on layer 2 is set to %f microns",ddet2));
+    AliDebug(1,Form("Chip thickness on layer 2 is set to %f microns",dchip2));
     if(rails == 0 ) {
-      AliInfo("Rails are out.");
+      AliDebug(1,"Rails are out.");
     } else {
-      AliInfo("Rails are in.");
+      AliDebug(1,"Rails are in.");
     }// end if
 
     ddet1  = ddet1*0.0001/2.; // conversion from tot length in um to half in cm
@@ -675,7 +940,6 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
     Int_t thickness = fMinorVersion/10;
     Int_t option    = fMinorVersion - 10*thickness;
 
-
     // Define some variables for SDD
 
 
@@ -1182,64 +1446,76 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
     ztpc = 284.;
     // --- Define ghost volume containing the whole ITS (including services) 
     //     and fill it with air
-    dgh[0] = 0.;
-    dgh[1] = 360.;
-    dgh[2] = 16.;
-    dgh[3] = -ztpc-5.-0.1;
-    dgh[4] = 46;   
-    dgh[5] = 85.;
-    dgh[6] = -ztpc;
-    dgh[7] = 46;   
-    dgh[8] = 85.;
-    dgh[9] = -ztpc;
-    dgh[10] = 46;  
-    dgh[11] = rlim+7.5;
-    dgh[12] = -97.5;
-    dgh[13] = 46;  
-    dgh[14] = rlim+7.5;
-    dgh[15] = -zmax;
-    dgh[16] = 46;  
-    dgh[17] = rlim+7.5;
-    dgh[18] = -48;   
-    dgh[19] = 6;
-    dgh[20] = rlim+7.5;
-    dgh[21] = -28.6;   
-    dgh[22] = 6;
-    dgh[23] = rlim+7.5;    
-    dgh[24] = -27.6;  
-    dgh[25] = 3.295;
-    dgh[26] = rlim+7.5; 
-    dgh[27] = 27.6;   
-    dgh[28] = 3.295;
-    dgh[29] = rlim+7.5;
-    dgh[30] = 28.6;   
-    dgh[31] = 6;
-    dgh[32] = rlim+7.5;
-    dgh[33] = 48;   
-    dgh[34] = 6;
-    dgh[35] = rlim+7.5;  
-    dgh[36] = zmax;
-    dgh[37] = 46;
-    dgh[38] = rlim+7.5;
-    dgh[39] = 97.5;
-    dgh[40] = 46;  
-    dgh[41] = rlim+7.5;
-    dgh[42] = ztpc;
-    dgh[43] = 62;     
-    dgh[44] = 62+4.;  
-    dgh[45] = ztpc;
-    dgh[46] = 62;     
-    dgh[47] = 85.;
-    dgh[48] = ztpc+4.+0.1;
-    dgh[49] = 62.0;//62.4;
-    dgh[50] = 85.;
-    gMC->Gsvolu("ITSV", "PCON", idtmed[205], dgh, 51);
 
+//     dgh[0] = 0.;
+//     dgh[1] = 360.;
+//     dgh[2] = 16.;
+//     dgh[3] = -ztpc-5.-0.1;
+//     dgh[4] = 46;   
+//     dgh[5] = 85.;
+//     dgh[6] = -ztpc;
+//     dgh[7] = 46;   
+//     dgh[8] = 85.;
+//     dgh[9] = -ztpc;
+//     dgh[10] = 46;  
+//     dgh[11] = rlim+7.5;
+//     dgh[12] = -97.5;
+//     dgh[13] = 46;  
+//     dgh[14] = rlim+7.5;
+//     dgh[15] = -zmax;
+//     dgh[16] = 46;  
+//     dgh[17] = rlim+7.5;
+//     dgh[18] = -48;   
+//     dgh[19] = 6;
+//     dgh[20] = rlim+7.5;
+//     dgh[21] = -28.6;   
+//     dgh[22] = 6;
+//     dgh[23] = rlim+7.5;    
+//     dgh[24] = -27.6;  
+//     dgh[25] = 3.295;
+//     dgh[26] = rlim+7.5; 
+//     dgh[27] = 27.6;   
+//     dgh[28] = 3.295;
+//     dgh[29] = rlim+7.5;
+//     dgh[30] = 28.6;   
+//     dgh[31] = 6;
+//     dgh[32] = rlim+7.5;
+//     dgh[33] = 48;   
+//     dgh[34] = 6;
+//     dgh[35] = rlim+7.5;  
+//     dgh[36] = zmax;
+//     dgh[37] = 46;
+//     dgh[38] = rlim+7.5;
+//     dgh[39] = 97.5;
+//     dgh[40] = 46;  
+//     dgh[41] = rlim+7.5;
+//     dgh[42] = ztpc;
+//     dgh[43] = 62;     
+//     dgh[44] = 62+4.;  
+//     dgh[45] = ztpc;
+//     dgh[46] = 62;     
+//     dgh[47] = 85.;
+//     dgh[48] = ztpc+4.+0.1;
+//     dgh[49] = 62.0;//62.4;
+//     dgh[50] = 85.;
+//     gMC->Gsvolu("ITSV", "PCON", idtmed[205], dgh, 51);
+    TGeoVolumeAssembly *itsV = gGeoManager->MakeVolumeAssembly("ITSV");
+    const Int_t length=100;
+    Char_t vstrng[length];
+    if(fIgm.WriteVersionString(vstrng,length,(AliITSVersion_t)IsVersion(),
+                               fMinorVersion,cvsDate,cvsRevision))
+      itsV->SetTitle(vstrng);
+    
     // --- Place the ghost volume in its mother volume (ALIC) and make it 
     //     invisible
-    //    gMC->Gspos("ITSV", 1, "ALIC", 0., 0., 0., 0, "ONLY");
-    gMC->Gspos("ITSV", 1, "ALIC", 0., 0., 0., idrotm[199], "MANY");
-    //gMC->Gsatt("ITSV", "SEEN", 0);
+    //    gMC->Gspos("ITSV", 1, "ALIC", 0., 0., 0., idrotm[199], "MANY");
+    TGeoVolume *alic = gGeoManager->GetVolume("ALIC");
+    if(alic==0) {
+        Error("CreateGeometry","alic=0");
+        return;
+    } // end if
+    // See idrotm[199] for angle definitions.
+    alic->AddNode(itsV,1,new TGeoRotation("", 90.,180., 90.,90., 180.,0.));
 
     // --- Define ghost volume containing the six layers and fill it with air 
   
@@ -1676,14 +1952,15 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
      dits[1] = 7.75;
      dits[2] = 26.1;
      gMC->Gsvolu("IT12", "TUBE", idtmed[254], dits, 3);   
-
+     /*
      dits[0] = 3.7;
      dits[1] = 7.7;
      dits[2] = 24;
      dits[3] = 57;
      dits[4] = 100;
-     gMC->Gsvolu("I12B", "TUBS", idtmed[254], dits, 5);   // sector
-
+     gMC->Gsvolu("I12B", "TUBS", idtmed[254], dits, 5);   // sector */
+     //    TGeoVolumeAssembly *i12b = gGeoManager->MakeVolumeAssembly("I12B");
+     gGeoManager->MakeVolumeAssembly("I12B");
      di10b[0] = 0.843;
      di10b[1] = ddet1+dchip1+dbus+0.0025;  
      di10b[2] = 19.344;
@@ -1948,12 +2225,13 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
      dits2[2] = 3.48;
      gMC->Gsvolu("ITS2", "BOX ", idtmed[200], dits2, 3);   // detector layer 2
 
-     dits[0] = 3.701;
-     dits[1] = 7.699;
-     dits[2] = 4;
-     dits[3] = 57.1;
-     dits[4] = 99.9;  
-     gMC->Gsvolu("I650", "TUBS", idtmed[254], dits, 5);  // was I150 in old geom.
+//      dits[0] = 3.701;
+//      dits[1] = 7.699;
+//      dits[2] = 4;
+//      dits[3] = 57.1;
+//      dits[4] = 99.9;  
+//      gMC->Gsvolu("I650", "TUBS", idtmed[254], dits, 5);  // was I150 in old geom.
+     gGeoManager->MakeVolumeAssembly("I650");
 
      dits[0] = 3.7;
      dits[1] = 7.75;
@@ -2773,42 +3051,62 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   dits[0] = 0;
   dits[1] = 360;
   dits[2] = 12;
+
   dits[3] = -59.7;
   dits[4] = 27;
   dits[5] = 28.6;
+
   dits[6] = -42.7;
   dits[7] = 10;
   dits[8] = 28.6;
+
   dits[9] = -34.65;
   dits[10] = 10;
   dits[11] = 28.6;
+
   dits[12] = -34.65;
   dits[13] = 10;
   dits[14] = 23.495;
+
   dits[15] = -23.7;
   dits[16] = 10;
   dits[17] = 23.495;
+
   dits[18] = -23.7;
   dits[19] = 10;
   dits[20] = 14.595;
+
   dits[21] = 23.7;
   dits[22] = 10;
   dits[23] = 14.595;
+
   dits[24] = 23.7;
   dits[25] = 10;
   dits[26] = 23.495;
+
   dits[27] = 34.65;
   dits[28] = 10;
   dits[29] = 23.495;
+
   dits[30] = 34.65;
   dits[31] = 10;
   dits[32] = 28.6;
+
   dits[33] = 42.7;
   dits[34] = 10;
   dits[35] = 28.6;
+
   dits[36] = 59.7;
   dits[37] = 27.2637;
-  dits[38] = 28.6;             
+  dits[38] = 28.6; 
+
+  
+  // fixing overlaps :
+  dits[15] = -27.35;
+  dits[18] = -27.35;
+  dits[21] = 27.35;
+  dits[24] = 27.35;
+          
   gMC->Gsvolu("IS02", "PCON", idtmed[204], dits, 39);
   
   dits[0] = 0;
@@ -3278,16 +3576,16 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
 
   if (option == 2) {
 
-     gMC->Gspos("I12B",1,"IT12",0.0,0.0,0.0,0,"MANY");
-     gMC->Gspos("I12B",8,"IT12",0.0,0.0,0.0,idrotm[233],"MANY");
-     gMC->Gspos("I12B",7,"IT12",0.0,0.0,0.0,idrotm[244],"MANY");
-     gMC->Gspos("I12B",6,"IT12",0.0,0.0,0.0,idrotm[236],"MANY");
-     gMC->Gspos("I12B",2,"IT12",0.0,0.0,0.0,idrotm[245],"MANY");
-     gMC->Gspos("I12B",3,"IT12",0.0,0.0,0.0,idrotm[234],"MANY");
-     gMC->Gspos("I12B",4,"IT12",0.0,0.0,0.0,idrotm[246],"MANY");
-     gMC->Gspos("I12B",5,"IT12",0.0,0.0,0.0,idrotm[247],"MANY");
-     gMC->Gspos("I12B",9,"IT12",0.0,0.0,0.0,idrotm[248],"MANY");
-     gMC->Gspos("I12B",10,"IT12",0.0,0.0,0.0,idrotm[249],"MANY");
+    gMC->Gspos("I12B",1,"IT12",0.0,0.0,0.0,0,"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",8,"IT12",0.0,0.0,0.0,idrotm[233],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",7,"IT12",0.0,0.0,0.0,idrotm[244],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",6,"IT12",0.0,0.0,0.0,idrotm[236],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",2,"IT12",0.0,0.0,0.0,idrotm[245],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",3,"IT12",0.0,0.0,0.0,idrotm[234],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",4,"IT12",0.0,0.0,0.0,idrotm[246],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",5,"IT12",0.0,0.0,0.0,idrotm[247],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",9,"IT12",0.0,0.0,0.0,idrotm[248],"ONLY"/*"MANY"*/);
+     gMC->Gspos("I12B",10,"IT12",0.0,0.0,0.0,idrotm[249],"ONLY"/*"MANY"*/);
      deltax=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Cos(270.*TMath::Pi()/180.);  // see definition of idrotm[238]
          deltay=((ddet1-0.01/2.)+(dchip1-0.015/2.))*TMath::Sin(270.*TMath::Pi()/180.);  // see definition of idrotm[238]
      gMC->Gspos("I10B",2,"I12B",0.203+deltax,3.8206+deltay,0.0,idrotm[238],"ONLY");      
@@ -3348,19 +3646,40 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
      gMC->Gspos("I124",1,"I12B",-0.4965,6.8742,0.0,idrotm[215],"ONLY");
      gMC->Gspos("I105",3,"I10B",-0.05,-0.01,-16.844,idrotm[201],"ONLY");
      gMC->Gspos("I105",4,"I10B",-0.05,-0.01,16.844,0,"ONLY");
-     gMC->Gspos("I107",2,"I10B",-0.0455,-di10b[1]+di107[1],3.536,0,"ONLY");
-     gMC->Gspos("I107",1,"I10B",-0.0455,-di10b[1]+di107[1],10.708,0,"ONLY");
-     gMC->Gspos("I107",4,"I10B",-0.0455,-di10b[1]+di107[1],-10.708,0,"ONLY");
-     gMC->Gspos("I107",3,"I10B",-0.0455,-di10b[1]+di107[1],-3.536,0,"ONLY");
+
+     // Insertion of half-stave level in SPD1:
+     gGeoManager->MakeVolumeAssembly("L1H-STAVE0");
+     gGeoManager->MakeVolumeAssembly("L1H-STAVE1");
+     gMC->Gspos("L1H-STAVE0",1,"I10B",0,0,0,0,"ONLY");
+     gMC->Gspos("L1H-STAVE1",1,"I10B",0,0,0,0,"ONLY");
+     gMC->Gspos("I107",1,"L1H-STAVE0",-0.0455,-di10b[1]+di107[1],10.708,0,"ONLY");
+     gMC->Gspos("I107",2,"L1H-STAVE0",-0.0455,-di10b[1]+di107[1],3.536,0,"ONLY");
+     gMC->Gspos("I107",3,"L1H-STAVE1",-0.0455,-di10b[1]+di107[1],-3.536,0,"ONLY");
+     gMC->Gspos("I107",4,"L1H-STAVE1",-0.0455,-di10b[1]+di107[1],-10.708,0,"ONLY");
+//      gMC->Gspos("I107",2,"I10B",-0.0455,-di10b[1]+di107[1],3.536,0,"ONLY");
+//      gMC->Gspos("I107",1,"I10B",-0.0455,-di10b[1]+di107[1],10.708,0,"ONLY");
+//      gMC->Gspos("I107",4,"I10B",-0.0455,-di10b[1]+di107[1],-10.708,0,"ONLY");
+//      gMC->Gspos("I107",3,"I10B",-0.0455,-di10b[1]+di107[1],-3.536,0,"ONLY");
+
+    // Insertion of half-stave level in SPD2:
+     gGeoManager->MakeVolumeAssembly("L2H-STAVE0");
+     gGeoManager->MakeVolumeAssembly("L2H-STAVE1");
+     gMC->Gspos("L2H-STAVE0",1,"I20B",0,0,0,0,"ONLY");
+     gMC->Gspos("L2H-STAVE1",1,"I20B",0,0,0,0,"ONLY");
+     gMC->Gspos("I1D7",1,"L2H-STAVE0",-0.0455,-di20b[1]+di1d7[1],10.708,0,"ONLY");
+     gMC->Gspos("I1D7",2,"L2H-STAVE0",-0.0455,-di20b[1]+di1d7[1],3.536,0,"ONLY");
+     gMC->Gspos("I1D7",3,"L2H-STAVE1",-0.0455,-di20b[1]+di1d7[1],-3.536,0,"ONLY");
+     gMC->Gspos("I1D7",4,"L2H-STAVE1",-0.0455,-di20b[1]+di1d7[1],-10.708,0,"ONLY");
+//      gMC->Gspos("I1D7",2,"I20B",-0.0455,-di20b[1]+di1d7[1],3.536,0,"ONLY");
+//      gMC->Gspos("I1D7",1,"I20B",-0.0455,-di20b[1]+di1d7[1],10.708,0,"ONLY");
+//      gMC->Gspos("I1D7",4,"I20B",-0.0455,-di20b[1]+di1d7[1],-10.708,0,"ONLY");
+//      gMC->Gspos("I1D7",3,"I20B",-0.0455,-di20b[1]+di1d7[1],-3.536,0,"ONLY");
+
      gMC->Gspos("I109",1,"I10B",-0.138,0.015,-16.844,idrotm[201],"ONLY");
      gMC->Gspos("I109",2,"I10B",-0.138,0.015,16.844,0,"ONLY");
      gMC->Gspos("I108",1,"I10B",-0.138,-di10b[1]+2.*di107[1]+di108[1],0.0,0,"ONLY");
      gMC->Gspos("I105",1,"I20B",-0.05,-0.01,-16.844,idrotm[201],"ONLY");
      gMC->Gspos("I105",2,"I20B",-0.05,-0.01,16.844,0,"ONLY");
-     gMC->Gspos("I1D7",2,"I20B",-0.0455,-di20b[1]+di1d7[1],3.536,0,"ONLY");
-     gMC->Gspos("I1D7",1,"I20B",-0.0455,-di20b[1]+di1d7[1],10.708,0,"ONLY");
-     gMC->Gspos("I1D7",4,"I20B",-0.0455,-di20b[1]+di1d7[1],-10.708,0,"ONLY");
-     gMC->Gspos("I1D7",3,"I20B",-0.0455,-di20b[1]+di1d7[1],-3.536,0,"ONLY");
      gMC->Gspos("I109",3,"I20B",-0.138,0.015,-16.844,idrotm[201],"ONLY");
      gMC->Gspos("I109",4,"I20B",-0.138,0.015,16.844,0,"ONLY");
      gMC->Gspos("I108",2,"I20B",-0.138,-di20b[1]+2.*di1d7[1]+di108[1],0.0,0,"ONLY");
@@ -3375,44 +3694,50 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
      gMC->Gspos("I116",1,"I113",0.0,0.0042,0.0,0,"ONLY");
      gMC->Gspos("I111",1,"I113",-0.1318,-0.0008,0.0,idrotm[204],"ONLY");
      gMC->Gspos("I112",1,"I113",-0.25,0.02,0.0,idrotm[203],"ONLY");
-     gMC->Gspos("I106",1,"I107",0.0,-dchip1,-1.4,0,"ONLY");
-     gMC->Gspos("I106",2,"I107",0.0,-dchip1,0.0,0,"ONLY");
-     gMC->Gspos("I106",3,"I107",0.0,-dchip1,1.4,0,"ONLY");
-     gMC->Gspos("I106",4,"I107",0.0,-dchip1,2.8,0,"ONLY");
-     gMC->Gspos("I106",5,"I107",0.0,-dchip1,-2.8,0,"ONLY");
-     gMC->Gspos("I101",1,"I107",0.0,ddet1,0.0,0,"ONLY");
-     gMC->Gspos("I1D6",1,"I1D7",0.0,-dchip2,-1.4,0,"ONLY");
-     gMC->Gspos("I1D6",2,"I1D7",0.0,-dchip2,0.0,0,"ONLY");
-     gMC->Gspos("I1D6",3,"I1D7",0.0,-dchip2,1.4,0,"ONLY");
-     gMC->Gspos("I1D6",4,"I1D7",0.0,-dchip2,2.8,0,"ONLY");
-     gMC->Gspos("I1D6",5,"I1D7",0.0,-dchip2,-2.8,0,"ONLY");
-     gMC->Gspos("I1D1",1,"I1D7",0.0,ddet2,0.0,0,"ONLY");
+     gMC->Gspos("I106",1,"I107",0.0,-ddet1,-1.4,0,"ONLY");
+     gMC->Gspos("I106",2,"I107",0.0,-ddet1,0.0,0,"ONLY");
+     gMC->Gspos("I106",3,"I107",0.0,-ddet1,1.4,0,"ONLY");
+     gMC->Gspos("I106",4,"I107",0.0,-ddet1,2.8,0,"ONLY");
+     gMC->Gspos("I106",5,"I107",0.0,-ddet1,-2.8,0,"ONLY");
+     gMC->Gspos("I101",1,"I107",0.0,dchip1,0.0,0,"ONLY");
+     gMC->Gspos("I1D6",1,"I1D7",0.0,-ddet2,-1.4,0,"ONLY");
+     gMC->Gspos("I1D6",2,"I1D7",0.0,-ddet2,0.0,0,"ONLY");
+     gMC->Gspos("I1D6",3,"I1D7",0.0,-ddet2,1.4,0,"ONLY");
+     gMC->Gspos("I1D6",4,"I1D7",0.0,-ddet2,2.8,0,"ONLY");
+     gMC->Gspos("I1D6",5,"I1D7",0.0,-ddet2,-2.8,0,"ONLY");
+     gMC->Gspos("I1D1",1,"I1D7",0.0,dchip2,0.0,0,"ONLY");
      gMC->Gspos("I117",1,"I116",0.0,0.0,0.0,0,"ONLY");
      gMC->Gspos("ITS1",1,"I101",0.0,0.0,0.0,0,"ONLY");
      gMC->Gspos("ITS2",1,"I1D1",0.0,0.0,0.0,0,"ONLY");
      gMC->Gspos("I651",1,"IT12",0.0,0.0,26.05,0,"ONLY");
-     gMC->Gspos("I651",2,"IT12",0.0,0.0,-26.05,0,"ONLY");     
-     gMC->Gspos("I650",16,"IT12",0.0,0.0,22.0,idrotm[1104],"MANY");
-     gMC->Gspos("I650",20,"IT12",0.0,0.0,22.0,idrotm[1130],"MANY");
-     gMC->Gspos("I650",18,"IT12",0.0,0.0,22.0,idrotm[1117],"MANY");
-     gMC->Gspos("I650",1,"IT12",0.0,0.0,22.0,0,"MANY");
-     gMC->Gspos("I650",4,"IT12",0.0,0.0,22.0,idrotm[1106],"MANY");
-     gMC->Gspos("I650",6,"IT12",0.0,0.0,22.0,idrotm[1039],"MANY");
-     gMC->Gspos("I650",8,"IT12",0.0,0.0,22.0,idrotm[1107],"MANY");
-     gMC->Gspos("I650",10,"IT12",0.0,0.0,22.0,idrotm[1065],"MANY");
-     gMC->Gspos("I650",12,"IT12",0.0,0.0,22.0,idrotm[1078],"MANY");
-     gMC->Gspos("I650",14,"IT12",0.0,0.0,22.0,idrotm[1091],"MANY");
-     gMC->Gspos("I650",19,"IT12",0.0,0.0,-22.0,idrotm[1108],"MANY");
-     gMC->Gspos("I650",2,"IT12",0.0,0.0,-22.0,idrotm[1109],"MANY");
-     gMC->Gspos("I650",3,"IT12",0.0,0.0,-22.0,idrotm[1110],"MANY");
-     gMC->Gspos("I650",5,"IT12",0.0,0.0,-22.0,idrotm[1111],"MANY");
-     gMC->Gspos("I650",7,"IT12",0.0,0.0,-22.0,idrotm[1112],"MANY");
-     gMC->Gspos("I650",9,"IT12",0.0,0.0,-22.0,idrotm[1113],"MANY");
-     gMC->Gspos("I650",11,"IT12",0.0,0.0,-22.0,idrotm[1114],"MANY");
-     gMC->Gspos("I650",13,"IT12",0.0,0.0,-22.0,idrotm[1115],"MANY");
-     gMC->Gspos("I650",15,"IT12",0.0,0.0,-22.0,idrotm[1116],"MANY");
-     gMC->Gspos("I650",17,"IT12",0.0,0.0,-22.0,idrotm[1118],"MANY");
-     gMC->Gspos("I666",1,"I650",0.0,0.0,0.25,idrotm[1003],"MANY");
+     gMC->Gspos("I651",2,"IT12",0.0,0.0,-26.05,0,"ONLY");
+
+
+     gMC->Gspos("I650",16,"IT12",0.0,0.0,22.0,idrotm[1104],"ONLY");
+     gMC->Gspos("I650",20,"IT12",0.0,0.0,22.0,idrotm[1130],"ONLY");
+     gMC->Gspos("I650",18,"IT12",0.0,0.0,22.0,idrotm[1117],"ONLY");
+     gMC->Gspos("I650",1,"IT12",0.0,0.0,22.0,0,"ONLY");
+     gMC->Gspos("I650",4,"IT12",0.0,0.0,22.0,idrotm[1106],"ONLY");
+     gMC->Gspos("I650",6,"IT12",0.0,0.0,22.0,idrotm[1039],"ONLY");
+     gMC->Gspos("I650",8,"IT12",0.0,0.0,22.0,idrotm[1107],"ONLY");
+     gMC->Gspos("I650",10,"IT12",0.0,0.0,22.0,idrotm[1065],"ONLY");
+     gMC->Gspos("I650",12,"IT12",0.0,0.0,22.0,idrotm[1078],"ONLY");
+     gMC->Gspos("I650",14,"IT12",0.0,0.0,22.0,idrotm[1091],"ONLY");
+     gMC->Gspos("I650",19,"IT12",0.0,0.0,-22.0,idrotm[1108],"ONLY");
+     gMC->Gspos("I650",2,"IT12",0.0,0.0,-22.0,idrotm[1109],"ONLY");
+     gMC->Gspos("I650",3,"IT12",0.0,0.0,-22.0,idrotm[1110],"ONLY");
+     gMC->Gspos("I650",5,"IT12",0.0,0.0,-22.0,idrotm[1111],"ONLY");
+     gMC->Gspos("I650",7,"IT12",0.0,0.0,-22.0,idrotm[1112],"ONLY");
+     gMC->Gspos("I650",9,"IT12",0.0,0.0,-22.0,idrotm[1113],"ONLY");
+     gMC->Gspos("I650",11,"IT12",0.0,0.0,-22.0,idrotm[1114],"ONLY");
+     gMC->Gspos("I650",13,"IT12",0.0,0.0,-22.0,idrotm[1115],"ONLY");
+     gMC->Gspos("I650",15,"IT12",0.0,0.0,-22.0,idrotm[1116],"ONLY");
+     gMC->Gspos("I650",17,"IT12",0.0,0.0,-22.0,idrotm[1118],"ONLY");
+
+
+
+     gMC->Gspos("I666",1,"I650",0.0,0.0,0.25,idrotm[1003],"ONLY");
+
      gMC->Gspos("I667",1,"I650",0.1102,0.9945,0.45,idrotm[1088],"ONLY");
      gMC->Gspos("I669",3,"I650",0.1883,4.0372,-3.2,0,"ONLY");
      gMC->Gspos("I671",3,"I650",0.1883,4.0372,0.6,0,"ONLY");
@@ -3437,9 +3762,11 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
      gMC->Gspos("I668",1,"I667",0.0,0.0,0.0,0,"ONLY");
      gMC->Gspos("I670",1,"I669",0.0,0.0,0.0,0,"ONLY");
      gMC->Gspos("I672",1,"I671",0.0,0.0,0.0,0,"ONLY");
-     gMC->Gspos("I674",1,"I673",0.0,0.0,0.0,0,"MANY");
+
+     gMC->Gspos("I674",1,"I673",0.0,0.0,0.0,0,"ONLY");
+
      gMC->Gspos("I675",1,"I673",0.0,0.0,-0.5,0,"ONLY");
-     gMC->Gspos("I677",1,"I676",0.0,0.0,0.0,0,"MANY");
+     gMC->Gspos("I677",1,"I676",0.0,0.0,0.0,0,"ONLY");
      gMC->Gspos("I678",1,"I676",0.0,0.0,-0.95,0,"ONLY");  
 
   }
@@ -3526,22 +3853,23 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
 
   gMC->Gspos("I022", 1,"I018",  0.0,     -1.79,   3.55,   idrotm[312], "ONLY");
   gMC->Gspos("I022", 2,"I018",  0.0,     -1.79,  -0.1,    idrotm[312], "ONLY");
-
   gMC->Gspos("I023", 1,"I018",  0.0,     -1.79,   1.725,  idrotm[341], "ONLY");
   gMC->Gspos("I023", 2,"I018",  0.0,     -1.79,  -1.925,  idrotm[341], "ONLY");
+  gMC->Gspos("I033", 1,"I018",  1.8,     -1.75,   1.35,   0,           "ONLY");
+
+  gMC->Gspos("I033", 2,"I018", -1.8,     -1.75,  -2.65,   idrotm[345], "ONLY");
+  gMC->Gspos("I033", 3,"I018", -1.8,     -1.75,   1.35,   idrotm[345], "ONLY");
+  gMC->Gspos("I033", 4,"I018",  1.8,     -1.75,  -2.65,   0,           "ONLY");
+
 
-  gMC->Gspos("I033", 1,"I018",  1.8,     -1.75,   1.35,   0,           "MANY");
-  gMC->Gspos("I033", 2,"I018", -1.8,     -1.75,  -2.65,   idrotm[345], "MANY");
-  gMC->Gspos("I033", 3,"I018", -1.8,     -1.75,   1.35,   idrotm[345], "MANY");
-  gMC->Gspos("I033", 4,"I018",  1.8,     -1.75,  -2.65,   0,           "MANY");
 
   gMC->Gspos("I034", 1,"I018",  1.6,     -1.775,  1.35,   idrotm[312], "ONLY");
   gMC->Gspos("I034", 2,"I018", -1.6,     -1.775, -2.65,   idrotm[348], "ONLY");
   gMC->Gspos("I034", 3,"I018", -1.6,     -1.775,  1.35,   idrotm[348], "ONLY");
   gMC->Gspos("I034", 4,"I018",  1.6,     -1.775, -2.65,   idrotm[312], "ONLY");
 
-  gMC->Gspos("I035", 1,"I018",  1.7,     -0.55, iI018dits[2]-iI035dits[2], 0, "MANY");
-  gMC->Gspos("I035", 2,"I018", -1.7,     -0.55, iI018dits[2]-iI035dits[2], 0, "MANY");
+  gMC->Gspos("I035", 1,"I018",  1.7,     -0.55, iI018dits[2]-iI035dits[2], 0, "ONLY");
+  gMC->Gspos("I035", 2,"I018", -1.7,     -0.55, iI018dits[2]-iI035dits[2], 0, "ONLY");
 
   gMC->Gspos("I036", 1,"I018",  0.3087,   1.7191, 3.56,   idrotm[346], "ONLY");
   gMC->Gspos("I036", 2,"I018",  0.3087,   1.7191,-0.11,   idrotm[346], "ONLY");
@@ -3649,7 +3977,7 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I421", 1,"I420", 0.0, 0.0, 0.0, idrotm[312], "ONLY");
   gMC->Gspos("I420", 1,"I028", -iI028dits[0]/3., iI028dits[1]-iI420dits[1], 0.0, 0, "ONLY");
   gMC->Gspos("I424", 1,"I028", xI424, yI424, 0.0, 0, "ONLY");
-  gMC->Gspos("I028", 1,"I024", 0.0, iI028dits[1]-iI024dits[1], iI024dits[2]-iI028dits[2], 0, "MANY");
+  gMC->Gspos("I028", 1,"I024", 0.0, iI028dits[1]-iI024dits[1], iI024dits[2]-iI028dits[2], 0, "ONLY");
 
 
   // -- build the SDD ladder 3
@@ -4056,8 +4384,10 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I556",2,"I553",1.0311,0.2033,-2.203,idrotm[577],"ONLY");
   gMC->Gspos("I556",4,"I553",-1.031,0.2033,-0.287,idrotm[579],"ONLY");
   gMC->Gspos("I559",2,"I553",-2.25,-1.615,0.0,idrotm[573],"ONLY");
-  gMC->Gspos("I561",1,"I553",2.1,-1.615,-0.24,0,"MANY");
-  gMC->Gspos("I561",2,"I553",-2.1,-1.615,-0.24,idrotm[573],"MANY");
+
+  gMC->Gspos("I561",1,"I553",2.1,-1.615,-0.24,0,"ONLY");
+  gMC->Gspos("I561",2,"I553",-2.1,-1.615,-0.24,idrotm[573],"ONLY");
+
   gMC->Gspos("I519",37,"I523",0.0001,-1.79,-0.99,idrotm[586],"ONLY");
   gMC->Gspos("I519",36,"I523",-3.2986,-1.79,-1.2943,0,"ONLY");
   gMC->Gspos("I519",35,"I523",-3.2986,-1.71,-1.2943,0,"ONLY");
@@ -4111,14 +4441,16 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I519",1,"I523",3.302,-1.71,-1.2943,0,"ONLY");
   gMC->Gspos("I520",1,"I523",2.2501,-1.845,-1.19,0,"ONLY");
   gMC->Gspos("I521",1,"I523",2.8161,-1.7075,-0.982,0,"ONLY");
-  gMC->Gspos("I522",1,"I523",2.2501,-1.655,-1.3,idrotm[583],"MANY");
-  gMC->Gspos("I522",2,"I523",-2.2499,-1.655,-1.3,idrotm[583],"MANY");
+
+  gMC->Gspos("I522",1,"I523",2.2501,-1.655,-1.3,idrotm[583],"ONLY");
+  gMC->Gspos("I522",2,"I523",-2.2499,-1.655,-1.3,idrotm[583],"ONLY");
+
   gMC->Gspos("I542",2,"I523",-2.2499,-1.615,0.0,idrotm[573],"ONLY");
   gMC->Gspos("I541",2,"I523",-2.2499,-1.615,0.0,idrotm[573],"ONLY");
   gMC->Gspos("I541",1,"I523",2.2501,-1.615,0.0,0,"ONLY");
   gMC->Gspos("I542",1,"I523",2.2501,-1.615,0.0,0,"ONLY");
-  gMC->Gspos("I543",1,"I523",2.1001,-1.615,0.955,0,"MANY");
-  gMC->Gspos("I543",2,"I523",-2.0999,-1.615,0.955,idrotm[573],"MANY");
+  gMC->Gspos("I543",1,"I523",2.1001,-1.615,0.955,0,"ONLY");
+  gMC->Gspos("I543",2,"I523",-2.0999,-1.615,0.955,idrotm[573],"ONLY");
   gMC->Gspos("I537",2,"I523",1.7501,-1.52,0.0,idrotm[583],"ONLY");
   gMC->Gspos("I538",2,"I523",1.8368,-1.3122,0.0,idrotm[575],"ONLY");
   gMC->Gspos("I537",3,"I523",0.1035,1.6901,0.0,idrotm[575],"ONLY");
@@ -4151,8 +4483,10 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I549",2,"I544",0.12,1.6613,0.0,idrotm[575],"ONLY");
   gMC->Gspos("I549",3,"I544",-1.8367,-1.3122,0.0,idrotm[581],"ONLY");
   gMC->Gspos("I548",3,"I544",-1.75,-1.52,0.0,idrotm[583],"ONLY");
-  gMC->Gspos("I552",1,"I544",2.1,-1.615,-0.24,0,"MANY");
-  gMC->Gspos("I552",2,"I544",-2.1,-1.615,-0.24,idrotm[573],"MANY");
+
+  gMC->Gspos("I552",1,"I544",2.1,-1.615,-0.24,0,"ONLY");
+  gMC->Gspos("I552",2,"I544",-2.1,-1.615,-0.24,idrotm[573],"ONLY");
+
   gMC->Gspos("I515",12,"I516",-1.6896,-1.7075,-0.9822,0,"ONLY");
   gMC->Gspos("I515",11,"I516",-1.6896,-1.7925,-0.9822,0,"ONLY");
   gMC->Gspos("I513",37,"I516",0.0,-1.79,-1.035,idrotm[586],"ONLY");
@@ -4221,14 +4555,16 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I529",1,"I516",1.8,-1.75,-0.195,idrotm[571],"ONLY");
   gMC->Gspos("I530",1,"I516",0.0,-1.785,1.905,idrotm[571],"ONLY");
   gMC->Gspos("I529",2,"I516",-1.8,-1.75,-0.195,idrotm[572],"ONLY");
-  gMC->Gspos("I517",1,"I516",2.25,-1.655,-1.3,idrotm[583],"MANY");
-  gMC->Gspos("I517",2,"I516",-2.25,-1.655,-1.3,idrotm[584],"MANY");
+
+  gMC->Gspos("I517",1,"I516",2.25,-1.655,-1.3,idrotm[583],"ONLY");
+  gMC->Gspos("I517",2,"I516",-2.25,-1.655,-1.3,idrotm[584],"ONLY");
+
   gMC->Gspos("I531",2,"I516",-2.25,-1.615,0.0,idrotm[573],"ONLY");
   gMC->Gspos("I531",1,"I516",2.25,-1.615,0.0,0,"ONLY");
   gMC->Gspos("I532",1,"I516",2.25,-1.615,0.0,0,"ONLY");
   gMC->Gspos("I532",2,"I516",-2.25,-1.615,0.0,idrotm[573],"ONLY");
-  gMC->Gspos("I533",1,"I516",2.1,-1.615,0.955,0,"MANY");
-  gMC->Gspos("I533",2,"I516",-2.1,-1.615,0.955,idrotm[573],"MANY");
+  gMC->Gspos("I533",1,"I516",2.1,-1.615,0.955,0,"ONLY");
+  gMC->Gspos("I533",2,"I516",-2.1,-1.615,0.955,idrotm[573],"ONLY");
   gMC->Gspos("ITS5",1,"I562",0.0,0.0,0.0,0,"ONLY");
 
   
@@ -4251,26 +4587,28 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   // --- Place volumes of SDD cone ---------------------------------- 
   
   
-  gMC->Gspos("I093",1,"IS02",0.0,0.0,0.0,0,"MANY");
-  gMC->Gspos("I093",2,"IS02",0.0,0.0,0.0,idrotm[856],"MANY");
-  gMC->Gspos("I099",4,"IS02",0.0,0.0,0.0,idrotm[857],"MANY");
-  gMC->Gspos("I099",3,"IS02",0.0,0.0,0.0,idrotm[858],"MANY");
-  gMC->Gspos("I099",5,"IS02",0.0,0.0,0.0,idrotm[859],"MANY");
-  gMC->Gspos("I099",6,"IS02",0.0,0.0,0.0,idrotm[860],"MANY");
-  gMC->Gspos("I099",7,"IS02",0.0,0.0,0.0,idrotm[861],"MANY");
-  gMC->Gspos("I099",2,"IS02",0.0,0.0,0.0,idrotm[862],"MANY");
-  gMC->Gspos("I200",4,"IS02",0.0,0.0,0.0,idrotm[863],"MANY");
-  gMC->Gspos("I200",3,"IS02",0.0,0.0,0.0,idrotm[864],"MANY");
-  gMC->Gspos("I200",2,"IS02",0.0,0.0,0.0,idrotm[865],"MANY");
-  gMC->Gspos("I200",13,"IS02",0.0,0.0,0.0,idrotm[867],"MANY");
-  gMC->Gspos("I200",12,"IS02",0.0,0.0,0.0,idrotm[869],"MANY");
-  gMC->Gspos("I200",11,"IS02",0.0,0.0,0.0,idrotm[870],"MANY");
-  gMC->Gspos("I200",10,"IS02",0.0,0.0,0.0,idrotm[871],"MANY");
-  gMC->Gspos("I200",9,"IS02",0.0,0.0,0.0,idrotm[872],"MANY");
-  gMC->Gspos("I200",8,"IS02",0.0,0.0,0.0,idrotm[873],"MANY");
-  gMC->Gspos("I200",7,"IS02",0.0,0.0,0.0,idrotm[874],"MANY");
-  gMC->Gspos("I200",6,"IS02",0.0,0.0,0.0,idrotm[875],"MANY");
-  gMC->Gspos("I200",5,"IS02",0.0,0.0,0.0,idrotm[876],"MANY");
+  gMC->Gspos("I093",1,"IS02",0.0,0.0,0.0,0,"ONLY");
+  gMC->Gspos("I093",2,"IS02",0.0,0.0,0.0,idrotm[856],"ONLY");
+  gMC->Gspos("I099",4,"IS02",0.0,0.0,0.0,idrotm[857],"ONLY");
+  gMC->Gspos("I099",3,"IS02",0.0,0.0,0.0,idrotm[858],"ONLY");
+  gMC->Gspos("I099",5,"IS02",0.0,0.0,0.0,idrotm[859],"ONLY");
+  gMC->Gspos("I099",6,"IS02",0.0,0.0,0.0,idrotm[860],"ONLY");
+  gMC->Gspos("I099",7,"IS02",0.0,0.0,0.0,idrotm[861],"ONLY");
+  gMC->Gspos("I099",2,"IS02",0.0,0.0,0.0,idrotm[862],"ONLY");
+
+  gMC->Gspos("I200",4,"IS02",0.0,0.0,0.0,idrotm[863],"ONLY");
+  gMC->Gspos("I200",3,"IS02",0.0,0.0,0.0,idrotm[864],"ONLY");
+  gMC->Gspos("I200",2,"IS02",0.0,0.0,0.0,idrotm[865],"ONLY");
+  gMC->Gspos("I200",13,"IS02",0.0,0.0,0.0,idrotm[867],"ONLY");
+  gMC->Gspos("I200",12,"IS02",0.0,0.0,0.0,idrotm[869],"ONLY");
+  gMC->Gspos("I200",11,"IS02",0.0,0.0,0.0,idrotm[870],"ONLY");
+  gMC->Gspos("I200",10,"IS02",0.0,0.0,0.0,idrotm[871],"ONLY");
+  gMC->Gspos("I200",9,"IS02",0.0,0.0,0.0,idrotm[872],"ONLY");
+  gMC->Gspos("I200",8,"IS02",0.0,0.0,0.0,idrotm[873],"ONLY");
+  gMC->Gspos("I200",7,"IS02",0.0,0.0,0.0,idrotm[874],"ONLY");
+  gMC->Gspos("I200",6,"IS02",0.0,0.0,0.0,idrotm[875],"ONLY");
+  gMC->Gspos("I200",5,"IS02",0.0,0.0,0.0,idrotm[876],"ONLY");
+
   gMC->Gspos("I090",2,"IS02",0.0,0.0,-39.4,0,"ONLY");    
   gMC->Gspos("I090",1,"IS02",0.0,0.0,39.4,idrotm[856],"ONLY");  
   gMC->Gspos("I099",9,"IS02",0.0,0.0,0.0,idrotm[877],"ONLY");
@@ -4291,10 +4629,12 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I200",21,"IS02",0.0,0.0,0.0,idrotm[892],"ONLY");
   gMC->Gspos("I200",20,"IS02",0.0,0.0,0.0,idrotm[868],"ONLY");
   gMC->Gspos("I200",19,"IS02",0.0,0.0,0.0,idrotm[893],"ONLY");
-  gMC->Gspos("I098",1,"IS02",0.0,0.0,33.6,0,"MANY");    
-  gMC->Gspos("I097",1,"IS02",0.0,0.0,26.6,0,"MANY");    
-  gMC->Gspos("I097",2,"IS02",0.0,0.0,-26.6,idrotm[856],"MANY");  
-  gMC->Gspos("I098",2,"IS02",0.0,0.0,-33.6,idrotm[856],"MANY");  
+
+  gMC->Gspos("I098",1,"IS02",0.0,0.0,33.6,0,"ONLY");    
+  gMC->Gspos("I097",1,"IS02",0.0,0.0,26.6,0,"ONLY");    
+  gMC->Gspos("I097",2,"IS02",0.0,0.0,-26.6,idrotm[856],"ONLY");  
+  gMC->Gspos("I098",2,"IS02",0.0,0.0,-33.6,idrotm[856],"ONLY");  
+
   gMC->Gspos("I202",1,"IS02",12.1,0.0,33.84,0,"ONLY");
   gMC->Gspos("I202",6,"IS02",-6.05,-10.4789,33.84,idrotm[930],"ONLY");
   gMC->Gspos("I202",5,"IS02",-6.05,10.4789,33.84,idrotm[929],"ONLY");
@@ -4314,6 +4654,8 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I203",2,"IS02",10.9227,18.9186,42.24,idrotm[853],"ONLY");
   gMC->Gspos("I203",1,"IS02",21.8453,0.0,42.24,0,"ONLY");
   gMC->Gspos("I095",1,"I098",0.0,0.0,0.0,0,"ONLY");
+
+  //I096 and I098 are real volume that are really overlapping, can not use ONLY
   gMC->Gspos("I096",23,"I098",22.77,0.0,0.0,idrotm[894],"MANY");
   gMC->Gspos("I096",14,"I098",22.3754,6.57,0.0,idrotm[895],"MANY");
   gMC->Gspos("I096",3,"I098",19.1553,12.3104,0.0,idrotm[896],"MANY");
@@ -4336,7 +4678,10 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I096",10,"I098",15.2714,-17.6241,0.0,idrotm[914],"MANY");
   gMC->Gspos("I096",21,"I098",19.1553,-12.3104,0.0,idrotm[915],"MANY");
   gMC->Gspos("I096",12,"I098",22.3754,-6.57,0.0,idrotm[916],"MANY");
+
   gMC->Gspos("I094",1,"I097",0.0,0.0,0.0,0,"ONLY");
+
+  // idem
   gMC->Gspos("I096",1,"I097",13.87,0.0,0.0,idrotm[894],"MANY");
   gMC->Gspos("I096",32,"I097",13.037,6.2783,0.0,idrotm[917],"MANY");
   gMC->Gspos("I096",25,"I097",8.6478,10.844,0.0,idrotm[918],"MANY");
@@ -4356,8 +4701,9 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   // --- Place volumes of SSD cone ----------------------------------    
 
     
-  gMC->Gspos("I212",2,"IS01",0.0,0.0,0.0,idrotm[701],"MANY");
-  gMC->Gspos("I212",1,"IS01",0.0,0.0,0.0,0,"MANY");
+  gMC->Gspos("I212",2,"IS01",0.0,0.0,0.0,idrotm[701],"ONLY");
+  gMC->Gspos("I212",1,"IS01",0.0,0.0,0.0,0,"ONLY");
+
   gMC->Gspos("I211",1,"IS01",0.0,0.0,-56.5,0,"ONLY");
   gMC->Gspos("I217",1,"IS01",0.0,0.0,-44.4,0,"ONLY");             // this will change after PPR to be symmetric
   gMC->Gspos("I219",1,"IS01",0.0,0.0,-50.25,0,"ONLY");            // this will change after PPR to be symmetric
@@ -4367,19 +4713,21 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I214",2,"IS01",0.0,0.0,67.25,idrotm[701],"ONLY");   
   gMC->Gspos("I213",2,"IS01",0.0,0.0,62.25,idrotm[701],"ONLY");  
   gMC->Gspos("I213",1,"IS01",0.0,0.0,-62.25,0,"ONLY");             
-  gMC->Gspos("I214",1,"IS01",0.0,0.0,-67.25,0,"ONLY");           
-  gMC->Gspos("I215",19,"IS01",0.0,0.0,0.0,idrotm[702],"MANY");
-  gMC->Gspos("I215",21,"IS01",0.0,0.0,0.0,idrotm[703],"MANY");
-  gMC->Gspos("I215",23,"IS01",0.0,0.0,0.0,idrotm[704],"MANY");
-  gMC->Gspos("I215",24,"IS01",0.0,0.0,0.0,idrotm[705],"MANY");
-  gMC->Gspos("I215",3,"IS01",0.0,0.0,0.0,idrotm[706],"MANY");
-  gMC->Gspos("I215",5,"IS01",0.0,0.0,0.0,idrotm[707],"MANY");
-  gMC->Gspos("I215",7,"IS01",0.0,0.0,0.0,idrotm[708],"MANY");
-  gMC->Gspos("I215",9,"IS01",0.0,0.0,0.0,idrotm[709],"MANY");
-  gMC->Gspos("I215",11,"IS01",0.0,0.0,0.0,idrotm[710],"MANY");
-  gMC->Gspos("I215",13,"IS01",0.0,0.0,0.0,idrotm[711],"MANY");
-  gMC->Gspos("I215",15,"IS01",0.0,0.0,0.0,idrotm[712],"MANY");
-  gMC->Gspos("I215",17,"IS01",0.0,0.0,0.0,idrotm[713],"MANY");
+  gMC->Gspos("I214",1,"IS01",0.0,0.0,-67.25,0,"ONLY");
+           
+  gMC->Gspos("I215",19,"IS01",0.0,0.0,0.0,idrotm[702],"ONLY");
+  gMC->Gspos("I215",21,"IS01",0.0,0.0,0.0,idrotm[703],"ONLY");
+  gMC->Gspos("I215",23,"IS01",0.0,0.0,0.0,idrotm[704],"ONLY");
+  gMC->Gspos("I215",24,"IS01",0.0,0.0,0.0,idrotm[705],"ONLY");
+  gMC->Gspos("I215",3,"IS01",0.0,0.0,0.0,idrotm[706],"ONLY");
+  gMC->Gspos("I215",5,"IS01",0.0,0.0,0.0,idrotm[707],"ONLY");
+  gMC->Gspos("I215",7,"IS01",0.0,0.0,0.0,idrotm[708],"ONLY");
+  gMC->Gspos("I215",9,"IS01",0.0,0.0,0.0,idrotm[709],"ONLY");
+  gMC->Gspos("I215",11,"IS01",0.0,0.0,0.0,idrotm[710],"ONLY");
+  gMC->Gspos("I215",13,"IS01",0.0,0.0,0.0,idrotm[711],"ONLY");
+  gMC->Gspos("I215",15,"IS01",0.0,0.0,0.0,idrotm[712],"ONLY");
+  gMC->Gspos("I215",17,"IS01",0.0,0.0,0.0,idrotm[713],"ONLY");
+
   gMC->Gspos("I216",9,"IS01",0.0,0.0,45.5,idrotm[714],"ONLY");
   gMC->Gspos("I216",11,"IS01",0.0,0.0,45.5,idrotm[715],"ONLY");
   gMC->Gspos("I216",12,"IS01",0.0,0.0,45.5,idrotm[716],"ONLY");
@@ -4392,28 +4740,29 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   gMC->Gspos("I216",4,"IS01",0.0,0.0,-44,idrotm[723],"ONLY");
   gMC->Gspos("I216",6,"IS01",0.0,0.0,-44,idrotm[724],"ONLY");
   gMC->Gspos("I216",8,"IS01",0.0,0.0,-44,idrotm[725],"ONLY");
-  gMC->Gspos("I215",1,"IS01",0.0,0.0,0.0,idrotm[726],"MANY");
-  gMC->Gspos("I215",2,"IS01",0.0,0.0,0.0,idrotm[727],"MANY");
-  gMC->Gspos("I215",4,"IS01",0.0,0.0,0.0,idrotm[728],"MANY");
-  gMC->Gspos("I215",6,"IS01",0.0,0.0,0.0,idrotm[729],"MANY");
-  gMC->Gspos("I215",8,"IS01",0.0,0.0,0.0,idrotm[733],"MANY");
-  gMC->Gspos("I215",10,"IS01",0.0,0.0,0.0,idrotm[730],"MANY");
-  gMC->Gspos("I215",12,"IS01",0.0,0.0,0.0,idrotm[731],"MANY");
-  gMC->Gspos("I215",14,"IS01",0.0,0.0,0.0,idrotm[768],"MANY");
-  gMC->Gspos("I215",16,"IS01",0.0,0.0,0.0,idrotm[732],"MANY");
-  gMC->Gspos("I215",18,"IS01",0.0,0.0,0.0,idrotm[734],"MANY");
-  gMC->Gspos("I215",20,"IS01",0.0,0.0,0.0,idrotm[798],"MANY");
-  gMC->Gspos("I215",22,"IS01",0.0,0.0,0.0,idrotm[735],"MANY");
+
+  gMC->Gspos("I215",1,"IS01",0.0,0.0,0.0,idrotm[726],"ONLY");
+  gMC->Gspos("I215",2,"IS01",0.0,0.0,0.0,idrotm[727],"ONLY");
+  gMC->Gspos("I215",4,"IS01",0.0,0.0,0.0,idrotm[728],"ONLY");
+  gMC->Gspos("I215",6,"IS01",0.0,0.0,0.0,idrotm[729],"ONLY");
+  gMC->Gspos("I215",8,"IS01",0.0,0.0,0.0,idrotm[733],"ONLY");
+  gMC->Gspos("I215",10,"IS01",0.0,0.0,0.0,idrotm[730],"ONLY");
+  gMC->Gspos("I215",12,"IS01",0.0,0.0,0.0,idrotm[731],"ONLY");
+  gMC->Gspos("I215",14,"IS01",0.0,0.0,0.0,idrotm[768],"ONLY");
+  gMC->Gspos("I215",16,"IS01",0.0,0.0,0.0,idrotm[732],"ONLY");
+  gMC->Gspos("I215",18,"IS01",0.0,0.0,0.0,idrotm[734],"ONLY");
+  gMC->Gspos("I215",20,"IS01",0.0,0.0,0.0,idrotm[798],"ONLY");
+  gMC->Gspos("I215",22,"IS01",0.0,0.0,0.0,idrotm[735],"ONLY");
            
                    
   // --- Place subdetectors' mother volumes and supports' mother volumes
   //     into ITS mother volume ITSD
     
-  gMC->Gspos("IT12",1,"ITSD",0.0,0.0,0.0,0,"MANY");  // SPD mother volume
-  gMC->Gspos("IT34",1,"ITSD",0.0,0.0,0.0,0,"MANY");  // SDD mother volume
-  gMC->Gspos("IT56",1,"ITSD",0.0,0.0,0.0,0,"MANY");  // SSD mother volume
-  gMC->Gspos("IS02",1,"ITSD",0.0,0.0,0.0,0,"MANY");  // SDD cones/supports
-  gMC->Gspos("IS01",1,"ITSD",0.0,0.0,0.0,0,"MANY");  // SSD cones/supports
+  gMC->Gspos("IT12",1,"ITSD",0.0,0.0,0.0,0,"ONLY");  // SPD mother volume
+  gMC->Gspos("IT34",1,"ITSD",0.0,0.0,0.0,0,"ONLY");  // SDD mother volume
+  gMC->Gspos("IT56",1,"ITSD",0.0,0.0,0.0,0,"ONLY");  // SSD mother volume
+  gMC->Gspos("IS02",1,"ITSD",0.0,0.0,0.0,0,"ONLY");  // SDD cones/supports
+  gMC->Gspos("IS01",1,"ITSD",0.0,0.0,0.0,0,"ONLY");  // SSD cones/supports
         
 
   // ****************************  SERVICES  *********************************
@@ -4757,9 +5106,9 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   dgh[1] = 12.;         
   dgh[2] = 5.;         
   gMC->Gsvolu("ISR2", "BOX ", idtmed[210], dgh, 3);   
-  gMC->Gspos("ISR2", 1, "ITSV", -53.5, 0., -125.5, idrotm[199], "MANY");
+  gMC->Gspos("ISR2", 1, "ITSV", -53.5, 0., -125.5, idrotm[199], "ONLY");
   gMC->Gsvolu("ISR3", "BOX ", idtmed[210], dgh, 3);   
-  gMC->Gspos("ISR3", 1, "ITSV", 53.5, 0., -125.5, idrotm[199], "MANY");  
+  gMC->Gspos("ISR3", 1, "ITSV", 53.5, 0., -125.5, idrotm[199], "ONLY");  
   
   dgh[0] = 5.-2.;        
   dgh[1] = 12.-2.;         
@@ -4775,9 +5124,9 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   dgh[1] = 5.;         
   dgh[2] = 2.;         
   gMC->Gsvolu("ISR6", "TUBE", idtmed[210], dgh, 3);   
-  gMC->Gspos("ISR6", 1, "ITSV", 0., 54., -77., idrotm[199], "MANY"); 
-  gMC->Gspos("ISR6", 2, "ITSV", 0., 54., 77., idrotm[199], "MANY"); 
-  gMC->Gspos("ISR6", 3, "ITSV", 0., -54., 77., idrotm[199], "MANY");                   
+  gMC->Gspos("ISR6", 1, "ITSV", 0., 54., -77., idrotm[199], "ONLY"); 
+  gMC->Gspos("ISR6", 2, "ITSV", 0., 54., 77., idrotm[199], "ONLY"); 
+  gMC->Gspos("ISR6", 3, "ITSV", 0., -54., 77., idrotm[199], "ONLY");                   
 
   // --- Outputs the geometry tree in the EUCLID/CAD format 
   
@@ -5002,6 +5351,7 @@ void AliITSvPPRasymmFMD::CreateGeometry(){
   }
 
 }
+
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::CreateMaterials(){
     // Create ITS materials
@@ -5517,6 +5867,7 @@ void AliITSvPPRasymmFMD::CreateMaterials(){
     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 AliITSvPPRasymmFMD::InitAliITSgeom(){
     //     Based on the geometry tree defined in Geant 3.21, this
@@ -5634,6 +5985,7 @@ void AliITSvPPRasymmFMD::InitAliITSgeom(){
     } // end for lay
     return;
 }
+
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::Init(){
     //     Initialise the ITS after it has been created.
@@ -5644,20 +5996,25 @@ void AliITSvPPRasymmFMD::Init(){
     // Return:
     //   none.
 
-    AliInfo(Form("Init: Major version %d Minor version %d",fMajorVersion,
+    AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
                 fMinorVersion));
     //
+    /*  obsolete initialization of AliITSgeom from external "det" file
     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
     AliITSgeom* geom = new AliITSgeom();
     SetITSgeom(geom);
     if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
     else this->InitAliITSgeom();
-    if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
+    */
+    UpdateInternalGeometry();
     AliITS::Init();
+    if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
+
     //
     fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
 }
+
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::SetDefaults(){
     // sets the default segmentation, response, digit and raw cluster classes
@@ -5668,98 +6025,20 @@ void AliITSvPPRasymmFMD::SetDefaults(){
     // Return:
     //   none.
 
-    const Float_t kconv = 1.0e+04; // convert cm to microns
-
     if(!fDetTypeSim){
        Warning("SetDefaults","Error fDetTypeSim not defined");
        return;
     }
 
-    AliITSgeomSPD  *s0;
-    AliITSgeomSDD  *s1;
-    AliITSgeomSSD  *s2;
-    Int_t i;
-    Float_t bx[256],bz[280];
-
     fDetTypeSim->SetDefaults();
     
-    //SPD
-    s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);
-    // Get shape info. Do it this way for now.
-    //AliITSCalibrationSPD* resp0=new AliITSCalibrationSPD();
-    AliITSsegmentationSPD* seg0 = 
-       (AliITSsegmentationSPD*)fDetTypeSim->GetSegmentationModel(0);
-    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=(fDetTypeSim->GetCalibrationModel(
-                           GetITSgeom()->GetStartSPD()))->DataType();
-    if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSPD,
-                                                             "AliITSdigit");
-    else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
-    // SDD
-    s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);
-    // Get shape info. Do it this way for now.
-
-    //AliITSCalibrationSDD* resp1=new AliITSCalibrationSDD("simulated");
-    AliITSsegmentationSDD* seg1 = 
-       (AliITSsegmentationSDD*)fDetTypeSim->GetSegmentationModel(1);
-    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=(fDetTypeSim->GetCalibrationModel(
-                           GetITSgeom()->GetStartSDD()))->DataType();
-    AliITSCalibrationSDD* rsp = 
-       (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(
-           GetITSgeom()->GetStartSDD());
-    const char *kopt=rsp->GetZeroSuppOption();
-    if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
-       fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigit");
-    } else fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
-    // SSD  Layer 5
-
-    s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);
-    // Get shape info. Do it this way for now.
-
-
-    //SetCalibrationModel(GetITSgeom()->GetStartSSD(),
-    // new AliITSCalibrationSSD("simulated"));
-    AliITSsegmentationSSD* seg2 = 
-       (AliITSsegmentationSSD*)fDetTypeSim->GetSegmentationModel(2);
-    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=(fDetTypeSim->GetCalibrationModel(
-                               GetITSgeom()->GetStartSSD()))->DataType();
-    if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,
-                                                             "AliITSdigit");
-    else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
     if(fgkNTYPES>3){
        Warning("SetDefaults",
                "Only the four basic detector types are initialised!");
     }// end if
     return;
 }
+
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::DrawModule() const{
     //     Draw a shaded view of the FMD version 10.
@@ -5812,6 +6091,8 @@ void AliITSvPPRasymmFMD::DrawModule() const{
     gMC->Gdhead(1111, "Inner Tracking System Version 1");
     gMC->Gdman(17, 6, "MAN");
 }
+
+/*
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::StepManager(){
     //    Called for every step in the ITS, then calles the AliITShit class
@@ -5945,3 +6226,261 @@ void AliITSvPPRasymmFMD::StepManager(){
 
     return;
 }
+
+*/
+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::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
+    // it the extra variables and the like used in the printing allocated.
+    // Inputs:
+    //   none.
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
+
+    if(!(this->IsActive())) return;
+    if(!(gMC->TrackCharge())) return;
+
+    Int_t  copy, id,kk;
+    Bool_t sensvol = kFALSE;
+
+    id = gMC->CurrentVolID(copy);
+    for(kk=0;kk<fIdN;kk++)if(id == fIdSens[kk]){
+        sensvol=kTRUE;
+        break;
+    } // end for if
+
+    if(!sensvol) return; // not an ITS tracking volume;
+
+    if(gMC->IsTrackExiting()){
+       AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber(), AliTrackReference::kITS);
+    } // if Outer ITS mother Volume
+
+    static TLorentzVector position, momentum; // Saves on calls to construtors
+    static AliITShit hit;// Saves on calls to construtors
+    Int_t   cpn0,cpn1,cpn2,status,mod;
+    //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
+    TClonesArray &lhits = *(Hits());
+    //
+    // Track status
+    status = 0;
+    if(gMC->IsTrackInside())      status +=  1;
+    if(gMC->IsTrackEntering())    status +=  2;
+    if(gMC->IsTrackExiting())     status +=  4;
+    if(gMC->IsTrackOut())         status +=  8;
+    if(gMC->IsTrackDisappeared()) status += 16;
+    if(gMC->IsTrackStop())        status += 32;
+    if(gMC->IsTrackAlive())       status += 64;
+    //
+    switch (kk){
+    case 0:case 1: // SPD
+        gMC->CurrentVolOffID(2,cpn2);
+        gMC->CurrentVolOffID(4,cpn1);
+        gMC->CurrentVolOffID(5,cpn0);
+        break;
+    case 2:case 3: // SDD
+        cpn2 = 1;
+        gMC->CurrentVolOffID(1,cpn1);
+        gMC->CurrentVolOffID(2,cpn0);
+        break;
+    case 4:case 5: // SSD
+        cpn2 = 1;
+        gMC->CurrentVolOffID(1,cpn1);
+        gMC->CurrentVolOffID(2,cpn0);
+        break;
+    default:
+      AliError(Form("Invalid value: kk= %d . Not an ITS sensitive volume",kk));
+      return; // not an ITS sensitive volume.
+    } //
+    fIgm.DecodeDetector(mod,kk+1,cpn0,cpn1,cpn2);
+    //Info("StepManager","lay=%d mod=%d cpn0=%d cpn1=%d cpn2=%d",kk+1,mod,cpn0,cpn1,cpn2);
+    Int_t lay,lad,det,cpy0,cpy1,cpy2;
+    fIgm.DecodeDetectorLayers(mod,lay,lad,det);
+    fIgm.RecodeDetector(mod,cpy0,cpy1,cpy2);
+//     printf("gMC: kk=%d cpn0=%d cpn1=%d cpn2=%d -> mod=%d -> "
+//            "lay=%d lad=%d det=%d -> cpn0=%d cpn1=%d cpn2=%d\n",
+//            kk,cpn0,cpn1,cpn2,mod,lay,lad,det,cpy0,cpy1,cpy2);
+    //
+    // Fill hit structure.
+    //
+    hit.SetModule(mod);
+    hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
+    gMC->TrackPosition(position);
+    gMC->TrackMomentum(momentum);
+    hit.SetPosition(position);
+    hit.SetTime(gMC->TrackTime());
+    hit.SetMomentum(momentum);
+    hit.SetStatus(status);
+    hit.SetEdep(gMC->Edep());
+    hit.SetShunt(GetIshunt());
+    if(gMC->IsTrackEntering()){
+        hit.SetStartPosition(position);
+        hit.SetStartTime(gMC->TrackTime());
+        hit.SetStartStatus(status);
+        return; // don't save entering hit.
+    } // end if IsEntering
+    // Fill hit structure with this new hit.
+    //Info("StepManager","Calling Copy Constructor");
+    new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
+    // Save old position... for next hit.
+    hit.SetStartPosition(position);
+    hit.SetStartTime(gMC->TrackTime());
+    hit.SetStartStatus(status);
+    //
+    /*
+    Int_t idettype,ix,iz;
+    Float_t lx,lz;
+    Double_t g0[4],l0[4],g1[4];
+    position.GetXYZT(g0);
+    gMC->Gmtod(g0,l0,1); // flag=1 convert coordiantes
+    gMC->Gdtom(l0,g1,1); // flag=1 convert coordinates
+    switch(idettype=(Int_t)GetITSgeom()->GetModuleType(mod)){
+    case kSPD:
+        AliITSsegmentationSPD *segspd = (AliITSsegmentationSPD *)GetSegmentationModelByModule(mod);
+        segspd->LocalToDet((Float_t)l0[0],(Float_t)l0[2],ix,iz);
+        segspd->DetToLocal(ix,iz,lx,lz);
+        break;
+    case kSDD:
+        AliITSsegmentationSDD *segsdd = (AliITSsegmentationSDD *)GetSegmentationModelByModule(mod);
+        segsdd->LocalToDet((Float_t)l0[0],(Float_t)l0[2],ix,iz);
+        segsdd->DetToLocal(ix,iz,lx,lz);
+        break;
+    case kSSD:
+        AliITSsegmentationSSD *segssd = (AliITSsegmentationSSD *)GetSegmentationModelByModule(mod);
+        segssd->LocalToDet((Float_t)l0[0],(Float_t)l0[2],ix,iz);
+        segssd->DetToLocal(ix,iz,lx,lz);
+        break;
+    default:
+        ix = iz = -1;
+        lx = lz = 0.0;
+        Warning("StepManager","Unknown module type id=%d mod=%d",
+                (Int_t)(GetITSgeom()->GetModuleType(mod)),mod);
+    } // end if
+    printf("    gMC: mod=%d g=%g %g %g %g -> "
+                           "l=%g %g %g %g -> "
+                           "g=%g %g %g %g -> "
+                           "ix=%d iz=%d -> lx=%g lz=%g\n",
+           mod,g0[0],g0[1],g0[2],g0[3],
+               l0[0],l0[1],l0[2],l0[3],
+               g1[0],g1[1],g1[2],g1[3],ix,iz,lx,lz);
+    GetITSgeom()->GtoL(mod,g0,l0);
+    GetITSgeom()->LtoG(mod,l0,g1);
+    printf("ITSgeom: mod=%d g=%g %g %g %g -> "
+                           "l=%g %g %g %g -> "
+                           "g=%g %g %g %g -> "
+                           "ix=%d iz=%d -> lx=%g lz=%g\n",
+           mod,g0[0],g0[1],g0[2],g0[3],
+               l0[0],l0[1],l0[2],l0[3],
+               g1[0],g1[1],g1[2],g1[3],ix,iz,lx,lz);
+    TGeoNode *cur = gGeoManager->GetCurrentNode();
+    cur->MasterToLocal(g0,l0);
+    cur->LocalToMaster(l0,g1);
+    printf("   TGeo: mod=%d g=%g %g %g %g -> "
+                           "l=%g %g %g %g -> "
+                           "g=%g %g %g %g\n",
+           mod,g0[0],g0[1],g0[2],g0[3],
+               l0[0],l0[1],l0[2],l0[3],
+               g1[0],g1[1],g1[2],g1[3]);
+    printf("=====================\n");
+    //
+    */
+    return;
+}
+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::PrintAscii(ostream *os)const{
+    // Print out class data values in Ascii Form to output stream
+    // Inputs:
+    //   ostream *os   Output stream where Ascii data is to be writen
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
+#if defined __GNUC__
+#if __GNUC__ > 2
+    ios::fmtflags fmt;
+#else
+    Int_t fmt;
+#endif
+#else
+#if defined __ICC || defined __ECC || defined __xlC__
+    ios::fmtflags fmt;
+#else
+    Int_t fmt;
+#endif
+#endif
+
+    *os << fGeomDetOut << " " << fGeomDetIn << " " << fByThick << " ";
+    *os << fMajorVersion << " " << fMinorVersion << " ";
+    *os << "\"" << fEuclidGeomDet.Data() << "\"" << " ";
+    *os << "\"" << fRead.Data() << "\"" << " ";
+    *os << "\"" << fWrite.Data() << "\"" << " ";
+    fmt = os->setf(ios::scientific); // set scientific floating point output
+    *os << fDet1 << " "  << fDet2 << " " << fChip1 << " " << fChip2 << " ";
+    *os << fRails << " " << fFluid << " " << fIDMother;
+    os->flags(fmt); // reset back to old Formating.
+    return;
+}
+
+//______________________________________________________________________
+void AliITSvPPRasymmFMD::ReadAscii(istream *is){
+    // Read in class data values in Ascii Form to output stream
+    // Inputs:
+    //   istream *is   Input stream where Ascii data is to be read in from
+    // Outputs:
+    //   none.
+    // Return:
+    //   none.
+    Char_t name[120];
+
+    *is >> fGeomDetOut >> fGeomDetIn >> fByThick;
+    *is >> fMajorVersion >> fMinorVersion;
+    *is >> name;
+    fEuclidGeomDet = name;
+    *is >> name;
+    fRead = name;
+    *is >> name;
+    fWrite = name;
+    *is >> fDet1 >> fDet2 >> fChip1 >> fChip2;
+    *is >> fRails >> fFluid >> fIDMother;
+    fIgm.SetVersion((AliITSVersion_t)fMajorVersion,fMinorVersion);
+    fIgm.SetGeometryName("ITS PPR aymmetric services with course"
+                         " cables on cones");
+}
+
+//______________________________________________________________________
+ostream &operator<<(ostream &os,const AliITSvPPRasymmFMD &s){
+    // Standard output streaming function
+    // Inputs:
+    //   ostream            &os  output steam
+    //   AliITSvPPRasymmFMD &s class to be streamed.
+    // Output:
+    //   none.
+    // Return:
+    //   ostream &os  The stream pointer
+
+    s.PrintAscii(&os);
+    return os;
+}
+
+//______________________________________________________________________
+istream &operator>>(istream &is,AliITSvPPRasymmFMD &s){
+    // Standard inputput streaming function
+    // Inputs:
+    //   istream            &is  input steam
+    //   AliITSvPPRasymmFMD &s class to be streamed.
+    // Output:
+    //   none.
+    // Return:
+    //   ostream &os  The stream pointer
+
+    s.ReadAscii(&is);
+    return is;
+}