]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSlatGeometryBuilder.cxx
Macro to generate the CTP configuiration and put it in CDB
[u/mrichter/AliRoot.git] / MUON / AliMUONSlatGeometryBuilder.cxx
index 12473ecd4fcdeecc6432c263e95870cc5edaff6a..63b30966a47335b2941d90a53fe57c56f28306ee 100644 (file)
 
 // $Id$
 //
-// Class AliMUONSlatGeometryBuilder
-// -------------------------------
-// Abstract base class for geometry construction per chamber.
-//
-
-
 
-// This Builder is designed according to the enveloppe methode. The basic idea is to be able to allow moves 
-// of the slats on the support panels. 
-// Those moves can be described with a simple set of parameters. The next step should be now to describe all 
-// the slats and their places by a unique 
-// class, which would make the SlatBuilder far more compact since now only three parameters can define a slat 
-// and its position, like:
-//   * Bool_t rounded_shape_slat
-//   * Float_t slat_length
-//   * Float_t slat_number or Float_t slat_position
-
-#include <TVirtualMC.h>
-#include <TGeoMatrix.h>
-#include <Riostream.h>
-
-#include "AliRun.h"
-#include "AliLog.h"
+//-----------------------------------------------------------------------------
+/// \class AliMUONSlatGeometryBuilder
+/// This Builder is designed according to the enveloppe methode. The basic idea is to be able to allow moves 
+/// of the slats on the support panels. 
+/// Those moves can be described with a simple set of parameters. The next step should be now to describe all 
+/// the slats and their places by a unique 
+/// class, which would make the SlatBuilder far more compact since now only three parameters can define a slat 
+/// and its position, like:
+///   - Bool_t rounded_shape_slat
+///   - Float_t slat_length
+///   - Float_t slat_number or Float_t slat_position
+/// Reference system is the one described in the note ALICE-INT-2003-038  v.2  EDMS Id 406391 
+///
+/// \author Eric Dumonteil (dumontei@cea.fr)
+//-----------------------------------------------------------------------------
 
 #include "AliMUONSlatGeometryBuilder.h"
 #include "AliMUON.h"
 #include "AliMUONGeometryEnvelopeStore.h"
 #include "AliMUONConstants.h"
 
-ClassImp(AliMUONSlatGeometryBuilder)
+#include "AliMpDEManager.h"
 
+#include "AliRun.h"
+#include "AliLog.h"
+
+#include <TVirtualMC.h>
+#include <TGeoBBox.h>
+#include <TGeoVolume.h>
+#include <TGeoManager.h>
+#include <TGeoMatrix.h>
+#include <TGeoCompositeShape.h>
+#include <TGeoTube.h>
+#include <Riostream.h>
+
+/// \cond CLASSIMP
+ClassImp(AliMUONSlatGeometryBuilder)
+/// \endcond
 
 //______________________________________________________________________________
 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(AliMUON* muon)
- : AliMUONVGeometryBuilder(4, 5, 6, 7, 8, 9),
+ : AliMUONVGeometryBuilder(4, 12),
    fMUON(muon)
 {
-// Standard constructor
+/// Standard constructor
 
 }
 
@@ -63,32 +71,13 @@ AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder()
  : AliMUONVGeometryBuilder(),
    fMUON(0)
 {
-// Default constructor
+/// Default constructor
 }
 
-
 //______________________________________________________________________________
-AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(const AliMUONSlatGeometryBuilder& rhs)
-  : AliMUONVGeometryBuilder(rhs)
+AliMUONSlatGeometryBuilder::~AliMUONSlatGeometryBuilder() 
 {
-  AliFatal("Copy constructor is not implemented.");
-}
-
-//______________________________________________________________________________
-AliMUONSlatGeometryBuilder::~AliMUONSlatGeometryBuilder() {
-//
-}
-
-//______________________________________________________________________________
-AliMUONSlatGeometryBuilder& 
-AliMUONSlatGeometryBuilder::operator = (const AliMUONSlatGeometryBuilder& rhs) 
-{
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  AliFatal("Assignment operator is not implemented.");
-    
-  return *this;  
+/// Destructor
 }
 
 //
