]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDv1.cxx
Corrections for gcc 4.0
[u/mrichter/AliRoot.git] / PMD / AliPMDv1.cxx
index d8f2e4ea46dd1d472f83e5f32cf57c7dce98e494..26b038163565cb1d7fd5a304d6e44a45e43b9395 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-/*
-$Log$
-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
-
-Revision 1.28  2003/10/08 12:59:08  bnandi
-zpos is positive
-
-Revision 1.27  2003/10/08 12:56:58  bnandi
-gaspmd[2] value changed from 7.0 to 0.25
-
-Revision 1.26  2003/10/03 06:04:10  bnandi
-z_psa and z_psb bugs fixed
-
-Revision 1.25  2003/10/01 11:08:04  bnandi
-changes for NewIO
+/* $Id$ */
 
-Revision 1.24  2003/10/01 08:32:51  hristov
-CurrentTrack replaced by GetCurrentTrackNumber
-
-Revision 1.23  2003/10/01 05:07:51  bnandi
-New geometry in new Alice Coordinate system
-
-New rectangular geometry for ALICE PMD - Bedanga Mohanty and Y. P. Viyogi
-June 2003
-*/
 //
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -58,24 +28,34 @@ June 2003
 ///////////////////////////////////////////////////////////////////////////////
 ////
 
-#include "AliPMDv1.h"
-#include "AliRun.h"
-#include "AliConst.h" 
-#include "AliMagF.h" 
 #include "Riostream.h"
 #include <TVirtualMC.h>
+
+#include "AliConst.h" 
+#include "AliLog.h"
 #include "AliMC.h"
+#include "AliMagF.h" 
+#include "AliPMDv1.h"
+#include "AliRun.h"
+
+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
 
-/* 
-   static Int_t     gAliNcolUM1, gAliNcolUM2, gAliNrowUM1, gAliNrowUM2;
-   static Int_t     gAliKdet;
-   static Float_t   gAliSMLengthax, gAliSMLengthay;
-   static Float_t   gAliSMLengthbx, gAliSMLengthby;
-   static Float_t   gAliZdist, gAliZdist1;
-   static Float_t   gAliSMthick, gAliCellRadius, gAliCellWall, gAliCellDepth;
-   static Float_t   gAliBoundary, gAliThBase, gAliThAir, gAliThPCB;
-   static Float_t   gAliThLead, gAliThSteel;
-*/
 ClassImp(AliPMDv1)
  
   //_____________________________________________________________________________
@@ -132,16 +112,11 @@ void AliPMDv1::CreateSupermodule()
   Int_t ihrotm,irotdm;
   Float_t xb, yb, zb;
 
-  //  const Float_t kroot3by2 = TMath::Sqrt(3.) /2.; 
-  //  const Float_t kroot3 = TMath::Sqrt(3.); 
-
   Int_t *idtmed = fIdtmed->GetArray()-599;
  
   AliMatrix(ihrotm, 90., 30.,   90.,  120., 0., 0.);
   AliMatrix(irotdm, 90., 180.,  90.,  270., 180., 0.);
  
-  //  gAliZdist = TMath::Abs(gAliZdist1);
-
   // First create the sensitive medium of a hexagon cell (ECAR)
   // Inner hexagon filled with gas (Ar+CO2)
   
@@ -168,7 +143,7 @@ void AliPMDv1::CreateSupermodule()
 
   // 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
@@ -198,28 +173,26 @@ void AliPMDv1::CreateSupermodule()
   zb = 0.;
   xb = -(dbox1[0]) + fgkCellRadius; 
   for (i = 1; i <= fgkNcolUM1; ++i) 
