]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt2GeometryBuilder.cxx
DQM configure file
[u/mrichter/AliRoot.git] / MUON / AliMUONSt2GeometryBuilder.cxx
index 8de152d3b5199de84d0da01ebe9ba385b0521e34..de0f380c6eeab68936c732a2eea8c159fd752995 100644 (file)
  **************************************************************************/
 
 // $Id$
-//
+
+//-----------------------------------------------------------------------------
 // Class AliMUONSt2GeometryBuilder
 // -------------------------------
 // MUON Station2 coarse geometry construction class.
 // Extracted from AliMUONv1
-// by Ivana Hrivnacova, IPN Orsay
-// Included in AliRoot 2004/01/23
+// Dummy version of station 2 with the right DE id (Ch. Finck)
+//-----------------------------------------------------------------------------
 
 #include <TVirtualMC.h>
 #include <TGeoMatrix.h>
+#include <TArrayI.h>
+
+#include "AliLog.h"
 
 #include "AliMUONSt2GeometryBuilder.h"
 #include "AliMUON.h"
-#include "AliMUONChamber.h"
-#include "AliMUONChamberGeometry.h"
+#include "AliMUONConstants.h"
+#include "AliMUONGeometryModule.h"
 #include "AliMUONGeometryEnvelopeStore.h"
 
+/// \cond CLASSIMP
 ClassImp(AliMUONSt2GeometryBuilder)
+/// \endcond
 
 //______________________________________________________________________________
 AliMUONSt2GeometryBuilder::AliMUONSt2GeometryBuilder(AliMUON* muon)
- : AliMUONVGeometryBuilder("st2.dat",
-                           &muon->Chamber(2), &muon->Chamber(3)),
+ : AliMUONVGeometryBuilder(2, 2), 
    fMUON(muon)
 {
-// Standard constructor
+/// Standard constructor
 
 }
 
@@ -48,38 +53,14 @@ AliMUONSt2GeometryBuilder::AliMUONSt2GeometryBuilder()
  : AliMUONVGeometryBuilder(),
    fMUON(0)
 {
-// Default constructor
-}
-
-
-//______________________________________________________________________________
-AliMUONSt2GeometryBuilder::AliMUONSt2GeometryBuilder(const AliMUONSt2GeometryBuilder& rhs)
-  : AliMUONVGeometryBuilder(rhs)
-{
-// Protected copy constructor
-
-  Fatal("Copy constructor", 
-        "Copy constructor is not implemented.");
+/// Default constructor
 }
 
-//______________________________________________________________________________
-AliMUONSt2GeometryBuilder::~AliMUONSt2GeometryBuilder() {
-//
-}
 
 //______________________________________________________________________________
-AliMUONSt2GeometryBuilder& 
-AliMUONSt2GeometryBuilder::operator = (const AliMUONSt2GeometryBuilder& rhs) 
+AliMUONSt2GeometryBuilder::~AliMUONSt2GeometryBuilder() 
 {
-// Protected assignement operator
-
-  // check assignement to self
-  if (this == &rhs) return *this;
-
-  Fatal("operator=", 
-        "Assignment operator is not implemented.");
-    
-  return *this;  
+/// Destructor
 }
 
 //