@@ -98,13 +87,13 @@ AliMUONSlatGeometryBuilder::operator = (const AliMUONSlatGeometryBuilder& rhs)
 //______________________________________________________________________________
 void AliMUONSlatGeometryBuilder::CreateGeometry()
 {
-  // CreateGeometry is the method containing all the informations concerning Stations 345 geometry.
-  // It includes description and placements of support panels and slats.
-  // The code comes directly from what was written in AliMUONv1.cxx before, with modifications concerning 
-  // the use of Enveloppe method to place the Geant volumes.
-  // Now, few changes would allow the creation of a Slat methode where slat could be described by few parameters, 
-  // and this builder would then be dedicated only to the
-  // placements of the slats. Those modifications could shorten the Station 345 geometry by a non-negligeable factor...
+  /// CreateGeometry is the method containing all the informations concerning Stations 345 geometry.
+  /// It includes description and placements of support panels and slats.
+  /// The code comes directly from what was written in AliMUONv1.cxx before, with modifications concerning 
+  /// the use of Enveloppe method to place the Geant volumes.
+  /// Now, few changes would allow the creation of a Slat methode where slat could be described by few parameters, 
+  /// and this builder would then be dedicated only to the
+  /// placements of the slats. Those modifications could shorten the Station 345 geometry by a non-negligeable factor...
  
   Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
 
@@ -112,7 +101,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
   Float_t *dum=0;
 
   // define the id of tracking media:
-  Int_t idAir    = idtmed[1100]; // medium 1
+  //  Int_t idAir    = idtmed[1100]; // medium 1
   Int_t idGas    = idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
   Int_t idCopper = idtmed[1110];
   Int_t idG10    = idtmed[1111];
@@ -121,6 +110,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
   Int_t idNomex  = idtmed[1114]; // honey comb
   Int_t idNoryl  = idtmed[1115]; 
   Int_t idNomexB = idtmed[1116]; // bulk material 
+  
+  // Getting mediums for pannel support geometry
+  TGeoMedium* kMedNomex     = gGeoManager->GetMedium("MUON_Nomex");
+  TGeoMedium* kMedCarbon    = gGeoManager->GetMedium("MUON_CARBON");
 
   // sensitive area: 40*40 cm**2
   const Float_t kSensLength = 40.; 
@@ -192,7 +185,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
   const Float_t kSlatHeight = kPcbHeight; 
   const Float_t kSlatWidth  = kSensWidth + 2.*(kPcbWidth + kInsuWidth + kPanelWidth 
                                               + kNomexBWidth); //replaced rohacell with Nomex Ch. Finck 
-  const Int_t   kSlatMaterial = idAir;
+  // const Int_t   kSlatMaterial = idAir;
   const Float_t kDslatLength  = -1.25; // position of the slat respect to the beam plane (half vertical spacer) Ch. Finck
   Float_t zSlat               = AliMUONConstants::DzSlat();// implemented Ch. Finck
   Float_t dzCh                = AliMUONConstants::DzCh();
@@ -200,6 +193,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
   Float_t spar[3];  
   Int_t i, j;
   Int_t detElemId;
+  Int_t moduleId;
 
   // the panel volume contains the nomex
   Float_t panelpar[3] = { kPanelLength/2., kPanelHeight/2., kPanelWidth/2. }; 
@@ -222,9 +216,6 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
   Float_t xx;
   Float_t xxmax = (kBframeLength - kNulocLength)/2.; 
   Int_t index=0;
-      
-  AliMUONChamber *iChamber, *iChamber1, *iChamber2;
-
   Int_t* fStations = new Int_t[5];
   for (Int_t i=0; i<5; i++) fStations[i] = 1;
   fStations[2] = 1;
@@ -234,40 +225,10 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       //********************************************************************
       //                            Station 3                             **
       //********************************************************************
-      // indices 1 and 2 for first and second chambers in the station
-      // iChamber (first chamber) kept for other quanties than Z,
-      // assumed to be the same in both chambers
-
-      iChamber = &fMUON->Chamber(4);
-      iChamber1 = iChamber;
-      iChamber2 = &fMUON->Chamber(5);
-     
-      //GetGeometry(4)->SetDebug(kTRUE);
-      //GetGeometry(5)->SetDebug(kTRUE);
-      if (gAlice->GetModule("DIPO")) {
-       // if DIPO is preset, the whole station will be placed in DDIP volume
-       GetGeometry(4)->SetMotherVolume("DDIP");
-       GetGeometry(5)->SetMotherVolume("DDIP");
-      }
-
-      if (!gAlice->GetModule("DIPO")) {
-       // Mother volume for each chamber in st3 are only defined if Dipole volue is there.
-       // Outer excess and inner recess for mother volume radius
-       // with respect to ROuter and RInner
-       Float_t dframepIn = kRframeHeight; 
-       Float_t dframepOut= kVframeLength + 37.0; // Additional 37 cm gap is needed to wrap the corners of the slats 
-       Float_t tpar[3];
-       Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(5)) -
-                              (-AliMUONConstants::DefaultChamberZ(4)) ) /2.1;
-       tpar[0] = AliMUONConstants::Rmin(2)-dframepIn; 
-       tpar[1] = AliMUONConstants::Rmax(2)+dframepOut;
-       tpar[2] = dstation;
-       gMC->Gsvolu("CH05", "TUBE", idAir, tpar, 3);
-       gMC->Gsvolu("CH06", "TUBE", idAir, tpar, 3);
-       GetGeometry(4)->SetVolume("CH05");
-       GetGeometry(5)->SetVolume("CH06");
-      }
+      // Mother volume for each chamber in St3 is an envelop (or assembly)
+      // There is one assembly mother per half a chamber
+      // Mother volume for each chamber in St3 is an envelop (or assembly)
+      // There is one assembly mother per half a chamber  called SC05I, SC05O, SC06I and SC06O
       // volumes for slat geometry (xx=5,..,10 chamber id): 
       // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
       // SxxG                          -->   Sensitive volume (gas)
@@ -279,8 +240,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       // SxxH, SxxV                    -->   Horizontal and Vertical frames (Noryl)
       // SB5x                          -->   Volumes for the 35 cm long PCB
       // slat dimensions: slat is a MOTHER volume!!! made of air
-
-      // only for chamber 5: slat 1 has a PCB shorter by 5cm!
+      // Only for chamber 5: slat 1 has a PCB shorter by 5cm!
 
       Float_t tlength = 35.;
       Float_t panelpar2[3]  = { tlength/2., panelpar[1],  panelpar[2]}; 
@@ -329,54 +289,86 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        Float_t zSlat3 = (i%2 ==0)? -zSlat : zSlat; // seems not that zSlat3 = zSlat4 & 5 refering to plan PQ7EN345-6 ?
 
        sprintf(idSlatCh5,"LA%d",i+kNslats3-1);
-       gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
        detElemId = 509 - (i + kNslats3-1-4);
-       GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
-                                    TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
+       moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 0)
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
+                                               TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
+                                               TGeoRotation("rot1",90,angle,90,270+angle,180,0) ); 
 
        sprintf(idSlatCh5,"LA%d",3*kNslats3-2+i);
-       gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
        detElemId = 500 + (i + kNslats3-1-4);
-       GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
-                                    TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
+       moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 0)
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
+                                               TGeoRotation("rot2",90,180+angle,90,270+angle,0,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
+                                               TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
 
        if (i > 0) { 
          sprintf(idSlatCh5,"LA%d",kNslats3-1-i);
-         gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
          detElemId = 509 + (i + kNslats3-1-4);
-         GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3), 
-                                      TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
+         moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+         if (detElemId % 2 == 0 && detElemId != 510)
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3), 
+                                                 TGeoRotation("rot3",90,angle,90,90+angle,0,0) );
+         else
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3), 
+                                                 TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
 
          sprintf(idSlatCh5,"LA%d",3*kNslats3-2-i);
-         gMC->Gsvolu(idSlatCh5,"BOX",kSlatMaterial,spar2,3);
          detElemId = 518 - (i + kNslats3-1-4);
-         GetEnvelopes(4)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
-                                      TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
+         moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+         if (detElemId % 2 == 1 && detElemId != 517)
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
+                                                 TGeoRotation("rot4",90,180+angle,90,90+angle,180,0) );
+         else
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
+                                                 TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );   
        }
 
        sprintf(idSlatCh6,"LB%d",kNslats3-1+i);  
-       gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
        detElemId = 609 - (i  + kNslats3-1-4);
-       GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
+       moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 0)
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
                                     TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
+                                    TGeoRotation("rot5",90,angle,90,270+angle,180,0) );
+
        sprintf(idSlatCh6,"LB%d",3*kNslats3-2+i);
-       gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
        detElemId = 600 + (i + kNslats3-1-4);
-       GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
-                                    TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
+       moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 0)
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
+                                               TGeoRotation("rot6",90,180+angle,90,270+angle,0,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
+                                               TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) ); 
 
        if (i > 0) { 
          sprintf(idSlatCh6,"LB%d",kNslats3-1-i);
-         gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
          detElemId = 609 + (i + kNslats3-1-4);
-         GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
-                                      TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
-
+         moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+         if (detElemId % 2 == 0 && detElemId != 610)
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
+                                                 TGeoRotation("rot7",90,angle,90,90+angle,0,0) );
+         else
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
+                                                 TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
          sprintf(idSlatCh6,"LB%d",3*kNslats3-2-i);