-       {
-         number = i;
-         gMC->Gsposp("ECCU", number, "EST1", xb,yb,zb, ihrotm, "ONLY", hexd1,10);
-         xb += (fgkCellRadius*2.);
-       }
+    {
+      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]) + fgkCellRadius; 
-      for (i = 1; i <= fgkNcolUM2; ++i) 
-       {
-         number = i;
-         gMC->Gsposp("ECCU", number, "EST2", xb,yb,zb, ihrotm, "ONLY", hexd1,10);
-         xb += (fgkCellRadius*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]+fgkCellRadius/2.;
   dbox3[1] = (dbox1[1]*fgkNrowUM1)-(fgkCellRadius*fgkSqroot3*(fgkNrowUM1-1)/6.); 
@@ -229,20 +202,20 @@ void AliPMDv1::CreateSupermodule()
   gMC->Gsatt("EUM1", "SEEN", 1);
   
   // Place rectangular strips EST1 inside EUM1 unit module
-
+  
   yb = -dbox3[1]+dbox1[1];  
   for (j = 1; j <= fgkNrowUM1; ++j)  
     {
       if(j%2 == 0)
        {
-      xb = fgkCellRadius/2.0;
+         xb = fgkCellRadius/2.0;
        }
       else
        {
          xb = -fgkCellRadius/2.0;
        }
       number = j;
-      gMC->Gsposp("EST1",number, "EUM1", xb, yb , 0. , 0, "MANY",dbox1,3);
+      gMC->Gspos("EST1",number, "EUM1", xb, yb , 0. , 0, "MANY");
       yb = (-dbox3[1]+dbox1[1])+j*1.0*fgkCellRadius*fgkSqroot3;
     }
 
@@ -252,25 +225,25 @@ void AliPMDv1::CreateSupermodule()
   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 <= fgkNrowUM2; ++j) 
