]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDv1.cxx
syntax correction for Mylar
[u/mrichter/AliRoot.git] / PMD / AliPMDv1.cxx
index 10109aac9d646ca301510a2dfe8809ca4955e1da..88b1e3872d6cf5419360bcaf870f4c66a5777983 100644 (file)
  **************************************************************************/
 /*
 $Log$
+Revision 1.35  2004/01/07 10:49:49  hristov
+Initialization to avoid runtime problems (valgrind)
+
+Revision 1.34  2003/12/18 04:25:03  bnandi
+overlap with beam pipe fixed and Gsposp changed to Gspos
+
+Revision 1.33  2003/11/03 14:33:26  hristov
+Correct initialization of static data members
+
+Revision 1.32  2003/11/03 11:53:05  bnandi
+global variables are removed
+
+Revision 1.31  2003/10/31 12:25:36  bnandi
+variable names are changed according to ALICE convention
+
+Revision 1.30  2003/10/23 16:32:19  hristov
+MC-dependent part of AliRun extracted in AliMC (F.Carminati)
+
 Revision 1.29  2003/10/13 05:28:59  bnandi
 gaspmd[2] value changed 0.25->7.0 because of overlap
 
@@ -59,15 +77,24 @@ June 2003
 #include "Riostream.h"
 #include <TVirtualMC.h>
 #include "AliMC.h"
-static Int_t     ncol_um1,ncol_um2, nrow_um1, nrow_um2;
-static Int_t     kdet;
-static Float_t   sm_length_ax,sm_length_ay;
-static Float_t   sm_length_bx,sm_length_by;
-static Float_t   zdist, zdist1;
-static Float_t   sm_thick, cell_radius, cell_wall, cell_depth;
-static Float_t   boundary, th_base, th_air, th_pcb;
-static Float_t   th_lead, th_steel;
+
+const Int_t   AliPMDv1::fgkNcolUM1    = 48;  // Number of cols in UM, type 1
+const Int_t   AliPMDv1::fgkNcolUM2    = 96;  // Number of cols in UM, type 2
+const Int_t   AliPMDv1::fgkNrowUM1    = 96;  // Number of rows in UM, type 1
+const Int_t   AliPMDv1::fgkNrowUM2    = 48;  // Number of rows in UM, type 2
+const Float_t AliPMDv1::fgkCellRadius = 0.25;     // Radius of a hexagonal cell
+const Float_t AliPMDv1::fgkCellWall   = 0.02;     // Thickness of cell Wall
+const Float_t AliPMDv1::fgkCellDepth  = 0.50;     // Gas thickness
+const Float_t AliPMDv1::fgkBoundary   = 0.7;      // Thickness of Boundary wall
+const Float_t AliPMDv1::fgkThBase     = 0.3;      // Thickness of Base plate
+const Float_t AliPMDv1::fgkThAir      = 0.1;      // Thickness of Air
+const Float_t AliPMDv1::fgkThPCB      = 0.16;     // Thickness of PCB
+const Float_t AliPMDv1::fgkThLead     = 1.5;      // Thickness of Pb
+const Float_t AliPMDv1::fgkThSteel    = 0.5;      // Thickness of Steel
+const Float_t AliPMDv1::fgkGap        = 0.025;    // Air Gap
+const Float_t AliPMDv1::fgkZdist      = 361.5;    // z-position of the detector
+const Float_t AliPMDv1::fgkSqroot3    = 1.7320508;// Square Root of 3
+const Float_t AliPMDv1::fgkSqroot3by2 = 0.8660254;// Square Root of 3 by 2
 
 ClassImp(AliPMDv1)
  
@@ -121,26 +148,23 @@ void AliPMDv1::CreateSupermodule()
 
   
   Int_t i,j;
-  Float_t xb, yb, zb;
   Int_t number;
   Int_t ihrotm,irotdm;
-  const Float_t root3_2 = TMath::Sqrt(3.) /2.; 
-  const Float_t root3 = TMath::Sqrt(3.); 
+  Float_t xb, yb, zb;
+
   Int_t *idtmed = fIdtmed->GetArray()-599;
  
   AliMatrix(ihrotm, 90., 30.,   90.,  120., 0., 0.);
   AliMatrix(irotdm, 90., 180.,  90.,  270., 180., 0.);
  
-  zdist = TMath::Abs(zdist1);
-
   // First create the sensitive medium of a hexagon cell (ECAR)
   // Inner hexagon filled with gas (Ar+CO2)
   
   Float_t hexd2[10] = {0.,360.,6,2,-0.25,0.,0.23,0.25,0.,0.23};
-  hexd2[4] = -cell_depth/2.;
-  hexd2[7] =  cell_depth/2.;
-  hexd2[6] =  cell_radius - cell_wall;
-  hexd2[9] =  cell_radius - cell_wall;
+  hexd2[4] = -fgkCellDepth/2.;
+  hexd2[7] =  fgkCellDepth/2.;
+  hexd2[6] =  fgkCellRadius - fgkCellWall;
+  hexd2[9] =  fgkCellRadius - fgkCellWall;
   
   gMC->Gsvolu("ECAR", "PGON", idtmed[604], hexd2,10);
   gMC->Gsatt("ECAR", "SEEN", 0);
@@ -149,17 +173,17 @@ void AliPMDv1::CreateSupermodule()
   // Outer hexagon made of Copper
   
   Float_t hexd1[10] = {0.,360.,6,2,-0.25,0.,0.25,0.25,0.,0.25};
-  hexd1[4] = -cell_depth/2.;
-  hexd1[7] =  cell_depth/2.;
-  hexd1[6] =  cell_radius;
-  hexd1[9] =  cell_radius;
+  hexd1[4] = -fgkCellDepth/2.;
+  hexd1[7] =  fgkCellDepth/2.;
+  hexd1[6] =  fgkCellRadius;
+  hexd1[9] =  fgkCellRadius;
 
   gMC->Gsvolu("ECCU", "PGON", idtmed[614], hexd1,10);
   gMC->Gsatt("ECCU", "SEEN", 0);
 
   // Place  inner hex (sensitive volume) inside outer hex (copper)
   
-  gMC->Gsposp("ECAR", 1, "ECCU", 0., 0., 0., 0, "ONLY", hexd2, 10);
+  gMC->Gspos("ECAR", 1, "ECCU", 0., 0., 0., 0, "ONLY");
   
   // Now create Rectangular TWO strips (EST1, EST2) 
   // of 1 column and 48 or 96 cells length
@@ -167,9 +191,9 @@ void AliPMDv1::CreateSupermodule()
   // volume for first strip EST1 made of AIR 
 
   Float_t dbox1[3];
-  dbox1[0] = ncol_um1*cell_radius;
-  dbox1[1] = cell_radius/root3_2;
-  dbox1[2] = cell_depth/2.;
+  dbox1[0] = fgkNcolUM1*fgkCellRadius;
+  dbox1[1] = fgkCellRadius/fgkSqroot3by2;
+  dbox1[2] = fgkCellDepth/2.;
   
   gMC->Gsvolu("EST1","BOX", idtmed[698], dbox1, 3);
   gMC->Gsatt("EST1", "SEEN", 0);
@@ -177,7 +201,7 @@ void AliPMDv1::CreateSupermodule()
   // volume for second strip EST2 
 
   Float_t dbox2[3];
-  dbox2[0] = ncol_um2*cell_radius;
+  dbox2[0] = fgkNcolUM2*fgkCellRadius;
   dbox2[1] = dbox1[1];
   dbox2[2] = dbox1[2];
 
@@ -187,82 +211,80 @@ void AliPMDv1::CreateSupermodule()
   // Place hexagonal cells ECCU placed inside EST1 
   yb = 0.; 
   zb = 0.;
-  xb = -(dbox1[0]) + cell_radius; 
-  for (i = 1; i <= ncol_um1; ++i) 
-       {
-         number = i;
-         gMC->Gsposp("ECCU", number, "EST1", xb,yb,zb, ihrotm, "ONLY", hexd1,10);
-         xb += (cell_radius*2.);
-       }
+  xb = -(dbox1[0]) + fgkCellRadius; 
+  for (i = 1; i <= fgkNcolUM1; ++i) 
+    {
+      number = i;
+      gMC->Gspos("ECCU", number, "EST1", xb,yb,zb, ihrotm, "ONLY");
+      xb += (fgkCellRadius*2.);
+    }
   // Place hexagonal cells ECCU placed inside EST2 
-      yb = 0.; 
-      zb = 0.;
-      xb = -(dbox2[0]) + cell_radius; 
-      for (i = 1; i <= ncol_um2; ++i) 
-       {
-         number = i;
-         gMC->Gsposp("ECCU", number, "EST2", xb,yb,zb, ihrotm, "ONLY", hexd1,10);
-         xb += (cell_radius*2.);
-       }
-
-
+  yb = 0.; 
+  zb = 0.;
+  xb = -(dbox2[0]) + fgkCellRadius; 
+  for (i = 1; i <= fgkNcolUM2; ++i) 
+    {
+      number = i;
+      gMC->Gspos("ECCU", number, "EST2", xb,yb,zb, ihrotm, "ONLY");
+      xb += (fgkCellRadius*2.);
+    }
 
   // 2 types of rectangular shaped unit modules EUM1 and EUM2 (defined by BOX) 
-
+  
   // Create EUM1
-
+  
   Float_t dbox3[3];
-  dbox3[0] = dbox1[0]+cell_radius/2.;
-  dbox3[1] = (dbox1[1]*nrow_um1)-(cell_radius*root3*(nrow_um1-1)/6.); 
-  dbox3[2] = cell_depth/2.;
+  dbox3[0] = dbox1[0]+fgkCellRadius/2.;
+  dbox3[1] = (dbox1[1]*fgkNrowUM1)-(fgkCellRadius*fgkSqroot3*(fgkNrowUM1-1)/6.); 
+  dbox3[2] = fgkCellDepth/2.;
   
   gMC->Gsvolu("EUM1","BOX", idtmed[698], dbox3, 3);
   gMC->Gsatt("EUM1", "SEEN", 1);
   
   // Place rectangular strips EST1 inside EUM1 unit module
-
+  
   yb = -dbox3[1]+dbox1[1];  
-  for (j = 1; j <= nrow_um1; ++j)  
+  for (j = 1; j <= fgkNrowUM1; ++j)  
     {
       if(j%2 == 0)
        {
-      xb =cell_radius/2.0;
+         xb = fgkCellRadius/2.0;
        }
       else
        {
-         xb = -cell_radius/2.0;
+         xb = -fgkCellRadius/2.0;
        }
       number = j;
-      gMC->Gsposp("EST1",number, "EUM1", xb, yb , 0. , 0, "MANY",dbox1,3);
-      yb = (-dbox3[1]+dbox1[1])+j*1.0*cell_radius*root3;
+      gMC->Gspos("EST1",number, "EUM1", xb, yb , 0. , 0, "MANY");
+      yb = (-dbox3[1]+dbox1[1])+j*1.0*fgkCellRadius*fgkSqroot3;
     }
 
   // Create EUM2
 
   Float_t dbox4[3];
-  dbox4[0] = dbox2[0]+cell_radius/2.;
-  dbox4[1] =(dbox2[1]*nrow_um2)-(cell_radius*root3*(nrow_um2-1)/6.); 
+  dbox4[0] = dbox2[0] + fgkCellRadius/2.;
+  dbox4[1] =(dbox2[1]*fgkNrowUM2)-(fgkCellRadius*fgkSqroot3*(fgkNrowUM2-1)/6.); 
   dbox4[2] = dbox3[2];
-
+  
   gMC->Gsvolu("EUM2","BOX", idtmed[698], dbox4, 3);
   gMC->Gsatt("EUM2", "SEEN", 1);
-
+  
   // Place rectangular strips EST2 inside EUM2 unit module
-
+  
   yb = -dbox4[1]+dbox2[1]; 
-  for (j = 1; j <= nrow_um2; ++j) 
-      {
+  for (j = 1; j <= fgkNrowUM2; ++j) 
+    {
       if(j%2 == 0)
        {
-      xb =cell_radius/2.0;
+         xb = fgkCellRadius/2.0;
        }
       else
        {
-         xb = -cell_radius/2.0;
+         xb = -fgkCellRadius/2.0;
        }
       number = j;
-      gMC->Gsposp("EST2",number, "EUM2", xb, yb , 0. , 0, "MANY",dbox2,3);
-      yb = (-dbox4[1]+dbox2[1])+j*1.0*cell_radius*root3;
+      gMC->Gspos("EST2",number, "EUM2", xb, yb , 0. , 0, "MANY");
+      yb = (-dbox4[1]+dbox2[1])+j*1.0*fgkCellRadius*fgkSqroot3;
     }
 
   // 2 types of Rectangular shaped supermodules (BOX) 
@@ -271,243 +293,234 @@ void AliPMDv1::CreateSupermodule()
   // volume for SUPERMODULE ESMA 
   //Space added to provide a gapping for HV between UM's
 
-  Float_t dbox_sm1[3];
-  dbox_sm1[0] = 3.0*dbox3[0]+(2.0*0.025);
-  dbox_sm1[1] = 2.0*dbox3[1]+0.025;
-  dbox_sm1[2] = cell_depth/2.;
-
-  gMC->Gsvolu("ESMA","BOX", idtmed[698], dbox_sm1, 3);
+  Float_t dboxSM1[3];
+  dboxSM1[0] = 3.0*dbox3[0]+(2.0*0.025);
+  dboxSM1[1] = 2.0*dbox3[1]+0.025;
+  dboxSM1[2] = fgkCellDepth/2.;
+  
+  gMC->Gsvolu("ESMA","BOX", idtmed[698], dboxSM1, 3);
   gMC->Gsatt("ESMA", "SEEN", 1);
-
+  
   //Position the 6 unit modules in EMSA
-  Float_t x_a1,x_a2,x_a3,y_a1,y_a2; 
-  x_a1 = -dbox_sm1[0] + dbox3[0];
-  x_a2 = 0.;
-  x_a3 = dbox_sm1[0]  - dbox3[0]; 
-  y_a1 = dbox_sm1[1]  - dbox3[1];
-  y_a2 = -dbox_sm1[1] + dbox3[1];
+  Float_t xa1,xa2,xa3,ya1,ya2; 
+  xa1 = -dboxSM1[0] + dbox3[0];
+  xa2 = 0.;
+  xa3 = dboxSM1[0]  - dbox3[0]; 
+  ya1 = dboxSM1[1]  - dbox3[1];
+  ya2 = -dboxSM1[1] + dbox3[1];
   
-  gMC->Gsposp("EUM1", 1, "ESMA", x_a1, y_a1, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 2, "ESMA", x_a2, y_a1, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 3, "ESMA", x_a3, y_a1, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 4, "ESMA", x_a1, y_a2, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 5, "ESMA", x_a2, y_a2, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 6, "ESMA", x_a3, y_a2, 0., 0, "ONLY",dbox3,3);
+  gMC->Gspos("EUM1", 1, "ESMA", xa1, ya1, 0., 0, "ONLY");
+  gMC->Gspos("EUM1", 2, "ESMA", xa2, ya1, 0., 0, "ONLY");
+  gMC->Gspos("EUM1", 3, "ESMA", xa3, ya1, 0., 0, "ONLY");
+  gMC->Gspos("EUM1", 4, "ESMA", xa1, ya2, 0., 0, "ONLY");
+  gMC->Gspos("EUM1", 5, "ESMA", xa2, ya2, 0., 0, "ONLY");
+  gMC->Gspos("EUM1", 6, "ESMA", xa3, ya2, 0., 0, "ONLY");
 
 
   // volume for SUPERMODULE ESMB 
   //Space is added to provide a gapping for HV between UM's
-  Float_t dbox_sm2[3];
-  dbox_sm2[0] = 2.0*dbox4[0]+0.025;
-  dbox_sm2[1] = 3.0*dbox4[1]+(2.0*0.025);
-  dbox_sm2[2] = cell_depth/2.;
+  Float_t dboxSM2[3];
+  dboxSM2[0] = 2.0*dbox4[0]+0.025;
+  dboxSM2[1] = 3.0*dbox4[1]+(2.0*0.025);
+  dboxSM2[2] = fgkCellDepth/2.;
   
-  gMC->Gsvolu("ESMB","BOX", idtmed[698], dbox_sm2, 3);
+  gMC->Gsvolu("ESMB","BOX", idtmed[698], dboxSM2, 3);
   gMC->Gsatt("ESMB", "SEEN", 1);
-
   //Position the 6 unit modules in EMSB
-  Float_t x_b1,x_b2,y_b1,y_b2,y_b3; 
-  x_b1 = -dbox_sm2[0] +dbox4[0];
-  x_b2 = dbox_sm2[0]-dbox4[0];
-  y_b1  =dbox_sm2[1]-dbox4[1];
-  y_b2  = 0.; 
-  y_b3  = -dbox_sm2[1]+dbox4[1];
+  Float_t xb1,xb2,yb1,yb2,yb3; 
+  xb1 = -dboxSM2[0] +dbox4[0];
+  xb2 = dboxSM2[0]-dbox4[0];
+  yb1 = dboxSM2[1]-dbox4[1];
+  yb2 = 0.; 
+  yb3 = -dboxSM2[1]+dbox4[1];
+  
+  gMC->Gspos("EUM2", 1, "ESMB", xb1, yb1, 0., 0, "ONLY");
+  gMC->Gspos("EUM2", 2, "ESMB", xb2, yb1, 0., 0, "ONLY");
+  gMC->Gspos("EUM2", 3, "ESMB", xb1, yb2, 0., 0, "ONLY");
+  gMC->Gspos("EUM2", 4, "ESMB", xb2, yb2, 0., 0, "ONLY");
+  gMC->Gspos("EUM2", 5, "ESMB", xb1, yb3, 0., 0, "ONLY");
+  gMC->Gspos("EUM2", 6, "ESMB", xb2, yb3, 0., 0, "ONLY");
   
-  gMC->Gsposp("EUM2", 1, "ESMB", x_b1, y_b1, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 2, "ESMB", x_b2, y_b1, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 3, "ESMB", x_b1, y_b2, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 4, "ESMB", x_b2, y_b2, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 5, "ESMB", x_b1, y_b3, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 6, "ESMB", x_b2, y_b3, 0., 0, "ONLY",dbox4,3);
-
-
   // Make a 3mm thick G10 Base plate for ESMA
-  Float_t dbox_g1a[3];
-  dbox_g1a[0] = dbox_sm1[0]; 
-  dbox_g1a[1] = dbox_sm1[1];       
-  dbox_g1a[2] = th_base/2.;
+  Float_t dboxG1a[3];
+  dboxG1a[0] = dboxSM1[0]; 
+  dboxG1a[1] = dboxSM1[1];       
+  dboxG1a[2] = fgkThBase/2.;
 
-  gMC->Gsvolu("EBPA","BOX", idtmed[607], dbox_g1a, 3);
+  gMC->Gsvolu("EBPA","BOX", idtmed[607], dboxG1a, 3);
   gMC->Gsatt("EBPA", "SEEN", 1);
 
   // Make a 1.6mm thick G10 PCB for ESMA
-  Float_t dbox_g2a[3];
-  dbox_g2a[0] = dbox_sm1[0]; 
-  dbox_g2a[1] = dbox_sm1[1];       
-  dbox_g2a[2] = th_pcb/2.;
+  Float_t dboxG2a[3];
+  dboxG2a[0] = dboxSM1[0]; 
+  dboxG2a[1] = dboxSM1[1];       
+  dboxG2a[2] = fgkThPCB/2.;
 
-  gMC->Gsvolu("EPCA","BOX", idtmed[607], dbox_g2a, 3);
+  gMC->Gsvolu("EPCA","BOX", idtmed[607], dboxG2a, 3);
   gMC->Gsatt("EPCA", "SEEN", 1);
 
 
   // Make a Full module EFPA of AIR to place EBPA, 
   // 1mm AIR, EPCA, ESMA,EPCA for PMD
   
-  Float_t dbox_alla[3];
-  dbox_alla[0] = dbox_sm1[0]; 
-  dbox_alla[1] = dbox_sm1[1];       
-  dbox_alla[2] = (th_base+0.1+th_pcb+dbox_sm1[2]+th_pcb)/2.;
+  Float_t dboxAlla[3];
+  dboxAlla[0] = dboxSM1[0]; 
+  dboxAlla[1] = dboxSM1[1];       
+  dboxAlla[2] = (fgkThBase+fgkThAir+fgkThPCB+dboxSM1[2]+fgkThPCB)/2.;
 
-  gMC->Gsvolu("EFPA","BOX", idtmed[698], dbox_alla, 3);
+  gMC->Gsvolu("EFPA","BOX", idtmed[698], dboxAlla, 3);
   gMC->Gsatt("EFPA", "SEEN", 1);
 
 
   // Make a Full module EFCA of AIR to place EBPA, 
   // 1mm AIR, EPCA, ESMA,EPC for CPV
-  Float_t dbox_alla2[3];
-  dbox_alla2[0] = dbox_sm1[0]; 
-  dbox_alla2[1] = dbox_sm1[1];       
-  dbox_alla2[2] = (th_base+0.1+th_pcb+dbox_sm1[2]+th_pcb)/2.;
+  Float_t dboxAlla2[3];
+  dboxAlla2[0] = dboxSM1[0]; 
+  dboxAlla2[1] = dboxSM1[1];       
+  dboxAlla2[2] = (fgkThBase+fgkThAir+fgkThPCB+dboxSM1[2]+fgkThPCB)/2.;
 
-  gMC->Gsvolu("EFCA","BOX", idtmed[698], dbox_alla2, 3);
+  gMC->Gsvolu("EFCA","BOX", idtmed[698], dboxAlla2, 3);
   gMC->Gsatt("EFCA", "SEEN", 1);
 
   // Now place everything in EFPA for PMD
 
-  Float_t z_bpa,z_pcba1,z_pcba2,z_sma; 
-  z_pcba1 = - dbox_alla[2]+th_pcb/2.0;
-  gMC->Gsposp("EPCA", 1, "EFPA", 0., 0., z_pcba1, 0, "ONLY",dbox_g2a,3);
-  z_sma = z_pcba1+dbox_sm1[2];
-  gMC->Gsposp("ESMA", 1, "EFPA", 0., 0., z_sma, 0, "ONLY",dbox_sm1,3);
-  z_pcba2 = z_sma+th_pcb/2.0;
-  gMC->Gsposp("EPCA", 2, "EFPA", 0., 0., z_pcba2, 0, "ONLY",dbox_g2a,3);
-  z_bpa = z_pcba2+0.1+th_base/2.0; // 0.1 for 0.1 mm Air gap 
-  gMC->Gsposp("EBPA", 1, "EFPA", 0., 0., z_bpa, 0, "ONLY",dbox_g1a,3);
+  Float_t zbpa,zpcba1,zpcba2,zsma; 
+  zpcba1 = - dboxAlla[2]+fgkThPCB/2.0;
+  gMC->Gspos("EPCA", 1, "EFPA", 0., 0., zpcba1, 0, "ONLY");
+  zsma = zpcba1+dboxSM1[2];
+  gMC->Gspos("ESMA", 1, "EFPA", 0., 0., zsma, 0, "ONLY");
+  zpcba2 = zsma+fgkThPCB/2.0;
+  gMC->Gspos("EPCA", 2, "EFPA", 0., 0., zpcba2, 0, "ONLY");
+  zbpa = zpcba2+fgkThAir+fgkThBase/2.0;
+  gMC->Gspos("EBPA", 1, "EFPA", 0., 0., zbpa, 0, "ONLY");
 
   // Now place everything in EFCA for CPV
 
-  Float_t z_bpa2,z_pcba12,z_pcba22,z_sma2; 
-  z_bpa2 = - dbox_alla2[2]+th_base/2.0;
-  gMC->Gsposp("EBPA", 1, "EFCA", 0., 0., z_bpa2, 0, "ONLY",dbox_g1a,3);
-  z_pcba12 = z_bpa2+0.1+th_pcb/2.0;
-  gMC->Gsposp("EPCA", 1, "EFCA", 0., 0., z_pcba12, 0, "ONLY",dbox_g2a,3);
-  z_sma2 = z_pcba12+dbox_sm1[2];
-  gMC->Gsposp("ESMA", 1, "EFCA", 0., 0., z_sma2, 0, "ONLY",dbox_sm1,3);
-  z_pcba22 = z_sma2+th_pcb/2.0;
-  gMC->Gsposp("EPCA", 2, "EFCA", 0., 0., z_pcba22, 0, "ONLY",dbox_g2a,3);
+  Float_t zbpa2,zpcba12,zpcba22,zsma2; 
+  zbpa2 = - dboxAlla2[2]+fgkThBase/2.0;
+  gMC->Gspos("EBPA", 1, "EFCA", 0., 0., zbpa2, 0, "ONLY");
+  zpcba12 = zbpa2+fgkThAir+fgkThPCB/2.0;
+  gMC->Gspos("EPCA", 1, "EFCA", 0., 0., zpcba12, 0, "ONLY");
+  zsma2 = zpcba12+dboxSM1[2];
+  gMC->Gspos("ESMA", 1, "EFCA", 0., 0., zsma2, 0, "ONLY");
+  zpcba22 = zsma2+fgkThPCB/2.0;
+  gMC->Gspos("EPCA", 2, "EFCA", 0., 0., zpcba22, 0, "ONLY");
 
 
 
   // Make a 3mm thick G10 Base plate for ESMB
-  Float_t dbox_g1b[3];
-  dbox_g1b[0] = dbox_sm2[0]; 
-  dbox_g1b[1] = dbox_sm2[1];       
-  dbox_g1b[2] = th_base/2.;
+  Float_t dboxG1b[3];
+  dboxG1b[0] = dboxSM2[0]; 
+  dboxG1b[1] = dboxSM2[1];       
+  dboxG1b[2] = fgkThBase/2.;
 
-  gMC->Gsvolu("EBPB","BOX", idtmed[607], dbox_g1b, 3);
+  gMC->Gsvolu("EBPB","BOX", idtmed[607], dboxG1b, 3);
   gMC->Gsatt("EBPB", "SEEN", 1);
 
   // Make a 1.6mm thick G10 PCB for ESMB
-  Float_t dbox_g2b[3];
-  dbox_g2b[0] = dbox_sm2[0]; 
-  dbox_g2b[1] = dbox_sm2[1];       
-  dbox_g2b[2] = th_pcb/2.;
+  Float_t dboxG2b[3];
+  dboxG2b[0] = dboxSM2[0]; 
+  dboxG2b[1] = dboxSM2[1];       
+  dboxG2b[2] = fgkThPCB/2.;
 
-  gMC->Gsvolu("EPCB","BOX", idtmed[607], dbox_g2b, 3);
+  gMC->Gsvolu("EPCB","BOX", idtmed[607], dboxG2b, 3);
   gMC->Gsatt("EPCB", "SEEN", 1);
 
-
   // Make a Full module EFPB of AIR to place EBPB, 
   //1mm AIR, EPCB, ESMB,EPCB for PMD
-  Float_t dbox_allb[3];
-  dbox_allb[0] = dbox_sm2[0]; 
-  dbox_allb[1] = dbox_sm2[1];       
-  dbox_allb[2] = (th_base+0.1+th_pcb+dbox_sm2[2]+th_pcb)/2.;
+  Float_t dboxAllb[3];
+  dboxAllb[0] = dboxSM2[0]; 
+  dboxAllb[1] = dboxSM2[1];       
+  dboxAllb[2] = (fgkThBase+fgkThAir+fgkThPCB+dboxSM2[2]+fgkThPCB)/2.;
 
-  gMC->Gsvolu("EFPB","BOX", idtmed[698], dbox_allb, 3);
+  gMC->Gsvolu("EFPB","BOX", idtmed[698], dboxAllb, 3);
   gMC->Gsatt("EFPB", "SEEN", 1);
 
   // Make a Full module EFCB of AIR to place EBPB, 
   //1mm AIR, EPCB, ESMB,EPCB for CPV
-  Float_t dbox_allb2[3];
-  dbox_allb2[0] = dbox_sm2[0]; 
-  dbox_allb2[1] = dbox_sm2[1];       
-  dbox_allb2[2] = (th_base+0.1+th_pcb+dbox_sm2[2]+th_pcb)/2.;
+  Float_t dboxAllb2[3];
+  dboxAllb2[0] = dboxSM2[0]; 
+  dboxAllb2[1] = dboxSM2[1];       
+  dboxAllb2[2] = (fgkThBase+fgkThAir+fgkThPCB+dboxSM2[2]+fgkThPCB)/2.;
 
-  gMC->Gsvolu("EFCB","BOX", idtmed[698], dbox_allb2, 3);
+  gMC->Gsvolu("EFCB","BOX", idtmed[698], dboxAllb2, 3);
   gMC->Gsatt("EFCB", "SEEN", 1);
 
 
   // Now place everything in EFPB for PMD
 
-  Float_t z_bpb,z_pcbb1,z_pcbb2,z_smb; 
-  z_pcbb1 = - dbox_allb[2]+th_pcb/2.0;
-  gMC->Gsposp("EPCB", 1, "EFPB", 0., 0., z_pcbb1, 0, "ONLY",dbox_g2b,3);
-  z_smb = z_pcbb1+dbox_sm2[2];
-  gMC->Gsposp("ESMB", 1, "EFPB", 0., 0., z_smb, 0, "ONLY",dbox_sm2,3);
-  z_pcbb2 = z_smb+th_pcb/2.0;
-  gMC->Gsposp("EPCB", 2, "EFPB", 0., 0., z_pcbb2, 0, "ONLY",dbox_g2b,3);
-  z_bpb = z_pcbb2+0.1+th_base/2.0; // 0.1 for 0.1 mm Air gap 
-  gMC->Gsposp("EBPB", 1, "EFPB", 0., 0., z_bpb, 0, "ONLY",dbox_g1b,3);
+  Float_t zbpb,zpcbb1,zpcbb2,zsmb; 
+  zpcbb1 = - dboxAllb[2]+fgkThPCB/2.0;
+  gMC->Gspos("EPCB", 1, "EFPB", 0., 0., zpcbb1, 0, "ONLY");
+  zsmb = zpcbb1+dboxSM2[2];
+  gMC->Gspos("ESMB", 1, "EFPB", 0., 0., zsmb, 0, "ONLY");
+  zpcbb2 = zsmb+fgkThPCB/2.0;
+  gMC->Gspos("EPCB", 2, "EFPB", 0., 0., zpcbb2, 0, "ONLY");
+  zbpb = zpcbb2+fgkThAir+fgkThBase/2.0;
+  gMC->Gspos("EBPB", 1, "EFPB", 0., 0., zbpb, 0, "ONLY");
 
 
   // Now place everything in EFCB for CPV
 
-  Float_t z_bpb2,z_pcbb12,z_pcbb22,z_smb2; 
-  z_bpb2 = - dbox_allb2[2]+th_base/2.0;
-  gMC->Gsposp("EBPB", 1, "EFCB", 0., 0., z_bpb2, 0, "ONLY",dbox_g1b,3);
-  z_pcbb12 = z_bpb2+0.1+th_pcb/2.0;
-  gMC->Gsposp("EPCB", 1, "EFCB", 0., 0., z_pcbb12, 0, "ONLY",dbox_g2b,3);
-  z_smb2 = z_pcbb12+dbox_sm2[2];
-  gMC->Gsposp("ESMB", 1, "EFCB", 0., 0., z_smb2, 0, "ONLY",dbox_sm2,3);
-  z_pcbb22 = z_smb2+th_pcb/2.0;
-  gMC->Gsposp("EPCB", 2, "EFCB", 0., 0., z_pcbb22, 0, "ONLY",dbox_g2b,3);
+  Float_t zbpb2,zpcbb12,zpcbb22,zsmb2; 
+  zbpb2 = - dboxAllb2[2]+fgkThBase/2.0;
+  gMC->Gspos("EBPB", 1, "EFCB", 0., 0., zbpb2, 0, "ONLY");
+  zpcbb12 = zbpb2+0.1+fgkThPCB/2.0;
+  gMC->Gspos("EPCB", 1, "EFCB", 0., 0., zpcbb12, 0, "ONLY");
+  zsmb2 = zpcbb12+dboxSM2[2];
+  gMC->Gspos("ESMB", 1, "EFCB", 0., 0., zsmb2, 0, "ONLY");
+  zpcbb22 = zsmb2+fgkThPCB/2.0;
+  gMC->Gspos("EPCB", 2, "EFCB", 0., 0., zpcbb22, 0, "ONLY");
 
 
   // Master MODULE EMPA of aluminum for PMD
-  //Float_t dbox_mm1[3];
-  dbox_mm1[0] = dbox_sm1[0]+boundary; 
-  dbox_mm1[1] = dbox_sm1[1]+boundary;       
-  dbox_mm1[2] = dbox_alla[2];
+  fDboxmm1[0] = dboxSM1[0]+fgkBoundary; 
+  fDboxmm1[1] = dboxSM1[1]+fgkBoundary;       
+  fDboxmm1[2] = dboxAlla[2];
 
-  gMC->Gsvolu("EMPA","BOX", idtmed[603], dbox_mm1, 3);
+  gMC->Gsvolu("EMPA","BOX", idtmed[603], fDboxmm1, 3);
   gMC->Gsatt("EMPA", "SEEN", 1);
 
   // Master MODULE EMCA of aluminum for CPV
-  //Float_t dbox_mm12[3];
-  dbox_mm12[0] = dbox_sm1[0]+boundary; 
-  dbox_mm12[1] = dbox_sm1[1]+boundary;       
-  dbox_mm12[2] = dbox_alla[2];
+  fDboxmm12[0] = dboxSM1[0]+fgkBoundary; 
+  fDboxmm12[1] = dboxSM1[1]+fgkBoundary;       
+  fDboxmm12[2] = dboxAlla[2];
 
-  gMC->Gsvolu("EMCA","BOX", idtmed[603], dbox_mm12, 3);
+  gMC->Gsvolu("EMCA","BOX", idtmed[603], fDboxmm12, 3);
   gMC->Gsatt("EMCA", "SEEN", 1);
 
 
   //Position EFMA inside EMMA for PMD and CPV
-  gMC->Gsposp("EFPA", 1, "EMPA", 0., 0., 0., 0, "ONLY",dbox_alla,3);
-  gMC->Gsposp("EFCA", 1, "EMCA", 0., 0., 0., 0, "ONLY",dbox_alla2,3);
+  gMC->Gspos("EFPA", 1, "EMPA", 0., 0., 0., 0, "ONLY");
+  gMC->Gspos("EFCA", 1, "EMCA", 0., 0., 0., 0, "ONLY");
 
 
   // Master MODULE EMPB of aluminum for PMD
-  //Float_t dbox_mm2[3];
-  dbox_mm2[0] = dbox_sm2[0]+boundary; 
-  dbox_mm2[1] = dbox_sm2[1]+boundary;       
-  dbox_mm2[2] = dbox_allb[2];
+  fDboxmm2[0] = dboxSM2[0]+fgkBoundary; 
+  fDboxmm2[1] = dboxSM2[1]+fgkBoundary;       
+  fDboxmm2[2] = dboxAllb[2];
 
-  gMC->Gsvolu("EMPB","BOX", idtmed[603], dbox_mm2, 3);
+  gMC->Gsvolu("EMPB","BOX", idtmed[603], fDboxmm2, 3);
   gMC->Gsatt("EMPB", "SEEN", 1);
 
   // Master MODULE EMCB of aluminum for CPV
-  //Float_t dbox_mm22[3];
-  dbox_mm22[0] = dbox_sm2[0]+boundary; 
-  dbox_mm22[1] = dbox_sm2[1]+boundary;       
-  dbox_mm22[2] = dbox_allb[2];
+  fDboxmm22[0] = dboxSM2[0]+fgkBoundary; 
+  fDboxmm22[1] = dboxSM2[1]+fgkBoundary;       
+  fDboxmm22[2] = dboxAllb[2];
 
-  gMC->Gsvolu("EMCB","BOX", idtmed[603], dbox_mm22, 3);
+  gMC->Gsvolu("EMCB","BOX", idtmed[603], fDboxmm22, 3);
   gMC->Gsatt("EMCB", "SEEN", 1);
 
   //Position EFMB inside EMMB
-  gMC->Gsposp("EFPB", 1, "EMPB", 0., 0., 0., 0, "ONLY",dbox_allb,3);
-  gMC->Gsposp("EFCB", 1, "EMCB", 0., 0., 0., 0, "ONLY",dbox_allb2,3);
-
+  gMC->Gspos("EFPB", 1, "EMPB", 0., 0., 0., 0, "ONLY");
+  gMC->Gspos("EFCB", 1, "EMCB", 0., 0., 0., 0, "ONLY");
 }
  
 //_____________________________________________________________________________
 
 void AliPMDv1::CreatePMD()
 {
-
   //
   // Create final detector from supermodules
   // -- Author : Bedanga and Viyogi June 2003
@@ -520,118 +533,140 @@ void AliPMDv1::CreatePMD()
 
   // --- DEFINE Iron, and lead volumes  for SM A
   
-  Float_t dbox_pba[3];
-  dbox_pba[0] = sm_length_ax;
-  dbox_pba[1] = sm_length_ay;
-  dbox_pba[2] = th_lead/2.;
+  Float_t dboxPba[3];
+  dboxPba[0] = fSMLengthax;
+  dboxPba[1] = fSMLengthay;
+  dboxPba[2] = fgkThLead/2.;
   
-  gMC->Gsvolu("EPBA","BOX", idtmed[600], dbox_pba, 3);
+  gMC->Gsvolu("EPBA","BOX", idtmed[600], dboxPba, 3);
   gMC->Gsatt ("EPBA", "SEEN", 0);
   
   //   Fe Support 
-  Float_t dbox_fea[3];
-  dbox_fea[0] = sm_length_ax;
-  dbox_fea[1] = sm_length_ay;
-  dbox_fea[2] = th_steel/2.;
+  Float_t dboxFea[3];
+  dboxFea[0] = fSMLengthax;
+  dboxFea[1] = fSMLengthay;
+  dboxFea[2] = fgkThSteel/2.;
   
-  gMC->Gsvolu("EFEA","BOX", idtmed[618], dbox_fea, 3);
+  gMC->Gsvolu("EFEA","BOX", idtmed[618], dboxFea, 3);
   gMC->Gsatt ("EFEA", "SEEN", 0);
 
   // --- DEFINE Iron, and lead volumes  for SM B
 
-  Float_t dbox_pbb[3];
-  dbox_pbb[0] = sm_length_bx;
-  dbox_pbb[1] = sm_length_by;
-  dbox_pbb[2] = th_lead/2.;
+  Float_t dboxPbb[3];
+  dboxPbb[0] = fSMLengthbx;
+  dboxPbb[1] = fSMLengthby;
+  dboxPbb[2] = fgkThLead/2.;
   
-  gMC->Gsvolu("EPBB","BOX", idtmed[600], dbox_pbb, 3);
+  gMC->Gsvolu("EPBB","BOX", idtmed[600], dboxPbb, 3);
   gMC->Gsatt ("EPBB", "SEEN", 0);
   
   //   Fe Support 
-  Float_t dbox_feb[3];
-  dbox_feb[0] = sm_length_bx;
-  dbox_feb[1] = sm_length_by;
-  dbox_feb[2] = th_steel/2.;
+  Float_t dboxFeb[3];
+  dboxFeb[0] = fSMLengthbx;
+  dboxFeb[1] = fSMLengthby;
+  dboxFeb[2] = fgkThSteel/2.;
   
-  gMC->Gsvolu("EFEB","BOX", idtmed[618], dbox_feb, 3);
+  gMC->Gsvolu("EFEB","BOX", idtmed[618], dboxFeb, 3);
   gMC->Gsatt ("EFEB", "SEEN", 0);
 
-
-  // Gaspmd, the dimension of RECTANGULAR mother volume of PMD,
-
-  Float_t gaspmd[3] = {81.5,94.5,7.};
-  gaspmd[0] = sm_length_ax+sm_length_bx;
-  gaspmd[1] = sm_length_ay+sm_length_by;
-
-
-  gMC->Gsvolu("EPMD", "BOX", idtmed[698], gaspmd, 3);
-  gMC->Gsatt("EPMD", "SEEN", 1);
-
   AliMatrix(irotdm, 90., 0.,  90.,  90., 180., 0.);
-   
   AliMatrix(jhrot12, 90., 180., 90., 270., 0., 0.);
   AliMatrix(jhrot13, 90., 240., 90., 330., 0., 0.);
 
-  Float_t x_sma,y_sma;
-  Float_t x_smb,y_smb;
-  x_sma = -(sm_length_bx)/1.0;
-  y_sma = sm_length_by;
-  x_smb = -sm_length_ax;
-  y_smb = -sm_length_ay;
+  // Gaspmd, the dimension of RECTANGULAR mother volume of PMD,
+  // Four mother volumes EPM1,EPM2 for A-type and 
+  // volumes EPM3 and EPM4 for B-type. Four to create a hole
+  // and avoid overlap with beam pipe
+
+  Float_t gaspmd[3];
+  gaspmd[0] = fDboxmm1[0];
+  gaspmd[1] = fDboxmm1[1];
+  gaspmd[2] = 7.0; // for the entire detector, including connectors etc
+
+  gMC->Gsvolu("EPM1", "BOX", idtmed[698], gaspmd, 3);
+  gMC->Gsatt("EPM1", "SEEN", 1);
+  gMC->Gsvolu("EPM2", "BOX", idtmed[698], gaspmd, 3);
+  gMC->Gsatt("EPM2", "SEEN", 1);
 
   //Complete detector for Type A
   //Position Super modules type A for both CPV and PMD in EPMD  
-  Float_t z_psa,z_pba,z_fea,z_cva; 
-
-  z_psa = - gaspmd[2] + sm_thick/2.;
-
-  gMC->Gsposp("EMPA", 1, "EPMD", x_sma, y_sma, z_psa, 0, "ONLY",dbox_mm1,3);
-  gMC->Gsposp("EMPA", 2, "EPMD", -x_sma, -y_sma, z_psa, jhrot12, "ONLY",dbox_mm1,3);
-  z_pba=z_psa+sm_thick/2.+dbox_pba[2];
-  gMC->Gsposp("EPBA", 1, "EPMD", x_sma, y_sma, z_pba, 0, "ONLY",dbox_pba,3);
-  gMC->Gsposp("EPBA", 2, "EPMD", -x_sma, -y_sma, z_pba, 0, "ONLY",dbox_pba,3);
-  z_fea=z_pba+dbox_pba[2]+dbox_fea[2];
-  gMC->Gsposp("EFEA", 1, "EPMD", x_sma, y_sma, z_fea, 0, "ONLY",dbox_fea,3);
-  gMC->Gsposp("EFEA", 2, "EPMD", -x_sma, -y_sma, z_fea, 0, "ONLY",dbox_fea,3);
-  z_cva=z_fea+dbox_fea[2]+sm_thick/2.;
-  gMC->Gsposp("EMCA", 1, "EPMD", x_sma, y_sma, z_cva, 0, "ONLY",dbox_mm12,3);
-  gMC->Gsposp("EMCA", 2, "EPMD", -x_sma,-y_sma, z_cva, jhrot12, "ONLY",dbox_mm12,3);
+  Float_t zpsa,zpba,zfea,zcva; 
+
+  // zpsa = - gaspmd[2] + fSMthick/2.;
+  // -2.5 is given to place PMD at -361.5 
+  // BM : In future after putting proper electronics
+  // -2.5 will be replaced by -gaspmd[2]
+  zpsa = -2.5 + fSMthick/2.;
+
+  gMC->Gspos("EMPA", 1, "EPM1", 0., 0., zpsa, 0, "ONLY");
+  gMC->Gspos("EMPA", 2, "EPM2", 0., 0., zpsa, jhrot12, "ONLY");
+  zpba=zpsa+fSMthick/2.+dboxPba[2];
+  gMC->Gspos("EPBA", 1, "EPM1", 0., 0., zpba, 0, "ONLY");
+  gMC->Gspos("EPBA", 2, "EPM2", 0., 0., zpba, 0, "ONLY");
+  zfea=zpba+dboxPba[2]+dboxFea[2];
+  gMC->Gspos("EFEA", 1, "EPM1", 0., 0., zfea, 0, "ONLY");
+  gMC->Gspos("EFEA", 2, "EPM2", 0., 0., zfea, 0, "ONLY");
+  zcva=zfea+dboxFea[2]+fSMthick/2.;
+  gMC->Gspos("EMCA", 1, "EPM1", 0., 0., zcva, 0, "ONLY");
+  gMC->Gspos("EMCA", 2, "EPM2", 0., 0., zcva, jhrot12, "ONLY");
  
+  gaspmd[0] = fDboxmm2[0];
+  gaspmd[1] = fDboxmm2[1];
+  gaspmd[2] = 7.0; // for the entire detector, including connectors etc
+
+  gMC->Gsvolu("EPM3", "BOX", idtmed[698], gaspmd, 3);
+  gMC->Gsatt("EPM3", "SEEN", 1);
+  gMC->Gsvolu("EPM4", "BOX", idtmed[698], gaspmd, 3);
+  gMC->Gsatt("EPM4", "SEEN", 1);
+
   //Complete detector for Type B
   //Position Super modules type B for both CPV and PMD in EPMD  
-  Float_t z_psb,z_pbb,z_feb,z_cvb; 
-  z_psb = - gaspmd[2] + sm_thick/2.;
-  
-  gMC->Gsposp("EMPB", 3, "EPMD", x_smb, y_smb, z_psb, 0, "ONLY",dbox_mm2,3);
-  gMC->Gsposp("EMPB", 4, "EPMD", -x_smb, -y_smb, z_psb, jhrot12, "ONLY",dbox_mm2,3);
-  z_pbb=z_psb+sm_thick/2.+dbox_pbb[2];
-  gMC->Gsposp("EPBB", 3, "EPMD", x_smb, y_smb, z_pbb, 0, "ONLY",dbox_pbb,3);
-  gMC->Gsposp("EPBB", 4, "EPMD", -x_smb, -y_smb, z_pbb, 0, "ONLY",dbox_pbb,3);
-  z_feb=z_pbb+dbox_pbb[2]+dbox_feb[2];
-  gMC->Gsposp("EFEB", 3, "EPMD", x_smb, y_smb, z_feb, 0, "ONLY",dbox_feb,3);
-  gMC->Gsposp("EFEB", 4, "EPMD", -x_smb, -y_smb, z_feb, 0, "ONLY",dbox_feb,3);
-  z_cvb=z_feb+dbox_feb[2]+sm_thick/2.;
-  gMC->Gsposp("EMCB", 3, "EPMD", x_smb, y_smb, z_cvb, 0, "ONLY",dbox_mm22,3);
-  gMC->Gsposp("EMCB", 4, "EPMD", -x_smb,-y_smb, z_cvb, jhrot12, "ONLY",dbox_mm22,3);
+  Float_t zpsb,zpbb,zfeb,zcvb; 
+  // zpsb = - gaspmd[2] + fSMthick/2.;
+  // -2.5 is given to place PMD at -361.5 
+  // BM: In future after putting proper electronics
+  // -2.5 will be replaced by -gaspmd[2]
+
+  zpsb = -2.5 + fSMthick/2.; 
+  gMC->Gspos("EMPB", 3, "EPM3", 0., 0., zpsb, 0, "ONLY");
+  gMC->Gspos("EMPB", 4, "EPM4", 0., 0., zpsb, jhrot12, "ONLY");
+  zpbb=zpsb+fSMthick/2.+dboxPbb[2];
+  gMC->Gspos("EPBB", 3, "EPM3", 0., 0., zpbb, 0, "ONLY");
+  gMC->Gspos("EPBB", 4, "EPM4", 0., 0., zpbb, 0, "ONLY");
+  zfeb=zpbb+dboxPbb[2]+dboxFeb[2];
+  gMC->Gspos("EFEB", 3, "EPM3", 0., 0., zfeb, 0, "ONLY");
+  gMC->Gspos("EFEB", 4, "EPM4", 0., 0., zfeb, 0, "ONLY");
+  zcvb=zfeb+dboxFeb[2]+fSMthick/2.;
+  gMC->Gspos("EMCB", 3, "EPM3", 0., 0., zcvb, 0, "ONLY");
+  gMC->Gspos("EMCB", 4, "EPM4", 0., 0., zcvb, jhrot12, "ONLY");
   
   // --- Place the EPMD in ALICE 
   xp = 0.;
   yp = 0.;
-  zp = zdist1;
+  zp = fgkZdist;
+
+  Float_t xsma,ysma;
+  Float_t xsmb,ysmb;
+  xsma = -fSMLengthbx;
+  ysma =  fSMLengthby;
+  xsmb = -fSMLengthax;
+  ysmb = -fSMLengthay;
 
   //Position Full PMD in ALICE   
-  gMC->Gsposp("EPMD", 1, "ALIC", xp,yp,zp, 0, "ONLY",gaspmd,3);
+  gMC->Gspos("EPM1", 1, "ALIC", xsma,ysma,zp, 0, "ONLY");
+  gMC->Gspos("EPM2", 1, "ALIC", -xsma,-ysma,zp, 0, "ONLY");
+  gMC->Gspos("EPM3", 1, "ALIC", xsmb,ysmb,zp, 0, "ONLY");
+  gMC->Gspos("EPM4", 1, "ALIC", -xsmb,-ysmb,zp, 0, "ONLY");
 
 }
 
  
 //_____________________________________________________________________________
-void AliPMDv1::DrawModule()
+void AliPMDv1::DrawModule() const
 {
-  cout << " Inside Draw Modules " << endl;
-  //
   // Draw a shaded view of the Photon Multiplicity Detector
   //
+  //  cout << " Inside Draw Modules " << endl;
 
   gMC->Gsatt("*", "seen", -1);
   gMC->Gsatt("alic", "seen", 0);
@@ -665,24 +700,22 @@ void AliPMDv1::DrawModule()
 //_____________________________________________________________________________
 void AliPMDv1::CreateMaterials()
 {
-  cout << " Inside create materials " << endl;
-  //
   // Create materials for the PMD
   //
   // ORIGIN    : Y. P. VIYOGI 
   //
-  
+  //  cout << " Inside create materials " << endl;
   // --- The Argon- CO2 mixture --- 
-  Float_t ag[2] = { 39.95 };
-  Float_t zg[2] = { 18. };
-  Float_t wg[2] = { .7,.3 };
-  Float_t dar   = .001782;   // --- Ar density in g/cm3 --- 
+  Float_t ag[2] = { 39.95, 44.01 };
+  Float_t zg[2] = { 18., 22. };
+  Float_t wg[2] = { 0.7,0.3 };
+  Float_t dar   = 0.001782;   // --- Ar density in g/cm3 --- 
   // --- CO2 --- 
   Float_t ac[2] = { 12.,16. };
   Float_t zc[2] = { 6.,8. };
   Float_t wc[2] = { 1.,2. };
-  Float_t dc    = .001977;
-  Float_t dco   = .002;  // --- CO2 density in g/cm3 ---
+  Float_t dc    = 0.001977;
+  Float_t dco   = 0.002;  // --- CO2 density in g/cm3 ---
   
   Float_t absl, radl, a, d, z;
   Float_t dg;
@@ -692,6 +725,11 @@ void AliPMDv1::CreateMaterials()
   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
   Float_t zsteel[4] = { 26.,24.,28.,14. };
   Float_t wsteel[4] = { .715,.18,.1,.005 };
+  // Mylar
+  Float_t aMylar[3]={1.00794,12.0107,15.9994};
+  Float_t zMylar[3]={1.,6.,8.};
+  Float_t wMylar[3]={0.041959,0.625017,0.333025};
+  Float_t dMylar   = 1.4;
   
   Int_t *idtmed = fIdtmed->GetArray()-599;
   Int_t isxfld = gAlice->Field()->Integ();
@@ -713,15 +751,15 @@ void AliPMDv1::CreateMaterials()
   AliMaterial(17, "POLYCARBONATE    $", 20., 10., 1.2, 34.6, 999.);
   AliMixture(19, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel); 
   // AliMaterial(31, "Xenon$", 131.3, 54., dxe, x0xe, 6.5e4);
-  
-  AliMaterial(96, "MYLAR$", 8.73, 4.55, 1.39, 28.7, 62.);
+  // AliMaterial(96, "MYLAR$", 8.73, 4.55, 1.39, 28.7, 62.);
+  AliMixture(96, "MYLAR$", aMylar, zMylar, dMylar, 3, wMylar);
   AliMaterial(97, "CONCR$", 20., 10., 2.5, 10.7, 40.);
   AliMaterial(98, "Vacum$", 1e-9, 1e-9, 1e-9, 1e16, 1e16);
   AliMaterial(99, "Air  $", 14.61, 7.3, .0012, 30420., 67500.);
  
   //   define gas-mixtures 
   
-  char namate[21];
+  char namate[21]="";
   gMC->Gfmate((*fIdmate)[3], namate, a, z, d, radl, absl, buf, nbuf);
   ag[1] = a;
   zg[1] = z;
@@ -806,7 +844,7 @@ void AliPMDv1::Init()
   //
 
   Int_t i;
-  kdet=1;
+  //  gAliKdet=1;
   //
   cout << " Inside Init " << endl;
   if(fDebug) {
@@ -818,7 +856,7 @@ void AliPMDv1::Init()
       printf("                 PMD simulation package (v1) initialised\n");
       printf("%s: parameters of pmd\n",ClassName());
       printf("%s: %10.2f %10.2f %10.2f \
-      %10.2f\n",ClassName(),cell_radius,cell_wall,cell_depth,zdist1 );
+      %10.2f\n",ClassName(),fgkCellRadius,fgkCellWall,fgkCellDepth,fgkZdist );
       printf("%s: ",ClassName());
       for(i=0;i<80;i++) printf("*");
       printf("\n");
@@ -839,7 +877,7 @@ void AliPMDv1::StepManager()
   Int_t   copy;
   Float_t hits[4], destep;
   Float_t center[3] = {0,0,0};
-  Int_t   vol[8]; //5
+  Int_t   vol[8];
   //const char *namep;
   
   if(gMC->GetMedium() == fMedSens && (destep = gMC->Edep())) {
@@ -902,35 +940,24 @@ void AliPMDv1::StepManager()
 
 void AliPMDv1::GetParameters()
 {
-  const Float_t root3 = TMath::Sqrt(3.); 
-  const Float_t root3_2 = TMath::Sqrt(3.) /2.; 
-  //
-  cell_radius=0.25;
-  cell_wall=0.02;
-  cell_depth=0.25 * 2.;
-  //
-  ncol_um1 = 48;
-  ncol_um2 = 96;
-  nrow_um1 = 96;//each strip has 1 row
-  nrow_um2 = 48;//each strip has 1 row
+  // This gives all the parameters of the detector
+  // such as Length of Supermodules, type A, type B,
+  // thickness of the Supermodule
   //
-  sm_length_ax = (3.0*(ncol_um1*cell_radius+cell_radius/2.)+(2.0*0.025)) + 0.7;
-  sm_length_bx = 2.0*(ncol_um2*cell_radius+cell_radius/2.)+0.025+0.7; 
-
-  sm_length_ay = 2.0*(((cell_radius/root3_2)*nrow_um1)-(cell_radius*root3*(nrow_um1-1)/6.))+0.025+0.7;
-  sm_length_by = 3.0*(((cell_radius/root3_2)*nrow_um2)-(cell_radius*root3*(nrow_um2-1)/6.))+(2.0*0.025)+0.7;
-    //
-    boundary=0.7;
-    //
-    th_base=0.3;
-    th_air=0.1;
-    th_pcb=0.16;
-    //
-    sm_thick = th_base + th_air + th_pcb + cell_depth + th_pcb + th_air + th_pcb;
-    //
-    th_lead=1.5;
-    th_steel=0.5;
-    
-    zdist1 = 361.5;
-
+  
+  fSMLengthax = (3.0*(fgkNcolUM1*fgkCellRadius+fgkCellRadius/2.)
+                + (2.0*fgkGap)) + fgkBoundary;
+  fSMLengthbx = 2.0*(fgkNcolUM2*fgkCellRadius+fgkCellRadius/2.)
+    + fgkGap + fgkBoundary; 
+  
+  fSMLengthay = 2.0*(((fgkCellRadius/fgkSqroot3by2)*fgkNrowUM1)
+                    - (fgkCellRadius*fgkSqroot3*(fgkNrowUM1-1)/6.))
+    + fgkGap + fgkBoundary;
+  fSMLengthby = 3.0*(((fgkCellRadius/fgkSqroot3by2)*fgkNrowUM2)
+                    - (fgkCellRadius*fgkSqroot3*(fgkNrowUM2-1)/6.))
+    + (2.0*fgkGap) + fgkBoundary;
+  
+  fSMthick    = fgkThBase + fgkThAir + fgkThPCB 
+    + fgkCellDepth + fgkThPCB + fgkThAir + fgkThPCB;
+  
 }