-         gMC->Gsvolu(idSlatCh6,"BOX",kSlatMaterial,spar,3);
          detElemId = 618 - (i + kNslats3-1-4);
-         GetEnvelopes(5)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
-                                      TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
+         moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+         if (detElemId % 2 == 1 && detElemId != 617)
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
+                                                 TGeoRotation("rot8",90,180+angle,90,90+angle,180,0) );
+         else
+             GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
+                                                 TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );   
        }
       }
      
@@ -441,38 +433,41 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
          sprintf(idSlatCh5,"LA%d",ConvertSlatNum(i,quadrant,kNslats3-1));
          sprintf(idSlatCh6,"LB%d",ConvertSlatNum(i,quadrant,kNslats3-1));
+         Int_t moduleSlatCh5 = GetModuleId(idSlatCh5);
+         Int_t moduleSlatCh6 = GetModuleId(idSlatCh6);
          Float_t xvFrame  = (slatLength3[i] - kVframeLength)/2.;
          Float_t xvFrame2  = xvFrame;
+         
 
          if (i == 0 || i == 1 || i == 2) xvFrame2 -= pcbDLength3/2.;
 
          // position the vertical frames 
          if ( i > 2) { 
-           GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
+           GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5, 
                                                    (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-           GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
+           GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5, 
                                                    (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6, 
                                                    (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6, 
                                                    (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));   
          } 
 
          if (i == 2) {
-           GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
+           GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5, 
                                                    (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
-           GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
+           GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5, 
                                                    (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6, 
                                                    (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6, 
                                                    (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
          }
 
          if (i == 0 || i == 1) { // no rounded spacer for the moment (Ch. Finck)
-           GetEnvelopes(4)->AddEnvelopeConstituent("S05V", idSlatCh5, 
+           GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5, 
                                                    (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
+           GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S06V", idSlatCh6, 
                                                    (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
          }
 
@@ -487,17 +482,17 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
            Float_t zPanel = spar[2] - nomexbpar[2]; 
 
            if ( (i == 0 || i == 1 || i == 2) && j == kNPCB3[i]-1) { // 1 pcb is shortened by 5cm 
-             GetEnvelopes(4)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
-             GetEnvelopes(4)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
-             GetEnvelopes(4)->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
+             GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
+             GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
+             GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
            } else {
-             GetEnvelopes(4)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
-             GetEnvelopes(4)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
-             GetEnvelopes(4)->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
+             GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+             GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
+             GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
            }
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
-           GetEnvelopes(5)->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
+           GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
  
          } 
        }
@@ -554,7 +549,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          gMC->Gspos("S05E",2*index-1,"SB5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
          gMC->Gspos("S05E",2*index  ,"SB5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
        }
-      }
+     }
 
       // position the volumes approximating the circular section of the pipe
       Float_t epsilon = 0.001; 
@@ -582,11 +577,13 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
        for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
          sprintf(idSlatCh5,"LA%d",ConvertSlatNum(1,quadrant,kNslats3-1));
          sprintf(idSlatCh6,"LB%d",ConvertSlatNum(1,quadrant,kNslats3-1));
+         Int_t moduleSlatCh5 = GetModuleId(idSlatCh5);
+         Int_t moduleSlatCh6 = GetModuleId(idSlatCh6);
 
-         GetEnvelopes(4)->AddEnvelopeConstituentParam("S05G", idSlatCh5, quadrant*100+imax+4*idiv+1,
+         GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituentParam("S05G", idSlatCh5, quadrant*100+imax+4*idiv+1,
                                                       TGeoTranslation(xvol-(kPcbLength * kNPCB3[1]/2.),yvol-kPcbLength,0.),3,divpar);
 
-         GetEnvelopes(5)->AddEnvelopeConstituentParam("S06G", idSlatCh6,  quadrant*100+imax+4*idiv+1,
+         GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituentParam("S06G", idSlatCh6,  quadrant*100+imax+4*idiv+1,
                                                       TGeoTranslation(xvol-(kPcbLength * kNPCB3[1]/2.),yvol-kPcbLength,0.),3,divpar);
        }
       }
@@ -617,65 +614,78 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
            sprintf(idSlatCh5,"LA%d",13);          
            sprintf(idSlatCh6,"LB%d",13);
          }        
-         GetEnvelopes(4)->AddEnvelopeConstituentParam("S05G", idSlatCh5,500+side*100+imax+4*idiv+1,
+         Int_t moduleSlatCh5 = GetModuleId(idSlatCh5);
+         Int_t moduleSlatCh6 = GetModuleId(idSlatCh6);
+         GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituentParam("S05G", idSlatCh5,500+side*100+imax+4*idiv+1,
                                                       TGeoTranslation(xvol-(kPcbLength * kNPCB3[0]/2.),yvol,0.),3,divpar);
 
-         GetEnvelopes(5)->AddEnvelopeConstituentParam("S06G", idSlatCh6,500+side*100+imax+4*idiv+1,
+         GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituentParam("S06G", idSlatCh6,500+side*100+imax+4*idiv+1,
                                                       TGeoTranslation(xvol-(kPcbLength * kNPCB3[0]/2.),yvol,0.),3,divpar);
        }
        ydiv += dydiv; // Going from bottom to top
       }
+      
+      //
+      //Geometry of the support pannel Verticla length 3.62m, horizontal length 1.62m, internal radius  dMotherInner of SC05 and SC06  (F. Orsini, Saclay)
+      //Carbon fiber of 0.3 mm thick (2 layers) and a central layer of Nomex of 15mm thick. 
+      // Outer excess and inner recess for mother volume radius
+      // with respect to ROuter and RInner
+      Float_t dMotherInner = AliMUONConstants::Rmin(2)-kRframeHeight; 
+      Float_t nomexthickness = 1.5;
+      Float_t carbonthickness = 0.03;
+      Float_t supporthlength =  162.;  
+      Float_t supportvlength =  362.; 
+      // Generating the composite shape of the carbon and nomex pannels
+      new TGeoBBox("shNomexBoxSt3",supporthlength/2., supportvlength/2. ,nomexthickness/2.+carbonthickness);
+      new TGeoBBox("shCarbonBoxSt3",supporthlength/2., supportvlength/2. ,carbonthickness/2.); 
+      new TGeoTubeSeg("shNomexHoleSt3",0., dMotherInner, nomexthickness/2.+carbonthickness+0.001, -90. ,90.);
+      new TGeoTubeSeg("shCarbonHoleSt3",0., dMotherInner, carbonthickness/2.+0.001, -90. ,90.);
+      TGeoTranslation* trHoleSt3 = new TGeoTranslation("trHoleSt3",-supporthlength/2.,0.,0.); 
+      trHoleSt3->RegisterYourself();
+      TGeoCompositeShape* shNomexSupportSt3  = new TGeoCompositeShape("shNomexSupportSt3","shNomexBoxSt3-shNomexHoleSt3:trHoleSt3");
+      TGeoCompositeShape* shCarbonSupportSt3 = new TGeoCompositeShape("shCarbonSupportSt3","shCarbonBoxSt3-shCarbonHoleSt3:trHoleSt3");
+      
+      // Generating Nomex and Carbon pannel volumes
+      TGeoVolume * voNomexSupportSt3  = new TGeoVolume("S05S", shNomexSupportSt3, kMedNomex);
+      TGeoVolume * voCarbonSupportSt3 = new TGeoVolume("S05K", shCarbonSupportSt3, kMedCarbon);
+      TGeoTranslation *trCarbon1St3   = new TGeoTranslation("trCarbon1St3",0.,0., -(nomexthickness+carbonthickness)/2.);
+      TGeoTranslation *trCarbon2St3   = new TGeoTranslation("trCarbon2St3",0.,0.,  (nomexthickness+carbonthickness)/2.);
+      voNomexSupportSt3->AddNode(voCarbonSupportSt3,1,trCarbon1St3);
+      voNomexSupportSt3->AddNode(voCarbonSupportSt3,2,trCarbon2St3);
+      Float_t dzCh5  = dzCh;
+      TGeoTranslation* trSupport1St3   = new TGeoTranslation("trSupport1St3", supporthlength/2., 0. , dzCh5);
+      TGeoRotation*    roSupportSt3    = new TGeoRotation("roSupportSt3",90.,180.,-90.);
+      TGeoCombiTrans*  coSupport2St3   = new TGeoCombiTrans(-supporthlength/2., 0., -dzCh5, roSupportSt3);       
+      GetEnvelopes(5)->AddEnvelope("S05S", 0, 1, *trSupport1St3);  
+      GetEnvelopes(4)->AddEnvelope("S05S", 0, 2, *coSupport2St3);  
+      GetEnvelopes(7)->AddEnvelope("S05S", 0, 3, *trSupport1St3);   
+      GetEnvelopes(6)->AddEnvelope("S05S", 0, 4, *coSupport2St3);  
+      // End of pannel support geometry          
+
       // cout << "Geometry for Station 3...... done" << endl;  
     }
-    
   if (fStations[3]) {
 
 
     // //********************************************************************
     // //                            Station 4                             **
     // //********************************************************************
-    //      // indices 1 and 2 for first and second chambers in the station
-    //      // iChamber (first chamber) kept for other quanties than Z,
-    //      // assumed to be the same in both chambers
-    //      corrected geometry (JP. Cussonneau, Ch. Finck)
-    iChamber = &fMUON->Chamber(6);
-    iChamber1 = iChamber;
-    iChamber2 = &fMUON->Chamber(7);
-
+    // Mother volume for each chamber in St4 is an envelop (or assembly)
+    // There is one assembly mother per half a chamber  called SC07I, SC07O, SC08I and SC08O
+    // Same volume name definitions as in St3
     const Int_t   kNslats4          = 7;  // number of slats per quadrant
     const Int_t   kNPCB4[kNslats4]  = {5, 6, 5, 5, 4, 3, 2}; // n PCB per slat
-    const Float_t kXpos4[kNslats4]  = {38.2, 0., 0., 0., 0., 0., 0.};
+    const Float_t kXpos4[kNslats4]  = {38.75, 0., 0., 0., 0., 0., 0.}; // J.C. Correct value
     const Float_t kYpos41[kNslats4] = {0., 38.2, 34.40, 36.60, 29.3, 37.0, 28.6};
     const Float_t kYpos42[kNslats4] = {0., 38.2, 37.85, 37.55, 29.4, 37.0, 28.6};
-
     Float_t slatLength4[kNslats4];     
-
-
-    // Mother volume for each chamber
-    // Outer excess and inner recess for mother volume radius
-    // with respect to ROuter and RInner
-    Float_t dframepIn = kRframeHeight; 
-    Float_t dframepOut= kVframeLength + 40.0; // Additional 30 cm gap is needed to wrap the corners of the slats 
-    Float_t tpar[3];
-    Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(7)) - 
-                           (-AliMUONConstants::DefaultChamberZ(6)) ) /2.2;
-    tpar[0] = AliMUONConstants::Rmin(3)-dframepIn; 
-    tpar[1] = AliMUONConstants::Rmax(3)+dframepOut;
-    tpar[2] = dstation;
-    gMC->Gsvolu("CH07", "TUBE", idAir, tpar, 3);
-    gMC->Gsvolu("CH08", "TUBE", idAir, tpar, 3);
-    GetGeometry(6)->SetVolume("CH07");
-    GetGeometry(7)->SetVolume("CH08");
     
-    // create and position the slat (mother) volumes 
-
     char idSlatCh7[5];
     char idSlatCh8[5];
     Float_t xSlat4;
     Float_t ySlat41 = 0;
     Float_t ySlat42 = 0;
-
     angle = 0.;
 
     for (i = 0; i<kNslats4; i++){
@@ -691,54 +701,84 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       Float_t zSlat4 = (i%2 ==0)? -zSlat : zSlat; 
 
       sprintf(idSlatCh7,"LC%d",kNslats4-1+i);
-      gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
       detElemId = 713 - (i + kNslats4-1-6);
-      GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
                                   TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
+                                  TGeoRotation("rot1",90,angle,90,270+angle,180,0) );
 
       sprintf(idSlatCh7,"LC%d",3*kNslats4-2+i);
-      gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
       detElemId = 700 + (i + kNslats4-1-6);
-      GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
+                                  TGeoRotation("rot2",90,180+angle,90,270+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
                                   TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
       if (i > 0) { 
        sprintf(idSlatCh7,"LC%d",kNslats4-1-i);
-       gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
        detElemId = 713 + (i + kNslats4-1-6);
-       GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
-                                    TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
-
+        moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 0 && detElemId != 714)
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
+                                               TGeoRotation("rot3",90,angle,90,90+angle,0,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
+                                               TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
        sprintf(idSlatCh7,"LC%d",3*kNslats4-2-i);
        detElemId = 726 - (i + kNslats4-1-6);
-       gMC->Gsvolu(idSlatCh7,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(6)->AddEnvelope(idSlatCh7, detElemId, true, 
-                                    TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
-                                    TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
+        moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 1 && detElemId != 725 )
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
+                                    TGeoRotation("rot4",90,180+angle,90,90+angle,180,0) );
+       else
+            GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
+                                    TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) ); 
       }
 
       sprintf(idSlatCh8,"LD%d",kNslats4-1+i);
-      gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
       detElemId = 813 - (i + kNslats4-1-6);
-      GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
                                   TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
+                                  TGeoRotation("rot5",90,angle,90,270+angle,180,0) ); 
 
       sprintf(idSlatCh8,"LD%d",3*kNslats4-2+i);
       detElemId = 800 + (i + kNslats4-1-6);
-      gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
-      GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
+                                  TGeoRotation("rot6",90,180+angle,90,270+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
                                   TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
       if (i > 0) { 
        sprintf(idSlatCh8,"LD%d",kNslats4-1-i);
        detElemId = 813 + (i + kNslats4-1-6);
-       gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
-                                    TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
+        moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 0 && detElemId != 814)
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
+                                               TGeoRotation("rot7",90,angle,90,90+angle,0,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
+                                               TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
        sprintf(idSlatCh8,"LD%d",3*kNslats4-2-i);
        detElemId = 826 - (i + kNslats4-1-6);
-       gMC->Gsvolu(idSlatCh8,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(7)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
+        moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 1 && detElemId != 825 )
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
+                                    TGeoRotation("rot8",90,180+angle,90,90+angle,180,0) ); 
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
                                     TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
+         
       }
     }
      