-      {
+    {
       if(j%2 == 0)
        {
-      xb = fgkCellRadius/2.0;
+         xb = fgkCellRadius/2.0;
        }
       else
        {
          xb = -fgkCellRadius/2.0;
        }
       number = j;
-      gMC->Gsposp("EST2",number, "EUM2", xb, yb , 0. , 0, "MANY",dbox2,3);
+      gMC->Gspos("EST2",number, "EUM2", xb, yb , 0. , 0, "MANY");
       yb = (-dbox4[1]+dbox2[1])+j*1.0*fgkCellRadius*fgkSqroot3;
     }
 
@@ -284,10 +257,10 @@ void AliPMDv1::CreateSupermodule()
   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 xa1,xa2,xa3,ya1,ya2; 
   xa1 = -dboxSM1[0] + dbox3[0];
@@ -296,12 +269,12 @@ void AliPMDv1::CreateSupermodule()
   ya1 = dboxSM1[1]  - dbox3[1];
   ya2 = -dboxSM1[1] + dbox3[1];
   
-  gMC->Gsposp("EUM1", 1, "ESMA", xa1, ya1, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 2, "ESMA", xa2, ya1, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 3, "ESMA", xa3, ya1, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 4, "ESMA", xa1, ya2, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 5, "ESMA", xa2, ya2, 0., 0, "ONLY",dbox3,3);
-  gMC->Gsposp("EUM1", 6, "ESMA", xa3, ya2, 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 
@@ -322,14 +295,13 @@ void AliPMDv1::CreateSupermodule()
   yb2 = 0.; 
   yb3 = -dboxSM2[1]+dbox4[1];
   
-  gMC->Gsposp("EUM2", 1, "ESMB", xb1, yb1, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 2, "ESMB", xb2, yb1, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 3, "ESMB", xb1, yb2, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 4, "ESMB", xb2, yb2, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 5, "ESMB", xb1, yb3, 0., 0, "ONLY",dbox4,3);
-  gMC->Gsposp("EUM2", 6, "ESMB", xb2, yb3, 0., 0, "ONLY",dbox4,3);
-
-
+  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");
+  
   // Make a 3mm thick G10 Base plate for ESMA
   Float_t dboxG1a[3];
   dboxG1a[0] = dboxSM1[0]; 
@@ -375,25 +347,25 @@ void AliPMDv1::CreateSupermodule()
 
   Float_t zbpa,zpcba1,zpcba2,zsma; 
   zpcba1 = - dboxAlla[2]+fgkThPCB/2.0;
-  gMC->Gsposp("EPCA", 1, "EFPA", 0., 0., zpcba1, 0, "ONLY",dboxG2a,3);
+  gMC->Gspos("EPCA", 1, "EFPA", 0., 0., zpcba1, 0, "ONLY");
   zsma = zpcba1+dboxSM1[2];
-  gMC->Gsposp("ESMA", 1, "EFPA", 0., 0., zsma, 0, "ONLY",dboxSM1,3);
+  gMC->Gspos("ESMA", 1, "EFPA", 0., 0., zsma, 0, "ONLY");
   zpcba2 = zsma+fgkThPCB/2.0;
-  gMC->Gsposp("EPCA", 2, "EFPA", 0., 0., zpcba2, 0, "ONLY",dboxG2a,3);
+  gMC->Gspos("EPCA", 2, "EFPA", 0., 0., zpcba2, 0, "ONLY");
   zbpa = zpcba2+fgkThAir+fgkThBase/2.0;
-  gMC->Gsposp("EBPA", 1, "EFPA", 0., 0., zbpa, 0, "ONLY",dboxG1a,3);
+  gMC->Gspos("EBPA", 1, "EFPA", 0., 0., zbpa, 0, "ONLY");
 
   // Now place everything in EFCA for CPV
 
   Float_t zbpa2,zpcba12,zpcba22,zsma2; 
   zbpa2 = - dboxAlla2[2]+fgkThBase/2.0;
-  gMC->Gsposp("EBPA", 1, "EFCA", 0., 0., zbpa2, 0, "ONLY",dboxG1a,3);
+  gMC->Gspos("EBPA", 1, "EFCA", 0., 0., zbpa2, 0, "ONLY");
   zpcba12 = zbpa2+fgkThAir+fgkThPCB/2.0;
-  gMC->Gsposp("EPCA", 1, "EFCA", 0., 0., zpcba12, 0, "ONLY",dboxG2a,3);
+  gMC->Gspos("EPCA", 1, "EFCA", 0., 0., zpcba12, 0, "ONLY");
   zsma2 = zpcba12+dboxSM1[2];
-  gMC->Gsposp("ESMA", 1, "EFCA", 0., 0., zsma2, 0, "ONLY",dboxSM1,3);
+  gMC->Gspos("ESMA", 1, "EFCA", 0., 0., zsma2, 0, "ONLY");
   zpcba22 = zsma2+fgkThPCB/2.0;
-  gMC->Gsposp("EPCA", 2, "EFCA", 0., 0., zpcba22, 0, "ONLY",dboxG2a,3);
+  gMC->Gspos("EPCA", 2, "EFCA", 0., 0., zpcba22, 0, "ONLY");
 
 
 
@@ -415,7 +387,6 @@ void AliPMDv1::CreateSupermodule()
   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 dboxAllb[3];
@@ -441,26 +412,26 @@ void AliPMDv1::CreateSupermodule()
 
   Float_t zbpb,zpcbb1,zpcbb2,zsmb; 
   zpcbb1 = - dboxAllb[2]+fgkThPCB/2.0;
-  gMC->Gsposp("EPCB", 1, "EFPB", 0., 0., zpcbb1, 0, "ONLY",dboxG2b,3);
+  gMC->Gspos("EPCB", 1, "EFPB", 0., 0., zpcbb1, 0, "ONLY");
   zsmb = zpcbb1+dboxSM2[2];
-  gMC->Gsposp("ESMB", 1, "EFPB", 0., 0., zsmb, 0, "ONLY",dboxSM2,3);
+  gMC->Gspos("ESMB", 1, "EFPB", 0., 0., zsmb, 0, "ONLY");
   zpcbb2 = zsmb+fgkThPCB/2.0;
-  gMC->Gsposp("EPCB", 2, "EFPB", 0., 0., zpcbb2, 0, "ONLY",dboxG2b,3);
+  gMC->Gspos("EPCB", 2, "EFPB", 0., 0., zpcbb2, 0, "ONLY");
   zbpb = zpcbb2+fgkThAir+fgkThBase/2.0;
-  gMC->Gsposp("EBPB", 1, "EFPB", 0., 0., zbpb, 0, "ONLY",dboxG1b,3);
+  gMC->Gspos("EBPB", 1, "EFPB", 0., 0., zbpb, 0, "ONLY");
 
 
   // Now place everything in EFCB for CPV
 
   Float_t zbpb2,zpcbb12,zpcbb22,zsmb2; 
   zbpb2 = - dboxAllb2[2]+fgkThBase/2.0;
-  gMC->Gsposp("EBPB", 1, "EFCB", 0., 0., zbpb2, 0, "ONLY",dboxG1b,3);
+  gMC->Gspos("EBPB", 1, "EFCB", 0., 0., zbpb2, 0, "ONLY");
   zpcbb12 = zbpb2+0.1+fgkThPCB/2.0;
-  gMC->Gsposp("EPCB", 1, "EFCB", 0., 0., zpcbb12, 0, "ONLY",dboxG2b,3);
+  gMC->Gspos("EPCB", 1, "EFCB", 0., 0., zpcbb12, 0, "ONLY");
   zsmb2 = zpcbb12+dboxSM2[2];
-  gMC->Gsposp("ESMB", 1, "EFCB", 0., 0., zsmb2, 0, "ONLY",dboxSM2,3);
+  gMC->Gspos("ESMB", 1, "EFCB", 0., 0., zsmb2, 0, "ONLY");
   zpcbb22 = zsmb2+fgkThPCB/2.0;
-  gMC->Gsposp("EPCB", 2, "EFCB", 0., 0., zpcbb22, 0, "ONLY",dboxG2b,3);
+  gMC->Gspos("EPCB", 2, "EFCB", 0., 0., zpcbb22, 0, "ONLY");
 
 
   // Master MODULE EMPA of aluminum for PMD
@@ -481,8 +452,8 @@ void AliPMDv1::CreateSupermodule()
 
 
   //Position EFMA inside EMMA for PMD and CPV
-  gMC->Gsposp("EFPA", 1, "EMPA", 0., 0., 0., 0, "ONLY",dboxAlla,3);
-  gMC->Gsposp("EFCA", 1, "EMCA", 0., 0., 0., 0, "ONLY",dboxAlla2,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
@@ -501,12 +472,9 @@ void AliPMDv1::CreateSupermodule()
   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",dboxAllb,3);
-  gMC->Gsposp("EFCB", 1, "EMCB", 0., 0., 0., 0, "ONLY",dboxAllb2,3);
-
-
+  gMC->Gspos("EFPB", 1, "EMPB", 0., 0., 0., 0, "ONLY");
+  gMC->Gspos("EFCB", 1, "EMCB", 0., 0., 0., 0, "ONLY");
 }
  
 //_____________________________________________________________________________
@@ -561,70 +529,94 @@ void AliPMDv1::CreatePMD()
   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] = fSMLengthax + fSMLengthbx;
-  gaspmd[1] = fSMLengthay + fSMLengthby;
-
-  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 xsma,ysma;
-  Float_t xsmb,ysmb;
-  xsma = -fSMLengthbx;
-  ysma =  fSMLengthby;
-  xsmb = -fSMLengthax;
-  ysmb = -fSMLengthay;
+  // 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 zpsa,zpba,zfea,zcva; 
 
-  zpsa = - gaspmd[2] + fSMthick/2.;
+  // 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->Gsposp("EMPA", 1, "EPMD", xsma, ysma, zpsa, 0, "ONLY",fDboxmm1,3);
-  gMC->Gsposp("EMPA", 2, "EPMD", -xsma, -ysma, zpsa, jhrot12, "ONLY",fDboxmm1,3);
+  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->Gsposp("EPBA", 1, "EPMD", xsma, ysma, zpba, 0, "ONLY",dboxPba,3);
-  gMC->Gsposp("EPBA", 2, "EPMD", -xsma, -ysma, zpba, 0, "ONLY",dboxPba,3);
+  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->Gsposp("EFEA", 1, "EPMD", xsma, ysma, zfea, 0, "ONLY",dboxFea,3);
-  gMC->Gsposp("EFEA", 2, "EPMD", -xsma, -ysma, zfea, 0, "ONLY",dboxFea,3);
+  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->Gsposp("EMCA", 1, "EPMD", xsma, ysma, zcva, 0, "ONLY",fDboxmm12,3);
-  gMC->Gsposp("EMCA", 2, "EPMD", -xsma,-ysma, zcva, jhrot12, "ONLY",fDboxmm12,3);
+  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 zpsb,zpbb,zfeb,zcvb; 
-  zpsb = - gaspmd[2] + fSMthick/2.;
-  
-  gMC->Gsposp("EMPB", 3, "EPMD", xsmb, ysmb, zpsb, 0, "ONLY",fDboxmm2,3);
-  gMC->Gsposp("EMPB", 4, "EPMD", -xsmb, -ysmb, zpsb, jhrot12, "ONLY",fDboxmm2,3);
+  // 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->Gsposp("EPBB", 3, "EPMD", xsmb, ysmb, zpbb, 0, "ONLY",dboxPbb,3);
-  gMC->Gsposp("EPBB", 4, "EPMD", -xsmb, -ysmb, zpbb, 0, "ONLY",dboxPbb,3);
+  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->Gsposp("EFEB", 3, "EPMD", xsmb, ysmb, zfeb, 0, "ONLY",dboxFeb,3);
-  gMC->Gsposp("EFEB", 4, "EPMD", -xsmb, -ysmb, zfeb, 0, "ONLY",dboxFeb,3);
+  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->Gsposp("EMCB", 3, "EPMD", xsmb, ysmb, zcvb, 0, "ONLY",fDboxmm22,3);
-  gMC->Gsposp("EMCB", 4, "EPMD", -xsmb,-ysmb, zcvb, jhrot12, "ONLY",fDboxmm22,3);
+  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 = 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");
 
 }
 