@@ -89,7 +70,7 @@ AliMUONSt2GeometryBuilder::operator = (const AliMUONSt2GeometryBuilder& rhs)
 //______________________________________________________________________________
 void AliMUONSt2GeometryBuilder::CreateGeometry() 
 {
-// From AliMUONv1::CreateGeometry()
+/// From AliMUONv1::CreateGeometry()
 
 //
 //********************************************************************
@@ -102,10 +83,12 @@ void AliMUONSt2GeometryBuilder::CreateGeometry()
      // Get tracking medias Ids     
      Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
      Int_t idAir= idtmed[1100]; // medium 1
-     Int_t idAlu1=idtmed[1103]; // medium 4
-     Int_t idAlu2=idtmed[1104]; // medium 5
+  //     Int_t idAlu1=idtmed[1103]; // medium 4
+     //     Int_t idAlu2=idtmed[1104]; // medium 5
      Int_t idGas=idtmed[1108];  // medium 9 = Ar-CO2 gas (80%+20%)
-     Bool_t frameCrosses=kTRUE;     
+
+     const Float_t kDeltaQuad = 0.01;//2.6; dummy value til we find the good value
+     const Float_t kDeltaZ = 6.5/2.;
 
      // Rotation matrices in the x-y plane  
      // phi= 0 deg
@@ -115,364 +98,126 @@ void AliMUONSt2GeometryBuilder::CreateGeometry()
      Int_t irot2;
      fMUON->AliMatrix(irot2,  90.,  90., 90., 180., 0., 0.);
 
-     AliMUONChamber* iChamber = GetChamber(2);
-     AliMUONChamber* iChamber1 = iChamber;
-     AliMUONChamber* iChamber2 = GetChamber(3);
-     
      // Half of the total thickness of frame crosses (including DAlu)
      // for each chamber in stations 1 and 2:
      // 3% of X0 of composite material,
      // but taken as Aluminium here, with same thickness in number of X0
-     Float_t dframez = 3. * 8.9 / 100;
+     //     Float_t dframez = 3. * 8.9 / 100;
      // DGas and DAlu not changed from standard values
-     Double_t zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
+     //     Double_t zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
              // The same parameters are defined in builder for station 1 
+
+     //    sensitive gas gap
+     const Float_t kDGas = 0.5;
+
+     //    3% radiation length of aluminum (X0=8.9 cm)      
+     // const Float_t kDAlu = 3.5 * 8.9 / 100.;
      
      // Mother volume
      // Outer excess and inner recess for mother volume radius
      // with respect to ROuter and RInner
-     Float_t dframep=.001; // Value for station 3 should be 6 ...
+     //     Float_t dframep=.001; // Value for station 3 should be 6 ...
      // Width (RdPhi) of the frame crosses for stations 1 and 2 (cm)
      // Float_t dframep1=.001;
-     Float_t phi=2*TMath::Pi()/12/2;
-             // The same parameters are defined in builder for station 1 
-
-     Float_t tpar[3];
-     Double_t dstation = (-iChamber2->Z()) - (-iChamber1->Z());
-     tpar[0] = iChamber->RInner()-dframep; 
-     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
-     tpar[2] = dstation/5;
+     //     Float_t phi=2*TMath::Pi()/12/2;
+             // The same parameters are defined in builder for station 1 (30deg)
 
-     gMC->Gsvolu("S03M", "TUBE", idAir, tpar, 3);
-     gMC->Gsvolu("S04M", "TUBE", idAir, tpar, 3);
+     Float_t tpar[5];
+     //     Double_t dstation = (-iChamber2->Z()) - (-iChamber1->Z());
 
-     // CHANGED
-     //gMC->Gspos("S03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
-     //gMC->Gspos("S04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
 
-     GetEnvelopes(2)->AddEnvelope("S03M", 300, false);
-     GetEnvelopes(3)->AddEnvelope("S04M", 400, false);
-     
-     gMC->Gsbool("S03M", "L3DO");
-     gMC->Gsbool("S03M", "L3O1");
-     gMC->Gsbool("S03M", "L3O2");
-     gMC->Gsbool("S04M", "L3DO");
-     gMC->Gsbool("S04M", "L3O1");
-     gMC->Gsbool("S04M", "L3O2");
-
-// // Aluminium frames
-// // Outer frames
-//      pgpar[0] = 360/12/2;
-//      pgpar[1] = 360.;
-//      pgpar[2] = 12.;
-//      pgpar[3] =   2;
-//      pgpar[4] = -dframez/2;
-//      pgpar[5] = iChamber->ROuter();
-//      pgpar[6] = pgpar[5]+dframep;
-//      pgpar[7] = +dframez/2;
-//      pgpar[8] = pgpar[5];
-//      pgpar[9] = pgpar[6];
-//      gMC->Gsvolu("S03O", "PGON", idAlu1, pgpar, 10);
-//      gMC->Gsvolu("S04O", "PGON", idAlu1, pgpar, 10);
-//      gMC->Gspos("S03O",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S03O",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
-//      gMC->Gspos("S04O",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S04O",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
-// //
-// // Inner frame
-//      tpar[0]= iChamber->RInner()-dframep;
-//      tpar[1]= iChamber->RInner();
-//      tpar[2]= dframez/2;
-//      gMC->Gsvolu("S03I", "TUBE", idAlu1, tpar, 3);
-//      gMC->Gsvolu("S04I", "TUBE", idAlu1, tpar, 3);
-
-//      gMC->Gspos("S03I",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S03I",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
-//      gMC->Gspos("S04I",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S04I",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
-//
-// Frame Crosses
-     if (frameCrosses) {
-         // outside gas
-         // security for inside mother volume
-         // ADDED !! Repeated     
-         Float_t dframep1 = 11.0;
-         Float_t dframez = 3. * 8.9 / 100;
-
-         Float_t bpar[3];
-        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
-          * TMath::Cos(TMath::ASin(dframep1 /
-                                  (iChamber->ROuter() - iChamber->RInner())))
-          / 2.0;
-        bpar[1] = dframep1/2;
-        // total thickness will be (4 * bpar[2]) for each chamber,
-        // which has to be equal to (2 * dframez) - DAlu
-        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
-        gMC->Gsvolu("S03B", "BOX", idAlu1, bpar, 3);
-        gMC->Gsvolu("S04B", "BOX", idAlu1, bpar, 3);
-        
-        gMC->Gspos("S03B",1,"S03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",2,"S03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",3,"S03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S03B",4,"S03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S03B",5,"S03M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",6,"S03M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",7,"S03M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S03B",8,"S03M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-        
-        gMC->Gspos("S04B",1,"S04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",2,"S04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",3,"S04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S04B",4,"S04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S04B",5,"S04M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",6,"S04M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",7,"S04M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S04B",8,"S04M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-     }
-//
-//   Chamber Material represented by Alu sheet
-     tpar[0]= iChamber->RInner();
-     tpar[1]= iChamber->ROuter();
-     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
-     gMC->Gsvolu("S03A", "TUBE", idAlu2, tpar, 3);
-     gMC->Gsvolu("S04A", "TUBE", idAlu2, tpar, 3);
-     gMC->Gspos("S03A", 1, "S03M", 0., 0., 0.,  0, "ONLY");
-     gMC->Gspos("S04A", 1, "S04M", 0., 0., 0.,  0, "ONLY");
-//     
-//   Sensitive volumes
-     // tpar[2] = iChamber->DGas();
-     tpar[2] = iChamber->DGas()/2;
-     gMC->Gsvolu("S03G", "TUBE", idGas, tpar, 3);
-     gMC->Gsvolu("S04G", "TUBE", idGas, tpar, 3);
-     gMC->Gspos("S03G", 1, "S03A", 0., 0., 0.,  0, "ONLY");
-     gMC->Gspos("S04G", 1, "S04A", 0., 0., 0.,  0, "ONLY");
-//
-// Frame Crosses to be placed inside gas 
-     // NONE: chambers are sensitive everywhere
-//      if (frameCrosses) {
-
-//      dr = (iChamber->ROuter() - iChamber->RInner());
-//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
-//      bpar[1] = dframep1/2;
-//      bpar[2] = iChamber->DGas()/2;
-//      gMC->Gsvolu("S03F", "BOX", idAlu1, bpar, 3);
-//      gMC->Gsvolu("S04F", "BOX", idAlu1, bpar, 3);
-        
-//      gMC->Gspos("S03F",1,"S03G", +iChamber->RInner()+bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S03F",2,"S03G", -iChamber->RInner()-bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S03F",3,"S03G", 0, +iChamber->RInner()+bpar[0] , 0, 
-//                 irot2,"ONLY");
-//      gMC->Gspos("S03F",4,"S03G", 0, -iChamber->RInner()-bpar[0] , 0, 
-//                 irot2,"ONLY");
-        
-//      gMC->Gspos("S04F",1,"S04G", +iChamber->RInner()+bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S04F",2,"S04G", -iChamber->RInner()-bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S04F",3,"S04G", 0, +iChamber->RInner()+bpar[0] , 0, 
-//                 irot2,"ONLY");
-//      gMC->Gspos("S04F",4,"S04G", 0, -iChamber->RInner()-bpar[0] , 0, 
-//                 irot2,"ONLY");
-//      }
-/*
-     iChamber1 = iChamber = (AliMUONChamber*) (*fChambers)[2];
-     iChamber2 =(AliMUONChamber*) (*fChambers)[3];
-     zpos1=iChamber1->Z(); 
-     zpos2=iChamber2->Z();
-     dstation = zpos2 - zpos1;
-     // DGas and DAlu not changed from standard values
-     zfpos=-(iChamber->DGas()+dframez+iChamber->DAlu())/2;
-     
-//
-//   Mother volume
-     tpar[0] = iChamber->RInner()-dframep; 
-     tpar[1] = (iChamber->ROuter()+dframep)/TMath::Cos(phi);
-     tpar[2] = dstation/5;
-
-     gMC->Gsvolu("S03M", "TUBE", idAir, tpar, 3);
-     gMC->Gsvolu("S04M", "TUBE", idAir, tpar, 3);
-     gMC->Gspos("S03M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
-     gMC->Gspos("S04M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
-     gMC->Gsbool("S03M", "L3DO");
-     gMC->Gsbool("S03M", "L3O1");
-     gMC->Gsbool("S03M", "L3O2");
-     gMC->Gsbool("S04M", "L3DO");
-     gMC->Gsbool("S04M", "L3O1");
-     gMC->Gsbool("S04M", "L3O2");
-
-// // Aluminium frames
-// // Outer frames
-//      pgpar[0] = 360/12/2;
-//      pgpar[1] = 360.;
-//      pgpar[2] = 12.;
-//      pgpar[3] =   2;
-//      pgpar[4] = -dframez/2;
-//      pgpar[5] = iChamber->ROuter();
-//      pgpar[6] = pgpar[5]+dframep;
-//      pgpar[7] = +dframez/2;
-//      pgpar[8] = pgpar[5];
-//      pgpar[9] = pgpar[6];
-//      gMC->Gsvolu("S03O", "PGON", idAlu1, pgpar, 10);
-//      gMC->Gsvolu("S04O", "PGON", idAlu1, pgpar, 10);
-//      gMC->Gspos("S03O",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S03O",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
-//      gMC->Gspos("S04O",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S04O",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
-// //
-// // Inner frame
-//      tpar[0]= iChamber->RInner()-dframep;
-//      tpar[1]= iChamber->RInner();
-//      tpar[2]= dframez/2;
-//      gMC->Gsvolu("S03I", "TUBE", idAlu1, tpar, 3);
-//      gMC->Gsvolu("S04I", "TUBE", idAlu1, tpar, 3);
-
-//      gMC->Gspos("S03I",1,"S03M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S03I",2,"S03M", 0.,0.,+zfpos,  0,"ONLY");
-//      gMC->Gspos("S04I",1,"S04M", 0.,0.,-zfpos,  0,"ONLY");
-//      gMC->Gspos("S04I",2,"S04M", 0.,0.,+zfpos,  0,"ONLY");
-//
-// Frame Crosses
-     if (frameCrosses) {
-         // outside gas
-         // security for inside mother volume
-        bpar[0] = (iChamber->ROuter() - iChamber->RInner())
-          * TMath::Cos(TMath::ASin(dframep1 /
-                                  (iChamber->ROuter() - iChamber->RInner())))
-          / 2.0;
-        bpar[1] = dframep1/2;
-        // total thickness will be (4 * bpar[2]) for each chamber,
-        // which has to be equal to (2 * dframez) - DAlu
-        bpar[2] = (2.0 * dframez - iChamber->DAlu()) / 4.0;
-        gMC->Gsvolu("S03B", "BOX", idAlu1, bpar, 3);
-        gMC->Gsvolu("S04B", "BOX", idAlu1, bpar, 3);
-        
-        gMC->Gspos("S03B",1,"S03M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",2,"S03M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",3,"S03M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S03B",4,"S03M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S03B",5,"S03M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",6,"S03M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S03B",7,"S03M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S03B",8,"S03M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-        
-        gMC->Gspos("S04B",1,"S04M", +iChamber->RInner()+bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",2,"S04M", -iChamber->RInner()-bpar[0] , 0,-zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",3,"S04M", 0, +iChamber->RInner()+bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S04B",4,"S04M", 0, -iChamber->RInner()-bpar[0] ,-zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S04B",5,"S04M", +iChamber->RInner()+bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",6,"S04M", -iChamber->RInner()-bpar[0] , 0,+zfpos, 
-                   irot1,"ONLY");
-        gMC->Gspos("S04B",7,"S04M", 0, +iChamber->RInner()+bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-        gMC->Gspos("S04B",8,"S04M", 0, -iChamber->RInner()-bpar[0] ,+zfpos, 
-                   irot2,"ONLY");
-     }
-//
+     Float_t posx, posy, posz;
 //   Chamber Material represented by Alu sheet
-     tpar[0]= iChamber->RInner();
-     tpar[1]= iChamber->ROuter();
-     tpar[2] = (iChamber->DGas()+iChamber->DAlu())/2;
-     gMC->Gsvolu("S03A", "TUBE", idAlu2, tpar, 3);
-     gMC->Gsvolu("S04A", "TUBE", idAlu2, tpar, 3);
-     gMC->Gspos("S03A", 1, "S03M", 0., 0., 0.,  0, "ONLY");
-     gMC->Gspos("S04A", 1, "S04M", 0., 0., 0.,  0, "ONLY");
+     tpar[0]= AliMUONConstants::Rmin(1);
+     tpar[1]= AliMUONConstants::Rmax(1);
+     tpar[2] = kDGas/2;
+     tpar[3] = 0.;
+     tpar[4] = 90.;
+  
 //     
 //   Sensitive volumes
-     // tpar[2] = iChamber->DGas();
-     tpar[2] = iChamber->DGas()/2;
-     gMC->Gsvolu("S03G", "TUBE", idGas, tpar, 3);
-     gMC->Gsvolu("S04G", "TUBE", idGas, tpar, 3);
-     gMC->Gspos("S03G", 1, "S03A", 0., 0., 0.,  0, "ONLY");
-     gMC->Gspos("S04G", 1, "S04A", 0., 0., 0.,  0, "ONLY");
-//
-// Frame Crosses to be placed inside gas 
-     // NONE: chambers are sensitive everywhere
-//      if (frameCrosses) {
-
-//      dr = (iChamber->ROuter() - iChamber->RInner());
-//      bpar[0] = TMath::Sqrt(dr*dr-dframep1*dframep1/4)/2;
-//      bpar[1] = dframep1/2;
-//      bpar[2] = iChamber->DGas()/2;
-//      gMC->Gsvolu("S03F", "BOX", idAlu1, bpar, 3);
-//      gMC->Gsvolu("S04F", "BOX", idAlu1, bpar, 3);
-        
-//      gMC->Gspos("S03F",1,"S03G", +iChamber->RInner()+bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S03F",2,"S03G", -iChamber->RInner()-bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S03F",3,"S03G", 0, +iChamber->RInner()+bpar[0] , 0, 
-//                 irot2,"ONLY");
-//      gMC->Gspos("S03F",4,"S03G", 0, -iChamber->RInner()-bpar[0] , 0, 
-//                 irot2,"ONLY");
-        
-//      gMC->Gspos("S04F",1,"S04G", +iChamber->RInner()+bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S04F",2,"S04G", -iChamber->RInner()-bpar[0] , 0, 0, 
-//                 irot1,"ONLY");
-//      gMC->Gspos("S04F",3,"S04G", 0, +iChamber->RInner()+bpar[0] , 0, 
-//                 irot2,"ONLY");
-//      gMC->Gspos("S04F",4,"S04G", 0, -iChamber->RInner()-bpar[0] , 0, 
-//                 irot2,"ONLY");
-//      }
-     }
-*/
+     gMC->Gsvolu("S03G", "TUBS", idGas, tpar, 5);
+     gMC->Gsvolu("S04G", "TUBS", idGas, tpar, 5);
+
+     Int_t detElemId;
+
+     posx = kDeltaQuad;
+     posy = kDeltaQuad;
+     posz = -kDeltaZ;
+
+     detElemId = 301;
+     gMC->Gsvolu("LE01", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(2)->AddEnvelope("LE01", detElemId, true, TGeoTranslation(posx, posy, posz),
+                                  TGeoRotation("rot1",90,0,90,90,0,0) );
+     detElemId = 401;
+     gMC->Gsvolu("LF01", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(3)->AddEnvelope("LF01", detElemId, true, TGeoTranslation(posx, posy, posz),
+                                  TGeoRotation("rot1",90,0,90,90,0,0) );
+     detElemId = 300;
+     gMC->Gsvolu("LE02", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(2)->AddEnvelope("LE02", detElemId, true, TGeoTranslation(-posx, posy,-posz),
+                                 TGeoRotation("rot2",90,180,90,90,180,0) );
+     detElemId = 400;
+     gMC->Gsvolu("LF02", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(3)->AddEnvelope("LF02", detElemId, true, TGeoTranslation(-posx, posy,-posz),
+                                 TGeoRotation("rot2",90,180,90,90,180,0) );
+     detElemId = 302;
+     gMC->Gsvolu("LE03", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(2)->AddEnvelope("LE03", detElemId, true, TGeoTranslation(posx, -posy, -posz),
+                                 TGeoRotation("rot3",90,0,90,270,180,0) );
+     detElemId = 402;
+     gMC->Gsvolu("LF03", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(3)->AddEnvelope("LF03", detElemId, true, TGeoTranslation(posx, -posy, -posz),
+                                 TGeoRotation("rot3",90,0,90,270,180,0) );
+     detElemId = 303;
+     gMC->Gsvolu("LE04", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(2)->AddEnvelope("LE04", detElemId, true, TGeoTranslation(-posx, -posy, posz),
+                                 TGeoRotation("rot4",90,180,90,270,0,0) );
+     detElemId = 403;
+     gMC->Gsvolu("LF04", "TUBS", idAir, tpar, 5);
+     GetEnvelopes(3)->AddEnvelope("LF04", detElemId, true, TGeoTranslation(-posx, -posy, posz),
+                                 TGeoRotation("rot4",90,180,90,270,0,0) );
+
+     GetEnvelopes(2)->AddEnvelopeConstituent("S03G", "LE01", 1);
+     GetEnvelopes(3)->AddEnvelopeConstituent("S04G", "LF01", 1);
+
+     GetEnvelopes(2)->AddEnvelopeConstituent("S03G", "LE02", 2);
+     GetEnvelopes(3)->AddEnvelopeConstituent("S04G", "LF02", 2);
+
+     GetEnvelopes(2)->AddEnvelopeConstituent("S03G", "LE03", 3);
+     GetEnvelopes(3)->AddEnvelopeConstituent("S04G", "LF03", 3);
+
+     GetEnvelopes(2)->AddEnvelopeConstituent("S03G", "LE04", 4);
+     GetEnvelopes(3)->AddEnvelopeConstituent("S04G", "LF04", 4);
+}
+
+//______________________________________________________________________________
+void AliMUONSt2GeometryBuilder::SetVolumes()
+{
+/// Defines the volumes for the station2 chambers.
+
+  // Define chamber volumes as virtual
+  SetVolume(2, "SC03", true);
+  SetVolume(3, "SC04", true);
 }
 
 //______________________________________________________________________________
 void AliMUONSt2GeometryBuilder::SetTransformations()
 {
-// Defines the transformations for the station2 chambers.
-// ---
-
-  AliMUONChamber* iChamber1 = GetChamber(2);
-  Double_t zpos1 = - iChamber1->Z(); 
-  iChamber1->GetGeometry()
-    ->SetTranslation(TGeoTranslation(0., 0., zpos1));
-
-  AliMUONChamber* iChamber2 = GetChamber(3);
-  Double_t zpos2 = - iChamber2->Z(); 
-  iChamber2->GetGeometry()
-    ->SetTranslation(TGeoTranslation(0., 0., zpos2));
+/// Defines the transformations for the station2 chambers.
+
+  Double_t zpos1 = - AliMUONConstants::DefaultChamberZ(2); 
+  SetTranslation(2, TGeoTranslation(0., 0., zpos1));
+
+  Double_t zpos2 = - AliMUONConstants::DefaultChamberZ(3); 
+  SetTranslation(3, TGeoTranslation(0., 0., zpos2));
 }
 
 //______________________________________________________________________________
 void AliMUONSt2GeometryBuilder::SetSensitiveVolumes()
 {
-// Defines the sensitive volumes for station2 chambers.
-// ---
+/// Defines the sensitive volumes for station2 chambers.
 
-  GetChamber(2)->GetGeometry()->SetSensitiveVolume("S03G");
-  GetChamber(3)->GetGeometry()->SetSensitiveVolume("S04G");
+  GetGeometry(2)->SetSensitiveVolume("S03G");
+  GetGeometry(3)->SetSensitiveVolume("S04G");
 }