]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt1GeometryBuilderV2.cxx
Add some class-docs.
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1GeometryBuilderV2.cxx
index c177550389b34f6f851cae3881226f9c969fff6b..f4a1b52b1b3f8ac88da1bfb187cfc57420604e85 100644 (file)
 
 // $Id$
 //
-// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
-//
+//-----------------------------------------------------------------------------
 // Class AliMUONSt1GeometryBuilderV2
 // ---------------------------------
 // MUON Station1 detailed geometry construction class.
 // (Originally defined in AliMUONv2.cxx - now removed.)
 // Included in AliRoot 2004/01/23
+// Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
+//-----------------------------------------------------------------------------
 
-#ifdef ST1_WITH_STL
-  #include <vector>
-#endif
+#include "AliMUONSt1GeometryBuilderV2.h"
+#include "AliMUONSt1SpecialMotif.h"
+#include "AliMUON.h"
+#include "AliMUONConstants.h"
+#include "AliMUONGeometryModule.h"
+#include "AliMUONGeometryEnvelopeStore.h"
 
-#ifdef ST1_WITH_ROOT
-  #include "TArrayI.h"
-#endif
+#include "AliMpSegmentation.h"
+#include "AliMpDEManager.h"
+#include "AliMpContainers.h"
+#include "AliMpConstants.h"
+#include "AliMpCDB.h"
+#include "AliMpSectorSegmentation.h"
+#include "AliMpSector.h"
+#include "AliMpRow.h"
+#include "AliMpVRowSegment.h"
+#include "AliMpMotifMap.h"
+#include "AliMpMotifPosition.h"
+#include "AliMpPlaneType.h"
+
+#include "AliRun.h"
+#include "AliMagF.h"
+#include "AliLog.h"
 
 #include <TVector2.h>
 #include <TVector3.h>
 #include <Riostream.h>
 #include <TSystem.h>
 #include <TVirtualMC.h>
+#include <TGeoManager.h>
+#include <TGeoVolume.h>
+#include <TGeoTube.h>
+#include <TGeoCompositeShape.h>
 
-#include "AliMpFiles.h"
-#include "AliMpReader.h"
-#include "AliMpSector.h"
-#include "AliMpRow.h"
-#include "AliMpVRowSegment.h"
-#include "AliMpMotifMap.h"
-#include "AliMpMotifPosition.h"
+#ifdef WITH_STL
+  #include <vector>
+#endif
 
-#include "AliMUONSt1GeometryBuilderV2.h"
-#include "AliMUONSt1SpecialMotif.h"
-#include "AliMUON.h"
-#include "AliMUONChamber.h"
-#include "AliMUONChamberGeometry.h"
-#include "AliMUONGeometryEnvelopeStore.h"
-#include "AliRun.h"
-#include "AliMagF.h"
+#ifdef WITH_ROOT
+  #include "TArrayI.h"
+#endif
 
+/// \cond CLASSIMP
 ClassImp(AliMUONSt1GeometryBuilderV2)
+/// \endcond
 
 // Thickness Constants
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzPadPlane=0.0148/2.;     //Pad plane
-const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFoam = 2.083/2.;        //Foam of mechanicalplane
-const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFR4 = 0.0031/2.;        //FR4 of mechanical plane
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFoam = 2.503/2.;        //Foam of mechanicalplane
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzFR4 = 0.062/2.;         //FR4 of mechanical plane
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzSnPb = 0.0091/2.;       //Pad/Kapton connection (66 pt)
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzKapton = 0.0122/2.;     //Kapton
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzBergPlastic = 0.3062/2.;//Berg connector
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzBergCopper = 0.1882/2.; //Berg connector
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzDaughter = 0.0156/2.;   //Daughter board
-const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzGas = 0.2/2.;           //Gas thickness
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkHzGas = 0.42/2.;          //Gas thickness
 
 // Quadrant Mother volume - TUBS1 - Middle layer of model
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkMotherIR1 = 18.3;
@@ -100,31 +114,29 @@ const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamX=1.46;
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamY=0.051;
 
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaQuadLHC=2.6;  // LHC Origin wrt Quadrant Origin
-const GReal_t AliMUONSt1GeometryBuilderV2::fgkFrameOffset=5.0;  
-
-const char* AliMUONSt1GeometryBuilderV2::fgkHoleName="MCHL";      
-const char* AliMUONSt1GeometryBuilderV2::fgkDaughterName="MCDB";  
-const char  AliMUONSt1GeometryBuilderV2::fgkFoamLayerSuffix='F';  // prefix for automatic volume naming
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkFrameOffset=5.2;
+              // Fix (1) of overlap SQN* layers with SQM* ones (was 5.0)
+             
+// Pad planes offsets
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkPadXOffsetBP =  0.50 - 0.63/2; // = 0.185
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkPadYOffsetBP = -0.31 - 0.42/2; // =-0.52
+
+const char* AliMUONSt1GeometryBuilderV2::fgkHoleName="SCHL";      
+const char* AliMUONSt1GeometryBuilderV2::fgkDaughterName="SCDB";  
+const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantEnvelopeName="SE";
 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantMLayerName="SQM";
 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantNLayerName="SQN";
 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantFLayerName="SQF";
+const Int_t AliMUONSt1GeometryBuilderV2::fgkFoamBoxNameOffset=200; 
+const Int_t AliMUONSt1GeometryBuilderV2::fgkFR4BoxNameOffset=400; 
+const Int_t AliMUONSt1GeometryBuilderV2::fgkDaughterCopyNoOffset=1000;
 
 //______________________________________________________________________________
 AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(AliMUON* muon)
-  : AliMUONVGeometryBuilder("st1V2.dat",
-                            &muon->Chamber(0), &muon->Chamber(1)),
+  : AliMUONVGeometryBuilder(0, 2),
     fMUON(muon)
 {
-   // set path to mapping data files
-   if (! gSystem->Getenv("MINSTALL")) {    
-     TString dirPath = gSystem->Getenv("ALICE_ROOT");
-     dirPath += "/MUON/mapping"; 
-     AliMpFiles::Instance()->SetTopPath(dirPath);
-     gSystem->Setenv("MINSTALL", dirPath.Data());
-     //cout << "AliMpFiles top path set to " << dirPath << endl;         
-   }
-   //else
-   //  cout << gSystem->Getenv("MINSTALL") << endl;              
+/// Standard constructor
 }
  
 //______________________________________________________________________________