@@ -797,19 +837,22 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
        sprintf(idSlatCh7,"LC%d",ConvertSlatNum(i,quadrant,kNslats4-1));
        sprintf(idSlatCh8,"LD%d",ConvertSlatNum(i,quadrant,kNslats4-1));
+       Int_t moduleSlatCh7 = GetModuleId(idSlatCh7);
+       Int_t moduleSlatCh8 = GetModuleId(idSlatCh8);
+
        Float_t xvFrame  = (slatLength4[i] - kVframeLength)/2.;
 
        // position the vertical frames 
        if (i != 1) { 
-         GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
-         GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
        } else { // no rounded spacer yet
-         GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         // GetEnvelopes(6)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
-         GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         // GetEnvelopes(7)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         // GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         // GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
        }
        // position the panels and the insulating material 
        for (j = 0; j < kNPCB4[i]; j++){
@@ -818,12 +861,12 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          Float_t xx = kSensLength * (-kNPCB4[i]/2.+j+.5); 
 
          Float_t zPanel = spar[2] - nomexbpar[2]; 
-         GetEnvelopes(6)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
-         GetEnvelopes(6)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
-         GetEnvelopes(6)->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
-         GetEnvelopes(7)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
-         GetEnvelopes(7)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
-         GetEnvelopes(7)->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
+         GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+         GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
+         GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
+         GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+         GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
+         GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
        }
       } 
     }
