]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMDv0.cxx
Coverity fix
[u/mrichter/AliRoot.git] / PMD / AliPMDv0.cxx
index 44b76b4ad42ef13148e81b22cfe1677cfccd7e37..b1d0c14231e29904e89a6e152b629a1ac47bc1cc 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 ////
 
-#include "Riostream.h"
+#include <Riostream.h>
+#include <TGeoManager.h>
+#include <TGeoGlobalMagField.h>
 #include <TVirtualMC.h>
+
 #include "AliConst.h" 
 #include "AliMagF.h" 
 #include "AliPMDv0.h"
 #include "AliRun.h"
 #include "AliMC.h"
+#include "AliLog.h"
 
 const Int_t   AliPMDv0::fgkNcellHole  = 24;       // Hole dimension
 const Float_t AliPMDv0::fgkCellRadius = 0.25;     // Radius of a hexagonal cell
@@ -55,22 +59,28 @@ const Float_t AliPMDv0::fgkPi         = 3.14159;  // pi
 ClassImp(AliPMDv0)
  
 //_____________________________________________________________________________
-  AliPMDv0::AliPMDv0()
+AliPMDv0::AliPMDv0():
+  fSMthick(0.),
+  fSMLength(0.),
+  fMedSens(0),
+  fNcellSM(0)
 {
   //
   // Default constructor 
   //
-  fMedSens=0;
 }
  
 //_____________________________________________________________________________
-AliPMDv0::AliPMDv0(const char *name, const char *title)
-  : AliPMD(name,title)
+AliPMDv0::AliPMDv0(const char *name, const char *title):
+  AliPMD(name,title),
+  fSMthick(0.),
+  fSMLength(0.),
+  fMedSens(0),
+  fNcellSM(0)
 {
   //
   // Standard constructor
   //
-  fMedSens=0;
 }
 
 //_____________________________________________________________________________
@@ -191,7 +201,7 @@ void AliPMDv0::CreateSupermodule()
   // Gas replaced by vacuum for v0(insensitive) version of PMD.
 
   gMC->Gsvolu("ECAR", "PGON", idtmed[697], hexd2,10);