@@ -132,49 +144,34 @@ AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2()
   : AliMUONVGeometryBuilder(),
     fMUON(0)
 {
-// Default Constructor
-// --
-}
-//______________________________________________________________________________
-AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(const AliMUONSt1GeometryBuilderV2& rhs)
-  : AliMUONVGeometryBuilder(rhs)
-{
-// Dummy copy constructor
-
- Fatal("Copy constructor", 
-        "Copy constructor is not implemented.");
+/// Default Constructor
 }
 
 //______________________________________________________________________________
 AliMUONSt1GeometryBuilderV2::~AliMUONSt1GeometryBuilderV2()
 {
-// Destructor
+/// Destructor
 }
 
 
-//______________________________________________________________________________
-AliMUONSt1GeometryBuilderV2& 
-AliMUONSt1GeometryBuilderV2::operator = (const AliMUONSt1GeometryBuilderV2& rhs) 
-{
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  Fatal("operator=", 
-        "Assignment operator is not implemented.");
-    
-  return *this;  
-}
-
 //
 //  Private methods
 //
 
+//______________________________________________________________________________
+TString 
+AliMUONSt1GeometryBuilderV2::QuadrantEnvelopeName(Int_t chamber, Int_t quadrant) const
+{ 
+/// Generate unique envelope name from chamber Id and quadrant number
+
+  return Form("%s%d", Form("%s%d",fgkQuadrantEnvelopeName,chamber), quadrant); 
+}
+
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateHole()
 {
-// Create all the elements found inside a foam hole
-// --
+/// Create all the elements found inside a foam hole
+
   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   Int_t idAir  = idtmed[1100];      // medium 1
   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper 
@@ -200,18 +197,18 @@ void AliMUONSt1GeometryBuilderV2::CreateHole()
   par[0] = fgkHxHole;
   par[1] = fgkHyBergPlastic;
   par[2] = fgkHzKapton;
-  gMC->Gsvolu("KAPT", "BOX", idCopper, par, 3);
+  gMC->Gsvolu("SKPT", "BOX", idCopper, par, 3);
   posX = 0.;
   posY = 0.;
   posZ = 0.;
-  gMC->Gspos("KAPT",1,fgkHoleName, posX, posY, posZ, 0,"ONLY");
+  gMC->Gspos("SKPT",1,fgkHoleName, posX, posY, posZ, 0,"ONLY");
 }
 
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateDaughterBoard()
 {
-// Create all the elements in a daughter board
-// --
+/// Create all the elements in a daughter board
+
   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   Int_t idAir  = idtmed[1100]; // medium 1
   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
@@ -230,43 +227,42 @@ void AliMUONSt1GeometryBuilderV2::CreateDaughterBoard()
   par[0]=fgkHxBergPlastic;
   par[1]=fgkHyBergPlastic;
   par[2]=fgkHzBergPlastic;
-  gMC->Gsvolu("BRGP","BOX",idPlastic,par,3);
+  gMC->Gsvolu("SBGP","BOX",idPlastic,par,3);
   posX=0.;
   posY=0.;
   posZ = -TotalHzDaughter() + fgkHzBergPlastic;
-  gMC->Gspos("BRGP",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
+  gMC->Gspos("SBGP",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
 
   par[0]=fgkHxBergCopper;
   par[1]=fgkHyBergCopper;
   par[2]=fgkHzBergCopper;
-  gMC->Gsvolu("BRGC","BOX",idCopper,par,3);
+  gMC->Gsvolu("SBGC","BOX",idCopper,par,3);
   posX=0.;
   posY=0.;
   posZ=0.;
-  gMC->Gspos("BRGC",1,"BRGP",posX,posY,posZ,0,"ONLY");
+  gMC->Gspos("SBGC",1,"SBGP",posX,posY,posZ,0,"ONLY");
 
   par[0]=fgkHxDaughter;
   par[1]=fgkHyDaughter;
   par[2]=fgkHzDaughter;
-  gMC->Gsvolu("DGHT","BOX",idCopper,par,3);
+  gMC->Gsvolu("SDGH","BOX",idCopper,par,3);
   posX=0.;
   posY=0.;
   posZ = -TotalHzDaughter() + 2.*fgkHzBergPlastic + fgkHzDaughter;
-  gMC->Gspos("DGHT",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
+  gMC->Gspos("SDGH",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
 }
 
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
 {
-// Create the layer of sensitive volumes with gas
-// and the copper layer.
-// --
+/// Create the layer of sensitive volumes with gas
+/// and the copper layer.
 
 // Gas Medium
   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099; 
-  //Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
+  Int_t idArCO2  = idtmed[1108];  // medium 9 (ArCO2 80%) 
   //Int_t idCopper  = idtmed[1109]; // medium 10 = copper
-  Int_t idArCO2   = idtmed[1124]; // medium 25 (ArCO2 80%) 
+  //Int_t idArCO2   = idtmed[1124]; // medium 25 (ArCO2 80%) 
   Int_t idCopper  = idtmed[1121]; // medium 22 = copper
 
   Float_t par[11];
@@ -476,70 +472,110 @@ void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
 {
-// create the quadrant (bending and non-bending planes)
-// for the given chamber
-// --
+/// Create the quadrant (bending and non-bending planes)
+/// for the given chamber
 
   CreateFrame(chamber);
 
-#ifdef ST1_WITH_STL
+#ifdef WITH_STL
   SpecialMap specialMap;
-  specialMap[1001] = AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.);
-  specialMap[1002] = AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36));
-  specialMap[1003] = AliMUONSt1SpecialMotif(TVector2(1.01, 0.36));
+  specialMap[76] = AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.);
+  specialMap[75] = AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36));
+  specialMap[47] = AliMUONSt1SpecialMotif(TVector2(1.01, 0.36));
 #endif
   
-#ifdef ST1_WITH_ROOT
+#ifdef WITH_ROOT
   SpecialMap specialMap;
-  specialMap.Add(1001, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.));
-  specialMap.Add(1002, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36)));
-  specialMap.Add(1003, (Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01, 0.36)));
+  specialMap.Add(76, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.));
+  specialMap.Add(75, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.5, 0.36)));
+  specialMap.Add(47, (Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01, 0.36)));
 #endif
 
