]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDgeometryHole.cxx
New chamber geometry
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometryHole.cxx
index 464bd08afbd7e83d6270765382949fe0eddd29a9..7410b83e9df6f94471402558eec64661c586a817 100644 (file)
 
 /*
 $Log$
+Revision 1.7  2002/02/11 14:21:16  cblume
+Update of the geometry. Get rid of MANY
+
+Revision 1.6  2001/05/11 07:56:12  hristov
+Consistent declarations needed on Alpha
+
+Revision 1.5  2001/02/14 18:22:26  cblume
+Change in the geometry of the padplane
+
+Revision 1.4  2000/11/01 14:53:21  cblume
+Merge with TRD-develop
+
+Revision 1.1.4.4  2000/10/15 23:40:01  cblume
+Remove AliTRDconst
+
+Revision 1.1.4.3  2000/10/06 16:49:46  cblume
+Made Getters const
+
+Revision 1.1.4.2  2000/10/04 16:34:58  cblume
+Replace include files by forward declarations
+
+Revision 1.1.4.1  2000/09/22 14:43:41  cblume
+Allow the pad/timebin-dimensions to be changed after initialization
+
+Revision 1.3  2000/10/02 21:28:19  fca
+Removal of useless dependecies via forward declarations
+
+Revision 1.2  2000/06/08 18:32:58  cblume
+Make code compliant to coding conventions
+
+Revision 1.1  2000/02/28 19:01:42  cblume
+Add new TRD classes
+
 */
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -23,6 +56,8 @@ $Log$
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include "AliMC.h"
+
 #include "AliTRDgeometryHole.h"
 
 ClassImp(AliTRDgeometryHole)
@@ -41,6 +76,9 @@ AliTRDgeometryHole::AliTRDgeometryHole():AliTRDgeometry()
 //_____________________________________________________________________________
 AliTRDgeometryHole::~AliTRDgeometryHole()
 {
+  //
+  // AliTRDgeometryHole destructor
+  //
 
 }
 
@@ -52,107 +90,29 @@ void AliTRDgeometryHole::Init()
   //
 
   Int_t iplan;