@@ -894,14 +937,54 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
        sprintf(idSlatCh7,"LC%d",ConvertSlatNum(1,quadrant,kNslats4-1));
        sprintf(idSlatCh8,"LD%d",ConvertSlatNum(1,quadrant,kNslats4-1));
+       Int_t moduleSlatCh7 = GetModuleId(idSlatCh7);
+       Int_t moduleSlatCh8 = GetModuleId(idSlatCh8);
         
-       GetEnvelopes(6)->AddEnvelopeConstituentParam("S07G",idSlatCh7, quadrant*100+imax+4*idiv+1,
+       GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituentParam("S07G",idSlatCh7, quadrant*100+imax+4*idiv+1,
                                                     TGeoTranslation(xvol-kPcbLength * kNPCB4[1]/2.,yvol-kPcbLength,0.),3,divpar);
         
-       GetEnvelopes(7)->AddEnvelopeConstituentParam("S08G", idSlatCh8, quadrant*100+imax+4*idiv+1,
+       GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituentParam("S08G", idSlatCh8, quadrant*100+imax+4*idiv+1,
                                                     TGeoTranslation(xvol-kPcbLength * kNPCB4[1]/2.,yvol-kPcbLength,0.),3,divpar);
       }
     }
+
+
+   //
+    //Geometry of the support pannel Verticla length 5.3m, horizontal length 2.6m, internal radius  dMotherInner o SC07 and SC08  (F. Orsini, Saclay)
+    //Carbon fiber of 0.3 mm thick (2 layers) and a central layer of Nomex of 15mm thick. 
+    Float_t dMotherInner =  AliMUONConstants::Rmin(3)-kRframeHeight; 
+    Float_t nomexthickness = 1.5;
+    Float_t carbonthickness = 0.03;
+    Float_t supporthlength =  260.;  
+    Float_t supportvlength =  530.;  
+    // Generating the composite shape of the carbon and nomex pannels
+    new TGeoBBox("shNomexBoxSt4",supporthlength/2., supportvlength/2. ,nomexthickness/2.+carbonthickness);
+    new TGeoBBox("shCarbonBoxSt4",supporthlength/2., supportvlength/2. ,carbonthickness/2.); 
+    new TGeoTubeSeg("shNomexHoleSt4",0., dMotherInner, nomexthickness/2.+carbonthickness+0.001, -90. ,90.);
+    new TGeoTubeSeg("shCarbonHoleSt4",0., dMotherInner, carbonthickness/2.+0.001, -90. ,90.);
+    TGeoTranslation* trHoleSt4 = new TGeoTranslation("trHoleSt4",-supporthlength/2.,0.,0.); 
+    trHoleSt4->RegisterYourself();
+    TGeoCompositeShape* shNomexSupportSt4  = new TGeoCompositeShape("shNomexSupportSt4","shNomexBoxSt4-shNomexHoleSt4:trHoleSt4");
+    TGeoCompositeShape* shCarbonSupportSt4 = new TGeoCompositeShape("shCarbonSupportSt4","shCarbonBoxSt4-shCarbonHoleSt4:trHoleSt4");
+   // Generating Nomex and Carbon pannel volumes
+    TGeoVolume* voNomexSupportSt4   = new TGeoVolume("S07S", shNomexSupportSt4, kMedNomex);
+    TGeoVolume* voCarbonSupportSt4  = new TGeoVolume("S07K", shCarbonSupportSt4, kMedCarbon);
+    TGeoTranslation* trCarbon1St4   = new TGeoTranslation("trCarbon1St4",0.,0., -(nomexthickness+carbonthickness)/2.);
+    TGeoTranslation* trCarbon2St4   = new TGeoTranslation("trCarbon2St4",0.,0.,  (nomexthickness+carbonthickness)/2.);
+    voNomexSupportSt4->AddNode(voCarbonSupportSt4,1,trCarbon1St4);
+    voNomexSupportSt4->AddNode(voCarbonSupportSt4,2,trCarbon2St4);
+    Float_t dzCh7  = dzCh;
+    TGeoTranslation* trSupport1St4   = new TGeoTranslation("trSupport1St4", supporthlength/2., 0. , dzCh7);
+    TGeoRotation*    roSupportSt4    = new TGeoRotation("roSupportSt4",90.,180.,-90.);
+    TGeoCombiTrans*  coSupport2St4   = new TGeoCombiTrans(-supporthlength/2., 0., -dzCh7, roSupportSt4); 
+    GetEnvelopes(9)->AddEnvelope("S07S", 0, 1, *trSupport1St4);  
+    GetEnvelopes(8)->AddEnvelope("S07S", 0, 2, *coSupport2St4);  
+    GetEnvelopes(11)->AddEnvelope("S07S", 0, 3, *trSupport1St4);   
+    GetEnvelopes(10)->AddEnvelope("S07S", 0, 4, *coSupport2St4);
+
+    // End of pannel support geometry    
+
     // cout << "Geometry for Station 4...... done" << endl;
 
   }