@@ -662,7 +654,7 @@ void AliPMDv1::DrawModule() const
   //gMC->Gdman(17, 5, "MAN");
   gMC->Gdopt("hide", "off");
 
-  cout << " Outside Draw Modules " << endl;
+  AliDebug(1,"Outside Draw Modules");
 }
 
 //_____________________________________________________________________________
@@ -673,78 +665,78 @@ void AliPMDv1::CreateMaterials()
   // 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] = { 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    = 0.001977;
-  Float_t dco   = 0.002;  // --- CO2 density in g/cm3 ---
-  
-  Float_t absl, radl, a, d, z;
-  Float_t dg;
-  Float_t x0ar;
-  Float_t buf[1];
-  Int_t nbuf;
-  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 };
-  
+
   Int_t *idtmed = fIdtmed->GetArray()-599;
   Int_t isxfld = gAlice->Field()->Integ();
   Float_t sxmgmx = gAlice->Field()->Max();
   
   // --- Define the various materials for GEANT --- 
+
   AliMaterial(1, "Pb    $", 207.19, 82., 11.35, .56, 18.5);
-  x0ar = 19.55 / dar;
-  AliMaterial(2, "Argon$", 39.95, 18., dar, x0ar, 6.5e4);
-  AliMixture(3, "CO2  $", ac, zc, dc, -2, wc);
+  
+  // Argon
+
+  Float_t dAr   = 0.001782;   // --- Ar density in g/cm3 --- 
+  Float_t x0Ar = 19.55 / dAr;
+  AliMaterial(2, "Argon$", 39.95, 18., dAr, x0Ar, 6.5e4);
+
+  // --- CO2 --- 
+
+  Float_t aCO2[2] = { 12.,16. };
+  Float_t zCO2[2] = { 6.,8. };
+  Float_t wCO2[2] = { 1.,2. };
+  Float_t dCO2    = 0.001977;
+  AliMixture(3, "CO2  $", aCO2, zCO2, dCO2, -2, wCO2);
+
   AliMaterial(4, "Al   $", 26.98, 13., 2.7, 8.9, 18.5);