-  AliMpReader reader1(kStation1, kBendingPlane);
-  AliMpSector* sector1 = reader1.BuildSector();
-
-  Bool_t reflectZ = true;
-  TVector3 where = TVector3(2.5+0.1+0.56+0.001, 2.5+0.1+0.001, 0.);
-  PlaceSector(sector1, specialMap, where, reflectZ, chamber);
+  // Load mapping from OCDB
+  if ( ! AliMpSegmentation::Instance() ) {
+    AliFatal("Mapping has to be loaded first !");
+  }
+       
+  const AliMpSectorSegmentation* kSegmentation1 
+    = dynamic_cast<const AliMpSectorSegmentation*>(
+        AliMpSegmentation::Instance()
+          ->GetMpSegmentation(100, AliMpDEManager::GetCathod(100, AliMp::kBendingPlane))); 
+  if ( ! kSegmentation1 ) {
+    AliFatal("Could not access sector segmentation !");
+  }
+    
+  const AliMpSector* kSector1 = kSegmentation1->GetSector();
+/*
+  AliMpSectorReader reader1(AliMp::kStation1, AliMp::kBendingPlane);
+  AliMpSector* kSector1 = reader1.BuildSector();
+*/
+  //Bool_t reflectZ = true;
+  Bool_t reflectZ = false;
+  //TVector3 where = TVector3(2.5+0.1+0.56+0.001, 2.5+0.1+0.001, 0.);
+  TVector3 where = TVector3(fgkDeltaQuadLHC + fgkPadXOffsetBP, 
+                            fgkDeltaQuadLHC + fgkPadYOffsetBP, 0.);
+  PlaceSector(kSector1, specialMap, where, reflectZ, chamber);
   
-#ifdef ST1_WITH_STL
+#ifdef WITH_STL
   specialMap.clear();
-  specialMap[4001] = AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.);
-  specialMap[4002] = AliMUONSt1SpecialMotif(TVector2(1.96, 0.17));
-  specialMap[4003] = AliMUONSt1SpecialMotif(TVector2(1.61,-1.18));
-  specialMap[4004] = AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08));
-  specialMap[4005] = AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25));
-  specialMap[4006] = AliMUONSt1SpecialMotif(TVector2(0.28, 0.21));
+  specialMap[76] = AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.);
+  specialMap[75] = AliMUONSt1SpecialMotif(TVector2(1.96, 0.17));
+  specialMap[47] = AliMUONSt1SpecialMotif(TVector2(2.18,-0.98));
+  specialMap[20] = AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08));
+  specialMap[46] = AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25));
+  specialMap[74] = AliMUONSt1SpecialMotif(TVector2(0.28, 0.21));
+      // Fix (7) - overlap of SQ42 with MCHL (after moving the whole sector
+      // in the true position)   
+      // Was: specialMap[47] = AliMUONSt1SpecialMotif(TVector2(1.61,-1.18));
 #endif
 
-#ifdef ST1_WITH_ROOT
+#ifdef WITH_ROOT
+  Int_t nb = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
   specialMap.Delete();
-  specialMap.Add(4001,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.));
-  specialMap.Add(4002,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.96, 0.17)));
-  specialMap.Add(4003,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.61,-1.18)));
-  specialMap.Add(4004,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08)));
-  specialMap.Add(4005,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25)));
-  specialMap.Add(4006,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.28, 0.21)));
+  specialMap.Add(76 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.));
+  specialMap.Add(75 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.96, 0.17)));
+  specialMap.Add(47 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(2.18,-0.98)));
+  specialMap.Add(20 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08)));
+  specialMap.Add(46 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25)));
+  specialMap.Add(74 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.28, 0.21)));  
+      // Fix (7) - overlap of SQ42 with MCHL (after moving the whole sector
+      // in the true position)   
+      // Was: specialMap.Add(47,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.61,-1.18)));
 #endif
-
-  AliMpReader reader2(kStation1, kNonBendingPlane);
+/*
+  AliMpSectorReader reader2(AliMp::kStation1, AliMp::kNonBendingPlane);
   AliMpSector* sector2 = reader2.BuildSector();
-
-  reflectZ = false;
-  where = TVector3(where.X()+0.63/2.,where.Y()+0.42/2., 0.); //add a half pad shift
-  PlaceSector(sector2, specialMap, where, reflectZ, chamber);
-
-#ifdef ST1_WITH_ROOT
+*/  
+  const AliMpSectorSegmentation* kSegmentation2 
+    = dynamic_cast<const AliMpSectorSegmentation*>(
+        AliMpSegmentation::Instance()
+          ->GetMpSegmentation(100, AliMpDEManager::GetCathod(100, AliMp::kNonBendingPlane))); 
+  if ( ! kSegmentation2 ) {
+    AliFatal("Could not access sector segmentation !");
+  }
+    
+  const AliMpSector* kSector2 = kSegmentation2->GetSector();
+
+  //reflectZ = false;
+  reflectZ = true;
+  TVector2 offset = kSector2->Position();
+  where = TVector3(where.X()+offset.X(), where.Y()+offset.Y(), 0.); 
+      // Add the half-pad shift of the non-bending plane wrt bending plane
+      // (The shift is defined in the mapping as sector offset)
+      // Fix (4) - was TVector3(where.X()+0.63/2, ... - now it is -0.63/2
+  PlaceSector(kSector2, specialMap, where, reflectZ, chamber);
+
+#ifdef WITH_ROOT
   specialMap.Delete();
 #endif
 }
 
 //______________________________________________________________________________