@@ -912,38 +995,16 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
     // //********************************************************************
     // //                            Station 5                             **
     // //********************************************************************
-    //      // indices 1 and 2 for first and second chambers in the station
-    //      // iChamber (first chamber) kept for other quanties than Z,
-    //      // assumed to be the same in both chambers
-    //      corrected geometry (JP. Cussonneau, Ch. Finck)
-
-    iChamber = &fMUON->Chamber(8);
-    iChamber1 = iChamber;
-    iChamber2 = &fMUON->Chamber(9);
+    // Mother volume for each chamber in St4 is an envelop (or assembly)
+    // There is one assembly mother per half a chamber  called SC09I, SC09O, SC10I and SC10O 
+    // Same volume name definitions as in St3
+    
     const Int_t   kNslats5         = 7;  // number of slats per quadrant
     const Int_t   kNPCB5[kNslats5] = {5, 6, 6, 6, 5, 4, 3}; // n PCB per slat
-    const Float_t kXpos5[kNslats5] = {38.2, 0., 0., 0., 0., 0., 0.};
+    const Float_t kXpos5[kNslats5] = {38.75, 0., 0., 0., 0., 0., 0.}; // J.C. Correct value  
     const Float_t kYpos5[kNslats5] = {0., 38.2, 37.9, 37.6, 37.3, 37.05, 36.75};
     Float_t slatLength5[kNslats5]; 
 
-    // Mother volume for each chamber
-    // Outer excess and inner recess for mother volume radius
-    // with respect to ROuter and RInner
-    Float_t dframepIn = kRframeHeight; 
-    Float_t dframepOut= kVframeLength + 40.0; // Additional 40 cm gap is needed to wrap the corners of the slats 
-    Float_t tpar[3];
-    Double_t dstation =  ( (-AliMUONConstants::DefaultChamberZ(9)) - 
-                           (-AliMUONConstants::DefaultChamberZ(8)) ) /2.3;
-    tpar[0] = AliMUONConstants::Rmin(4)-dframepIn; 
-    tpar[1] = AliMUONConstants::Rmax(4)+dframepOut;
-    tpar[2] = dstation;
-    gMC->Gsvolu("CH09", "TUBE", idAir, tpar, 3);
-    gMC->Gsvolu("CH10", "TUBE", idAir, tpar, 3);
-    GetGeometry(8)->SetVolume("CH09");
-    GetGeometry(9)->SetVolume("CH10");
-
-    // create and position the slat (mother) volumes 
 
     char idSlatCh9[5];
     char idSlatCh10[5];
@@ -966,53 +1027,81 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
       sprintf(idSlatCh9,"LE%d",kNslats5-1+i);
       detElemId = 913 - (i + kNslats5-1-6);
-      gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
-      GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
-                                  TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
-
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
+                                             TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
+                                             TGeoRotation("rot1",90,angle,90,270+angle,180,0) );
       sprintf(idSlatCh9,"LE%d",3*kNslats5-2+i);
       detElemId = 900 + (i + kNslats5-1-6);
-      gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
-      GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
-                                  TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
+                                             TGeoRotation("rot2",90,180+angle,90,270+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
+                                             TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
       if (i > 0) { 
        sprintf(idSlatCh9,"LE%d",kNslats5-1-i);
        detElemId = 913 + (i + kNslats5-1-6);
-       gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
+       moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0  && detElemId != 914)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
+                                    TGeoRotation("rot3",90,angle,90,90+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
                                     TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
-
        sprintf(idSlatCh9,"LE%d",3*kNslats5-2-i);
        detElemId = 926 - (i + kNslats5-1-6);
-       gMC->Gsvolu(idSlatCh9,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(8)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
-                                    TGeoRotation("rot4",90,180+angle,90,270+angle,0,0)  );
+       moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 1 && detElemId != 925 )
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
+                                               TGeoRotation("rot4",90,180+angle,90,90+angle,180,0)  );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
+                                               TGeoRotation("rot4",90,180+angle,90,270+angle,0,0)  );   
       }
 
       sprintf(idSlatCh10,"LF%d",kNslats5-1+i);
       detElemId = 1013 - (i + kNslats5-1-6);
-      gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
-      GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
-                                  TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
+                                             TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
+                                             TGeoRotation("rot5",90,angle,90,270+angle,180,0) );
 
       sprintf(idSlatCh10,"LF%d",3*kNslats5-2+i);
       detElemId = 1000 + (i + kNslats5-1-6);
-      gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
-      GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
-                                  TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
-
+      moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
+                                             TGeoRotation("rot6",90,180+angle,90,270+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
+                                             TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) ); 
       if (i > 0) { 
        sprintf(idSlatCh10,"LF%d",kNslats5-1-i);
        detElemId = 1013 + (i + kNslats5-1-6);
-       gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
+        moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+      if (detElemId % 2 == 0  && detElemId != 1014)
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
+                                    TGeoRotation("rot7",90,angle,90,90+angle,0,0) );
+      else
+         GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
                                     TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
        sprintf(idSlatCh10,"LF%d",3*kNslats5-2-i);
        detElemId = 1026 - (i + kNslats5-1-6);
-       gMC->Gsvolu(idSlatCh10,"BOX",kSlatMaterial,spar,3);
-       GetEnvelopes(9)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
-                                    TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
+        moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+       if (detElemId % 2 == 1 && detElemId != 1025 )
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
+                                             TGeoRotation("rot8",90,180+angle,90,90+angle,180,0) );
+       else
+           GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
+                                             TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) ); 
       }
     }
 