-
-  // The length of the inner chambers
-  for (iplan = 0; iplan < kNplan; iplan++) 
-    fClengthI[iplan] = 110.0;
-
-  // The length of the middle chambers
-  fClengthM1[0] = 123.5;
-  fClengthM1[1] = 131.0;
-  fClengthM1[2] = 138.5;
-  fClengthM1[3] = 146.0;
-  fClengthM1[4] = 153.0;
-  fClengthM1[5] = 160.5;
-
-  fClengthM2[0] = 123.5 - 7.0;
-  fClengthM2[1] = 131.0 - 7.0;
-  fClengthM2[2] = 138.5 - 7.0;
-  fClengthM2[3] = 146.0 - 7.0;
-  fClengthM2[4] = 153.0 - 7.0;
-  fClengthM2[5] = 160.4 - 7.0;
-
-  // The length of the outer chambers
-  fClengthO1[0] = 123.5;
-  fClengthO1[1] = 131.0;
-  fClengthO1[2] = 134.5;
-  fClengthO1[3] = 142.0;
-  fClengthO1[4] = 142.0;
-  fClengthO1[5] = 134.5;
-
-  fClengthO2[0] = 123.5;
-  fClengthO2[1] = 131.0;
-  fClengthO2[2] = 134.5;
-  fClengthO2[3] = 142.0;
-  fClengthO2[4] = 142.0;
-  fClengthO2[5] = 134.5;
-
-  fClengthO3[0] =  86.5;
-  fClengthO3[1] = 101.5;
-  fClengthO3[2] = 112.5;
-  fClengthO3[3] = 127.5;
-  fClengthO3[4] = 134.5;
-  fClengthO3[5] = 134.5;
-
-  // The maximum number of pads
-  // and the position of pad 0,0,0 
-  // 
-  // chambers seen from the top:
-  //     +----------------------------+
-  //     |                            |
-  //     |                            |     ^
-  //     |                            | rphi|
-  //     |                            |     |
-  //     |0                           |     | 
-  //     +----------------------------+     +------>
-  //                                             z 
-  // chambers seen from the side:           ^
-  //     +----------------------------+ time|
-  //     |                            |     |
-  //     |0                           |     |
-  //     +----------------------------+     +------>
-  //                                             z
-  //                                             
-
-  // The pad row (z-direction)
-  for (iplan = 0; iplan < kNplan; iplan++) {
-
-    for (Int_t isect = 0; isect < kNsect; isect++) {
-      Float_t clengthI = fClengthI[iplan];
-      Float_t clengthM = fClengthM1[iplan];
-      Float_t clengthO = fClengthO1[iplan];
-      switch (isect) {
-      case 12:
-      case 13:
-      case 14:
-      case 15:
-      case 16:
-        clengthM = fClengthM2[iplan];
-        clengthO = fClengthO2[iplan];
-        break;
-      case 4:
-      case 5:
-      case 6:
-        clengthO = fClengthO3[iplan];
-        break;
-      };
-      fRowMax[iplan][0][isect] = 1 + TMath::Nint((clengthO - 2. * kCcthick) 
-                                                           / fRowPadSize - 0.5);
-      fRowMax[iplan][1][isect] = 1 + TMath::Nint((clengthM - 2. * kCcthick) 
-                                                           / fRowPadSize - 0.5);
-      fRowMax[iplan][2][isect] = 1 + TMath::Nint((clengthI - 2. * kCcthick) 
-                                                           / fRowPadSize - 0.5);
-      fRowMax[iplan][3][isect] = 1 + TMath::Nint((clengthM - 2. * kCcthick) 
-                                                           / fRowPadSize - 0.5);
-      fRowMax[iplan][4][isect] = 1 + TMath::Nint((clengthO - 2. * kCcthick) 
-                                                           / fRowPadSize - 0.5);
-      fRow0[iplan][0][isect]   = -clengthI/2. - clengthM - clengthO + kCcthick; 
-      fRow0[iplan][1][isect]   = -clengthI/2. - clengthM            + kCcthick;
-      fRow0[iplan][2][isect]   = -clengthI/2.                       + kCcthick;
-      fRow0[iplan][3][isect]   =  clengthI/2.                       + kCcthick; 
-      fRow0[iplan][4][isect]   =  clengthI/2. + clengthM            + kCcthick; 
+  Int_t icham;
+
+  // The outer lengths of the chambers for the sectors with holes for the PHOS
+  Float_t lengthPH[kNplan][kNcham] = { {   0.0,   0.0,   0.0, 117.0, 124.0 }
+                                    , {   0.0,   0.0,   0.0, 124.0, 131.0 }
+                                    , {   0.0,   0.0,   0.0, 131.0, 138.0 }
+                                    , {   0.0,   0.0,   0.0, 138.0, 145.0 }
+                                    , {   0.0,   0.0,   0.0, 140.0, 147.0 }
+                                     , {   0.0,   0.0,   0.0, 140.0, 147.0 } };
+
+  // The outer lengths of the chambers for the sectors with holes for the RICH
+  Float_t lengthRH[kNplan][kNcham] = { {   0.0,   0.0,   0.0,   0.0,  87.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 101.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 115.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 129.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 133.5 }
+                                     , {   0.0,   0.0,   0.0,   0.0, 133.5 } };
+
+  for (icham = 0; icham < kNcham; icham++) {
+    for (iplan = 0; iplan < kNplan; iplan++) {
+      fClengthPH[iplan][icham] = lengthPH[iplan][icham];
+      fClengthRH[iplan][icham] = lengthRH[iplan][icham];
     }
-
   }
 
 }
@@ -161,258 +121,646 @@ void AliTRDgeometryHole::Init()
 void AliTRDgeometryHole::CreateGeometry(Int_t *idtmed)
 {
   //
-  // Create the TRD geometry with hole
+  // Create the TRD geometry with holes
+  //
+  // Names of the TRD volumina (xx = detector number):
+  //
+  //      Lower part of the readout chambers (gas volume + radiator)
+  //
+  //        UAxx    Aluminum frames             (Al)
+  //        UBxx    G10 frames                  (C)
+  //        UCxx    Inner volumes               (Air)
+  //
+  //      Upper part of the readout chambers (readout plane + fee)
+  //
+  //        UDxx    G10 frames                  (C)
+  //        UExx    Inner volumes of the G10    (Air)
+  //        UFxx    Aluminum frames             (Al)
+  //        UGxx    Inner volumes of the Al     (Air)
+  //
+  //      Inner material layers
+  //
+  //        UHxx    Radiator                    (Rohacell)
+  //        UIxx    Entrance window             (Mylar)
+  //        UJxx    Drift volume                (Xe/CO2)
+  //        UKxx    Amplification volume        (Xe/CO2)
+  //        ULxx    Pad plane                   (Cu)
+  //        UMxx    Support structure           (Rohacell)
+  //        UNxx    FEE + signal lines          (Cu)
+  //        UOxx    Cooling device              (Al)
+  //        UPxx    Cooling device              (Water)
   //
 
-  Int_t iplan;
-
-  const Int_t npar_trd = 4;
-  const Int_t npar_cha = 3;
+  const Int_t kNdet    = kNplan * kNcham;
 
-  Float_t par_trd[npar_trd];
-  Float_t par_cha[npar_cha];
+  const Int_t kNparTrd = 4;
+  const Int_t kNparCha = 3;
 
   Float_t xpos, ypos, zpos;
 
+  Float_t parTrd[kNparTrd];
+  Float_t parCha[kNparCha];
+
+  Char_t  cTagV[5];
+  Char_t  cTagM[5];
+
   AliTRDgeometry::CreateGeometry(idtmed);
 
-  // The TRD mother volume for one sector (Air) (dimensions identical to BTR1)
-  par_trd[0] = kSwidth1/2.;
-  par_trd[1] = kSwidth2/2.;
-  par_trd[2] = kSlenTR1/2.;
-  par_trd[3] = kSheight/2.;
-  gMC->Gsvolu("TRD1","TRD1",idtmed[1302-1],par_trd,npar_trd);
-  
-  // The TRD mother volume for one sector (Air) (dimensions identical to BTR2)
-  par_trd[0] = kSwidth1/2.;
-  par_trd[1] = kSwidth2/2.;
-  par_trd[2] = kSlenTR2/2.;
-  par_trd[3] = kSheight/2.;
-  gMC->Gsvolu("TRD2","TRD1",idtmed[1302-1],par_trd,npar_trd);
-
-  // The TRD mother volume for one sector (Air) (dimensions identical to BTR3)
-  par_trd[0] = kSwidth1/2.;
-  par_trd[1] = kSwidth2/2.;
-  par_trd[2] = kSlenTR3/2.;
-  par_trd[3] = kSheight/2.;
-  gMC->Gsvolu("TRD3","TRD1",idtmed[1302-1],par_trd,npar_trd);
-
-  // Position the chambers in the TRD mother volume
-  for (iplan = 1; iplan <= kNplan; iplan++) {
-
-    // The inner chambers ---------------------------------------------------------------
-
-    // the aluminum frame
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthI[iplan-1]/2.;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = 0.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAFI",iplan       ,"TRD1",xpos,ypos,zpos,0,"MANY",par_cha,npar_cha);
-
-    // the inner part of the aluminum frame
-    par_cha[0] = fCwidth[iplan-1]/2.   - kCathick;
-    par_cha[1] = fClengthI[iplan-1]/2. - kCathick;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = 0.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAII",iplan       ,"TRD1",xpos,ypos,zpos,0,"ONLY",par_cha,npar_cha);
-
-    // the carbon frame
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthI[iplan-1]/2.;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = 0.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCFI",iplan       ,"TRD1",xpos,ypos,zpos,0,"MANY",par_cha,npar_cha);
-
-    // the inner part of the carbon frame
-    par_cha[0] = fCwidth[iplan-1]/2.   - kCcthick;
-    par_cha[1] = fClengthI[iplan-1]/2. - kCcthick;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = 0.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCII",iplan       ,"TRD1",xpos,ypos,zpos,0,"ONLY",par_cha,npar_cha);
-
-    // The middle chambers --------------------------------------------------------------
-
-    // the aluminum frame
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthM1[iplan-1]/2.;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2.  + fClengthM1[iplan-1]/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAFM",iplan         ,"TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-    gMC->Gsposp("UAFM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthM2[iplan-1]/2.;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAFM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-
-    // the inner part of the aluminum frame
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
-    par_cha[1] = fClengthM1[iplan-1]/2. - kCathick;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2.  + fClengthM1[iplan-1]/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAIM",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    gMC->Gsposp("UAIM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
-    par_cha[1] = fClengthM2[iplan-1]/2. - kCathick;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAIM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-
-    // the carbon frame
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthM1[iplan-1]/2.;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]/2.;
-    zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCFM",iplan         ,"TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-    gMC->Gsposp("UCFM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthM2[iplan-1]/2.;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCFM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-
-    // the inner part of the carbon frame
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
-    par_cha[1] = fClengthM1[iplan-1]/2. - kCcthick;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]/2.;
-    zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCIM",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    gMC->Gsposp("UCIM",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
-    par_cha[1] = fClengthM2[iplan-1]/2. - kCcthick;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCIM",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-
-    // The outer chambers ---------------------------------------------------------------
-
-    // the aluminum frame
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthO1[iplan-1]/2.;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAFO",iplan         ,"TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-    gMC->Gsposp("UAFO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthO2[iplan-1]/2.;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAFO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthO3[iplan-1]/2.;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAFO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-
-    // the inner part of the aluminum frame
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
-    par_cha[1] = fClengthO1[iplan-1]/2. - kCathick;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAIO",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    gMC->Gsposp("UAIO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
-    par_cha[1] = fClengthO2[iplan-1]/2. - kCathick;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAIO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCathick;
-    par_cha[1] = fClengthO3[iplan-1]/2. - kCathick;
-    par_cha[2] = kCaframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
-    zpos       = kCheight - kCaframe/2. - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UAIO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-
-    // the carbon frame
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthO1[iplan-1]/2.;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
-    zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCFO",iplan,         "TRD1",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-    gMC->Gsposp("UCFO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"MANY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthO2[iplan-1]/2.;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCFO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.;
-    par_cha[1] = fClengthO3[iplan-1]/2.;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCFO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"MANY",par_cha,npar_cha);
-
-    // the inner part of the carbon frame
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
-    par_cha[1] = fClengthO1[iplan-1]/2. - kCcthick;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthI[iplan-1]/2. + fClengthM1[iplan-1]    + fClengthO1[iplan-1]/2.;
-    zpos       = kCcframe/2.           - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCIO",iplan         ,"TRD1",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    gMC->Gsposp("UCIO",iplan+  kNplan,"TRD1",xpos,-ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
-    par_cha[1] = fClengthO2[iplan-1]/2. - kCcthick;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthM2[iplan-1]    + fClengthO2[iplan-1]/2. - kSlenTR2/2.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCIO",iplan+2*kNplan,"TRD2",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
-    par_cha[0] = fCwidth[iplan-1]/2.    - kCcthick;
-    par_cha[1] = fClengthO3[iplan-1]/2. - kCcthick;
-    par_cha[2] = kCcframe/2.;
-    xpos       = 0.;
-    ypos       = fClengthO3[iplan-1]/2. - kSlenTR3/2.;
-    zpos       = kCcframe/2.            - kSheight/2. + (iplan-1) * (kCheight + kCspace);
-    gMC->Gsposp("UCIO",iplan+4*kNplan,"TRD3",xpos, ypos,zpos,0,"ONLY",par_cha,npar_cha);
+  // The TRD mother volume for one sector (Air), full length in z-direction
+  parTrd[0] = fgkSwidth1/2.;
+  parTrd[1] = fgkSwidth2/2.;
+  parTrd[2] = fgkSlenTR1/2.;
+  parTrd[3] = fgkSheight/2.;
+  gMC->Gsvolu("UTR1","TRD1",idtmed[1302-1],parTrd,kNparTrd);
+
+  // The TRD mother volume for one sector (Air), leaving hole for PHOS
+  parTrd[0] = fgkSwidth1/2.;
+  parTrd[1] = fgkSwidth2/2.;
+  parTrd[2] = fgkSlenTR2/2.;
+  parTrd[3] = fgkSheight/2.;
+  gMC->Gsvolu("UTR2","TRD1",idtmed[1302-1],parTrd,kNparTrd);
+
+  // The TRD mother volume for one sector (Air), leaving hole for RICH
+  parTrd[0] = fgkSwidth1/2.;
+  parTrd[1] = fgkSwidth2/2.;
+  parTrd[2] = fgkSlenTR3/2.;
+  parTrd[3] = fgkSheight/2.;
+  gMC->Gsvolu("UTR3","TRD1",idtmed[1302-1],parTrd,kNparTrd);
+
+  for (Int_t icham = 0; icham < kNcham; icham++) {
+    for (Int_t iplan = 0; iplan < kNplan; iplan++) {  
+
+      Int_t iDet = GetDetectorSec(iplan,icham);
+
+      // The lower part of the readout chambers (gas volume + radiator) 
+      // The aluminum frames 
+      sprintf(cTagV,"UA%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2.;
+      parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
+      parCha[2] = fgkCraH/2. + fgkCdrH/2.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+      // The G10 frames 
+      sprintf(cTagV,"UB%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2. - fgkCalT; 
+      parCha[1] = -1.;
+      parCha[2] = -1.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
+      // The inner part (air)
+      sprintf(cTagV,"UC%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2. - fgkCalT - fgkCclsT; 
+      parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.- fgkCclfT;
+      parCha[2] = -1.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      if (fClengthPH[iplan][icham] > 0.0) {
+        // The aluminum frames 
+        sprintf(cTagV,"UA%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2.;
+        parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
+        parCha[2] = fgkCraH/2. + fgkCdrH/2.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+        // The G10 frames 
+        sprintf(cTagV,"UB%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2. - fgkCalT; 
+        parCha[1] = -1.;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
+        // The inner part (air)
+        sprintf(cTagV,"UC%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2. - fgkCalT - fgkCclsT; 
+        parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.- fgkCclfT;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      }
+      if (fClengthRH[iplan][icham] > 0.0) {
+        // The aluminum frames 
+        sprintf(cTagV,"UA%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2.;
+        parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
+        parCha[2] = fgkCraH/2. + fgkCdrH/2.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+        // The G10 frames 
+        sprintf(cTagV,"UB%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2. - fgkCalT; 
+        parCha[1] = -1.;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
+        // The inner part (air)
+        sprintf(cTagV,"UC%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2. - fgkCalT - fgkCclsT; 
+        parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.- fgkCclfT;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      }
+
+      // The upper part of the readout chambers (readout plane + fee)
+      // The G10 frames
+      sprintf(cTagV,"UD%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2. + fgkCroW;
+      parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
+      parCha[2] = fgkCamH/2.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
+      // The inner part of the G10 frame (air)
+      sprintf(cTagV,"UE%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCcuT; 
+      parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.- fgkCcuT;
+      parCha[2] = -1.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      // The aluminum frames
+      sprintf(cTagV,"UF%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2. + fgkCroW;
+      parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
+      parCha[2] = fgkCroH/2.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+      // The inner part of the aluminum frames
+      sprintf(cTagV,"UG%02d",iDet);
+      parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCauT; 
+      parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.- fgkCauT;
+      parCha[2] = -1.;
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      if (fClengthPH[iplan][icham] > 0.0) {
+        sprintf(cTagV,"UD%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW;
+        parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
+        parCha[2] = fgkCamH/2.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
+        // The inner part of the G10 frame (air)
+        sprintf(cTagV,"UE%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCcuT; 
+        parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.- fgkCcuT;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+        // The aluminum frames
+        sprintf(cTagV,"UF%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW;
+        parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
+        parCha[2] = fgkCroH/2.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+        // The inner part of the aluminum frames
+        sprintf(cTagV,"UG%02d",iDet+kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCauT; 
+        parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.- fgkCauT;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      }
+      if (fClengthRH[iplan][icham] > 0.0) {
+        sprintf(cTagV,"UD%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW;
+        parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
+        parCha[2] = fgkCamH/2.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
+        // The inner part of the G10 frame (air)
+        sprintf(cTagV,"UE%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCcuT; 
+        parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.- fgkCcuT;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+        // The aluminum frames
+        sprintf(cTagV,"UF%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW;
+        parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
+        parCha[2] = fgkCroH/2.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+        // The inner part of the aluminum frames
+        sprintf(cTagV,"UG%02d",iDet+2*kNdet);
+        parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCauT; 
+        parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.- fgkCauT;
+        parCha[2] = -1.;
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
+      }
+
+      // The material layers inside the chambers
+      parCha[0] = -1.;
+      parCha[1] = -1.;
+      // Rohacell layer (radiator)
+      parCha[2] = fgkRaThick/2;
+      sprintf(cTagV,"UH%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1315-1],parCha,kNparCha);
+      // Mylar layer (entrance window + HV cathode) 
+      parCha[2] = fgkMyThick/2;
+      sprintf(cTagV,"UI%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1308-1],parCha,kNparCha);
+      // Xe/Isobutane layer (drift volume) 
+      parCha[2] = fgkDrThick/2.;
+      sprintf(cTagV,"UJ%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);
+      // Xe/Isobutane layer (amplification volume)
+      parCha[2] = fgkAmThick/2.;
+      sprintf(cTagV,"UK%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);  
+      // Cu layer (pad plane)
+      parCha[2] = fgkCuThick/2;
+      sprintf(cTagV,"UL%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
+      // G10 layer (support structure / honeycomb)
+      parCha[2] = fgkSuThick/2;
+      sprintf(cTagV,"UM%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1313-1],parCha,kNparCha);
+      // Cu layer (FEE + signal lines)
+      parCha[2] = fgkFeThick/2;
+      sprintf(cTagV,"UN%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
+      // Al layer (cooling devices)
+      parCha[2] = fgkCoThick/2;
+      sprintf(cTagV,"UO%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+      // Water layer (cooling)
+      parCha[2] = fgkWaThick/2;
+      sprintf(cTagV,"UP%02d",iDet);
+      gMC->Gsvolu(cTagV,"BOX ",idtmed[1314-1],parCha,kNparCha);
+      if (fClengthPH[iplan][icham] > 0.0) {
+        // Rohacell layer (radiator)
+        parCha[2] = fgkRaThick/2;
+        sprintf(cTagV,"UH%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1315-1],parCha,kNparCha);
+        // Mylar layer (entrance window + HV cathode) 
+        parCha[2] = fgkMyThick/2;
+        sprintf(cTagV,"UI%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1308-1],parCha,kNparCha);
+        // Xe/Isobutane layer (drift volume) 
+        parCha[2] = fgkDrThick/2.;
+        sprintf(cTagV,"UJ%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);
+        // Xe/Isobutane layer (amplification volume)
+        parCha[2] = fgkAmThick/2.;
+        sprintf(cTagV,"UK%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);  
+        // Cu layer (pad plane)
+        parCha[2] = fgkCuThick/2;
+        sprintf(cTagV,"UL%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
+        // G10 layer (support structure / honeycomb)
+        parCha[2] = fgkSuThick/2;
+        sprintf(cTagV,"UM%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1313-1],parCha,kNparCha);
+        // Cu layer (FEE + signal lines)
+        parCha[2] = fgkFeThick/2;
+        sprintf(cTagV,"UN%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
+        // Al layer (cooling devices)
+        parCha[2] = fgkCoThick/2;
+        sprintf(cTagV,"UO%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+        // Water layer (cooling)
+        parCha[2] = fgkWaThick/2;
+        sprintf(cTagV,"UP%02d",iDet+kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1314-1],parCha,kNparCha);
+      }
+      if (fClengthRH[iplan][icham] > 0.0) {
+        // Rohacell layer (radiator)
+        parCha[2] = fgkRaThick/2;
+        sprintf(cTagV,"UH%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1315-1],parCha,kNparCha);
+        // Mylar layer (entrance window + HV cathode) 
+        parCha[2] = fgkMyThick/2;
+        sprintf(cTagV,"UI%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1308-1],parCha,kNparCha);
+        // Xe/Isobutane layer (drift volume) 
+        parCha[2] = fgkDrThick/2.;
+        sprintf(cTagV,"UJ%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);
+        // Xe/Isobutane layer (amplification volume)
+        parCha[2] = fgkAmThick/2.;
+        sprintf(cTagV,"UK%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);  
+        // Cu layer (pad plane)
+        parCha[2] = fgkCuThick/2;
+        sprintf(cTagV,"UL%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
+        // G10 layer (support structure / honeycomb)
+        parCha[2] = fgkSuThick/2;
+        sprintf(cTagV,"UM%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1313-1],parCha,kNparCha);
+        // Cu layer (FEE + signal lines)
+        parCha[2] = fgkFeThick/2;
+        sprintf(cTagV,"UN%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
+        // Al layer (cooling devices)
+        parCha[2] = fgkCoThick/2.;
+        sprintf(cTagV,"UO%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
+        // Water layer (cooling)
+        parCha[2] = fgkWaThick/2;
+        sprintf(cTagV,"UP%02d",iDet+2*kNdet);
+        gMC->Gsvolu(cTagV,"BOX ",idtmed[1314-1],parCha,kNparCha);
+      }
+
+      // Position the layers in the chambers
+      xpos = 0;
+      ypos = 0;
+      // Lower part
+      // Rohacell layer (radiator)
+      zpos = fgkRaZpos;
+      sprintf(cTagV,"UH%02d",iDet);
+      sprintf(cTagM,"UC%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Mylar layer (entrance window + HV cathode)   
+      zpos = fgkMyZpos;
+      sprintf(cTagV,"UI%02d",iDet);
+      sprintf(cTagM,"UC%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Xe/Isobutane layer (drift volume) 
+      zpos = fgkDrZpos;
+      sprintf(cTagV,"UJ%02d",iDet);
+      sprintf(cTagM,"UC%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Upper part
+      // Xe/Isobutane layer (amplification volume)
+      zpos = fgkAmZpos;
+      sprintf(cTagV,"UK%02d",iDet);
+      sprintf(cTagM,"UE%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Readout part
+      // Cu layer (pad plane)
+      zpos = fgkCuZpos; 
+      sprintf(cTagV,"UL%02d",iDet);
+      sprintf(cTagM,"UG%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // G10 layer (support structure)
+      zpos = fgkSuZpos;
+      sprintf(cTagV,"UM%02d",iDet);
+      sprintf(cTagM,"UG%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Cu layer (FEE + signal lines)
+      zpos = fgkFeZpos; 
+      sprintf(cTagV,"UN%02d",iDet);
+      sprintf(cTagM,"UG%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Al layer (cooling devices)
+      zpos = fgkCoZpos;
+      sprintf(cTagV,"UO%02d",iDet);
+      sprintf(cTagM,"UG%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // Water layer (cooling)
+      zpos = fgkWaZpos;
+      sprintf(cTagV,"UP%02d",iDet);
+      sprintf(cTagM,"UG%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      if (fClengthPH[iplan][icham] > 0.0) {
+        // Lower part
+        // Rohacell layer (radiator)
+        zpos = fgkRaZpos;
+        sprintf(cTagV,"UH%02d",iDet+kNdet);
+        sprintf(cTagM,"UC%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Mylar layer (entrance window + HV cathode)   
+        zpos = fgkMyZpos;
+        sprintf(cTagV,"UI%02d",iDet+kNdet);
+        sprintf(cTagM,"UC%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Xe/Isobutane layer (drift volume) 
+        zpos = fgkDrZpos;
+        sprintf(cTagV,"UJ%02d",iDet+kNdet);
+        sprintf(cTagM,"UC%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Upper part
+        // Xe/Isobutane layer (amplification volume)
+        zpos = fgkAmZpos;
+        sprintf(cTagV,"UK%02d",iDet+kNdet);
+        sprintf(cTagM,"UE%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Readout part
+        // Cu layer (pad plane)
+        zpos = fgkCuZpos; 
+        sprintf(cTagV,"UL%02d",iDet+kNdet);
+        sprintf(cTagM,"UG%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // G10 layer (support structure)
+        zpos = fgkSuZpos;
+        sprintf(cTagV,"UM%02d",iDet+kNdet);
+        sprintf(cTagM,"UG%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Cu layer (FEE + signal lines)
+        zpos = fgkFeZpos; 
+        sprintf(cTagV,"UN%02d",iDet+kNdet);
+        sprintf(cTagM,"UG%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Al layer (cooling devices)
+        zpos = fgkCoZpos;
+        sprintf(cTagV,"UO%02d",iDet+kNdet);
+        sprintf(cTagM,"UG%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Water layer (cooling)
+        zpos = fgkWaZpos;
+        sprintf(cTagV,"UP%02d",iDet+kNdet);
+        sprintf(cTagM,"UG%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      }
+      if (fClengthRH[iplan][icham] > 0.0) {
+        // Lower part
+        // Rohacell layer (radiator)
+        zpos = fgkRaZpos;
+        sprintf(cTagV,"UH%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UC%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Mylar layer (entrance window + HV cathode)   
+        zpos = fgkMyZpos;
+        sprintf(cTagV,"UI%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UC%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Xe/Isobutane layer (drift volume) 
+        zpos = fgkDrZpos;
+        sprintf(cTagV,"UJ%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UC%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Upper part
+        // Xe/Isobutane layer (amplification volume)
+        zpos = fgkAmZpos;
+        sprintf(cTagV,"UK%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UE%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Readout part
+        // Cu layer (pad plane)
+        zpos = fgkCuZpos; 
+        sprintf(cTagV,"UL%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UG%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // G10 layer (support structure)
+        zpos = fgkSuZpos;
+        sprintf(cTagV,"UM%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UG%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Cu layer (FEE + signal lines)
+        zpos = fgkFeZpos; 
+        sprintf(cTagV,"UN%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UG%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Al layer (cooling devices)
+        zpos = fgkCoZpos;
+        sprintf(cTagV,"UO%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UG%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // Water layer (cooling)
+        zpos = fgkWaZpos;
+        sprintf(cTagV,"UP%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UG%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      }
+
+      // Position the inner volumes of the chambers in the frames
+      xpos      = 0.0;
+      ypos      = 0.0;
+      zpos      = 0.0;
+      // The inside of the lower G10 frame
+      sprintf(cTagV,"UC%02d",iDet);
+      sprintf(cTagM,"UB%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // The lower G10 frame inside the aluminum frame
+      sprintf(cTagV,"UB%02d",iDet);
+      sprintf(cTagM,"UA%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // The inside of the upper G10 frame
+      sprintf(cTagV,"UE%02d",iDet);
+      sprintf(cTagM,"UD%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+      // The inside of the upper aluminum frame
+      sprintf(cTagV,"UG%02d",iDet);
+      sprintf(cTagM,"UF%02d",iDet);
+      gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");      
+      if (fClengthPH[iplan][icham] > 0.0) {
+        // The inside of the lower G10 frame
+        sprintf(cTagV,"UC%02d",iDet+kNdet);
+        sprintf(cTagM,"UB%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // The lower G10 frame inside the aluminum frame
+        sprintf(cTagV,"UB%02d",iDet+kNdet);
+        sprintf(cTagM,"UA%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // The inside of the upper G10 frame
+        sprintf(cTagV,"UE%02d",iDet+kNdet);
+        sprintf(cTagM,"UD%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // The inside of the upper aluminum frame
+        sprintf(cTagV,"UG%02d",iDet+kNdet);
+        sprintf(cTagM,"UF%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");      
+      }
+      if (fClengthRH[iplan][icham] > 0.0) {
+        // The inside of the lower G10 frame
+        sprintf(cTagV,"UC%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UB%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // The lower G10 frame inside the aluminum frame
+        sprintf(cTagV,"UB%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UA%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // The inside of the upper G10 frame
+        sprintf(cTagV,"UE%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UD%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
+        // The inside of the upper aluminum frame
+        sprintf(cTagV,"UG%02d",iDet+2*kNdet);
+        sprintf(cTagM,"UF%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");      
+      }
+
+      // Position the frames of the chambers in the TRD mother volume
+      xpos  = 0.;
+      ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
+      for (Int_t ic = 0; ic < icham; ic++) {
+        ypos += fClength[iplan][ic];        
+      }
+      ypos += fClength[iplan][icham]/2.;
+      zpos  = fgkCraH/2. + fgkCdrH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
+      // The lower aluminum frame, radiator + drift region
+      sprintf(cTagV,"UA%02d",iDet);
+      gMC->Gspos(cTagV,1,"UTR1",xpos,ypos,zpos,0,"ONLY");
+      // The upper G10 frame, amplification region
+      sprintf(cTagV,"UD%02d",iDet);
+      zpos += fgkCamH/2. + fgkCraH/2. + fgkCdrH/2.;
+      gMC->Gspos(cTagV,1,"UTR1",xpos,ypos,zpos,0,"ONLY");
+      // The upper aluminum frame
+      sprintf(cTagV,"UF%02d",iDet);
+      zpos += fgkCroH/2. + fgkCamH/2.;
+      gMC->Gspos(cTagV,1,"UTR1",xpos,ypos,zpos,0,"ONLY");
+      if (fClengthPH[iplan][icham] > 0.0) {
+        xpos  = 0.;
+        ypos  = - fgkSlenTR2/2.;
+        for (Int_t ic = 0; ic < icham; ic++) {
+          ypos += fClengthPH[iplan][ic];        
+        }
+        ypos += fClengthPH[iplan][icham]/2.;
+        zpos  = fgkCraH/2. + fgkCdrH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
+        // The lower aluminum frame, radiator + drift region
+        sprintf(cTagV,"UA%02d",iDet+kNdet);
+        gMC->Gspos(cTagV,1,"UTR2",xpos,ypos,zpos,0,"ONLY");
+        // The upper G10 frame, amplification region
+        sprintf(cTagV,"UD%02d",iDet+kNdet);
+        zpos += fgkCamH/2. + fgkCraH/2. + fgkCdrH/2.;
+        gMC->Gspos(cTagV,1,"UTR2",xpos,ypos,zpos,0,"ONLY");
+        // The upper aluminum frame
+        sprintf(cTagV,"UF%02d",iDet+kNdet);
+        zpos += fgkCroH/2. + fgkCamH/2.;
+        gMC->Gspos(cTagV,1,"UTR2",xpos,ypos,zpos,0,"ONLY");
+      }
+      if (fClengthRH[iplan][icham] > 0.0) {
+        xpos  = 0.;
+        ypos  = - fgkSlenTR3/2.;
+        for (Int_t ic = 0; ic < icham; ic++) {
+          ypos += fClengthRH[iplan][ic];        
+        }
+        ypos += fClengthRH[iplan][icham]/2.;
+        zpos  = fgkCraH/2. + fgkCdrH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
+        // The lower aluminum frame, radiator + drift region
+        sprintf(cTagV,"UA%02d",iDet+2*kNdet);
+        gMC->Gspos(cTagV,1,"UTR3",xpos,ypos,zpos,0,"ONLY");
+        // The upper G10 frame, amplification region
+        sprintf(cTagV,"UD%02d",iDet+2*kNdet);
+        zpos += fgkCamH/2. + fgkCraH/2. + fgkCdrH/2.;
+        gMC->Gspos(cTagV,1,"UTR3",xpos,ypos,zpos,0,"ONLY");
+        // The upper aluminum frame
+        sprintf(cTagV,"UF%02d",iDet+2*kNdet);
+        zpos += fgkCroH/2. + fgkCamH/2.;
+        gMC->Gspos(cTagV,1,"UTR3",xpos,ypos,zpos,0,"ONLY");
+      }
 
+    }
   }
 
-  xpos     = 0.;
-  ypos     = 0.;
-  zpos     = 0.;
-  gMC->Gspos("TRD1",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
-  gMC->Gspos("TRD2",1,"BTR2",xpos,ypos,zpos,0,"ONLY");
-  gMC->Gspos("TRD3",1,"BTR3",xpos,ypos,zpos,0,"ONLY");
+  xpos = 0.;
+  ypos = 0.;
+  zpos = 0.;
+  gMC->Gspos("UTR1",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
+  gMC->Gspos("UTR2",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
+  gMC->Gspos("UTR3",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
 
 }
+
+//_____________________________________________________________________________
+void AliTRDgeometryHole::SetOldGeometry()
+{
+  //
+  // Use the old chamber lengths
+  //
+
+  Int_t icham;
+  Int_t iplan;
+
+  AliTRDgeometry::SetOldGeometry();
+
+  // The outer lengths of the chambers for the sectors with holes for the PHOS
+  Float_t lengthPH[kNplan][kNcham] = { {   0.0,   0.0,   0.0, 116.5, 123.5 }
+                                    , {   0.0,   0.0,   0.0, 124.0, 131.0 }
+                                    , {   0.0,   0.0,   0.0, 131.5, 134.5 }
+                                    , {   0.0,   0.0,   0.0, 139.0, 142.0 }
+                                    , {   0.0,   0.0,   0.0, 146.0, 142.0 }
+                                     , {   0.0,   0.0,   0.0, 153.5, 134.5 } };
+
+  // The outer lengths of the chambers for the sectors with holes for the RICH
+  Float_t lengthRH[kNplan][kNcham] = { {   0.0,   0.0,   0.0,   0.0,  86.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 101.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 112.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 127.5 }
+                                    , {   0.0,   0.0,   0.0,   0.0, 134.5 }
+                                     , {   0.0,   0.0,   0.0,   0.0, 134.5 } };
+
+  for (icham = 0; icham < kNcham; icham++) {
+    for (iplan = 0; iplan < kNplan; iplan++) {
+      fClengthPH[iplan][icham] = lengthPH[iplan][icham];
+      fClengthRH[iplan][icham] = lengthRH[iplan][icham];
+    }
+  }
+
+}
+
+
+