]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt1GeometryBuilderV2.cxx
TClonesArray->Clone() removed
[u/mrichter/AliRoot.git] / MUON / AliMUONSt1GeometryBuilderV2.cxx
index 1234905961bdb2d8c8c2bfbe1a2226138b5edd91..2ed8def5d1cdc727b52fc1bfe61e4e331898a504 100644 (file)
 #include "AliMUONGeometryModule.h"
 #include "AliMUONGeometryEnvelopeStore.h"
 
+#include "AliMpSegmentation.h"
+#include "AliMpDEManager.h"
 #include "AliMpContainers.h"
 #include "AliMpConstants.h"
-#include "AliMpFiles.h"
-#include "AliMpSectorReader.h"
+#include "AliMpCDB.h"
+#include "AliMpSectorSegmentation.h"
 #include "AliMpSector.h"
 #include "AliMpRow.h"
 #include "AliMpVRowSegment.h"
@@ -108,7 +110,7 @@ const GReal_t AliMUONSt1GeometryBuilderV2::fgkHxDaughter=2.3/2.;
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkHyDaughter=6.3/2.;
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkOffsetX=1.46;
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkOffsetY=0.71;
-const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamX=1.46;
+const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamX=1.00;
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaFilleEtamY=0.051;
 
 const GReal_t AliMUONSt1GeometryBuilderV2::fgkDeltaQuadLHC=2.6;  // LHC Origin wrt Quadrant Origin
@@ -125,6 +127,7 @@ const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantEnvelopeName="SE";
 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantMLayerName="SQM";
 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantNLayerName="SQN";
 const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantFLayerName="SQF";
+const char* AliMUONSt1GeometryBuilderV2::fgkQuadrantMFLayerName="SQMF";
 const Int_t AliMUONSt1GeometryBuilderV2::fgkFoamBoxNameOffset=200; 
 const Int_t AliMUONSt1GeometryBuilderV2::fgkFR4BoxNameOffset=400; 
 const Int_t AliMUONSt1GeometryBuilderV2::fgkDaughterCopyNoOffset=1000;
@@ -135,17 +138,6 @@ AliMUONSt1GeometryBuilderV2::AliMUONSt1GeometryBuilderV2(AliMUON* muon)
     fMUON(muon)
 {
 /// Standard constructor
-
-   // set path to mapping data files
-   if (! gSystem->Getenv("MINSTALL")) {    
-     TString dirPath = gSystem->Getenv("ALICE_ROOT");
-     dirPath += "/MUON/mapping"; 
-     AliMpFiles::SetTopPath(dirPath);
-     gSystem->Setenv("MINSTALL", dirPath.Data());
-     //cout << "AliMpFiles top path set to " << dirPath << endl;         
-   }
-   //else
-   //  cout << gSystem->Getenv("MINSTALL") << endl;              
 }
  
 //______________________________________________________________________________
@@ -269,9 +261,9 @@ void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
 
 // 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];
@@ -478,80 +470,173 @@ void AliMUONSt1GeometryBuilderV2::CreateInnerLayers()
   gMC->Gsvolu("SK1C", "TRAP", idCopper,par, 11);
 }
 
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::CreateSpacer0()
+{
+/// The spacer volumes are defined according to the input prepared by Nicole Willis
+/// without any modifications
+///                                                                       <pre>
+/// No.    Type  Material Center (mm)            Dimensions (mm) (half lengths)
+///  5     BOX   EPOXY    408.2  430.4 522.41    5.75  1.5   25.5
+///  5P    BOX   EPOXY    408.2  445.4 522.41    5.75  1.5   25.5
+///  6     BOX   EPOXY    408.2  437.9 519.76    5.75  15.0   1.0
+///  6P    BOX   EPOXY    408.2  437.9 525.06    5.75  15.0   1.0
+///  7     CYL   INOX     408.2  437.9 522.41    r=3.0  hz=20.63
+///                                                                      </pre>
+
+  // tracking medias
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+  Int_t idFrameEpoxy = idtmed[1123]; // medium 24 = Frame Epoxy ME730  // was 20 not 16
+  Int_t idInox = idtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) // was 21 not 17
+
+  GReal_t par[3];
+  par[0] = 0.575;
+  par[1] = 0.150;
+  par[2] = 2.550;
+  gMC->Gsvolu("Spacer05","BOX",idFrameEpoxy,par,3);
+
+  par[0] = 0.575;
+  par[1] = 1.500;
+  par[2] = 0.100;
+  gMC->Gsvolu("Spacer06","BOX",idFrameEpoxy,par,3);
+
+  par[0] = 0.000;
+  par[1] = 0.300;
+  par[2] = 2.063;
+  gMC->Gsvolu("Spacer07","TUBE",idInox,par,3);
+}  
+
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::CreateSpacer()
+{
+/// The spacer volumes are defined according to the input prepared by Nicole Willis
+/// with modifications needed to fit into existing geometry.
+///                                                                       <pre>
+/// No.    Type  Material Center (mm)            Dimensions (mm) (half lengths)
+///  5     BOX   EPOXY    408.2  430.4 522.41    5.75  1.5   25.5
+///  5P    BOX   EPOXY    408.2  445.4 522.41    5.75  1.5   25.5
+///  6     BOX   EPOXY    408.2  437.9 519.76    5.75  15.0   1.0
+///  6P    BOX   EPOXY    408.2  437.9 525.06    5.75  15.0   1.0
+///  7     CYL   INOX     408.2  437.9 522.41    r=3.0  hz=20.63
+///                                                                      </pre>
+/// To fit in existing volumes the volumes 5 and 7 are represented by 2 volumes
+/// with half size in z (5A, &A); the dimensions of the volume 5A were also modified
+/// to avoid overlaps (x made smaller, y larger to abotain the identical volume)   
+
+  // tracking medias
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+  Int_t idFrameEpoxy = idtmed[1123]; // medium 24 = Frame Epoxy ME730  // was 20 not 16
+  Int_t idInox = idtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) // was 21 not 17
+
+  //GReal_t par[3];
+  //par[0] = 0.575;
+  //par[1] = 0.150;
+  //par[2] = 2.550;
+  //gMC->Gsvolu("Spacer5","BOX",idFrameEpoxy,par,3);
+
+  GReal_t par[3];
+  par[0] = 0.510;
+  par[1] = 0.170;
+  par[2] = 1.1515;
+  gMC->Gsvolu("Spacer5A","BOX",idFrameEpoxy,par,3);
+
+  par[0] = 0.516;
+  par[1] = 1.500;
+  par[2] = 0.100;
+  gMC->Gsvolu("Spacer6","BOX",idFrameEpoxy,par,3);
+
+  //par[0] = 0.000;
+  //par[1] = 0.300;
+  //par[2] = 2.063;
+  //gMC->Gsvolu("Spacer7","TUBE",idInox,par,3);
+
+  par[0] = 0.000;
+  par[1] = 0.300;
+  par[2] = 1.0315;
+  gMC->Gsvolu("Spacer7A","TUBE",idInox,par,3);
+}  
+
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateQuadrant(Int_t chamber)
 {
 /// Create the quadrant (bending and non-bending planes)
 /// for the given chamber
 
-  CreateFrame(chamber);
+  // CreateQuadrantLayersAsVolumes(chamber);
+  CreateQuadrantLayersAsAssemblies(chamber);
 
-#ifdef WITH_STL
-  SpecialMap specialMap;
-  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
+  CreateFrame(chamber);
   
-#ifdef WITH_ROOT
-  SpecialMap specialMap;
-  specialMap.Add(76, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.1, 0.84), 90.));
+  TExMap specialMap;
+  specialMap.Add(76, (Long_t) new AliMUONSt1SpecialMotif(TVector2( 0.1, 0.72), 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
 
-  AliMpSectorReader reader1(AliMp::kStation1, AliMp::kBendingPlane);
-  AliMpSector* sector1 = reader1.BuildSector();
+  // 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();
 
   //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(sector1, specialMap, where, reflectZ, chamber);
+  PlaceSector(kSector1, specialMap, where, reflectZ, chamber);
   
-#ifdef WITH_STL
-  specialMap.clear();
-  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 WITH_ROOT
   Int_t nb = AliMpConstants::ManuMask(AliMp::kNonBendingPlane);
+  TExMapIter it(&specialMap);
+  Long_t key;
+  Long_t value;
+  while ( it.Next(key,value) == kTRUE ) { 
+    delete reinterpret_cast<AliMUONSt1SpecialMotif*>(value);
+  }
   specialMap.Delete();
-  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(76 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.01,0.51),90.));
+  specialMap.Add(75 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(1.96,-0.04)));
+  specialMap.Add(47 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(2.18,-1.11)));
   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)));  