+
+  // ArCO2
+
+  Float_t aArCO2[3] = {39.948,12.0107,15.9994};
+  Float_t zArCO2[3] = {18.,6.,8.};
+  Float_t wArCO2[3] = {0.7,0.08,0.22};
+  Float_t dArCO2    = dAr * 0.7 + dCO2 * 0.3;
+  AliMixture(5, "ArCO2$", aArCO2, zArCO2, dArCO2, 3, wArCO2);
+
   AliMaterial(6, "Fe   $", 55.85, 26., 7.87, 1.76, 18.5);
-  AliMaterial(7, "W    $", 183.85, 74., 19.3, .35, 10.3);
-  AliMaterial(8, "G10  $", 20., 10., 1.7, 19.4, 999.);
-  AliMaterial(9, "SILIC$", 28.09, 14., 2.33, 9.36, 45.);
-  AliMaterial(10, "Be   $", 9.01, 4., 1.848, 35.3, 36.7);
-  AliMaterial(15, "Cu   $", 63.54, 29., 8.96, 1.43, 15.);
-  AliMaterial(16, "C    $", 12.01, 6., 2.265, 18.8, 49.9);
-  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(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 
+
+  // G10
   
-  char namate[21];
-  gMC->Gfmate((*fIdmate)[3], namate, a, z, d, radl, absl, buf, nbuf);
-  ag[1] = a;
-  zg[1] = z;
-  dg = (dar * 4 + dco) / 5;
-  AliMixture(5, "ArCO2$", ag, zg, dg, 2, wg);
+  Float_t aG10[4]={1.,12.011,15.9994,28.086};
+  Float_t zG10[4]={1.,6.,8.,14.};
+  //PH  Float_t wG10[4]={0.148648649,0.104054054,0.483499056,0.241666667};
+  Float_t wG10[4]={0.15201,0.10641,0.49444,0.24714};
+  AliMixture(8,"G10",aG10,zG10,1.7,4,wG10);
   
+  AliMaterial(15, "Cu   $", 63.54, 29., 8.96, 1.43, 15.);
+
+  // Steel
+  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 };
+  Float_t dSteel    = 7.88;
+  AliMixture(19, "STAINLESS STEEL$", aSteel, zSteel, dSteel, 4, wSteel); 
+
+  //Air
+
+  Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
+  Float_t zAir[4]={6.,7.,8.,18.};
+  Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
+  Float_t dAir1 = 1.20479E-10;
+  Float_t dAir = 1.20479E-3;
+  AliMixture(98, "Vacum$", aAir,  zAir, dAir1, 4, wAir);
+  AliMixture(99, "Air  $", aAir,  zAir, dAir , 4, wAir);
+
   // Define tracking media 