@@ -1071,19 +1160,21 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
 
        sprintf(idSlatCh9,"LE%d",ConvertSlatNum(i,quadrant,kNslats5-1));
        sprintf(idSlatCh10,"LF%d",ConvertSlatNum(i,quadrant,kNslats5-1));
+       Int_t moduleSlatCh9 = GetModuleId(idSlatCh9);
+       Int_t moduleSlatCh10 = GetModuleId(idSlatCh10);
        Float_t xvFrame  = (slatLength5[i] - kVframeLength)/2.; // ok
 
        // position the vertical frames (spacers)
        if (i != 1) { 
-         GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
-         GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
        } else {  // no rounded spacer yet
-         GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         //       GetEnvelopes(8)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
-         GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
-         //       GetEnvelopes(9)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         //       GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
+         GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
+         //       GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
        }
 
        // position the panels and the insulating material 
@@ -1093,13 +1184,13 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
          Float_t xx = kSensLength * (-kNPCB5[i]/2.+j+.5); 
 
          Float_t zPanel = spar[2] - nomexbpar[2]; 
-         GetEnvelopes(8)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
-         GetEnvelopes(8)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
-         GetEnvelopes(8)->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
+         GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+         GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
+         GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
 
-         GetEnvelopes(9)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
-         GetEnvelopes(9)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
-         GetEnvelopes(9)->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
+         GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
+         GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
+         GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
        }
       } 
     }
@@ -1143,7 +1234,7 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       gMC->Gspos("S10E",2*index-1,"S10B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
       gMC->Gspos("S10E",2*index  ,"S10B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
     }
-
+  
 
     // position the volumes approximating the circular section of the pipe
     Float_t epsilon = 0.001; 
@@ -1170,68 +1261,163 @@ void AliMUONSlatGeometryBuilder::CreateGeometry()
       for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
        sprintf(idSlatCh9,"LE%d",ConvertSlatNum(1,quadrant,kNslats5-1));
        sprintf(idSlatCh10,"LF%d",ConvertSlatNum(1,quadrant,kNslats5-1));
+       Int_t moduleSlatCh9 = GetModuleId(idSlatCh9);
+       Int_t moduleSlatCh10 = GetModuleId(idSlatCh10);
 
-       GetEnvelopes(8)->AddEnvelopeConstituentParam("S09G", idSlatCh9, quadrant*100+imax+4*idiv+1,
+       GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituentParam("S09G", idSlatCh9, quadrant*100+imax+4*idiv+1,
                                                     TGeoTranslation(xvol-kPcbLength * kNPCB5[1]/2.,yvol-kPcbLength,0.),3,divpar);
-       GetEnvelopes(9)->AddEnvelopeConstituentParam("S10G", idSlatCh10,  quadrant*100+imax+4*idiv+1,
+       GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituentParam("S10G", idSlatCh10,  quadrant*100+imax+4*idiv+1,
                                                     TGeoTranslation(xvol-kPcbLength * kNPCB5[1]/2.,yvol-kPcbLength,0.),3,divpar);
       }
     }
+    //
+    //Geometry of the support pannel Verticla length 5.7m, horizontal length 2.6m, internal radius  dMotherInner o SC09 and SC10  (F. Orsini, Saclay)
+    //Carbon fiber of 0.3 mm thick (2 layers) and a central layer of Nomex of 15mm thick. 
+    Float_t dMotherInner =  AliMUONConstants::Rmin(4)-kRframeHeight; 
+    Float_t nomexthickness = 1.5;
+    Float_t carbonthickness = 0.03;
+    Float_t supporthlength =  260.;  
+    Float_t supportvlength =  570.;  
+    // Generating the composite shape of the carbon and nomex pannels
+    new TGeoBBox("shNomexBoxSt5",supporthlength/2., supportvlength/2. ,nomexthickness/2.+carbonthickness);
+    new TGeoBBox("shCarbonBoxSt5",supporthlength/2., supportvlength/2. ,carbonthickness/2.); 
+    new TGeoTubeSeg("shNomexHoleSt5",0., dMotherInner, nomexthickness/2.+carbonthickness+0.001, -90. ,90.);
+    new TGeoTubeSeg("shCarbonHoleSt5",0., dMotherInner, carbonthickness/2.+0.001, -90. ,90.);
+    TGeoTranslation* trHoleSt5 = new TGeoTranslation("trHoleSt5",-supporthlength/2.,0.,0.); 
+    trHoleSt5->RegisterYourself();
+    TGeoCompositeShape* shNomexSupportSt5  = new TGeoCompositeShape("shNomexSupportSt5","shNomexBoxSt5-shNomexHoleSt5:trHoleSt5");
+    TGeoCompositeShape* shCarbonSupportSt5 = new TGeoCompositeShape("shCarbonSupportSt5","shCarbonBoxSt5-shCarbonHoleSt5:trHoleSt5");
+   // Generating Nomex and Carbon pannel volumes
+    TGeoVolume* voNomexSupportSt5  = new TGeoVolume("S09S", shNomexSupportSt5, kMedNomex);
+    TGeoVolume* voCarbonSupportSt5 = new TGeoVolume("S09K", shCarbonSupportSt5, kMedCarbon);
+    TGeoTranslation* trCarbon1St5   = new TGeoTranslation("trCarbon1St5",0.,0., -(nomexthickness+carbonthickness)/2.);
+    TGeoTranslation* trCarbon2St5   = new TGeoTranslation("trCarbon2St5",0.,0.,  (nomexthickness+carbonthickness)/2.);
+    voNomexSupportSt5->AddNode(voCarbonSupportSt5,1,trCarbon1St5);
+    voNomexSupportSt5->AddNode(voCarbonSupportSt5,2,trCarbon2St5);
+    Float_t dzCh9  = dzCh;
+    TGeoTranslation* trSupport1St5   = new TGeoTranslation("trSupport1St5", supporthlength/2., 0. , dzCh9);
+    TGeoRotation*    roSupportSt5    = new TGeoRotation("roSupportSt5",90.,180.,-90.);
+    TGeoCombiTrans*  coSupport2St5   = new TGeoCombiTrans(-supporthlength/2., 0., -dzCh9, roSupportSt5);
+    GetEnvelopes(13)->AddEnvelope("S09S", 0, 1, *trSupport1St5);  
+    GetEnvelopes(12)->AddEnvelope("S09S", 0, 2, *coSupport2St5);  
+    GetEnvelopes(15)->AddEnvelope("S09S", 0, 3, *trSupport1St5);   
+    GetEnvelopes(14)->AddEnvelope("S09S", 0, 4, *coSupport2St5);
+
+
+    // End of pannel support geometry    
+
     // cout << "Geometry for Station 5...... done" << endl;
 
   }