+  specialMap.Add(46 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.6 , 0.17)));
+  specialMap.Add(74 | nb,(Long_t) new AliMUONSt1SpecialMotif(TVector2(0.28, -0.10)));  
       // 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
 
-  AliMpSectorReader reader2(AliMp::kStation1, AliMp::kNonBendingPlane);
-  AliMpSector* sector2 = reader2.BuildSector();
-  
+  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 = sector2->Position();
+  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(sector2, specialMap, where, reflectZ, chamber);
+  PlaceSector(kSector2, specialMap, where, reflectZ, chamber);
 
-#ifdef WITH_ROOT
+  it.Reset();
+  while ( it.Next(key,value) == kTRUE ) {
+    delete reinterpret_cast<AliMUONSt1SpecialMotif*>(value);
+  }
   specialMap.Delete();
-#endif
 }
 
 //______________________________________________________________________________
@@ -609,17 +694,175 @@ void AliMUONSt1GeometryBuilderV2::CreatePlaneSegment(Int_t segNumber,
 /// and the mother board.)
   
   CreateFoamBox(segNumber,dimensions);
+  
+  // Place spacer in the concrete plane segments:
+  // S225 (in S025), S267 (in S067) in chamber1 and S309 (in S109). S351(in S151) 
+  // in chamber2
+  // The segments were found as those which caused overlaps when we placed
+  // the spacer in global coordinates via PlaceSpacer0 
+  //
+  //    <posXYZ   X_Y_Z=" 12.6000;   0.75000;   0.0000"> <volume name="Spacer5A"/>
+  //    <posXYZ   X_Y_Z=" 12.6000;  -0.75000;   0.0000"> <volume name="Spacer5A"/>
+  //    <posXYZ   X_Y_Z=" 12.6000;   0.0000;    1.1515"> <volume name="Spacer6"/>
+  //    <posXYZ   X_Y_Z=" 12.6000;   0.0000;    0.0000"> <volume name="Spacer7A"/>
+
+  if ( FoamBoxName(segNumber) == "S225" || 
+       FoamBoxName(segNumber) == "S267" ||
+       FoamBoxName(segNumber) == "S309" ||
+       FoamBoxName(segNumber) == "S351"    )  
+  {
+    GReal_t posX =  12.6;
+    GReal_t posY =  0.75;
+    GReal_t posZ = -0.1;
+    if ( FoamBoxName(segNumber) == "S267" || 
+         FoamBoxName(segNumber) == "S351" ) posY += fgkPadYOffsetBP;    
+    gMC->Gspos("Spacer5A", 1, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+
+    posY = -0.75;
+    if ( FoamBoxName(segNumber) == "S267" || 
+         FoamBoxName(segNumber) == "S351" ) posY += fgkPadYOffsetBP;    
+    gMC->Gspos("Spacer5A", 2, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+
+    posY = 0.0;
+    posZ = 1.1515;
+    if ( FoamBoxName(segNumber) == "S267" || 
+         FoamBoxName(segNumber) == "S351" ) posY += fgkPadYOffsetBP;    
+    gMC->Gspos("Spacer6",  1, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+
+    posY = 0.0;
+    posZ = 0.0;
+    if ( FoamBoxName(segNumber) == "S267" || 
+         FoamBoxName(segNumber) == "S351" ) posY += fgkPadYOffsetBP;    
+    gMC->Gspos("Spacer7A", 1, FoamBoxName(segNumber).Data(), posX, posY, posZ,0, "ONLY");
+  }  
 
   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,
                FoamBoxName(segNumber).Data(),posX,posY,posZ,0,"ONLY");
   }
 }
 
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::CreateQuadrantLayersAsVolumes(Int_t chamber)
+{
+/// Create the three main layers as real volumes.
+/// Not used anymore.
+
+  // tracking medias
+  Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
+  Int_t idAir  = idtmed[1100];       // medium 1
+
+  Float_t par[11];
+  Float_t posX,posY,posZ;
+
+// Quadrant volume TUBS1, positioned at the end
+  par[0] = fgkMotherIR1;
+  par[1] = fgkMotherOR1; 
+  par[2] = fgkMotherThick1;  
+  par[3] = fgkMotherPhiL1; 
+  par[4] = fgkMotherPhiU1;
+  gMC->Gsvolu(QuadrantMLayerName(chamber),"TUBS",idAir,par,5);
+  // gMC->Gsvolu(QuadrantMFLayerName(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);
+    }
+
+    TGeoVolume* malayer 
+      = gGeoManager->FindVolumeFast(QuadrantMFLayerName(chamber));
+    if ( !malayer ) {
+      AliErrorStream() 
+         << "Quadrant volume " << QuadrantMFLayerName(chamber) << " not found" 
+        << endl;
+    }
+    else {
+      TGeoShape* quadrant = malayer->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      
+      malayer->SetShape(composite);
+    }
+  }  
+
+// Quadrant volume TUBS2, positioned at the end
+  par[0] = fgkMotherIR2;
+  par[1] = fgkMotherOR2; 
+  par[2] = fgkMotherThick2;  
+  par[3] = fgkMotherPhiL2; 
+  par[4] = fgkMotherPhiU2;
+
+  gMC->Gsvolu(QuadrantNLayerName(chamber),"TUBS",idAir,par,5); 
+  gMC->Gsvolu(QuadrantFLayerName(chamber),"TUBS",idAir,par,5); 
+}  
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::CreateQuadrantLayersAsAssemblies(Int_t chamber)
+{
+/// Create the three main layers as assemblies
+
+  gGeoManager->MakeVolumeAssembly(QuadrantMLayerName(chamber).Data()); 
+  gGeoManager->MakeVolumeAssembly(QuadrantMFLayerName(chamber).Data()); 
+  gGeoManager->MakeVolumeAssembly(QuadrantNLayerName(chamber).Data()); 
+  gGeoManager->MakeVolumeAssembly(QuadrantFLayerName(chamber).Data()); 
+}  
+
 //______________________________________________________________________________
 void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
 {
@@ -650,12 +893,18 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
 /// 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] ).
 
+  // TString quadrantMLayerName = QuadrantMLayerName(chamber);
+
+  TString quadrantMLayerName = QuadrantMFLayerName(chamber);
+  TString quadrantNLayerName = QuadrantNLayerName(chamber);
+  TString quadrantFLayerName = QuadrantFLayerName(chamber);
+
   const Float_t kNearFarLHC=2.4;    // Near and Far TUBS Origin wrt LHC Origin
 
   // tracking medias
   Int_t* idtmed = fMUON->GetIdtmed()->GetArray()-1099;
   
-  Int_t idAir  = idtmed[1100];       // medium 1
+  //Int_t idAir  = idtmed[1100];       // medium 1
   //Int_t idFrameEpoxy = idtmed[1115]; // medium 16 = Frame Epoxy ME730
   //Int_t idInox = idtmed[1116];       // medium 17 Stainless Steel (18%Cr,9%Ni,Fe)
   //Int_t idFR4 = idtmed[1110];        // medium 11 FR4
@@ -1108,64 +1357,6 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
  Float_t par[11];
  Float_t posX,posY,posZ;
 
-// Quadrant volume TUBS1, positioned at the end
-  par[0] = fgkMotherIR1;
-  par[1] = fgkMotherOR1; 
-  par[2] = fgkMotherThick1;  
-  par[3] = fgkMotherPhiL1; 
-  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; 
-  par[2] = fgkMotherThick2;  
-  par[3] = fgkMotherPhiL2; 
-  par[4] = fgkMotherPhiU2;
-
-  gMC->Gsvolu(QuadrantNLayerName(chamber),"TUBS",idAir,par,5); 
-  gMC->Gsvolu(QuadrantFLayerName(chamber),"TUBS",idAir,par,5); 
-
    if (chamber==1) {   
     // InVFrame  
     par[0] = kHxInVFrame;
@@ -1597,7 +1788,7 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = kHxInVFrame;
     posY = 2.0*kHyInHFrame+2.*kHyH1mm+kIAF+kHyInVFrame;        
     posZ = 0.;
-    gMC->Gspos("SQ00",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ00",1,quadrantMLayerName,posX, posY, posZ, 0, "ONLY"); 
 
 // keep memory of the mid position. Used for placing screws
     const GReal_t kMidVposX = posX;
@@ -1608,85 +1799,85 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = 2.0*kHxInVFrame+kHxV1mm;
     posY = 2.0*kHyInHFrame+2.*kHyH1mm+kIAF+kHyV1mm;
     posZ = 0.;
-    gMC->Gspos("SQ01",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
+    gMC->Gspos("SQ01",1,quadrantMLayerName,posX, posY, posZ,0, "ONLY"); 
     
     // TopFrameAnode place 2 layers of TopFrameAnode cuboids  
     posX = kHxTFA;
     posY = 2.*kHyInHFrame+2.*kHyH1mm+kIAF+2.*kHyInVFrame+kHyTFA;   
     posZ = kHzOuterFrameInox;
-    gMC->Gspos("SQ02",1,QuadrantMLayerName(chamber),posX, posY, posZ,0,"ONLY"); 
+    gMC->Gspos("SQ02",1,quadrantMLayerName,posX, posY, posZ,0,"ONLY"); 
     posZ = posZ+kHzOuterFrameInox;
-    gMC->Gspos("SQ03",1,QuadrantMLayerName(chamber),posX, posY, posZ,0,"ONLY");
+    gMC->Gspos("SQ03",1,quadrantMLayerName,posX, posY, posZ,0,"ONLY");
     
     // place 2 layers of TopFrameAnodeA trapezoids 
     posX = 35.8932+fgkDeltaQuadLHC;
     posY = 92.6745+fgkDeltaQuadLHC;
     posZ = kHzOuterFrameInox; 
-    gMC->Gspos("SQ04",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
+    gMC->Gspos("SQ04",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");
     posZ = posZ+kHzOuterFrameInox;
-    gMC->Gspos("SQ05",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
+    gMC->Gspos("SQ05",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");
     
     // place 2 layers of TopFrameAnodeB trapezoids 
     posX = 44.593+fgkDeltaQuadLHC;
     posY = 90.737+fgkDeltaQuadLHC;
     posZ = kHzOuterFrameInox; 
-    gMC->Gspos("SQ06",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
+    gMC->Gspos("SQ06",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");
     posZ = posZ+kHzOuterFrameInox;
-    gMC->Gspos("SQ07",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");    
+    gMC->Gspos("SQ07",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");    
 
     // TopAnode1 place 2 layers  
     posX = 6.8+fgkDeltaQuadLHC;
     posY = 99.85+fgkDeltaQuadLHC;
     posZ = -1.*kHzAnodeFR4;
-    gMC->Gspos("SQ08",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");  
+    gMC->Gspos("SQ08",1,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");  
     posZ = posZ+kHzTopAnodeSteel1;
-    gMC->Gspos("SQ09",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");    
+    gMC->Gspos("SQ09",1,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");    
          
     // TopAnode2 place 2 layers
     posX = 18.534+fgkDeltaQuadLHC;
     posY = 99.482+fgkDeltaQuadLHC; 
     posZ = -1.*kHzAnodeFR4;    
-    gMC->Gspos("SQ10",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
+    gMC->Gspos("SQ10",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");
     posZ = posZ+kHzTopAnodeSteel2;    
-    gMC->Gspos("SQ11",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");       
+    gMC->Gspos("SQ11",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");       
     
     // TopAnode3 place 1 layer
     posX = 25.80+fgkDeltaQuadLHC;
     posY = 98.61+fgkDeltaQuadLHC;
     posZ = 0.;    
-    gMC->Gspos("SQ12",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");  
+    gMC->Gspos("SQ12",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");  
           
     // TopEarthFace - 2 copies
     posX = 23.122+fgkDeltaQuadLHC;
     posY = 96.90+fgkDeltaQuadLHC;
     posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+kHzTopEarthFaceCu;
-    gMC->Gspos("SQ13",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
+    gMC->Gspos("SQ13",1,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");
     posZ = -1.*posZ;
-    gMC->Gspos("SQ13",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
+    gMC->Gspos("SQ13",2,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");
 
     // TopEarthProfile 
     posX = 14.475+fgkDeltaQuadLHC;
     posY = 97.900+fgkDeltaQuadLHC; 
     posZ = kHzTopEarthProfileCu;
-    gMC->Gspos("SQ14",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
+    gMC->Gspos("SQ14",1,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");
     posZ = -1.0*posZ;
-    gMC->Gspos("SQ14",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
+    gMC->Gspos("SQ14",2,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");
 
     // TopGasSupport - 2 copies                            
     posX = 4.9500+fgkDeltaQuadLHC;
     posY = 96.200+fgkDeltaQuadLHC;
     posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+kHzTopGasSupportAl;
-    gMC->Gspos("SQ15",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
+    gMC->Gspos("SQ15",1,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");
     posZ = -1.*posZ;
-    gMC->Gspos("SQ15",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");
+    gMC->Gspos("SQ15",2,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");
     
     // TopPositioner parameters - single Stainless Steel trapezoid - 2 copies
     posX = 7.60+fgkDeltaQuadLHC;
     posY = 98.98+fgkDeltaQuadLHC;   
     posZ = kHzOuterFrameEpoxy+kHzOuterFrameInox+2.*kHzTopGasSupportAl+kHzTopPositionerSteel;
-    gMC->Gspos("SQ16",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY");
+    gMC->Gspos("SQ16",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY");
     posZ = -1.*posZ;
-    gMC->Gspos("SQ16",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY"); 
+    gMC->Gspos("SQ16",2,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY"); 
 
     // OutEdgeFrame 
     Float_t xCenter[8]; 
@@ -1717,31 +1908,31 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     yCenter[7] = 87.418 + fgkDeltaQuadLHC; 
       
     posZ = -1.0*kHzOuterFrameInox;     
-    gMC->Gspos("SQ17",1,QuadrantMLayerName(chamber), xCenter[0], yCenter[0], posZ, rot2,"ONLY");
-    gMC->Gspos("SQ17",2,QuadrantMLayerName(chamber), xCenter[4], yCenter[4], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ17",1,quadrantMLayerName, xCenter[0], yCenter[0], posZ, rot2,"ONLY");
+    gMC->Gspos("SQ17",2,quadrantMLayerName, xCenter[4], yCenter[4], posZ, rot3,"ONLY");
 
-    gMC->Gspos("SQ19",1,QuadrantMLayerName(chamber), xCenter[1], yCenter[1], posZ, rot2,"ONLY");   
-    gMC->Gspos("SQ19",2,QuadrantMLayerName(chamber), xCenter[5], yCenter[5], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ19",1,quadrantMLayerName, xCenter[1], yCenter[1], posZ, rot2,"ONLY");   
+    gMC->Gspos("SQ19",2,quadrantMLayerName, xCenter[5], yCenter[5], posZ, rot3,"ONLY");
 
-    gMC->Gspos("SQ21",1,QuadrantMLayerName(chamber), xCenter[2], yCenter[2], posZ, rot2,"ONLY");
-    gMC->Gspos("SQ21",2,QuadrantMLayerName(chamber), xCenter[6], yCenter[6], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ21",1,quadrantMLayerName, xCenter[2], yCenter[2], posZ, rot2,"ONLY");
+    gMC->Gspos("SQ21",2,quadrantMLayerName, xCenter[6], yCenter[6], posZ, rot3,"ONLY");
     
-    gMC->Gspos("SQ23",1,QuadrantMLayerName(chamber), xCenter[3], yCenter[3], posZ, rot2,"ONLY");
-    gMC->Gspos("SQ23",2,QuadrantMLayerName(chamber), xCenter[7], yCenter[7], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ23",1,quadrantMLayerName, xCenter[3], yCenter[3], posZ, rot2,"ONLY");
+    gMC->Gspos("SQ23",2,quadrantMLayerName, xCenter[7], yCenter[7], posZ, rot3,"ONLY");
      
-    posZ = posZ+kHzOuterFrameEpoxy;
+    posZ = posZ+kHzOuterFrameEpoxy + kHzOuterFrameInox;
    
-    gMC->Gspos("SQ18",1,QuadrantMLayerName(chamber), xCenter[0], yCenter[0], posZ, rot2,"ONLY");
-    gMC->Gspos("SQ18",2,QuadrantMLayerName(chamber), xCenter[4], yCenter[4], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ18",1,quadrantMLayerName, xCenter[0], yCenter[0], posZ, rot2,"ONLY");
+    gMC->Gspos("SQ18",2,quadrantMLayerName, xCenter[4], yCenter[4], posZ, rot3,"ONLY");
     
-    gMC->Gspos("SQ20",1,QuadrantMLayerName(chamber), xCenter[1], yCenter[1], posZ, rot2,"ONLY");   
-    gMC->Gspos("SQ20",2,QuadrantMLayerName(chamber), xCenter[5], yCenter[5], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ20",1,quadrantMLayerName, xCenter[1], yCenter[1], posZ, rot2,"ONLY");   
+    gMC->Gspos("SQ20",2,quadrantMLayerName, xCenter[5], yCenter[5], posZ, rot3,"ONLY");
 
-    gMC->Gspos("SQ22",1,QuadrantMLayerName(chamber), xCenter[2], yCenter[2], posZ, rot2,"ONLY");
-    gMC->Gspos("SQ22",2,QuadrantMLayerName(chamber), xCenter[6], yCenter[6], posZ, rot3,"ONLY");
+    gMC->Gspos("SQ22",1,quadrantMLayerName, xCenter[2], yCenter[2], posZ, rot2,"ONLY");
+    gMC->Gspos("SQ22",2,quadrantMLayerName, xCenter[6], yCenter[6], posZ, rot3,"ONLY");
        
-    gMC->Gspos("SQ24",1,QuadrantMLayerName(chamber), xCenter[3], yCenter[3], posZ, rot2,"ONLY");
-    gMC->Gspos("SQ24",2,QuadrantMLayerName(chamber), xCenter[7], yCenter[7], posZ, rot3,"ONLY");  
+    gMC->Gspos("SQ24",1,quadrantMLayerName, xCenter[3], yCenter[3], posZ, rot2,"ONLY");
+    gMC->Gspos("SQ24",2,quadrantMLayerName, xCenter[7], yCenter[7], posZ, rot3,"ONLY");  
 
 //---    
         
@@ -1749,7 +1940,7 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = 2.*kHxInVFrame+kIAF+2.*kHxInHFrame-kHxOutVFrame+2.*kHxV1mm;
     posY = 2.*kHyInHFrame+kHyOutVFrame;    
     posZ = 0.;              
-    gMC->Gspos("SQ25",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ25",1,quadrantMLayerName,posX, posY, posZ, 0, "ONLY"); 
 
  // keep memory of the mid position. Used for placing screws
     const GReal_t kMidOVposX = posX;
@@ -1763,112 +1954,112 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = kOUTX;
     posY = kTOPY+((kBl1OCTF+kTl1OCTF)/2.);
     posZ = 0.;     
-    gMC->Gspos("SQ26",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1,"ONLY"); 
+    gMC->Gspos("SQ26",1,quadrantMLayerName,posX, posY, posZ, rot1,"ONLY"); 
 
 // VertEarthFaceCu - 2 copies
     posX = 89.4000+fgkDeltaQuadLHC;
     posY = 25.79+fgkDeltaQuadLHC;    
     posZ = kHzFrameThickness+2.0*kHzFoam+kHzVertEarthFaceCu;              
-    gMC->Gspos("SQ27",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
+    gMC->Gspos("SQ27",1,quadrantMLayerName,posX, posY, posZ, rot1, "ONLY"); 
     posZ = -1.0*posZ; 
-    gMC->Gspos("SQ27",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
+    gMC->Gspos("SQ27",2,quadrantMLayerName,posX, posY, posZ, rot1, "ONLY"); 
     
 // VertEarthSteel - 2 copies
     posX = 91.00+fgkDeltaQuadLHC;
     posY = 30.616+fgkDeltaQuadLHC;    
     posZ = kHzFrameThickness+2.0*kHzFoam+kHzVertBarSteel;              
-    gMC->Gspos("SQ28",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
+    gMC->Gspos("SQ28",1,quadrantMLayerName,posX, posY, posZ, rot1, "ONLY"); 
     posZ = -1.0*posZ;              
-    gMC->Gspos("SQ28",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY");
+    gMC->Gspos("SQ28",2,quadrantMLayerName,posX, posY, posZ, rot1, "ONLY");
  
 // VertEarthProfCu - 2 copies
     posX = 92.000+fgkDeltaQuadLHC;
     posY = 29.64+fgkDeltaQuadLHC;    
     posZ = kHzFrameThickness;              
-    gMC->Gspos("SQ29",1,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
+    gMC->Gspos("SQ29",1,quadrantMLayerName,posX, posY, posZ, rot1, "ONLY"); 
     posZ = -1.0*posZ;    
-    gMC->Gspos("SQ29",2,QuadrantMLayerName(chamber),posX, posY, posZ, rot1, "ONLY"); 
+    gMC->Gspos("SQ29",2,quadrantMLayerName,posX, posY, posZ, rot1, "ONLY"); 
 
 // SuppLateralPositionner - 2 copies 
     posX = 90.2-kNearFarLHC;
     posY = 5.00-kNearFarLHC;    
     posZ = kHzLateralPosnAl-fgkMotherThick2;             
-    gMC->Gspos("SQ30",1,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ30",1,quadrantFLayerName,posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;            
-    gMC->Gspos("SQ30",2,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ30",2,quadrantNLayerName,posX, posY, posZ, 0, "ONLY"); 
 
 // LateralPositionner - 2 copies - Face view
     posX = 92.175-kNearFarLHC-2.*kHxLPP;
     posY = 5.00-kNearFarLHC;   
     posZ =2.0*kHzLateralPosnAl+kHzLateralPosnInoxFace-fgkMotherThick2;              
-    gMC->Gspos("SQ31",1,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ31",1,quadrantFLayerName,posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;             
-    gMC->Gspos("SQ31",2,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ31",2,quadrantNLayerName,posX, posY, posZ, 0, "ONLY"); 
 
 // LateralPositionner -  Profile view   
     posX = 92.175+fgkDeltaQuadLHC+kHxLPF-kHxLPP;
     posY = 5.00+fgkDeltaQuadLHC;    
     posZ = 0.;              
-    gMC->Gspos("SQ32",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // middle layer
+    gMC->Gspos("SQ32",1,quadrantMLayerName,posX, posY, posZ, 0, "ONLY"); // middle layer
 
     posX = 92.175-kNearFarLHC+kHxLPF-kHxLPP; 
     posY = 5.0000-kNearFarLHC;    
     posZ = fgkMotherThick2-kHzLPNF;              
-    gMC->Gspos("SQ33",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // near layer
+    gMC->Gspos("SQ33",1,quadrantNLayerName,posX, posY, posZ, 0, "ONLY"); // near layer
     posZ = -1.*posZ;
-    gMC->Gspos("SQ33",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); // far layer
+    gMC->Gspos("SQ33",2,quadrantFLayerName,posX, posY, posZ, 0, "ONLY"); // far layer
       
 // VertCradleA  1st Trapezoid - 3 copies
     posX = 95.73+fgkDeltaQuadLHC;
     posY = 33.26+fgkDeltaQuadLHC; 
     posZ = 0.;              
-    gMC->Gspos("SQ34",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
+    gMC->Gspos("SQ34",2,quadrantMLayerName,posX, posY, posZ, 0, "ONLY");  
 
     posX = 95.73-kNearFarLHC;
     posY = 33.26-kNearFarLHC;
     posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;               
-    gMC->Gspos("SQ34",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ34",1,quadrantNLayerName,posX, posY, posZ, 0, "ONLY");
     posZ = -1.0*posZ;              
-    gMC->Gspos("SQ34",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ34",3,quadrantFLayerName,posX, posY, posZ, 0, "ONLY");
 
 // VertCradleB  2nd Trapezoid - 3 copies
     posX = 97.29+fgkDeltaQuadLHC;
     posY = 23.02+fgkDeltaQuadLHC;    
     posZ = 0.;              
-    gMC->Gspos("SQ35",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ35",2,quadrantMLayerName,posX, posY, posZ, 0, "ONLY");
 
     posX = 97.29-kNearFarLHC;
     posY = 23.02-kNearFarLHC;   
     posZ = 2.0*kHzLateralSightAl+kHzVerticalCradleAl-fgkMotherThick2;          
-    gMC->Gspos("SQ35",1,QuadrantNLayerName(chamber),posX, posY, posZ, 0, "ONLY");    
+    gMC->Gspos("SQ35",1,quadrantNLayerName,posX, posY, posZ, 0, "ONLY");    
     posZ = -1.0*posZ;          
-    gMC->Gspos("SQ35",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ35",3,quadrantFLayerName,posX, posY, posZ, 0, "ONLY");
 
 // OutVertCradleC  3rd Trapeze - 3 copies
     posX = 98.31+fgkDeltaQuadLHC;
     posY = 12.77+fgkDeltaQuadLHC;  
     posZ = 0.;              
-    gMC->Gspos("SQ36",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ36",2,quadrantMLayerName,posX, posY, posZ, 0, "ONLY");
 
     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");       
+    gMC->Gspos("SQ36",1,quadrantNLayerName,posX, posY, posZ, 0, "ONLY");       
     posZ = -1.0*posZ;
-    gMC->Gspos("SQ36",3,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY");  
+    gMC->Gspos("SQ36",3,quadrantFLayerName,posX, posY, posZ, 0, "ONLY");  
 
 // OutVertCradleD  4th Trapeze - 3 copies
     posX = 98.81+fgkDeltaQuadLHC;
     posY = 2.52+fgkDeltaQuadLHC;    
     posZ = 0.;              
-    gMC->Gspos("SQ37",2,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ37",2,quadrantMLayerName,posX, posY, posZ, 0, "ONLY");
    
     posZ = fgkMotherThick1-kHzVerticalCradleAl;                
-    gMC->Gspos("SQ37",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");
+    gMC->Gspos("SQ37",1,quadrantMLayerName,posX, posY, posZ, 0, "ONLY");
     posZ = -1.0*posZ;          
-    gMC->Gspos("SQ37",3,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY");          
+    gMC->Gspos("SQ37",3,quadrantMLayerName,posX, posY, posZ, 0, "ONLY");          
              
 // LateralSightSupport - 2 copies
     posX = 98.33-kNearFarLHC;
@@ -1876,15 +2067,15 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     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"); 
+    gMC->Gspos("SQ38",1,quadrantNLayerName,posX, posY, posZ, 0, "ONLY"); 
     posZ = -1.0*posZ;             
-    gMC->Gspos("SQ38",2,QuadrantFLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ38",2,quadrantFLayerName,posX, posY, posZ, 0, "ONLY"); 
     
 // Mire placement
     posX = 92.84+fgkDeltaQuadLHC;  
     posY = 8.13+fgkDeltaQuadLHC;
     posZ = 0.;
-    gMC->Gspos("SQ39",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0,"ONLY");    
+    gMC->Gspos("SQ39",1,quadrantMLayerName,posX, posY, posZ, 0,"ONLY");    
 
 //---
 
@@ -1892,7 +2083,7 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = 2.0*kHxInVFrame+2.*kHxV1mm+kIAF+kHxInHFrame;
     posY = kHyInHFrame;
     posZ = 0.;       
-    gMC->Gspos("SQ40",1,QuadrantMLayerName(chamber),posX, posY, posZ, 0, "ONLY"); 
+    gMC->Gspos("SQ40",1,quadrantMLayerName,posX, posY, posZ, 0, "ONLY"); 
  
  // keep memory of the mid position. Used for placing screws
     const GReal_t kMidHposX = posX;
@@ -1903,13 +2094,13 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = 2.0*kHxInVFrame+2.*kHxV1mm+kIAF+kHxH1mm;
     posY = 2.0*kHyInHFrame+kHyH1mm;
     posZ = 0.;
-    gMC->Gspos("SQ41",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
+    gMC->Gspos("SQ41",1,quadrantMLayerName,posX, posY, posZ,0, "ONLY"); 
         
 // InArcFrame 
     posX = 2.0*kHxInVFrame+2.*kHxV1mm;
     posY = 2.0*kHyInHFrame+2.*kHyH1mm;
     posZ = 0.;    
-    gMC->Gspos("SQ42",1,QuadrantMLayerName(chamber),posX, posY, posZ,0, "ONLY"); 
+    gMC->Gspos("SQ42",1,quadrantMLayerName,posX, posY, posZ,0, "ONLY"); 
 
 // keep memory of the mid position. Used for placing screws
     const GReal_t kMidArcposX = posX;
@@ -1939,10 +2130,10 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
      posX = fgkDeltaQuadLHC + scruX[i];
      posY = fgkDeltaQuadLHC + scruY[i];
      posZ = 0.;   
-     gMC->Gspos("SQ43",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");      
+     gMC->Gspos("SQ43",i+1,quadrantMLayerName,posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");      
      if (chamber==1)
        gMC->Gspos("SQ44",i+1,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY");
-     gMC->Gspos("SQ45",i+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
+     gMC->Gspos("SQ45",i+1,quadrantMLayerName,posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
      }
      // special screw coordinates
      scruX[63] = 16.3;  
@@ -1950,10 +2141,10 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
      posX = fgkDeltaQuadLHC + scruX[63];
      posY = fgkDeltaQuadLHC + scruY[63];
      posZ = 0.;            
-     gMC->Gspos("SQ43",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");
+     gMC->Gspos("SQ43",64,quadrantMLayerName,posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");
      if (chamber==1)
        gMC->Gspos("SQ44",64,"SQ40",posX+0.1-kMidHposX, posY+0.1-kMidHposY, posZ-kMidHposZ, 0, "ONLY"); 
-     gMC->Gspos("SQ45",64,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");  
+     gMC->Gspos("SQ45",64,quadrantMLayerName,posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");  
      
 // Screws on the IVEpoxyFrame
   
@@ -1978,10 +2169,10 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = fgkDeltaQuadLHC + scruX[i+lastScrew-1];
     posY = fgkDeltaQuadLHC + scruY[i+lastScrew-1];
     posZ = 0.;       
-    gMC->Gspos("SQ43",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
+    gMC->Gspos("SQ43",i+lastScrew,quadrantMLayerName,posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
     if (chamber==1)
       gMC->Gspos("SQ44",i+lastScrew,"SQ00",posX+0.1-kMidVposX, posY+0.1-kMidVposY, posZ-kMidVposZ, 0, "ONLY"); 
-    gMC->Gspos("SQ45",i+lastScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
+    gMC->Gspos("SQ45",i+lastScrew,quadrantMLayerName,posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
     }    
     
 // Screws on the OVEpoxyFrame
@@ -2005,11 +2196,11 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = fgkDeltaQuadLHC + scruX[i+firstScrew-1];
     posY = fgkDeltaQuadLHC + scruY[i+firstScrew-1];
     posZ = 0.;   
-    gMC->Gspos("SQ43",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
+    gMC->Gspos("SQ43",i+firstScrew,quadrantMLayerName,posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");     
     // ??
     if (chamber==1)
       gMC->Gspos("SQ44",i+firstScrew,"SQ25",posX+0.1-kMidOVposX, posY+0.1-kMidOVposY, posZ-kMidOVposZ, 0, "ONLY"); 
-    gMC->Gspos("SQ45",i+firstScrew,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
+    gMC->Gspos("SQ45",i+firstScrew,quadrantMLayerName,posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY"); 
     }
     // special case for 1st screw, inside the horizontal frame (volume 40)
     posX = fgkDeltaQuadLHC + scruX[firstScrew-1];
@@ -2029,10 +2220,10 @@ void AliMUONSt1GeometryBuilderV2::CreateFrame(Int_t chamber)
     posX = fgkDeltaQuadLHC + scruX[i+58];
     posY = fgkDeltaQuadLHC + scruY[i+58];
     posZ = 0.;   
-    gMC->Gspos("SQ43",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");    
+    gMC->Gspos("SQ43",i+58+1,quadrantMLayerName,posX+0.1, posY+0.1, posZ-kHzInHFrame-kSCRUHLE, 0, "ONLY");    
     if (chamber==1)
       gMC->Gspos("SQ44",i+58+1,"SQ42",posX+0.1-kMidArcposX, posY+0.1-kMidArcposY, posZ-kMidArcposZ, 0, "ONLY");
-    gMC->Gspos("SQ45",i+58+1,QuadrantMLayerName(chamber),posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
+    gMC->Gspos("SQ45",i+58+1,quadrantMLayerName,posX+0.1, posY+0.1, posZ+kHzInHFrame+kSCRUNLE, 0, "ONLY");
     }
 }
 
@@ -2134,14 +2325,60 @@ void AliMUONSt1GeometryBuilderV2::PlaceInnerLayers(Int_t chamber)
   gMC->Gspos("SK1C", 2+dpos ,QuadrantMLayerName(chamber),x,y,-zc,0,"ONLY");
 }
 
+
 //______________________________________________________________________________
-void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap specialMap, 
+void AliMUONSt1GeometryBuilderV2::PlaceSpacer0(Int_t chamber)
+{
+/// Place the spacer defined in global positions
+/// !! This method should be used only to find out the right mother volume
+/// for the spacer if geometry is changed and the plane segment volumes
+/// will change their numbering
+
+  // Global position of mother volume for the QuadrantMLayer
+  // SQM1: (-2.6, -2.6, -522.41)
+  // SQM2: (-2.6, -2.6, -541.49)
+  GReal_t mx =  2.6;
+  GReal_t my = -2.6;
+  GReal_t mz =  522.41;
+  
+  GReal_t x, y, z;
+  x = 40.82  - mx;
+  y = 43.04  - my;
+  z = 522.41 - mz;
+  AliDebugStream(2) << "spacer05 pos1: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer05", 1, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  y = 44.54  - my;
+  AliDebugStream(2) << "spacer05 pos2: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer05", 2, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  x = 40.82  - mx;
+  y = 43.79  - my;
+  z = 519.76 - mz;
+  AliDebugStream(2) << "spacer06 pos1: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer06", 1, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  z = 525.06 - mz;
+  AliDebugStream(2) << "spacer06 pos2: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer06", 2, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+
+  x = 40.82  - mx;
+  y = 43.79  - my;
+  z = 522.41 - mz;
+  AliDebugStream(2) << "spacer07 pos1: " << x << ", " << y << ", " << z << endl;
+  gMC->Gspos("Spacer07", 1, QuadrantMLayerName(chamber), x, y, z, 0, "ONLY");
+}
+
+//______________________________________________________________________________
+void AliMUONSt1GeometryBuilderV2::PlaceSector(const AliMpSector* sector,
+                            TExMap 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.
-
-/// \cond SKIP
+/// by the sector's data.                                                      \n
+/// The lines with comments COMMENT OUT BEGIN/END indicates blocks
+/// which can be commented out in order to reduce the number of volumes
+/// in a sector to the plane segments corresponding to regular motifs only.
 
   static Int_t segNum=1;
   Int_t sgn;
@@ -2176,18 +2413,9 @@ 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);
       
-#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 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
         CreatePlaneSegment(segNum, seg->Dimensions(), seg->GetNofMotifs());
@@ -2199,6 +2427,8 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
                   QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
 
         // and place all the daughter boards of this segment
+
+// COMMENT OUT BEGIN
         for (Int_t motifNum=0;motifNum<seg->GetNofMotifs();motifNum++) {
 
          // Copy number
@@ -2212,13 +2442,15 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
           posX = where.X() + motifPos->Position().X() + fgkOffsetX;
           posY = where.Y() + motifPos->Position().Y() + fgkOffsetY;
          posZ = where.Z() + sgn * (fgkMotherThick1 - TotalHzDaughter()); 
-
           gMC->Gspos(fgkDaughterName, copyNo, QuadrantMLayerName(chamber), posX, posY, posZ, reflZ, "ONLY");
         }  
+// COMMENT OUT END
+
         segNum++;
        
       } else { 
 
+// COMMENT OUT BEGIN
         // if this is a special segment        
         for (Int_t motifNum=0;motifNum<seg->GetNofMotifs();motifNum++) {// for each motif
 
@@ -2241,8 +2473,7 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
 
           AliMUONSt1SpecialMotif spMot = *((AliMUONSt1SpecialMotif*)specialMap.GetValue(motifPosId));
 #endif
-          // check
-         // cout << chamber << " processing special motif: " << motifPosId << endl;  
+         AliDebugStream(2) << chamber << " processing special motif: " << motifPosId << endl;  
 
           AliMpMotifPosition* motifPos = sector->GetMotifMap()->FindMotifPosition(motifPosId);
 
@@ -2272,9 +2503,10 @@ void AliMUONSt1GeometryBuilderV2::PlaceSector(AliMpSector* sector,SpecialMap spe
             alreadyDone.Set(2*nofAlreadyDone); 
           alreadyDone.AddAt(motifPosId, nofAlreadyDone++);               
 #endif
-          // check
-         // cout << chamber << " processed motifPosId: " << motifPosId << endl;
+         AliDebugStream(2) << chamber << " processed motifPosId: " << motifPosId << endl;
        }               
+// COMMENT OUT END
       }// end of special motif case
     }
   }
@@ -2346,14 +2578,14 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
   // --- 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}; 
@@ -2408,7 +2640,7 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
   GReal_t stmin  = -.8;
   GReal_t maxStepAlu   = fMUON->GetMaxStepAlu();
   GReal_t maxDestepAlu = fMUON->GetMaxDestepAlu();
-  GReal_t maxStepGas   = fMUON->GetMaxStepGas();
+  // GReal_t maxStepGas   = fMUON->GetMaxStepGas();
   Int_t iSXFLD   = gAlice->Field()->PrecInteg();
   Float_t sXMGMX = gAlice->Field()->Max();
 
@@ -2416,9 +2648,9 @@ void AliMUONSt1GeometryBuilderV2::CreateMaterials()
                    tmaxfd, maxStepAlu, maxDestepAlu, epsil, stmin);
 
                   // 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
@@ -2454,6 +2686,8 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
   CreateHole();
   CreateDaughterBoard();
   CreateInnerLayers();
+  // CreateSpacer0();
+  CreateSpacer();
   
   // Create reflexion matrices
   //
@@ -2539,6 +2773,9 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
       GetEnvelopes(ich-1)
         ->AddEnvelopeConstituent(QuadrantMLayerName(ich), QuadrantEnvelopeName(ich,i),
                     i+1, TGeoTranslation(posx, posy, posz));
+      GetEnvelopes(ich-1)
+        ->AddEnvelopeConstituent(QuadrantMFLayerName(ich), QuadrantEnvelopeName(ich,i),
+                    i+5, TGeoTranslation(posx, posy, posz));
 
       // Near/far layers
       GReal_t  posx2 = posx + shiftXY;;
@@ -2554,6 +2791,13 @@ void AliMUONSt1GeometryBuilderV2::CreateGeometry()
       GetEnvelopes(ich-1)
         ->AddEnvelopeConstituent(QuadrantFLayerName(ich), QuadrantEnvelopeName(ich,i), 
                     i+1, TGeoTranslation(posx2, posy2, posz2)); 
+
+      // Place spacer in global coordinates in the first non rotated quadrant
+      // if ( detElemId[i] == 0 ) PlaceSpacer0(ich);
+               // !! This placement should be used only to find out the right mother volume
+               // for the spacer if geometry is changed and the plane segment volumes
+               // will change their numbering
+               // The call to the method CreateSpacer0(); above haa to be uncommented, too
    }
  }     
 }