-  AliMedium(1, "Pb conv.$", 1,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
-  AliMedium(7, "W  conv.$", 7,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
-  AliMedium(8, "G10plate$", 8,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
-  AliMedium(4, "Al      $", 4,  0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
-  AliMedium(6, "Fe      $", 6,  0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
-  AliMedium(5, "ArCO2   $", 5,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
-  AliMedium(9, "SILICON $", 9,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
-  AliMedium(10, "Be      $", 10, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
-  AliMedium(98, "Vacuum  $", 98, 0, 0, isxfld, sxmgmx, 1., .1, .1,  10);
-  AliMedium(99, "Air gaps$", 99, 0, 0, isxfld, sxmgmx, 1., .1, .1,  .1);
-  AliMedium(15, "Cu      $", 15, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
-  AliMedium(16, "C       $", 16, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
-  AliMedium(17, "PLOYCARB$", 17, 0, 0, isxfld, sxmgmx, .1,  .1, .01, .1);
-  AliMedium(19, " S steel$", 19, 0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
-  //  AliMedium(31, "Xenon   $", 31,  1, 0, isxfld, sxmgmx, .1,  .1, .1,  .1);
+  AliMedium(1,  "Pb conv.$", 1,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
+  AliMedium(4,  "Al      $", 4,  0, 0, isxfld, sxmgmx, .1, .1, .01, .1);
+  AliMedium(5,  "ArCO2   $", 5,  1, 0, isxfld, sxmgmx, .1, .1, .10, .1);
+  AliMedium(6,  "Fe      $", 6,  0, 0, isxfld, sxmgmx, .1, .1, .01, .1);
+  AliMedium(8,  "G10plate$", 8,  0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
+  AliMedium(15, "Cu      $", 15, 0, 0, isxfld, sxmgmx, .1, .1, .01, .1);
+  AliMedium(19, "S  steel$", 19, 0, 0, isxfld, sxmgmx, 1., .1, .01, .1);
+  AliMedium(98, "Vacuum  $", 98, 0, 0, isxfld, sxmgmx, 1., .1, .10, 10);
+  AliMedium(99, "Air gaps$", 99, 0, 0, isxfld, sxmgmx, 1., .1, .10, .1);
   
   // --- Generate explicitly delta rays in the iron, aluminium and lead --- 
   gMC->Gstpar(idtmed[600], "LOSS", 3.);
@@ -759,9 +751,6 @@ void AliPMDv1::CreateMaterials()
   gMC->Gstpar(idtmed[605], "LOSS", 3.);
   gMC->Gstpar(idtmed[605], "DRAY", 1.);
   
-  gMC->Gstpar(idtmed[606], "LOSS", 3.);
-  gMC->Gstpar(idtmed[606], "DRAY", 1.);
-  
   gMC->Gstpar(idtmed[607], "LOSS", 3.);
   gMC->Gstpar(idtmed[607], "DRAY", 1.);
   
@@ -771,23 +760,20 @@ void AliPMDv1::CreateMaterials()
   gMC->Gstpar(idtmed[600], "CUTELE", 1e-4);
   gMC->Gstpar(idtmed[600], "CUTNEU", 1e-4);
   gMC->Gstpar(idtmed[600], "CUTHAD", 1e-4);
+
   gMC->Gstpar(idtmed[605], "CUTGAM", 1e-4);
   gMC->Gstpar(idtmed[605], "CUTELE", 1e-4);
   gMC->Gstpar(idtmed[605], "CUTNEU", 1e-4);
   gMC->Gstpar(idtmed[605], "CUTHAD", 1e-4);
-  gMC->Gstpar(idtmed[606], "CUTGAM", 1e-4);
-  gMC->Gstpar(idtmed[606], "CUTELE", 1e-4);
-  gMC->Gstpar(idtmed[606], "CUTNEU", 1e-4);
-  gMC->Gstpar(idtmed[606], "CUTHAD", 1e-4);
+
   gMC->Gstpar(idtmed[603], "CUTGAM", 1e-4);
   gMC->Gstpar(idtmed[603], "CUTELE", 1e-4);
   gMC->Gstpar(idtmed[603], "CUTNEU", 1e-4);
   gMC->Gstpar(idtmed[603], "CUTHAD", 1e-4);
-  gMC->Gstpar(idtmed[609], "CUTGAM", 1e-4);
-  gMC->Gstpar(idtmed[609], "CUTELE", 1e-4);
-  gMC->Gstpar(idtmed[609], "CUTNEU", 1e-4);
-  gMC->Gstpar(idtmed[609], "CUTHAD", 1e-4);
-  
+//   gMC->Gstpar(idtmed[609], "CUTGAM", 1e-4);
+//   gMC->Gstpar(idtmed[609], "CUTELE", 1e-4);
+//   gMC->Gstpar(idtmed[609], "CUTNEU", 1e-4);
+//   gMC->Gstpar(idtmed[609], "CUTHAD", 1e-4);
   // --- Prevent particles stopping in the gas due to energy cut-off --- 
   gMC->Gstpar(idtmed[604], "CUTGAM", 1e-5);
   gMC->Gstpar(idtmed[604], "CUTELE", 1e-5);
@@ -795,7 +781,7 @@ void AliPMDv1::CreateMaterials()
   gMC->Gstpar(idtmed[604], "CUTHAD", 1e-5);
   gMC->Gstpar(idtmed[604], "CUTMUO", 1e-5);
 
-  cout << " Outside create materials " << endl;
+  AliDebug(1,"Outside create materials");
 
 }
 
@@ -806,25 +792,12 @@ void AliPMDv1::Init()
   // Initialises PMD detector after it has been built
   //
 
-  Int_t i;
-  //  gAliKdet=1;
   //
-  cout << " Inside Init " << endl;
-  if(fDebug) {
-      printf("\n%s: ",ClassName());
-      for(i=0;i<35;i++) printf("*");
-      printf(" PMD_INIT ");
-      for(i=0;i<35;i++) printf("*");
-      printf("\n%s: ",ClassName());
-      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(),fgkCellRadius,fgkCellWall,fgkCellDepth,fgkZdist );
-      printf("%s: ",ClassName());
-      for(i=0;i<80;i++) printf("*");
-      printf("\n");
-  }
-  
+  AliDebug(2,"Inside Init");
+  AliDebug(2,"PMD simulation package (v1) initialised");
+  AliDebug(2,"parameters of pmd");
+  AliDebug(2,Form("%10.2f %10.2f %10.2f %10.2f\n",
+                 fgkCellRadius,fgkCellWall,fgkCellDepth,fgkZdist));
   Int_t *idtmed = fIdtmed->GetArray()-599;
   fMedSens=idtmed[605-1];