+
+  delete [] fStations;
+
 }
 
 
 //______________________________________________________________________________
 void AliMUONSlatGeometryBuilder::SetTransformations()
 {
-// Defines the transformations for the station345 chambers.
-// ---
+/// Defines the transformations for the station345 chambers.
+
+  if (gAlice->GetModule("DIPO")) {
+    // if DIPO is preset, the whole station will be placed in DDIP volume
+    SetMotherVolume(4, "DDIP");
+    SetMotherVolume(5, "DDIP");
+    SetMotherVolume(6, "DDIP");
+    SetMotherVolume(7, "DDIP");
+  }    
+  SetVolume(4, "SC05I", true);
+  SetVolume(5, "SC05O", true);
+  SetVolume(6, "SC06I", true);
+  SetVolume(7, "SC06O", true);
+     
+  if (gAlice->GetModule("SHIL")) {
+    SetMotherVolume(8, "YOUT2");
+    SetMotherVolume(9, "YOUT2");
+    SetMotherVolume(10, "YOUT2");
+    SetMotherVolume(11, "YOUT2");
+    SetMotherVolume(12, "YOUT2");
+    SetMotherVolume(13, "YOUT2");
+    SetMotherVolume(14, "YOUT2");
+    SetMotherVolume(15, "YOUT2");
+  }  
+
+  SetVolume( 8, "SC07I", true);
+  SetVolume( 9, "SC07O", true);
+  SetVolume(10, "SC08I", true);
+  SetVolume(11, "SC08O", true);
+  SetVolume(12, "SC09I", true);
+  SetVolume(13, "SC09O", true);
+  SetVolume(14, "SC10I", true);
+  SetVolume(15, "SC10O", true);
+
 // Stations 345 are not perpendicular to the beam axis
 // See AliMUONConstants class
   TGeoRotation st345inclination("rot99");
   st345inclination.RotateX(AliMUONConstants::St345Inclination());
   
+// The rotation of the half-chamber is done with respect the center of the chamber.
+// the distance beween the roation axis and the chamber position is 
+// AliMUONConstants::DzCh()+AliMUONConstants::DzSlat()
+// Therefore the position of the half-chamber has to be corrected by a traslation in Z and Y axis
+  Double_t deltaY = (AliMUONConstants::DzCh()+AliMUONConstants::DzSlat())*
+    TMath::Sin(AliMUONConstants::St345Inclination() * TMath::Pi()/180.);
+  Double_t deltaZ = (AliMUONConstants::DzCh()+AliMUONConstants::DzSlat())*
+    (1.-TMath::Cos(AliMUONConstants::St345Inclination() * TMath::Pi()/180.));
+
+
   Double_t zpos1= - AliMUONConstants::DefaultChamberZ(4); 
-  SetTransformation(4, TGeoTranslation(0., 0., zpos1), st345inclination);
+  SetTransformation(4, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
+  SetTransformation(5, TGeoTranslation(0.,  deltaY,  deltaZ+zpos1), st345inclination);
 
   zpos1= - AliMUONConstants::DefaultChamberZ(5); 
-  SetTransformation(5, TGeoTranslation(0., 0., zpos1), st345inclination);
+  SetTransformation(6, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
+  SetTransformation(7, TGeoTranslation(0.,  deltaY,  deltaZ+zpos1), st345inclination);
 
   zpos1 = - AliMUONConstants::DefaultChamberZ(6); 
-  SetTransformation(6, TGeoTranslation(0., 0., zpos1), st345inclination);
+  SetTransformation(8, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
+  SetTransformation(9, TGeoTranslation(0.,  deltaY,  deltaZ+zpos1), st345inclination);
 
   zpos1 = - AliMUONConstants::DefaultChamberZ(7); 
-  SetTransformation(7, TGeoTranslation(0., 0., zpos1), st345inclination );
+  SetTransformation(10, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination );
+  SetTransformation(11, TGeoTranslation(0.,  deltaY,  deltaZ+zpos1), st345inclination );
 
   zpos1 = - AliMUONConstants::DefaultChamberZ(8); 
-  SetTransformation(8, TGeoTranslation(0., 0., zpos1), st345inclination);
+  SetTransformation(12, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
+  SetTransformation(13, TGeoTranslation(0.,  deltaY,  deltaZ+zpos1), st345inclination);
 
   zpos1 = - AliMUONConstants::DefaultChamberZ(9); 
-  SetTransformation(9, TGeoTranslation(0., 0., zpos1), st345inclination);
+  SetTransformation(14, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
+  SetTransformation(15, TGeoTranslation(0.,  deltaY,  deltaZ+zpos1), st345inclination);
 
 }
 
 //______________________________________________________________________________
 void AliMUONSlatGeometryBuilder::SetSensitiveVolumes()
 {
-// Defines the sensitive volumes for slat stations chambers.
-// ---
-
-  GetGeometry(4)->SetSensitiveVolume("S05G");
-  GetGeometry(5)->SetSensitiveVolume("S06G");
-  GetGeometry(6)->SetSensitiveVolume("S07G");
-  GetGeometry(7)->SetSensitiveVolume("S08G");
-  GetGeometry(8)->SetSensitiveVolume("S09G");
-  GetGeometry(9)->SetSensitiveVolume("S10G");
+/// Defines the sensitive volumes for slat stations chambers.
+
+  GetGeometry( 4)->SetSensitiveVolume("S05G");
+  GetGeometry( 5)->SetSensitiveVolume("S05G");
+  GetGeometry( 6)->SetSensitiveVolume("S06G");
+  GetGeometry( 7)->SetSensitiveVolume("S06G");
+  GetGeometry( 8)->SetSensitiveVolume("S07G");
+  GetGeometry( 9)->SetSensitiveVolume("S07G");
+  GetGeometry(10)->SetSensitiveVolume("S08G");
+  GetGeometry(11)->SetSensitiveVolume("S08G");
+  GetGeometry(12)->SetSensitiveVolume("S09G");
+  GetGeometry(13)->SetSensitiveVolume("S09G");
+  GetGeometry(14)->SetSensitiveVolume("S10G");
+  GetGeometry(15)->SetSensitiveVolume("S10G");
 }
 
 //______________________________________________________________________________
 Int_t  AliMUONSlatGeometryBuilder::ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
 {
-// On-line function establishing the correspondance between numslat (the slat number on a particular quadrant (numslat->0....4 for St3))
-// and slatnum (the slat number on the whole panel (slatnum->1...18 for St3)
+/// On-line function establishing the correspondance between numslat (the slat number on a particular quadrant (numslat->0....4 for St3))
+/// and slatnum (the slat number on the whole panel (slatnum->1...18 for St3)
   numslat += 1;
   if (quadnum==2 || quadnum==3) 
     numslat += fspq;