-  gMC->Gsatt("ECAR", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ECAR", "SEEN", 0);
   
   // Outer hexagon made of Copper
   
@@ -203,7 +213,7 @@ void AliPMDv0::CreateSupermodule()
   hexd1[9]=   fgkCellRadius;
 
   gMC->Gsvolu("ECCU", "PGON", idtmed[614], hexd1,10);
-  gMC->Gsatt("ECCU", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("ECCU", "SEEN", 1);
 
   // --- place  inner hex inside outer hex 
 
@@ -220,10 +230,10 @@ void AliPMDv0::CreateSupermodule()
   
   //
   gMC->Gsvolu("ESMA","PARA", idtmed[607], dparasm1, 6);
-  gMC->Gsatt("ESMA", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ESMA", "SEEN", 0);
   //
   gMC->Gsvolu("ESMB","PARA", idtmed[607], dparasm1, 6);
-  gMC->Gsatt("ESMB", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ESMB", "SEEN", 0);
   
   // Air residing between the PCB and the base
   
@@ -233,7 +243,7 @@ void AliPMDv0::CreateSupermodule()
   dparaair[2]= fgkThAir/2.;
   
   gMC->Gsvolu("EAIR","PARA", idtmed[698], dparaair, 6);
-  gMC->Gsatt("EAIR", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("EAIR", "SEEN", 0);
   
   // volume for honeycomb chamber EHC1 
   
@@ -243,7 +253,7 @@ void AliPMDv0::CreateSupermodule()
   dpara1[2] = fgkCellDepth/2.;
 
   gMC->Gsvolu("EHC1","PARA", idtmed[698], dpara1, 6);
-  gMC->Gsatt("EHC1", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("EHC1", "SEEN", 1);
   
   // Place hexagonal cells ECCU cells  inside EHC1 (72 X 72)
 
@@ -300,10 +310,10 @@ void AliPMDv0::CreateSupermodule()
   dparasm2[2] = fSMthick/2.;
 
   gMC->Gsvolu("ESMX","PARA", idtmed[607], dparasm2, 6);
-  gMC->Gsatt("ESMX", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ESMX", "SEEN", 0);
   //
   gMC->Gsvolu("ESMY","PARA", idtmed[607], dparasm2, 6);
-  gMC->Gsatt("ESMY", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ESMY", "SEEN", 0);
 
   Float_t dpara2[6] = {12.5,12.5,0.4,30.,0.,0.};
   dpara2[0] = dparasm2[0];
@@ -311,7 +321,7 @@ void AliPMDv0::CreateSupermodule()
   dpara2[2] = fgkCellDepth/2.;
 
   gMC->Gsvolu("EHC2","PARA", idtmed[698], dpara2, 6);
-  gMC->Gsatt("EHC2", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("EHC2", "SEEN", 1);
 
 
   // Air residing between the PCB and the base
@@ -322,7 +332,7 @@ void AliPMDv0::CreateSupermodule()
   dpara2Air[2]= fgkThAir/2.;
 
   gMC->Gsvolu("EAIX","PARA", idtmed[698], dpara2Air, 6);
-  gMC->Gsatt("EAIX", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("EAIX", "SEEN", 0);
 
   // Place hexagonal single cells ECCU inside EHC2
   // skip cells which go into the hole in top left corner.
@@ -375,10 +385,10 @@ void AliPMDv0::CreateSupermodule()
   dparaSM3[2] = fSMthick/2.;
 
   gMC->Gsvolu("ESMP","PARA", idtmed[607], dparaSM3, 6);
-  gMC->Gsatt("ESMP", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ESMP", "SEEN", 0);
   //
   gMC->Gsvolu("ESMQ","PARA", idtmed[607], dparaSM3, 6);
-  gMC->Gsatt("ESMQ", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("ESMQ", "SEEN", 0);
 
   Float_t dpara3[6] = {12.5,12.5,0.4,30.,0.,0.};
   dpara3[0] = dparaSM3[0];
@@ -386,7 +396,7 @@ void AliPMDv0::CreateSupermodule()
   dpara3[2] = fgkCellDepth/2.;
 
   gMC->Gsvolu("EHC3","PARA", idtmed[698], dpara3, 6);
-  gMC->Gsatt("EHC3", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("EHC3", "SEEN", 1);
 
   // Air residing between the PCB and the base
 
@@ -396,7 +406,7 @@ void AliPMDv0::CreateSupermodule()
   dpara3Air[2]= fgkThAir/2.;
 
   gMC->Gsvolu("EAIP","PARA", idtmed[698], dpara3Air, 6);
-  gMC->Gsatt("EAIP", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("EAIP", "SEEN", 0);
 
 
   // Place hexagonal single cells ECCU inside EHC3
@@ -474,7 +484,7 @@ void AliPMDv0::CreatePMD()
   gaspmd[8] = gaspmd[5];
 
   gMC->Gsvolu("EPMD", "PGON", idtmed[698], gaspmd, 10);
-  gMC->Gsatt("EPMD", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute("EPMD", "SEEN", 0);
 
   AliMatrix(irotdm, 90., 0.,  90.,  90., 180., 0.);
    
@@ -495,7 +505,7 @@ void AliPMDv0::CreatePMD()
   dparaemm1[2] = dmthick/2.;
 
   gMC->Gsvolu("EMM1","PARA", idtmed[698], dparaemm1, 6);
-  gMC->Gsatt("EMM1", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("EMM1", "SEEN", 1);
 
   //
   // --- DEFINE Modules, iron, and lead volumes 
@@ -507,7 +517,7 @@ void AliPMDv0::CreatePMD()
   dparapb1[2] = fgkThLead/2.;
 
   gMC->Gsvolu("EPB1","PARA", idtmed[600], dparapb1, 6);
-  gMC->Gsatt ("EPB1", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute ("EPB1", "SEEN", 0);
 
   //   Fe Support for EMM1
   Float_t dparafe1[6] = {12.5,12.5,8.,30.,0.,0.};
@@ -516,7 +526,7 @@ void AliPMDv0::CreatePMD()
   dparafe1[2] = fgkThSteel/2.;
 
   gMC->Gsvolu("EFE1","PARA", idtmed[618], dparafe1, 6);
-  gMC->Gsatt ("EFE1", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute ("EFE1", "SEEN", 0);
 
   //  
   // position supermodule ESMA, ESMB, EPB1, EFE1 inside EMM1
@@ -541,7 +551,7 @@ void AliPMDv0::CreatePMD()
   dparaemm2[2] = dmthick/2.;
 
   gMC->Gsvolu("EMM2","PARA", idtmed[698], dparaemm2, 6);
-  gMC->Gsatt("EMM2", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("EMM2", "SEEN", 1);
 
   //   Pb Convertor for EMM2
   Float_t dparapb2[6] = {12.5,12.5,8.,30.,0.,0.};
@@ -550,7 +560,7 @@ void AliPMDv0::CreatePMD()
   dparapb2[2] = fgkThLead/2.;
 
   gMC->Gsvolu("EPB2","PARA", idtmed[600], dparapb2, 6);
-  gMC->Gsatt ("EPB2", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute ("EPB2", "SEEN", 0);
 
   //   Fe Support for EMM2
   Float_t dparafe2[6] = {12.5,12.5,8.,30.,0.,0.};
@@ -559,7 +569,7 @@ void AliPMDv0::CreatePMD()
   dparafe2[2] = fgkThSteel/2.;
 
   gMC->Gsvolu("EFE2","PARA", idtmed[618], dparafe2, 6);
-  gMC->Gsatt ("EFE2", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute ("EFE2", "SEEN", 0);
 
   // position supermodule  ESMX, ESMY inside EMM2
 
@@ -581,7 +591,7 @@ void AliPMDv0::CreatePMD()
   dparaemm3[2] = dmthick/2.;
 
   gMC->Gsvolu("EMM3","PARA", idtmed[698], dparaemm3, 6);
-  gMC->Gsatt("EMM3", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute("EMM3", "SEEN", 1);
 
   //   Pb Convertor for EMM3
   Float_t dparapb3[6] = {12.5,12.5,8.,30.,0.,0.};
@@ -590,7 +600,7 @@ void AliPMDv0::CreatePMD()
   dparapb3[2] = fgkThLead/2.;
 
   gMC->Gsvolu("EPB3","PARA", idtmed[600], dparapb3, 6);
-  gMC->Gsatt ("EPB3", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute ("EPB3", "SEEN", 0);
 
   //   Fe Support for EMM3
   Float_t dparafe3[6] = {12.5,12.5,8.,30.,0.,0.};
@@ -599,7 +609,7 @@ void AliPMDv0::CreatePMD()
   dparafe3[2] = fgkThSteel/2.;
 
   gMC->Gsvolu("EFE3","PARA", idtmed[618], dparafe3, 6);
-  gMC->Gsatt ("EFE3", "SEEN", 0);
+  gGeoManager->SetVolumeAttribute ("EFE3", "SEEN", 0);
 
   // position supermodule  ESMP, ESMQ inside EMM3
 
@@ -621,7 +631,7 @@ void AliPMDv0::CreatePMD()
   //d_hole[2] = dmthick/2.;
   //
   //gMC->Gsvolu("EHOL", "TUBE", idtmed[698], d_hole, 3);
-  //gMC->Gsatt("EHOL", "SEEN", 1);
+  //gGeoManager->SetVolumeAttribute("EHOL", "SEEN", 1);
 
   //Al-rod as boundary of the supermodules
 
@@ -631,7 +641,7 @@ void AliPMDv0::CreatePMD()
   alRod[2] = dmthick/2.;
 
   gMC->Gsvolu("EALM","BOX ", idtmed[698], alRod, 3);
-  gMC->Gsatt ("EALM", "SEEN", 1);
+  gGeoManager->SetVolumeAttribute ("EALM", "SEEN", 1);
   Float_t xalm[3];
   xalm[0]=alRod[0] + gaspmd[5] + 3.0*fgkBoundary;
   xalm[1]=-xalm[0]/2.;
@@ -698,13 +708,12 @@ void AliPMDv0::CreatePMD()
         ysup[i]*TMath::Sin(theta[j]);
        ypos[i]=ymod[j] + xsup[i]*TMath::Sin(theta[j]) +
         ysup[i]*TMath::Cos(theta[j]);
-       if(fDebug) 
-        printf("%s: %f %f \n", ClassName(), xpos[i], ypos[i]);
+        
+       AliDebugClass(1,Form("xpos: %f, ypos: %f", xpos[i], ypos[i]));
        
        nummod = nummod+1;
        
-       if(fDebug) 
-        printf("\n%s: nummod %d\n",ClassName(),nummod);
+       AliDebugClass(1,Form("nummod %d",nummod));
        
        gMC->Gspos("EMM1", nummod + 6, "EPMD", xpos[i],ypos[i], 0., irotate[j], "ONLY");
        
@@ -725,40 +734,6 @@ void AliPMDv0::CreatePMD()
 }
 
  
-//_____________________________________________________________________________
-void AliPMDv0::DrawModule() const
-{
-  //
-  // Draw a shaded view of the Photon Multiplicity Detector
-  //
-
-  gMC->Gsatt("*", "seen", -1);
-  gMC->Gsatt("alic", "seen", 0);
-  //
-  // Set the visibility of the components
-  // 
-  gMC->Gsatt("ECAR","seen",0);
-  gMC->Gsatt("ECCU","seen",1);
-  gMC->Gsatt("EHC1","seen",1);
-  gMC->Gsatt("EHC1","seen",1);
-  gMC->Gsatt("EHC2","seen",1);
-  gMC->Gsatt("EMM1","seen",1);
-  gMC->Gsatt("EHOL","seen",1);
-  gMC->Gsatt("EPMD","seen",0);
-  //
-  gMC->Gdopt("hide", "on");
-  gMC->Gdopt("shad", "on");
-  gMC->Gsatt("*", "fill", 7);
-  gMC->SetClipBox(".");
-  gMC->SetClipBox("*", 0, 3000, -3000, 3000, -6000, 6000);
-  gMC->DefaultRange();
-  gMC->Gdraw("alic", 40, 30, 0, 22, 20.5, .02, .02);
-  gMC->Gdhead(1111, "Photon Multiplicity Detector Version 1");
-
-  //gMC->Gdman(17, 5, "MAN");
-  gMC->Gdopt("hide", "off");
-}
-
 //_____________________________________________________________________________
 void AliPMDv0::CreateMaterials()
 {
@@ -768,137 +743,79 @@ void AliPMDv0::CreateMaterials()
   // ORIGIN    : Y. P. VIYOGI 
   //
   
-  // --- The Argon- CO2 mixture --- 
-  Float_t ag[2] = { 39.95 };
-  Float_t zg[2] = { 18. };
-  Float_t wg[2] = { .8,.2 };
-  Float_t dar   = .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 absl, radl, a, d, z;
-  Float_t dg;
-  Float_t x0ar;
-  //Float_t x0xe=2.4;
-  //Float_t dxe=0.005858;
-  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 };
-  // 
-  // 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;
-  
+  //  cout << " Inside create materials " << endl;
 
-  Int_t *idtmed = fIdtmed->GetArray()-599;
-  Int_t isxfld = gAlice->Field()->Integ();
-  Float_t sxmgmx = gAlice->Field()->Max();
+  Int_t isxfld = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->Integ();
+  Float_t sxmgmx = ((AliMagF*)TGeoGlobalMagField::Instance()->GetField())->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.);
-  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 
+
+  // 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);
-  
-  // --- Generate explicitly delta rays in the iron, aluminium and lead --- 
-  gMC->Gstpar(idtmed[600], "LOSS", 3.);
-  gMC->Gstpar(idtmed[600], "DRAY", 1.);
-  
-  gMC->Gstpar(idtmed[603], "LOSS", 3.);
-  gMC->Gstpar(idtmed[603], "DRAY", 1.);
-  
-  gMC->Gstpar(idtmed[604], "LOSS", 3.);
-  gMC->Gstpar(idtmed[604], "DRAY", 1.);
-  
-  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.);
-  
-  // --- Energy cut-offs in the Pb and Al to gain time in tracking --- 
-  // --- without affecting the hit patterns --- 
-  gMC->Gstpar(idtmed[600], "CUTGAM", 1e-4);
-  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);
-  
-  // --- 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);
-  gMC->Gstpar(idtmed[604], "CUTNEU", 1e-5);
-  gMC->Gstpar(idtmed[604], "CUTHAD", 1e-5);
-  gMC->Gstpar(idtmed[604], "CUTMUO", 1e-5);
+  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);
+
 }
 
 //_____________________________________________________________________________
@@ -910,7 +827,7 @@ void AliPMDv0::Init()
   Int_t i;
   //  kdet=1;
   //
-  if(fDebug) {
+  if(AliLog::GetGlobalDebugLevel()>0) {
       printf("\n%s: ",ClassName());
       for(i=0;i<35;i++) printf("*");
       printf(" PMD_INIT ");
@@ -926,6 +843,8 @@ void AliPMDv0::Init()
   }
   Int_t *idtmed = fIdtmed->GetArray()-599;
   fMedSens=idtmed[605-1];
+  // --- Generate explicitly delta rays in the iron, aluminium and lead --- 
+  // removed all Gstpar and energy cut-offs moved to galice.cuts
 }
 
 //_____________________________________________________________________________
@@ -935,50 +854,32 @@ void AliPMDv0::StepManager()
   // Called at each step in the PMD
   //
   Int_t   copy;
-  Float_t hits[4], destep;
+  Float_t hits[5], destep;
   Float_t center[3] = {0,0,0};
-  Int_t   vol[5];
+  Int_t   vol[6];
   //char *namep;
   
-  if(gMC->GetMedium() == fMedSens && (destep = gMC->Edep())) {
+  if(gMC->CurrentMedium() == fMedSens && (destep = gMC->Edep())) {
   
     gMC->CurrentVolID(copy);
-
-    //namep=gMC->CurrentVolName();
-    //printf("Current vol is %s \n",namep);
-
-    vol[0]=copy;
+    vol[0] = copy;
     gMC->CurrentVolOffID(1,copy);
-
-    //namep=gMC->CurrentVolOffName(1);
-    //printf("Current vol 11 is %s \n",namep);
-
-    vol[1]=copy;
+    vol[1] = copy;
     gMC->CurrentVolOffID(2,copy);
-
-    //namep=gMC->CurrentVolOffName(2);
-    //printf("Current vol 22 is %s \n",namep);
-
-    vol[2]=copy;
-
-    // if(strncmp(namep,"EHC1",4))vol[2]=1;
-
+    vol[2] = copy;
     gMC->CurrentVolOffID(3,copy);
-
-    //namep=gMC->CurrentVolOffName(3);
-    //printf("Current vol 33 is %s \n",namep);
-
-    vol[3]=copy;
+    vol[3] = copy;
     gMC->CurrentVolOffID(4,copy);
-
-    //namep=gMC->CurrentVolOffName(4);
-    //printf("Current vol 44 is %s \n",namep);
-
-    vol[4]=copy;
-    //printf("volume number %d,%d,%d,%d,%d,%f \n",vol[0],vol[1],vol[2],vol[3],vol[4],destep*1000000);
+    vol[4] = copy;
+    gMC->CurrentVolOffID(5,copy);
+    vol[5] = copy;
 
     gMC->Gdtom(center,hits,1);
     hits[3] = destep*1e9; //Number in eV
+
+   // this is for pile-up events
+    hits[4] = gMC->TrackTime();
+
     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
   }
 }