-void AliMUONSt1GeometryBuilderV2::CreateFoamBox(const char* name,const  TVector2& dimensions)
+void AliMUONSt1GeometryBuilderV2::CreateFoamBox(
+                                        Int_t segNumber,
+                                        const  TVector2& dimensions)
 {
-// create all the elements in the copper plane
-// --
+/// Create all the elements in the copper plane
 
   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   Int_t idAir  = idtmed[1100]; // medium 1
@@ -553,89 +589,82 @@ void AliMUONSt1GeometryBuilderV2::CreateFoamBox(const char* name,const  TVector2
   par[0] = dimensions.X();
   par[1] = dimensions.Y();
   par[2] = TotalHzPlane();
-  gMC->Gsvolu(name,"BOX",idAir,par,3);
+  gMC->Gsvolu(PlaneSegmentName(segNumber).Data(),"BOX",idAir,par,3);
   
   // foam layer
-  GReal_t posX,posY,posZ;
-  char eName[5];
-  strcpy(eName,name);
-  eName[3]=fgkFoamLayerSuffix;
   par[0] = dimensions.X();
   par[1] = dimensions.Y();
   par[2] = fgkHzFoam;
-  gMC->Gsvolu(eName,"BOX",idFoam,par,3);
+  gMC->Gsvolu(FoamBoxName(segNumber).Data(),"BOX",idFoam,par,3);
+  GReal_t posX,posY,posZ;
   posX=0.;
   posY=0.;
   posZ = -TotalHzPlane() + fgkHzFoam;
-  gMC->Gspos(eName,1,name,posX,posY,posZ,0,"ONLY");
+  gMC->Gspos(FoamBoxName(segNumber).Data(),1, 
+             PlaneSegmentName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
 
   // mechanical plane FR4 layer
-  eName[3]='R';
   par[0] = dimensions.X();
   par[1] = dimensions.Y();
   par[2] = fgkHzFR4;
-  gMC->Gsvolu(eName,"BOX",idFR4,par,3);
+  gMC->Gsvolu(FR4BoxName(segNumber).Data(),"BOX",idFR4,par,3);
   posX=0.;
   posY=0.;
   posZ = -TotalHzPlane()+ 2.*fgkHzFoam + fgkHzFR4;
-  gMC->Gspos(eName,1,name,posX,posY,posZ,0,"ONLY");
+  gMC->Gspos(FR4BoxName(segNumber).Data(),1,
+             PlaneSegmentName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
 }
 
 //______________________________________________________________________________
-void AliMUONSt1GeometryBuilderV2::CreatePlaneSegment(const char* name,const  TVector2& dimensions,
-                                  Int_t nofHoles)
+void AliMUONSt1GeometryBuilderV2::CreatePlaneSegment(Int_t segNumber,
+                                    const  TVector2& dimensions,
+                                   Int_t nofHoles)
 {
-// Create a segment of a plane (this includes a foam layer, 
-// holes in the foam to feed the kaptons through, kapton connectors
-// and the mother board.)
-// --
+/// Create a segment of a plane (this includes a foam layer, 
+/// holes in the foam to feed the kaptons through, kapton connectors
+/// and the mother board.)
   
-  CreateFoamBox(name,dimensions);
+  CreateFoamBox(segNumber,dimensions);
 
-  char eName[5];
-  strcpy(eName,name);
-  eName[3]=fgkFoamLayerSuffix;
-  
   for (Int_t holeNum=0;holeNum<nofHoles;holeNum++) {
     GReal_t posX = ((2.*holeNum+1.)/nofHoles-1.)*dimensions.X();
     GReal_t posY = 0.;
     GReal_t posZ = 0.;
   
-    gMC->Gspos(fgkHoleName,holeNum+1,eName,posX,posY,posZ,0,"ONLY");
+    gMC->Gspos(fgkHoleName,holeNum+1,
+               FoamBoxName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
   }
 }
 
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
 {
-// Create the non-sensitive elements of the frame for the  <chamber>
-//
-// 
-// Model and notation:
-//
-// The Quadrant volume name starts with SQ
-// The volume segments are numbered 00 to XX.
-//
-//                              OutTopFrame
-//                               (SQ02-16) 
-//                              ------------  
-//             OutEdgeFrame   /              |
-//             (SQ17-24)     /               |  InVFrame (SQ00-01) 
-//                          /                |
-//                          |                |   
-//               OutVFrame  |            _- - 
-//               (SQ25-39)  |           |   InArcFrame (SQ42-45)
-//                          |           |
-//                          -------------
-//                        InHFrame (SQ40-41)
-//                          
-//
-// 06 February 2003 - Overlapping volumes resolved.
-// One quarter chamber is comprised of three TUBS volumes: SQMx, SQNx, and SQFx,
-// where SQMx is the Quadrant Middle layer for chamber <x> ( posZ in [-3.25,3.25]),
-// SQNx is the Quadrant Near side layer for chamber <x> ( posZ in [-6.25,3-.25) ), and
-// SQFx is the Quadrant Far side layer for chamber <x> ( posZ in (3.25,6.25] ).
-//---
+/// Create the non-sensitive elements of the frame for the \a chamber
+///
+/// Model and notation:                                                     \n
+///                                                                         \n
+/// The Quadrant volume name starts with SQ                                 \n
+/// The volume segments are numbered 00 to XX                               \n
+///                                                                         \n
+///                              OutTopFrame                                \n
+///                               (SQ02-16)                                 \n 
+///                              ------------                               \n
+///             OutEdgeFrame   /              |                             \n
+///             (SQ17-24)     /               |  InVFrame (SQ00-01)         \n 
+///                          /                |                             \n
+///                          |                |                             \n 
+///               OutVFrame  |            _- -                              \n
+///               (SQ25-39)  |           |   InArcFrame (SQ42-45)           \n
+///                          |           |                                  \n 
+///                          -------------                                  \n 
+///                        InHFrame (SQ40-41)                               \n 
+///                                                                         \n                         
+///                                                                         \n
+/// 06 February 2003 - Overlapping volumes resolved.                        \n
+/// One quarter chamber is comprised of three TUBS volumes: SQMx, SQNx, and SQFx,
+/// where SQMx is the Quadrant Middle layer for chamber \a chamber ( posZ in [-3.25,3.25]),
+/// SQNx is the Quadrant Near side layer for chamber \a chamber ( posZ in [-6.25,3-.25) ), and
+/// SQFx is the Quadrant Far side layer for chamber \a chamber ( posZ in (3.25,6.25] ).
 
   const Float_t kNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 
@@ -877,13 +906,19 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
   const Float_t kAlp2OETF2 = 2.94; 
  
 // Trapezoid 3
-  const Float_t kBl1OETF3 = 1.767/2.;
-  const Float_t kTl1OETF3 = 3.01/2.;
+  //const Float_t kBl1OETF3 = 1.767/2.;
+  //const Float_t kTl1OETF3 = 3.01/2.;
+  const Float_t kBl1OETF3 = 1.117/2.;
+  const Float_t kTl1OETF3 = 2.36/2.;
   const Float_t kAlp1OETF3 = 4.94;
+        // Fix (5) - overlap of SQ21 with 041M and 125M
       
-  const Float_t kBl2OETF3 = 1.767/2.;
-  const Float_t kTl2OETF3 = 3.01/2.; 
+  //const Float_t kBl2OETF3 = 1.767/2.;
+  //const Float_t kTl2OETF3 = 3.01/2.; 
+  const Float_t kBl2OETF3 = 1.117/2.;
+  const Float_t kTl2OETF3 = 2.36/2.;
   const Float_t kAlp2OETF3 = 4.94; 
+        // Fix (5) - overlap of SQ21 with 041M and 125M
   
 // Trapezoid 4
   const Float_t kBl1OETF4 = 0.;
@@ -1097,6 +1132,46 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
   par[4] = fgkMotherPhiU1;
   gMC->Gsvolu(QuadrantMLayerName(chamber),"TUBS",idAir,par,5);
 
+// Replace the volume shape with a composite shape
+// with substracted overlap with beam shield (YMOT)
+
+  if ( gMC->IsRootGeometrySupported() ) { 
+
+    // Get shape
+    TGeoVolume* mlayer 
+      = gGeoManager->FindVolumeFast(QuadrantMLayerName(chamber));
+    if ( !mlayer ) {
+      AliErrorStream() 
+         << "Quadrant volume " << QuadrantMLayerName(chamber) << " not found" 
+        << endl;
+    }
+    else {
+      TGeoShape* quadrant = mlayer->GetShape();
+      quadrant->SetName("quadrant");    
+
+      // Beam shield recess
+      par[0] = 0;
+      par[1] = 15.4; 
+      par[2] = fgkMotherThick1;  
+      new TGeoTube("shield_tube", par[0], par[1], par[2]);
+  
+      // Displacement
+      posX = 2.6;
+      posY = 2.6;
+      posZ = 0;
+      TGeoTranslation* displacement 
+        = new TGeoTranslation("TR", posX, posY, posZ);
+      displacement->RegisterYourself();
+
+      // Composite shape
+      TGeoShape* composite
+      = new TGeoCompositeShape("composite", "quadrant-shield_tube:TR"); 
+      
+      // Reset shape to volume      
+      mlayer->SetShape(composite);
+    }
+  }    
+
 // Quadrant volume TUBS2, positioned at the end
   par[0] = fgkMotherIR2;
   par[1] = fgkMotherOR2; 
@@ -1635,13 +1710,17 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     
     xCenter[0] = 73.201 + fgkDeltaQuadLHC;
     xCenter[1] = 78.124 + fgkDeltaQuadLHC; 
-    xCenter[2] = 82.862 + fgkDeltaQuadLHC;
+    //xCenter[2] = 82.862 + fgkDeltaQuadLHC;
+    xCenter[2] = 83.102 + fgkDeltaQuadLHC;
     xCenter[3] = 87.418 + fgkDeltaQuadLHC; 
+        // Fix (5) - overlap of SQ21 with 041M and 125M
     
     yCenter[0] = 68.122 + fgkDeltaQuadLHC;
     yCenter[1] = 62.860 + fgkDeltaQuadLHC;   
-    yCenter[2] = 57.420 + fgkDeltaQuadLHC;
+    //yCenter[2] = 57.420 + fgkDeltaQuadLHC;
+    yCenter[2] = 57.660 + fgkDeltaQuadLHC;
     yCenter[3] = 51.800 + fgkDeltaQuadLHC; 
+        // Fix (5) - overlap of SQ21 with 041M and 125M
       
     xCenter[4] = 68.122 + fgkDeltaQuadLHC;
     xCenter[5] = 62.860 + fgkDeltaQuadLHC; 
@@ -1787,10 +1866,11 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posZ = 0.;              
     gMC->Gspos("SQ36",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
 
-    posX = 98.31-kNearFarLHC;
+    posX = 98.05-kNearFarLHC;
     posY = 12.77-kNearFarLHC;        
-
     posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;         
+           // Fix (2) of extrusion SQ36 from SQN1, SQN2, SQF1, SQF2 
+          // (was posX = 98.31 ...)
     gMC->Gspos("SQ36",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");       
     posZ = -1.0*posZ;
     gMC->Gspos("SQ36",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
@@ -1807,9 +1887,11 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     gMC->Gspos("SQ37",3,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");          
              
 // LateralSightSupport - 2 copies
-    posX = 98.53-kNearFarLHC;
+    posX = 98.33-kNearFarLHC;
     posY = 10.00-kNearFarLHC;    
     posZ = kHzLateralSightAl-fgkMotherThick2;
+           // Fix (3) of extrusion SQ38 from SQN1, SQN2, SQF1, SQF2 
+           // (was posX = 98.53 ...)
     gMC->Gspos("SQ38",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;             
     gMC->Gspos("SQ38",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
@@ -1973,8 +2055,7 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::PlaceInnerLayers(Int_t chamber)
 {
-// Place the gas and copper layers for the specified chamber.
-// --
+/// Place the gas and copper layers for the specified chamber.
 
 // Rotation Matrices 
   Int_t rot1, rot2, rot3, rot4;   
@@ -2070,12 +2151,14 @@ void AliMUONSt1GeometryBuilderV2::PlaceInnerLayers(Int_t chamber)
 }
 
 //______________________________________________________________________________
-void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap specialMap, 
+void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
+                            SpecialMap specialMap, 
                             const TVector3& where, Bool_t reflectZ, Int_t chamber)
 {
-// Place all the segments in the mother volume, at the position defined
-// by the sector's data.
-// --
+/// Place all the segments in the mother volume, at the position defined
+/// by the sector's data.
+
+/// \cond SKIP
 
   static Int_t segNum=1;
   Int_t sgn;
@@ -2094,11 +2177,11 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
   
   GReal_t posX,posY,posZ;
   
-#ifdef ST1_WITH_STL  
+#ifdef WITH_STL  
   vector<Int_t> alreadyDone;
 #endif
 
-#ifdef ST1_WITH_ROOT  
+#ifdef WITH_ROOT  
   TArrayI alreadyDone(20);
   Int_t nofAlreadyDone = 0;
 #endif  
@@ -2109,40 +2192,45 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
 
     for (Int_t iseg=0;iseg<row->GetNofRowSegments();iseg++){ // for each row segment
       AliMpVRowSegment* seg = row->GetRowSegment(iseg);
-      char segName[5];
       
-#ifdef ST1_WITH_STL 
+#ifdef WITH_STL 
       SpecialMap::iterator iter 
         = specialMap.find(seg->GetMotifPositionId(0));
 
       if ( iter == specialMap.end()){ //if this is a normal segment (ie. not part of <specialMap>)
 #endif  
       
-#ifdef ST1_WITH_ROOT  
+#ifdef WITH_ROOT  
       Long_t value = specialMap.GetValue(seg->GetMotifPositionId(0));
 
       if ( value == 0 ){ //if this is a normal segment (ie. not part of <specialMap>)
 #endif  
       
         // create the cathode part
-        sprintf(segName,"%.3dM", segNum);
-        CreatePlaneSegment(segName, seg->Dimensions()/10., seg->GetNofMotifs());
+        CreatePlaneSegment(segNum, seg->Dimensions(), seg->GetNofMotifs());
   
-        posX = where.X() + seg->Position().X()/10.;
-        posY = where.Y() + seg->Position().Y()/10.;
+        posX = where.X() + seg->Position().X();
+        posY = where.Y() + seg->Position().Y();
         posZ = where.Z() + sgn * (TotalHzPlane() + fgkHzGas + 2.*fgkHzPadPlane);
-        gMC->Gspos(segName, 1, QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
+        gMC->Gspos(PlaneSegmentName(segNum).Data(), 1, 
+                  QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
 
         // and place all the daughter boards of this segment
         for (Int_t motifNum=0;motifNum<seg->GetNofMotifs();motifNum++) {
+
+         // Copy number
           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
           AliMpMotifPosition* motifPos = 
             sector->GetMotifMap()->FindMotifPosition(motifPosId);
+         Int_t copyNo = motifPosId;
+         if ( sector->GetDirection() == AliMp::kX) copyNo += fgkDaughterCopyNoOffset;
   
-          posX = where.X() + motifPos->Position().X()/10.+fgkOffsetX;
-          posY = where.Y() + motifPos->Position().Y()/10.+fgkOffsetY;
+          // Position
+          posX = where.X() + motifPos->Position().X() + fgkOffsetX;
+          posY = where.Y() + motifPos->Position().Y() + fgkOffsetY;
          posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
-          gMC->Gspos(fgkDaughterName, motifPosId, QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
+
+          gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
         }  
         segNum++;
        
@@ -2153,13 +2241,13 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
 
           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
           
-#ifdef ST1_WITH_STL
+#ifdef WITH_STL
           if (find(alreadyDone.begin(),alreadyDone.end(),motifPosId)
               != alreadyDone.end()) continue; // don't treat the same motif twice
 
           AliMUONSt1SpecialMotif spMot = specialMap[motifPosId];
 #endif
-#ifdef ST1_WITH_ROOT
+#ifdef WITH_ROOT
           Bool_t isDone = false;
          Int_t i=0;
          while (i<nofAlreadyDone && !isDone) {
@@ -2175,24 +2263,28 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
 
           AliMpMotifPosition* motifPos = sector->GetMotifMap()->FindMotifPosition(motifPosId);
 
+          // Copy number
+         Int_t copyNo = motifPosId;
+         if ( sector->GetDirection() == AliMp::kX) copyNo += fgkDaughterCopyNoOffset;
+
           // place the hole for the motif, wrt the requested rotation angle
           Int_t rot = ( spMot.GetRotAngle()<0.1 ) ? reflZ:rotMat;
 
-          posX = where.X() + motifPos->Position().X()/10.+spMot.GetDelta().X();
-          posY = where.Y() + motifPos->Position().Y()/10.+spMot.GetDelta().Y();
+          posX = where.X() + motifPos->Position().X() + spMot.GetDelta().X();
+          posY = where.Y() + motifPos->Position().Y() + spMot.GetDelta().Y();
           posZ = where.Z() + sgn * (TotalHzPlane() + fgkHzGas + 2.*fgkHzPadPlane);
-          gMC->Gspos(fgkHoleName, motifPosId, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
+          gMC->Gspos(fgkHoleName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
 
           // then place the daughter board for the motif, wrt the requested rotation angle
           posX = posX+fgkDeltaFilleEtamX;
           posY = posY+fgkDeltaFilleEtamY;
          posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
-          gMC->Gspos(fgkDaughterName, motifPosId, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
+          gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, rot, "ONLY");
 
-#ifdef ST1_WITH_STL
+#ifdef WITH_STL
           alreadyDone.push_back(motifPosId);// mark this motif as done
 #endif
-#ifdef ST1_WITH_ROOT
+#ifdef WITH_ROOT
           if (nofAlreadyDone == alreadyDone.GetSize()) 
             alreadyDone.Set(2*nofAlreadyDone); 
           alreadyDone.AddAt(motifPosId, nofAlreadyDone++);               
@@ -2203,13 +2295,13 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
       }// end of special motif case
     }
   }
+/// \endcond
 } 
 
 //______________________________________________________________________________
 TString AliMUONSt1GeometryBuilderV2::GasVolumeName(const TString& name, Int_t chamber) const
 {
-// Inserts the chamber number into the name.
-// ---
+/// Insert the chamber number into the name.
 
   TString newString(name);
  
@@ -2221,43 +2313,6 @@ TString AliMUONSt1GeometryBuilderV2::GasVolumeName(const TString& name, Int_t ch
   return newString;
 }
 
-/*
-//______________________________________________________________________________
-Bool_t AliMUONSt1GeometryBuilderV2::IsInChamber(Int_t ich, Int_t volGid) const
-{
-// True if volume <volGid> is part of the sensitive 
-// volumes of chamber <ich> 
-// ---
-  for (Int_t i = 0; i < fChamberV2[ich]->GetSize(); i++) {
-      if (fChamberV2[ich]->At(i) == volGid) return kTRUE;
-  }
-  return kFALSE;
-}
-*/
-
-//
-// protected methods
-//
-
-/*
-//______________________________________________________________________________
-Int_t  AliMUONSt1GeometryBuilderV2::GetChamberId(Int_t volId) const
-{
-// Check if the volume with specified  volId is a sensitive volume (gas) 
-// of some chamber and returns the chamber number;
-// if not sensitive volume - return 0.
-// ---
-
-  for (Int_t i = 1; i <=2; i++) 
-     if (IsInChamber(i-1,volId)) return i;
-  
-  for (Int_t i = 3; i <= AliMUONConstants::NCh(); i++)
-    if (volId==((AliMUONChamber*)(*fChambers)[i-1])->GetGid()) return i;
-
-  return 0;
-}
-*/
-
 //
 // public methods
 //
@@ -2265,6 +2320,8 @@ Int_t  AliMUONSt1GeometryBuilderV2::GetChamberId(Int_t volId) const
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateMaterials()
 {
+/// Define materials specific to station 1
+
 // Materials and medias defined in MUONv1:
 //
 //  AliMaterial( 9, "ALUMINIUM$", 26.98, 13., 2.7, 8.9, 37.2);
@@ -2292,6 +2349,7 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
 //  AliMedium(12, "VETRONITE         ",  32, 0, iSXFLD, ... 
 //  AliMedium(13, "CARBON            ",  33, 0, iSXFLD, ... 
 //  AliMedium(14, "Rohacell          ",  34, 0, iSXFLD, ... 
+//  AliMedium(24, "FrameCH$          ",  44, 1, iSXFLD, ...
 
   //
   // --- Define materials for GEANT ---
@@ -2301,30 +2359,18 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
        // was id: 9
        // from PDG and "The Particle Detector BriefBook", Bock and Vasilescu, P.18  
         // ??? same but the last but one argument < 0 
-  
-  fMUON->AliMaterial(42, "Copper$", 63.546,29.,8.96,-1.43,9.6);
-       // was id: 30
-
-  fMUON->AliMaterial(43, "FR4$", 17.749, 8.875, 1.7, -19.4, 999.);    // from DPG
-       // was id: 31
-
-  fMUON->AliMaterial(44, "FrameEpoxy",12.24,6.0,1.85,-19.14,999);// use 16.75cm
-        // was id: 36
-        // Density of FrameEpoxy only from manufacturer's specifications
-        // Frame composite epoxy , X0 in g/cm**2 (guestimation!)
-  
   //
   // --- Define mixtures for GEANT ---
   //
 
-  //     Ar-CO2 gas II (80%+20%)
-  Float_t ag1[2]   = { 39.95,  44.01};
-  Float_t zg1[2]   = { 18., 22.};
-  Float_t wg1[2]   = { .8, 0.2};
-  Float_t dg1      = .001821;
-  fMUON->AliMixture(45, "ArCO2 II 80%$", ag1, zg1, dg1, 2, wg1);  
-            // was id: 22
-            // use wg1 weighting factors (6th arg > 0)
+ //  //     Ar-CO2 gas II (80%+20%)   
+//   Float_t ag1[2]   = { 39.95,  44.01};
+//   Float_t zg1[2]   = { 18., 22.};
+//   Float_t wg1[2]   = { .8, 0.2};
+//   Float_t dg1      = .001821;
+//   fMUON->AliMixture(45, "ArCO2 II 80%$", ag1, zg1, dg1, 2, wg1);  
+//             // was id: 22
+//             // use wg1 weighting factors (6th arg > 0)
 
   // Rohacell 51  II - imide methacrylique
   Float_t aRohacell51[4] = { 12.01, 1.01, 16.00, 14.01}; 
@@ -2354,7 +2400,6 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
  
   // Not used, to be removed
   //
-  fMUON->AliMaterial(49, "Kapton$", 12.01,6,1.42,-28.6,999);          // from DPG
        // was id: 34
 
   // Inox/Stainless Steel (18%Cr, 9%Ni)
@@ -2380,25 +2425,17 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
   GReal_t stmin  = -.8;
   GReal_t maxStepAlu   = fMUON->GetMaxStepAlu();
   GReal_t maxDestepAlu = fMUON->GetMaxDestepAlu();
-  GReal_t maxStepGas   = fMUON->GetMaxStepGas();
-  Int_t iSXFLD   = gAlice->Field()->Integ();
+  // GReal_t maxStepGas   = fMUON->GetMaxStepGas();
+  Int_t iSXFLD   = gAlice->Field()->PrecInteg();
   Float_t sXMGMX = gAlice->Field()->Max();
 
   fMUON->AliMedium(21, "ALU_II$",    41, 0, iSXFLD, sXMGMX, 
                    tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
-                  // was med: 4  mat: 9
-  fMUON->AliMedium(22, "COPPER_II$", 42, 0, iSXFLD, sXMGMX, 
-                   tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
-                  // was med: 10  mat: 30
-  fMUON->AliMedium(23, "FR4_CH$",    43, 0, iSXFLD, sXMGMX, 
-                   10.0, 0.01, 0.1, 0.003, 0.003);
-                  // was med: 15  mat: 31 
-  fMUON->AliMedium(24, "FrameCH$",   44, 1, iSXFLD, sXMGMX, 
-                   10.0, 0.001, 0.001, 0.001, 0.001);
+
                   // was med: 20  mat: 36
-  fMUON->AliMedium(25, "ARG_CO2_II", 45, 1, iSXFLD, sXMGMX,
-                   tmaxfd, maxStepGas, maxDestepAlu, epsil, stmin);
-                  // was med: 9   mat: 22
//  fMUON->AliMedium(25, "ARG_CO2_II", 45, 1, iSXFLD, sXMGMX,
+//                    tmaxfd, maxStepGas, maxDestepAlu, epsil, stmin);
+//                // was med: 9   mat: 22
   fMUON->AliMedium(26, "FOAM_CH$",   46, 0, iSXFLD, sXMGMX,
                    10.0,  0.1, 0.1, 0.1, 0.1, 0, 0) ;
                   // was med: 16  mat: 32
@@ -2411,9 +2448,7 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
 
   // Not used, to be romoved
   //
-  fMUON->AliMedium(29, "Kapton$",    49, 0, iSXFLD, sXMGMX,  
-                   10.0, 0.01, 1.0, 0.003, 0.003);
-                  // was med: 18  mat: 34 
+
   fMUON->AliMedium(30, "InoxBolts$", 50, 1, iSXFLD, sXMGMX, 
                    10.0, 0.01, 1.0, 0.003, 0.003);
                   // was med: 21  mat: 37
@@ -2424,10 +2459,12 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateGeometry()
 {
-// Create the detailed GEANT geometry for the dimuon arm station1
-// --
-  cout << "AliMUONSt1GeometryBuilderV2::CreateGeometry()" << endl;
-  cout << "_________________________________________" << endl;
+/// Create the detailed GEANT geometry for the dimuon arm station1
+
+  AliDebug(1,"Called");
+
+  // Define chamber volumes as virtual
+  // 
 
   // Create basic volumes
   // 
@@ -2444,11 +2481,15 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
   fMUON->AliMatrix(reflXY,  90., 180., 90., 270., 0., 0.);
 */
   // Define transformations for each quadrant
+  // In old coordinate system:        In new coordinate system:
   // 
-  //     II. |  I.
-  //   _____ | ____
-  //         |
-  //    III. |  IV.
+  // 
+  //     II. |  I.                   I. |  II. 
+  //         |                    (101) | (100)
+  //   _____ | ____               _____ | ____                         
+  //         |                          |
+  //    III. |  IV.                 IV. | III.
+  //                              (102) | (103) 
   // 
 /*
   Int_t rotm[4];
@@ -2470,16 +2511,16 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
   scale[3] = TVector3( 1, -1, -1);  // quadrant IV
   
   Int_t  detElemId[4];  
-  detElemId[0] =  0;  // quadrant I
-  detElemId[1] = 51;  // quadrant II
-  detElemId[2] = 50;  // quadrant III
-  detElemId[3] =  1;  // quadrant IV
+  detElemId[0] =  1;  // quadrant I
+  detElemId[1] =  0;  // quadrant II
+  detElemId[2] =  3;  // quadrant III
+  detElemId[3] =  2;  // quadrant IV
   
   // Shift in Z of the middle layer
-  Double_t deltaZ = 6.5/2.;         
+  Double_t deltaZ = 7.5/2.;         
 
   // Position of quadrant I wrt to the chamber position
-  TVector3 pos0(-fgkDeltaQuadLHC, -fgkDeltaQuadLHC, deltaZ);
+  // TVector3 pos0(-fgkDeltaQuadLHC, -fgkDeltaQuadLHC, deltaZ);
 
   // Shift for near/far layers
   GReal_t  shiftXY = fgkFrameOffset;
@@ -2498,29 +2539,38 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
     // Place the quadrant
     for (Int_t i=0; i<4; i++) {
 
+      // DE envelope
+      GReal_t posx0, posy0, posz0;
+      posx0 = fgkPadXOffsetBP * scale[i].X();
+      posy0 = fgkPadYOffsetBP * scale[i].Y();;
+      posz0 = deltaZ * scale[i].Z();
+      GetEnvelopes(ich-1)
+        ->AddEnvelope(QuadrantEnvelopeName(ich,i), detElemId[i] + ich*100, true,
+                     TGeoTranslation(posx0, posy0, posz0), rotm[i]);
+
       // Middle layer
       GReal_t posx, posy, posz;
-      posx = pos0.X() * scale[i].X();
-      posy = pos0.Y() * scale[i].Y();
-      //posz = pos0.Z() * scale[i].Z() + AliMUONConstants::DefaultChamberZ(ich-1);
-      //gMC->Gspos(QuadrantMLayerName(ich), i+1, "ALIC", posx, posy, posz, rotm[i], "ONLY");
-      posz = pos0.Z() * scale[i].Z();
+      posx = -fgkDeltaQuadLHC - fgkPadXOffsetBP;
+      posy = -fgkDeltaQuadLHC - fgkPadYOffsetBP;
+      posz = 0.;
       GetEnvelopes(ich-1)
-        ->AddEnvelope(QuadrantMLayerName(ich), detElemId[i] + ich*100, i+1,
-                     TGeoTranslation(posx, posy, posz), rotm[i]);
+        ->AddEnvelopeConstituent(QuadrantMLayerName(ich), QuadrantEnvelopeName(ich,i),
+                    i+1, TGeoTranslation(posx, posy, posz));
 
       // Near/far layers
-      Real_t  posx2 = posx + shiftXY * scale[i].X();
-      Real_t  posy2 = posy + shiftXY * scale[i].Y();
-      Real_t  posz2 = posz - scale[i].Z()*shiftZ;
+      GReal_t  posx2 = posx + shiftXY;;
+      GReal_t  posy2 = posy + shiftXY;;
+      GReal_t  posz2 = posz - shiftZ;;
       //gMC->Gspos(QuadrantNLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
       GetEnvelopes(ich-1)
-        ->AddEnvelope(QuadrantNLayerName(ich), 0, i+1, TGeoTranslation(posx2, posy2, posz2), rotm[i]); 
+        ->AddEnvelopeConstituent(QuadrantNLayerName(ich), QuadrantEnvelopeName(ich,i),
+                    i+1, TGeoTranslation(posx2, posy2, posz2)); 
     
-      posz2 = posz + scale[i].Z()*shiftZ;      
+      posz2 = posz + shiftZ;      
       //gMC->Gspos(QuadrantFLayerName(ich), i+1, "ALIC", posx2, posy2, posz2, rotm[i],"ONLY");
       GetEnvelopes(ich-1)
-        ->AddEnvelope(QuadrantFLayerName(ich), 0, i+1, TGeoTranslation(posx2, posy2, posz2), rotm[i]); 
+        ->AddEnvelopeConstituent(QuadrantFLayerName(ich), QuadrantEnvelopeName(ich,i), 
+                    i+1, TGeoTranslation(posx2, posy2, posz2)); 
    }
  }     
 }
@@ -2528,48 +2578,50 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::SetTransformations() 
 {
-// Defines the transformations for the station2 chambers.
-// ---
-
-  AliMUONChamber* iChamber1 = GetChamber(0);
-  Double_t zpos1 = - iChamber1->Z(); 
-  iChamber1->GetGeometry()
-    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
-
-  AliMUONChamber* iChamber2 = GetChamber(1);
-  Double_t zpos2 = - iChamber2->Z(); 
-  iChamber2->GetGeometry()
-    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+/// Define the transformations for the station2 chambers.
+
+  if (gAlice->GetModule("SHIL")) {
+    SetMotherVolume(0, "YOUT1");
+    SetMotherVolume(1, "YOUT1");
+  }  
+
+  SetVolume(0, "SC01", true);
+  SetVolume(1, "SC02", true);
+
+  Double_t zpos1 = - AliMUONConstants::DefaultChamberZ(0); 
+  SetTranslation(0, TGeoTranslation(0., 0., zpos1));
+
+  Double_t zpos2 = - AliMUONConstants::DefaultChamberZ(1); 
+  SetTranslation(1, TGeoTranslation(0., 0., zpos2));
 }
 
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::SetSensitiveVolumes()
 {
-// Defines the sensitive volumes for station2 chambers.
-// ---
-
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SA1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SB1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SC1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SD1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SE1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SF1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SG1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SH1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SI1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SJ1G");
-  GetChamber(0)->GetGeometry()->SetSensitiveVolume("SK1G");
+/// Define the sensitive volumes for station2 chambers.
+
+  GetGeometry(0)->SetSensitiveVolume("SA1G");
+  GetGeometry(0)->SetSensitiveVolume("SB1G");
+  GetGeometry(0)->SetSensitiveVolume("SC1G");
+  GetGeometry(0)->SetSensitiveVolume("SD1G");
+  GetGeometry(0)->SetSensitiveVolume("SE1G");
+  GetGeometry(0)->SetSensitiveVolume("SF1G");
+  GetGeometry(0)->SetSensitiveVolume("SG1G");
+  GetGeometry(0)->SetSensitiveVolume("SH1G");
+  GetGeometry(0)->SetSensitiveVolume("SI1G");
+  GetGeometry(0)->SetSensitiveVolume("SJ1G");
+  GetGeometry(0)->SetSensitiveVolume("SK1G");
     
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SA2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SB2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SC2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SD2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SE2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SF2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SG2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SH2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SI2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SJ2G");
-  GetChamber(1)->GetGeometry()->SetSensitiveVolume("SK2G");
+  GetGeometry(1)->SetSensitiveVolume("SA2G");
+  GetGeometry(1)->SetSensitiveVolume("SB2G");
+  GetGeometry(1)->SetSensitiveVolume("SC2G");
+  GetGeometry(1)->SetSensitiveVolume("SD2G");
+  GetGeometry(1)->SetSensitiveVolume("SE2G");
+  GetGeometry(1)->SetSensitiveVolume("SF2G");
+  GetGeometry(1)->SetSensitiveVolume("SG2G");
+  GetGeometry(1)->SetSensitiveVolume("SH2G");
+  GetGeometry(1)->SetSensitiveVolume("SI2G");
+  GetGeometry(1)->SetSensitiveVolume("SJ2G");
+  GetGeometry(1)->SetSensitiveVolume("SK2G");
 }