]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/AliZDCv3.cxx
AddTimeStamp was always increasing track length but accounting
[u/mrichter/AliRoot.git] / ZDC / AliZDCv3.cxx
index ae43b808d2c933d05de40ca132985803a1060eeb..6f226abb74c5079a369388b17bce902868fd5648 100644 (file)
 #include <TVirtualMC.h>
 #include <TGeoManager.h>
 #include <TGeoMatrix.h>
+#include <TGeoTube.h>
 #include <TGeoCone.h>
 #include <TGeoShape.h>
+#include <TGeoScaledShape.h>
 #include <TGeoCompositeShape.h>
 #include <TParticle.h>
 
@@ -63,6 +65,8 @@ AliZDCv3::AliZDCv3() :
   fMedSensGR(0),
   fMedSensPI(0),
   fMedSensTDI(0),
+  fMedSensVColl(0),
+  fMedSensLumi(0),
   fNalfan(0),
   fNalfap(0),
   fNben(0),  
@@ -70,21 +74,35 @@ AliZDCv3::AliZDCv3() :
   fZEMLength(0),
   fpLostITC(0), 
   fpLostD1C(0), 
+  fpcVCollC(0),
   fpDetectedC(0),
   fnDetectedC(0),
-  fnLumiC(0),
   fpLostITA(0), 
   fpLostD1A(0), 
   fpLostTDI(0), 
+  fpcVCollA(0),
   fpDetectedA(0),
   fnDetectedA(0),
-  fnLumiA(0),
-  fnTrou(0)
+  fVCollSideCAperture(7./2.),
+  fVCollSideCApertureNeg(7./2.),
+  fVCollSideCCentreY(0.),
+  fVCollSideAAperture(7./2.),
+  fVCollSideAApertureNeg(7./2.),
+  fVCollSideACentreY(0.),
+  fTCDDAperturePos(2.0),
+  fTCDDApertureNeg(2.2),
+  fTDIAperturePos(5.5),
+  fTDIApertureNeg(5.5),
+  fLumiLength(15.)
 {
   //
   // Default constructor for Zero Degree Calorimeter
   //
-  
+  for(Int_t i=0; i<3; i++){
+     fDimZN[i] = fDimZP[i] = 0.;
+     fPosZNC[i] = fPosZNA[i] = fPosZPC[i]= fPosZPA[i] = fPosZEM[i] = 0.;
+     fFibZN[i] = fFibZP[i] = 0.;
+  }
 }
  
 //_____________________________________________________________________________
@@ -98,6 +116,8 @@ AliZDCv3::AliZDCv3(const char *name, const char *title) :
   fMedSensGR(0),
   fMedSensPI(0),
   fMedSensTDI(0),
+  fMedSensVColl(0),
+  fMedSensLumi(0),
   fNalfan(90),
   fNalfap(90),
   fNben(18),  
@@ -105,16 +125,26 @@ AliZDCv3::AliZDCv3(const char *name, const char *title) :
   fZEMLength(0),
   fpLostITC(0), 
   fpLostD1C(0), 
+  fpcVCollC(0),
   fpDetectedC(0),
   fnDetectedC(0),
-  fnLumiC(0),
   fpLostITA(0), 
   fpLostD1A(0), 
   fpLostTDI(0), 
+  fpcVCollA(0),
   fpDetectedA(0),
-  fnDetectedA(0),  
-  fnLumiA(0),
-  fnTrou(0)
+  fnDetectedA(0),
+  fVCollSideCAperture(7./2.),
+  fVCollSideCApertureNeg(7./2.),
+  fVCollSideCCentreY(0.),
+  fVCollSideAAperture(7./2.),
+  fVCollSideAApertureNeg(7./2.),
+  fVCollSideACentreY(0.),
+  fTCDDAperturePos(2.0),
+  fTCDDApertureNeg(2.2),
+  fTDIAperturePos(5.5),
+  fTDIApertureNeg(5.5),
+  fLumiLength(15.)  
 {
   //
   // Standard constructor for Zero Degree Calorimeter 
@@ -157,13 +187,13 @@ AliZDCv3::AliZDCv3(const char *name, const char *title) :
   fDimZP[1] = 6.;
   fDimZP[2] = 75.;    
   fPosZNC[0] = 0.;
-  fPosZNC[1] = 1.2;
+  fPosZNC[1] = 0.;
   fPosZNC[2] = -11397.3; 
   fPosZPC[0] = 24.35;
   fPosZPC[1] = 0.;
   fPosZPC[2] = -11389.3; 
   fPosZNA[0] = 0.;
-  fPosZNA[1] = 1.2;
+  fPosZNA[1] = 0.;
   fPosZNA[2] = 11395.8;  
   fPosZPA[0] = 24.35;
   fPosZPA[1] = 0.;
@@ -299,16 +329,40 @@ void AliZDCv3::CreateBeamLine()
   tubpar[0] = 18.6/2.;
   tubpar[1] = 7.6/2.;
   tubpar[2] = totLength1/2.;
-  gMC->Gsvolu("QE01", "ELTU", idtmed[7], tubpar, 3);  
+//  gMC->Gsvolu("QE01", "ELTU", idtmed[7], tubpar, 3);  
+  // temporary replace with a scaled tube (AG)
+  TGeoTube *tubeQE01 = new TGeoTube(0.,tubpar[0],tubpar[2]);
+  TGeoScale *scaleQE01 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
+  TGeoScaledShape *sshapeQE01 = new TGeoScaledShape(tubeQE01, scaleQE01);
+  new TGeoVolume("QE01", sshapeQE01, gGeoManager->GetMedium(idtmed[7]));
 
   tubpar[0] = 18.0/2.;
   tubpar[1] = 7.0/2.;
   tubpar[2] = totLength1/2.;
-  gMC->Gsvolu("QE02", "ELTU", idtmed[10], tubpar, 3);  
-  gMC->Gspos("QE02", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY"); 
+//  gMC->Gsvolu("QE02", "ELTU", idtmed[10], tubpar, 3);  
+  // temporary replace with a scaled tube (AG)
+  TGeoTube *tubeQE02 = new TGeoTube(0.,tubpar[0],tubpar[2]);
+  TGeoScale *scaleQE02 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
+  TGeoScaledShape *sshapeQE02 = new TGeoScaledShape(tubeQE02, scaleQE02);
+  new TGeoVolume("QE02", sshapeQE02, gGeoManager->GetMedium(idtmed[10]));
+
+  gMC->Gspos("QE01", 1, "ZDCC", 0., 0., -tubpar[2]-zd1, 0, "ONLY"); 
   gMC->Gspos("QE02", 1, "QE01", 0., 0., 0., 0, "ONLY");  
   // Ch.debug
-  //printf("   QE02 ELTU from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
+  //printf("   QE01 ELTU from z = %1.2f to z= %1.2f\n",-zd1,-2*tubpar[2]-zd1);
+  
+  // Vertical collimator jaws (defined ONLY if fVCollAperture<3.5!)
+  if(fVCollSideCAperture<3.5){
+    boxpar[0] = 5.4/2.;
+    boxpar[1] = (3.5-fVCollSideCAperture-fVCollSideCCentreY-0.7)/2.;
+    if(boxpar[1]<0.) boxpar[1]=0.;
+    boxpar[2] = 124.4/2.;
+    printf("  AliZDCv3 -> sideC VCollimator jaws: apertures +%1.2f/-%1.2f center %1.2f [cm]\n", 
+       fVCollSideCAperture, fVCollSideCApertureNeg,fVCollSideCCentreY);
+    gMC->Gsvolu("QCVC" , "BOX ", idtmed[13], boxpar, 3); 
+    gMC->Gspos("QCVC", 1, "QE02", -boxpar[0],  fVCollSideCAperture+fVCollSideCCentreY+boxpar[1], -totLength1/2.+160.8+78.+148./2., 0, "ONLY");  
+    gMC->Gspos("QCVC", 2, "QE02", -boxpar[0], -fVCollSideCApertureNeg+fVCollSideCCentreY-boxpar[1], -totLength1/2.+160.8+78.+148./2., 0, "ONLY");  
+  }
   
   zd1 += tubpar[2] * 2.;
   
@@ -566,7 +620,7 @@ void AliZDCv3::CreateBeamLine()
   TGeoCompositeShape *pOutTrousersC = new TGeoCompositeShape("outTrousersC", "QCLext:ZDCC_c1+QCLext:ZDCC_c2");
   
   // Volume: QCLext
-  TGeoMedium *medZDCFe = gGeoManager->GetMedium("ZDC_ZIRON");
+  TGeoMedium *medZDCFe = gGeoManager->GetMedium("ZDC_ZIRONT");
   TGeoVolume *pQCLext = new TGeoVolume("QCLext",pOutTrousersC, medZDCFe);
   pQCLext->SetLineColor(kGreen);
   pQCLext->SetVisLeaves(kTRUE);
@@ -602,10 +656,10 @@ void AliZDCv3::CreateBeamLine()
   
   // transition x2zdc to recombination chamber : skewed cone  
   conpar[0] = (10.-0.2-offset)/2.;
-  conpar[1] = 5.4/2.;
-  conpar[2] = 5.8/2.;
-  conpar[3] = 6.3/2.;
-  conpar[4] = 7.0/2.;
+  conpar[1] = 6.3/2.;
+  conpar[2] = 7.0/2.;
+  conpar[3] = 5.4/2.;
+  conpar[4] = 5.8/2.;
   gMC->Gsvolu("QC10", "CONE", idtmed[7], conpar, 5); 
   gMC->Gspos("QC10", 1, "ZDCC", -7.9-0.175, 0., -conpar[0]-0.1-zd1, irotpipe1, "ONLY");
   gMC->Gspos("QC10", 2, "ZDCC", 7.9+0.175, 0., -conpar[0]-0.1-zd1, irotpipe2, "ONLY");
@@ -629,8 +683,8 @@ void AliZDCv3::CreateBeamLine()
   // -- Luminometer (Cu box) in front of ZN - side C
   boxpar[0] = 8.0/2.;
   boxpar[1] = 8.0/2.;
-  boxpar[2] = 15./2.;
-  gMC->Gsvolu("QLUC", "BOX ", idtmed[6], boxpar, 3);
+  boxpar[2] = fLumiLength/2.;
+  gMC->Gsvolu("QLUC", "BOX ", idtmed[9], boxpar, 3);
   gMC->Gspos("QLUC", 1, "ZDCC", 0., 0.,  fPosZNC[2]+66.+boxpar[2], 0, "ONLY");
   //printf("   QLUC LUMINOMETER from z = %1.2f to z= %1.2f\n",  fPosZNC[2]+66., fPosZNC[2]+66.+2*boxpar[2]);
                 
@@ -890,8 +944,10 @@ void AliZDCv3::CreateBeamLine()
   gMC->Gspos("Q11T", 1, "Q10T", 0., -1.1,  0., 0, "ONLY");  
   
   // positioning  TCDD elements in ZDCA, (inside TCDD volume)
-  gMC->Gspos("Q08T", 1, "ZDCA", 0., 2., -100.+zd2, 0, "ONLY");  
-  gMC->Gspos("Q10T", 1, "ZDCA", 0., -2., -100.+zd2, 0, "ONLY");  
+  gMC->Gspos("Q08T", 1, "ZDCA", 0., fTCDDAperturePos, -100.+zd2, 0, "ONLY");  
+  gMC->Gspos("Q10T", 1, "ZDCA", 0., -fTCDDApertureNeg, -100.+zd2, 0, "ONLY");  
+  printf("  AliZDCv3 -> TCDD apertures +%1.2f/-%1.2f cm\n", 
+       fTCDDAperturePos, fTCDDApertureNeg);
     
   // RF screen 
   boxpar[0] = 0.2/2.;
@@ -911,17 +967,40 @@ void AliZDCv3::CreateBeamLine()
   tubpar[0] = 18.4/2.;
   tubpar[1] = 7.4/2.;
   tubpar[2] = 313.3/2.;
-  gMC->Gsvolu("QA06", "ELTU", idtmed[7], tubpar, 3);  
+//  gMC->Gsvolu("QA06", "ELTU", idtmed[7], tubpar, 3);  
+  // temporary replace with a scaled tube (AG)
+  TGeoTube *tubeQA06 = new TGeoTube(0.,tubpar[0],tubpar[2]);
+  TGeoScale *scaleQA06 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
+  TGeoScaledShape *sshapeQA06 = new TGeoScaledShape(tubeQA06, scaleQA06);
+  new TGeoVolume("QA06", sshapeQA06, gGeoManager->GetMedium(idtmed[7]));
   //printf("   QA06 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
 
   tubpar[0] = 18.0/2.;
   tubpar[1] = 7.0/2.;
   tubpar[2] = 313.3/2.;
-  gMC->Gsvolu("QA07", "ELTU", idtmed[10], tubpar, 3);  
+//  gMC->Gsvolu("QA07", "ELTU", idtmed[10], tubpar, 3);  
+  // temporary replace with a scaled tube (AG)
+  TGeoTube *tubeQA07 = new TGeoTube(0.,tubpar[0],tubpar[2]);
+  TGeoScale *scaleQA07 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
+  TGeoScaledShape *sshapeQA07 = new TGeoScaledShape(tubeQA07, scaleQA07);
+  new TGeoVolume("QA07", sshapeQA07, gGeoManager->GetMedium(idtmed[10]));
   //printf("   QA07 TUBE from z = %1.2f to z= %1.2f\n",zd2,2*tubpar[2]+zd2);
   gMC->Gspos("QA06", 1, "ZDCA", 0., 0., tubpar[2]+zd2, 0, "ONLY"); 
   gMC->Gspos("QA07", 1, "QA06", 0., 0., 0., 0, "ONLY");  
-
+  
+  // Vertical collimator jaws (defined ONLY if fVCollAperture<3.5!)
+  if(fVCollSideAAperture<3.5){
+    boxpar[0] = 5.4/2.;
+    boxpar[1] = (3.5-fVCollSideAAperture-fVCollSideACentreY-0.7)/2.;
+    if(boxpar[1]<0.) boxpar[1]=0.;
+    boxpar[2] = 124.4/2.;
+    gMC->Gsvolu("QCVA" , "BOX ", idtmed[13], boxpar, 3); 
+    gMC->Gspos("QCVA", 1, "QA07", -boxpar[0], fVCollSideAAperture+fVCollSideACentreY+boxpar[1], -313.3/2.+78.+148./2., 0, "ONLY");  
+    gMC->Gspos("QCVA", 2, "QA07", -boxpar[0], -fVCollSideAApertureNeg+fVCollSideACentreY-boxpar[1], -313.3/2.+78.+148./2., 0, "ONLY");  
+    printf("  AliZDCv3 -> sideA VCollimator jaws: apertures +%1.2f/-%1.2f center %1.2f [cm]\n", 
+       fVCollSideAAperture, fVCollSideAApertureNeg,fVCollSideACentreY);
+  }
+  
   zd2 += 2.*tubpar[2];
       
   // VCTCP second part: transition cone from ID=180 to ID=212.7 
@@ -983,20 +1062,22 @@ void AliZDCv3::CreateBeamLine()
   boxpar[1] = 9.0/2.;
   boxpar[2] = 540.0/2.;
   gMC->Gsvolu("QTD1", "BOX ", idtmed[7], boxpar, 3);
-  gMC->Gspos("QTD1", 1, "Q13TM", -3.8, 10.5,  0., 0, "ONLY");
+  gMC->Gspos("QTD1", 1, "Q13TM", -3.8, boxpar[1]+fTDIAperturePos,  0., 0, "ONLY");
   boxpar[0] = 11.0/2.;
   boxpar[1] = 9.0/2.;
   boxpar[2] = 540.0/2.;
   gMC->Gsvolu("QTD2", "BOX ", idtmed[7], boxpar, 3);
-  gMC->Gspos("QTD2", 1, "Q13TM", -3.8, -10.5,  0., 0, "ONLY");  
+  gMC->Gspos("QTD2", 1, "Q13TM", -3.8, -boxpar[1]-fTDIApertureNeg,  0., 0, "ONLY");  
   boxpar[0] = 5.1/2.;
   boxpar[1] = 0.2/2.;
   boxpar[2] = 540.0/2.;
   gMC->Gsvolu("QTD3", "BOX ", idtmed[7], boxpar, 3);
-  gMC->Gspos("QTD3", 1, "Q13TM", -3.8+5.5+boxpar[0], 6.1,  0., 0, "ONLY");  
-  gMC->Gspos("QTD3", 2, "Q13TM", -3.8+5.5+boxpar[0], -6.1,  0., 0, "ONLY"); 
-  gMC->Gspos("QTD3", 3, "Q13TM", -3.8-5.5-boxpar[0], 6.1,  0., 0, "ONLY");  
-  gMC->Gspos("QTD3", 4, "Q13TM", -3.8-5.5-boxpar[0], -6.1,  0., 0, "ONLY");  
+  gMC->Gspos("QTD3", 1, "Q13TM", -3.8+5.5+boxpar[0], fTDIAperturePos,  0., 0, "ONLY");  
+  gMC->Gspos("QTD3", 2, "Q13TM", -3.8+5.5+boxpar[0], -fTDIApertureNeg,  0., 0, "ONLY"); 
+  gMC->Gspos("QTD3", 3, "Q13TM", -3.8-5.5-boxpar[0], fTDIAperturePos,  0., 0, "ONLY");  
+  gMC->Gspos("QTD3", 4, "Q13TM", -3.8-5.5-boxpar[0], -fTDIApertureNeg,  0., 0, "ONLY");  
+  printf("  AliZDCv3 -> TDI apertures +%1.2f/-%1.2f cm\n\n", 
+       fTDIAperturePos, fTDIApertureNeg);
   //
   tubspar[0] = 12.0/2.;
   tubspar[1] = 12.4/2.;
@@ -1345,8 +1426,8 @@ void AliZDCv3::CreateBeamLine()
   // -- Luminometer (Cu box) in front of ZN - side A
   boxpar[0] = 8.0/2.;
   boxpar[1] = 8.0/2.;
-  boxpar[2] = 15./2.;
-  gMC->Gsvolu("QLUA", "BOX ", idtmed[6], boxpar, 3);
+  boxpar[2] = fLumiLength/2.;
+  gMC->Gsvolu("QLUA", "BOX ", idtmed[9], boxpar, 3);
   gMC->Gspos("QLUA", 1, "ZDCA", 0., 0.,  fPosZNA[2]-66.-boxpar[2], 0, "ONLY");
   //printf("   QLUA LUMINOMETER from z = %1.2f to z= %1.2f\n\n",  fPosZNA[2]-66., fPosZNA[2]-66.-2*boxpar[2]);
 
@@ -1844,105 +1925,6 @@ void AliZDCv3::CreateZDC()
   
 }
  
-//_____________________________________________________________________________
-void AliZDCv3::DrawModule() const
-{
-  //
-  // Draw a shaded view of the Zero Degree Calorimeter version 1
-  //
-
-  // Set everything unseen
-  gMC->Gsatt("*", "seen", -1);
-  // 
-  // Set ALIC mother transparent
-  gMC->Gsatt("ALIC","SEEN",0);
-  //
-  // Set the volumes visible
-  gMC->Gsatt("ZDCC","SEEN",0);
-  gMC->Gsatt("QT01","SEEN",1);
-  gMC->Gsatt("QT02","SEEN",1);
-  gMC->Gsatt("QT03","SEEN",1);
-  gMC->Gsatt("QT04","SEEN",1);
-  gMC->Gsatt("QT05","SEEN",1);
-  gMC->Gsatt("QT06","SEEN",1);
-  gMC->Gsatt("QT07","SEEN",1);
-  gMC->Gsatt("QT08","SEEN",1);
-  gMC->Gsatt("QT09","SEEN",1);
-  gMC->Gsatt("QT10","SEEN",1);
-  gMC->Gsatt("QT11","SEEN",1);
-  gMC->Gsatt("QT12","SEEN",1);
-  gMC->Gsatt("QT13","SEEN",1);
-  gMC->Gsatt("QC01","SEEN",1);
-  gMC->Gsatt("QC02","SEEN",1);
-  gMC->Gsatt("QC03","SEEN",1);
-  gMC->Gsatt("QC04","SEEN",1);
-  gMC->Gsatt("QC05","SEEN",1);
-  gMC->Gsatt("QC06","SEEN",1);
-  gMC->Gsatt("QC07","SEEN",1);
-  gMC->Gsatt("QC08","SEEN",1);
-  gMC->Gsatt("QC09","SEEN",1);
-  gMC->Gsatt("QC10","SEEN",1);
-  gMC->Gsatt("MQXL","SEEN",1);
-  gMC->Gsatt("YMQL","SEEN",1);
-  gMC->Gsatt("MQX ","SEEN",1);
-  gMC->Gsatt("YMQ ","SEEN",1);
-  gMC->Gsatt("ZQYX","SEEN",1);
-  gMC->Gsatt("MD1 ","SEEN",1);
-  gMC->Gsatt("MD1V","SEEN",1);
-  gMC->Gsatt("YD1 ","SEEN",1);
-  gMC->Gsatt("MD2 ","SEEN",1);
-  gMC->Gsatt("YD2 ","SEEN",1);
-  gMC->Gsatt("ZNEU","SEEN",0);
-  gMC->Gsatt("ZNF1","SEEN",0);
-  gMC->Gsatt("ZNF2","SEEN",0);
-  gMC->Gsatt("ZNF3","SEEN",0);
-  gMC->Gsatt("ZNF4","SEEN",0);
-  gMC->Gsatt("ZNG1","SEEN",0);
-  gMC->Gsatt("ZNG2","SEEN",0);
-  gMC->Gsatt("ZNG3","SEEN",0);
-  gMC->Gsatt("ZNG4","SEEN",0);
-  gMC->Gsatt("ZNTX","SEEN",0);
-  gMC->Gsatt("ZN1 ","COLO",4); 
-  gMC->Gsatt("ZN1 ","SEEN",1);
-  gMC->Gsatt("ZNSL","SEEN",0);
-  gMC->Gsatt("ZNST","SEEN",0);
-  gMC->Gsatt("ZPRO","SEEN",0);
-  gMC->Gsatt("ZPF1","SEEN",0);
-  gMC->Gsatt("ZPF2","SEEN",0);
-  gMC->Gsatt("ZPF3","SEEN",0);
-  gMC->Gsatt("ZPF4","SEEN",0);
-  gMC->Gsatt("ZPG1","SEEN",0);
-  gMC->Gsatt("ZPG2","SEEN",0);
-  gMC->Gsatt("ZPG3","SEEN",0);
-  gMC->Gsatt("ZPG4","SEEN",0);
-  gMC->Gsatt("ZPTX","SEEN",0);
-  gMC->Gsatt("ZP1 ","COLO",6); 
-  gMC->Gsatt("ZP1 ","SEEN",1);
-  gMC->Gsatt("ZPSL","SEEN",0);
-  gMC->Gsatt("ZPST","SEEN",0);
-  gMC->Gsatt("ZEM ","COLO",7); 
-  gMC->Gsatt("ZEM ","SEEN",1);
-  gMC->Gsatt("ZEMF","SEEN",0);
-  gMC->Gsatt("ZETR","SEEN",0);
-  gMC->Gsatt("ZEL0","SEEN",0);
-  gMC->Gsatt("ZEL1","SEEN",0);
-  gMC->Gsatt("ZEL2","SEEN",0);
-  gMC->Gsatt("ZEV0","SEEN",0);
-  gMC->Gsatt("ZEV1","SEEN",0);
-  gMC->Gsatt("ZES0","SEEN",0);
-  gMC->Gsatt("ZES1","SEEN",0);
-  //
-  gMC->Gdopt("hide", "on");
-  gMC->Gdopt("shad", "on");
-  gMC->Gsatt("*", "fill", 7);
-  gMC->SetClipBox(".");
-  gMC->SetClipBox("*", 0, 100, -100, 100, 12000, 16000);
-  gMC->DefaultRange();
-  gMC->Gdraw("alic", 40, 30, 0, 488, 220, .07, .07);
-  gMC->Gdhead(1111, "Zero Degree Calorimeter Version 3");
-  gMC->Gdman(18, 4, "MAN");
-}
-
 //_____________________________________________________________________________
 void AliZDCv3::CreateMaterials()
 {
@@ -1986,11 +1968,15 @@ void AliZDCv3::CreateMaterials()
   
   // --- Lead 
   ubuf[0] = 1.12;
-  AliMaterial(5, "LEAD", 207.19, 82., 11.35, .56, 18.5, ubuf, 1);
+  AliMaterial(5, "LEAD", 207.19, 82., 11.35, .56, 0., ubuf, 1);
 
   // --- Copper (energy loss taken into account)
   ubuf[0] = 1.10;
   AliMaterial(6, "COPP0", 63.54, 29., 8.96, 1.4, 0., ubuf, 1);
+
+  // --- Copper 
+  ubuf[0] = 1.10;
+  AliMaterial(9, "COPP1", 63.54, 29., 8.96, 1.4, 0., ubuf, 1);
   
   // --- Iron (energy loss taken into account)
   ubuf[0] = 1.1;
@@ -1999,6 +1985,10 @@ void AliZDCv3::CreateMaterials()
   // --- Iron (no energy loss)
   ubuf[0] = 1.1;
   AliMaterial(8, "IRON1", 55.85, 26., 7.87, 1.76, 0., ubuf, 1);
+  
+  // --- Tatalum 
+  ubuf[0] = 1.1;
+  AliMaterial(13, "TANT", 183.84, 74., 19.3, 0.35, 0., ubuf, 1);
     
   // ---------------------------------------------------------  
   Float_t aResGas[3]={1.008,12.0107,15.9994};
@@ -2027,8 +2017,8 @@ void AliZDCv3::CreateMaterials()
   // --- Fibers (SiO2) = 3 ; 
   // --- Fibers (SiO2) = 4 ; 
   // --- Lead = 5 ; 
-  // --- Copper (with energy loss)= 6 ;
-  // --- Copper (with energy loss)= 13 ; 
+  // --- Copper (with high thr.)= 6 ;
+  // --- Copper (with low thr.)=  9;
   // --- Iron (with energy loss) = 7 ; 
   // --- Iron (without energy loss) = 8 ; 
   // --- Vacuum (no field) = 10 
@@ -2042,6 +2032,7 @@ void AliZDCv3::CreateMaterials()
   Float_t stmin  = 0.01;   // Min. value 4 max. step (cm)
   Float_t stemax = 1.;     // Max. step permitted (cm) 
   Float_t tmaxfd = 0.;     // Maximum angle due to field (degrees) 
+  Float_t tmaxfdv = 0.1;   // Maximum angle due to field (degrees) 
   Float_t deemax = -1.;    // Maximum fractional energy loss
   Float_t nofieldm = 0.;   // Max. field value (no field)
   Float_t fieldm = 45.;    // Max. field value (with field)
@@ -2051,7 +2042,7 @@ void AliZDCv3::CreateMaterials()
   Int_t ifield =2;         // IFIELD=2 -> magnetic field defined in AliMagFC.h
   // *****************************************************
   
-  AliMedium(1, "ZTANT", 1, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(1, "ZWALL", 1, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
   AliMedium(2, "ZBRASS",2, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
   AliMedium(3, "ZSIO2", 3, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
   AliMedium(4, "ZQUAR", 3, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
@@ -2059,11 +2050,12 @@ void AliZDCv3::CreateMaterials()
   AliMedium(6, "ZCOPP", 6, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
   AliMedium(7, "ZIRON", 7, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
   AliMedium(8, "ZIRONN",8, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(9, "ZCOPL", 6, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
   AliMedium(10,"ZVOID",10, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(12,"ZAIR", 12, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  //
-  AliMedium(11,"ZVOIM",11, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-
+  AliMedium(11,"ZVOIM",11, isvol, ifield, fieldm, tmaxfdv, stemax, deemax, epsil, stmin);
+  AliMedium(12,"ZAIR", 12, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(13,"ZTANT",13, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
+  AliMedium(14, "ZIRONT", 7, isvol, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
 
 } 
 
@@ -2105,97 +2097,17 @@ void AliZDCv3::Init()
 {
  InitTables();
   Int_t *idtmed = fIdtmed->GetArray();  
-  Int_t i;
-  // Thresholds for showering in the ZDCs 
-  i = 1; //tantalum
-  gMC->Gstpar(idtmed[i], "CUTGAM", .001);
-  gMC->Gstpar(idtmed[i], "CUTELE", .001);
-  gMC->Gstpar(idtmed[i], "CUTNEU", .01);
-  gMC->Gstpar(idtmed[i], "CUTHAD", .01);
-  i = 2; //brass
-  gMC->Gstpar(idtmed[i], "CUTGAM", .001);
-  gMC->Gstpar(idtmed[i], "CUTELE", .001);
-  gMC->Gstpar(idtmed[i], "CUTNEU", .01);
-  gMC->Gstpar(idtmed[i], "CUTHAD", .01);
-  i = 5; //lead
-  gMC->Gstpar(idtmed[i], "CUTGAM", .001);
-  gMC->Gstpar(idtmed[i], "CUTELE", .001);
-  gMC->Gstpar(idtmed[i], "CUTNEU", .01);
-  gMC->Gstpar(idtmed[i], "CUTHAD", .01);
-  
-  // Avoid too detailed showering in TDI 
-  i = 6; //copper
-  gMC->Gstpar(idtmed[i], "CUTGAM", .1);
-  gMC->Gstpar(idtmed[i], "CUTELE", .1);
-  gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
-  gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
-  
-  // Avoid too detailed showering along the beam line 
-  i = 7; //iron with energy loss (ZIRON)
-  gMC->Gstpar(idtmed[i], "CUTGAM", .1);
-  gMC->Gstpar(idtmed[i], "CUTELE", .1);
-  gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
-  gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
-  
-  // Avoid too detailed showering along the beam line 
-  i = 8; //iron with energy loss (ZIRONN)
-  gMC->Gstpar(idtmed[i], "CUTGAM", .1);
-  gMC->Gstpar(idtmed[i], "CUTELE", .1);
-  gMC->Gstpar(idtmed[i], "CUTNEU", 1.);
-  gMC->Gstpar(idtmed[i], "CUTHAD", 1.);
-  
-  // Avoid interaction in fibers (only energy loss allowed) 
-  i = 3; //fibers (ZSI02)
-  gMC->Gstpar(idtmed[i], "DCAY", 0.);
-  gMC->Gstpar(idtmed[i], "MULS", 0.);
-  gMC->Gstpar(idtmed[i], "PFIS", 0.);
-  gMC->Gstpar(idtmed[i], "MUNU", 0.);
-  gMC->Gstpar(idtmed[i], "LOSS", 1.);
-  gMC->Gstpar(idtmed[i], "PHOT", 0.);
-  gMC->Gstpar(idtmed[i], "COMP", 0.);
-  gMC->Gstpar(idtmed[i], "PAIR", 0.);
-  gMC->Gstpar(idtmed[i], "BREM", 0.);
-  gMC->Gstpar(idtmed[i], "DRAY", 0.);
-  gMC->Gstpar(idtmed[i], "ANNI", 0.);
-  gMC->Gstpar(idtmed[i], "HADR", 0.);
-  i = 4; //fibers (ZQUAR)
-  gMC->Gstpar(idtmed[i], "DCAY", 0.);
-  gMC->Gstpar(idtmed[i], "MULS", 0.);
-  gMC->Gstpar(idtmed[i], "PFIS", 0.);
-  gMC->Gstpar(idtmed[i], "MUNU", 0.);
-  gMC->Gstpar(idtmed[i], "LOSS", 1.);
-  gMC->Gstpar(idtmed[i], "PHOT", 0.);
-  gMC->Gstpar(idtmed[i], "COMP", 0.);
-  gMC->Gstpar(idtmed[i], "PAIR", 0.);
-  gMC->Gstpar(idtmed[i], "BREM", 0.);
-  gMC->Gstpar(idtmed[i], "DRAY", 0.);
-  gMC->Gstpar(idtmed[i], "ANNI", 0.);
-  gMC->Gstpar(idtmed[i], "HADR", 0.);
-  
-  // Avoid interaction in void 
-  i = 11; //void with field
-  gMC->Gstpar(idtmed[i], "DCAY", 0.);
-  gMC->Gstpar(idtmed[i], "MULS", 0.);
-  gMC->Gstpar(idtmed[i], "PFIS", 0.);
-  gMC->Gstpar(idtmed[i], "MUNU", 0.);
-  gMC->Gstpar(idtmed[i], "LOSS", 0.);
-  gMC->Gstpar(idtmed[i], "PHOT", 0.);
-  gMC->Gstpar(idtmed[i], "COMP", 0.);
-  gMC->Gstpar(idtmed[i], "PAIR", 0.);
-  gMC->Gstpar(idtmed[i], "BREM", 0.);
-  gMC->Gstpar(idtmed[i], "DRAY", 0.);
-  gMC->Gstpar(idtmed[i], "ANNI", 0.);
-  gMC->Gstpar(idtmed[i], "HADR", 0.);
-
   //
-  fMedSensZN  = idtmed[1];  // Sensitive volume: ZN passive material
-  fMedSensZP  = idtmed[2];  // Sensitive volume: ZP passive material
-  fMedSensF1  = idtmed[3];  // Sensitive volume: fibres type 1
-  fMedSensF2  = idtmed[4];  // Sensitive volume: fibres type 2
-  fMedSensZEM = idtmed[5];  // Sensitive volume: ZEM passive material
-  fMedSensTDI = idtmed[6];  // Sensitive volume: TDI Cu shield
-  fMedSensPI  = idtmed[7];  // Sensitive volume: beam pipes
-  fMedSensGR  = idtmed[12]; // Sensitive volume: air into the grooves
+  fMedSensZN     = idtmed[1];  // Sensitive volume: ZN passive material
+  fMedSensZP     = idtmed[2];  // Sensitive volume: ZP passive material
+  fMedSensF1     = idtmed[3];  // Sensitive volume: fibres type 1
+  fMedSensF2     = idtmed[4];  // Sensitive volume: fibres type 2
+  fMedSensZEM    = idtmed[5];  // Sensitive volume: ZEM passive material
+  fMedSensTDI    = idtmed[6];  // Sensitive volume: TDI Cu shield
+  fMedSensPI     = idtmed[7];  // Sensitive volume: beam pipes
+  fMedSensLumi   = idtmed[9];  // Sensitive volume: luminometer
+  fMedSensGR     = idtmed[12]; // Sensitive volume: air into the grooves
+  fMedSensVColl  = idtmed[13]; // Sensitive volume: collimator jaws
 }
 
 //_____________________________________________________________________________
@@ -2206,80 +2118,132 @@ void AliZDCv3::InitTables()
  //
 
   Int_t k, j;
-
-  char *lightfName1,*lightfName2,*lightfName3,*lightfName4,
-       *lightfName5,*lightfName6,*lightfName7,*lightfName8;
-  FILE *fp1, *fp2, *fp3, *fp4, *fp5, *fp6, *fp7, *fp8;
+  int read=1;
 
   //  --- Reading light tables for ZN 
-  lightfName1 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362207s");
-  if((fp1 = fopen(lightfName1,"r")) == NULL){
+  char *lightfName1 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362207s");
+  FILE *fp1 = fopen(lightfName1,"r");
+  if(fp1 == NULL){
      printf("Cannot open file fp1 \n");
      return;
   }
-  lightfName2 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362208s");
-  if((fp2 = fopen(lightfName2,"r")) == NULL){
+  else{
+    for(k=0; k<fNalfan; k++){
+      for(j=0; j<fNben; j++){
+       read = fscanf(fp1,"%f",&fTablen[0][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 1");
+      }
+    }
+    fclose(fp1);
+  }
+  char *lightfName2 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362208s");
+  FILE *fp2 = fopen(lightfName2,"r");
+  if(fp2 == NULL){
      printf("Cannot open file fp2 \n");
      return;
   }  
-  lightfName3 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362209s");
-  if((fp3 = fopen(lightfName3,"r")) == NULL){
+  else{
+    for(k=0; k<fNalfan; k++){
+      for(j=0; j<fNben; j++){
+       read = fscanf(fp2,"%f",&fTablen[1][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 2");
+      }
+    }
+    fclose(fp2);
+  }
+  char *lightfName3 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362209s");
+  FILE *fp3 = fopen(lightfName3,"r");
+  if(fp3 == NULL){
      printf("Cannot open file fp3 \n");
      return;
   }
-  lightfName4 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362210s");
-  if((fp4 = fopen(lightfName4,"r")) == NULL){
+  else{
+    for(k=0; k<fNalfan; k++){
+      for(j=0; j<fNben; j++){
+       read = fscanf(fp3,"%f",&fTablen[2][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 3");
+      }
+    }
+    fclose(fp3);
+  }
+  char *lightfName4 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362210s");
+  FILE *fp4 = fopen(lightfName4,"r");
+  if(fp4 == NULL){
      printf("Cannot open file fp4 \n");
      return;
   }
-  
-  for(k=0; k<fNalfan; k++){
-     for(j=0; j<fNben; j++){
-       fscanf(fp1,"%f",&fTablen[0][k][j]);
-       fscanf(fp2,"%f",&fTablen[1][k][j]);
-       fscanf(fp3,"%f",&fTablen[2][k][j]);
-       fscanf(fp4,"%f",&fTablen[3][k][j]);
-     } 
+  else{
+    for(k=0; k<fNalfan; k++){
+      for(j=0; j<fNben; j++){
+       read = fscanf(fp4,"%f",&fTablen[3][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 4");
+      }
+    }
+    fclose(fp4);
   }
-  fclose(fp1);
-  fclose(fp2);
-  fclose(fp3);
-  fclose(fp4);
-  
+    
   //  --- Reading light tables for ZP and ZEM
-  lightfName5 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552207s");
-  if((fp5 = fopen(lightfName5,"r")) == NULL){
+  char *lightfName5 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552207s");
+  FILE *fp5 = fopen(lightfName5,"r");
+  if(fp5 == NULL){
      printf("Cannot open file fp5 \n");
      return;
   }
-  lightfName6 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552208s");
-  if((fp6 = fopen(lightfName6,"r")) == NULL){
+  else{
+    for(k=0; k<fNalfap; k++){
+      for(j=0; j<fNbep; j++){
+       read = fscanf(fp5,"%f",&fTablep[0][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 5");
+      }
+    }
+    fclose(fp5);
+  }
+  char *lightfName6 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552208s");
+  FILE *fp6 = fopen(lightfName6,"r");
+  if(fp6 == NULL){
      printf("Cannot open file fp6 \n");
      return;
   }
-  lightfName7 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552209s");
-  if((fp7 = fopen(lightfName7,"r")) == NULL){
+  else{
+    for(k=0; k<fNalfap; k++){
+      for(j=0; j<fNbep; j++){
+       read = fscanf(fp6,"%f",&fTablep[1][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 6");
+      }
+    }
+    fclose(fp6);
+  }
+  char *lightfName7 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552209s");
+  FILE *fp7 = fopen(lightfName7,"r");
+  if(fp7 == NULL){
      printf("Cannot open file fp7 \n");
      return;
   }
-  lightfName8 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552210s");
-  if((fp8 = fopen(lightfName8,"r")) == NULL){
+  else{
+    for(k=0; k<fNalfap; k++){
+      for(j=0; j<fNbep; j++){
+       read = fscanf(fp7,"%f",&fTablep[2][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 7");
+      }
+    }
+   fclose(fp7);
+  }
+  char *lightfName8 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552210s");
+  FILE *fp8 = fopen(lightfName8,"r");
+  if(fp8 == NULL){
      printf("Cannot open file fp8 \n");
      return;
   }
-  
-  for(k=0; k<fNalfap; k++){
-     for(j=0; j<fNbep; j++){
-       fscanf(fp5,"%f",&fTablep[0][k][j]);
-       fscanf(fp6,"%f",&fTablep[1][k][j]);
-       fscanf(fp7,"%f",&fTablep[2][k][j]);
-       fscanf(fp8,"%f",&fTablep[3][k][j]);
-     } 
+  else{
+    for(k=0; k<fNalfap; k++){
+      for(j=0; j<fNbep; j++){
+       read = fscanf(fp8,"%f",&fTablep[3][k][j]);
+       if(read==0) AliDebug(3, " Error in reading light table 8");
+      }
+    }
+   fclose(fp8);
   }
-  fclose(fp5);
-  fclose(fp6);
-  fclose(fp7);
-  fclose(fp8);
+
 }
 //_____________________________________________________________________________
 void AliZDCv3::StepManager()
@@ -2288,22 +2252,21 @@ void AliZDCv3::StepManager()
   // Routine called at every step in the Zero Degree Calorimeters
   //
   Int_t   j, vol[2]={0,0}, ibeta=0, ialfa=0, ibe=0, nphe=0;
-  Float_t hits[12], x[3], xdet[3], um[3], ud[3];
-  Float_t m=0., ekin=0., destep=0., be=0., out=0.;
-  // Parametrization for light guide uniformity
-  // NEW!!! Light guide tilted @ 51 degrees
-  Float_t guiPar[4]={0.31,-0.0006305,0.01337,0.8895};
-  Double_t s[3], p[3];
+  Float_t hits[13], x[3], xdet[3]={999.,999.,999.}, um[3], ud[3];
+  Float_t destep=0., be=0., out=0.;
+  Double_t s[3], p[4];
   const char *knamed;
   //
-  for(j=0;j<12;j++) hits[j]=-999.;
+  for(j=0;j<13;j++) hits[j]=-999.;
   //
-  // --- This part is for no shower developement in beam pipe and TDI
-  // If particle interacts with beam pipe or TDI -> return
-  if((gMC->CurrentMedium() == fMedSensPI) || (gMC->CurrentMedium() == fMedSensTDI)){ 
+  // --- This part is for no shower developement in beam pipe, TDI, VColl
+  // If particle interacts with beam pipe, TDI, VColl -> return
+  if(fNoShower==1 && ((gMC->CurrentMedium() == fMedSensPI) || (gMC->CurrentMedium() == fMedSensTDI) ||  
+     (gMC->CurrentMedium() == fMedSensVColl || (gMC->CurrentMedium() == fMedSensLumi)))){ 
+    
     // If option NoShower is set -> StopTrack
+
     Int_t ipr = 0; 
-    if(fNoShower==1){
       gMC->TrackPosition(s[0],s[1],s[2]);
       if(gMC->CurrentMedium() == fMedSensPI){
         knamed = gMC->CurrentVolName();
@@ -2317,7 +2280,6 @@ void AliZDCv3::StepManager()
          else fpLostD1A += 1;
          ipr=1;
        }
-       else if(!strncmp(knamed,"QAL",3)) fnTrou++;
       }
       else if(gMC->CurrentMedium() == fMedSensTDI){ 
         knamed = gMC->CurrentVolName();
@@ -2327,11 +2289,12 @@ void AliZDCv3::StepManager()
          ipr=1;
         }
        else if(!strncmp(knamed,"QTD",3)) fpLostTDI += 1;
-       else if(!strncmp(knamed,"QLU",3)){
-         if(s[2]<0) fnLumiC ++;
-         else fnLumiA++;
-         ipr=1;
-       }
+      }
+      else if(gMC->CurrentMedium() == fMedSensVColl){ 
+        knamed = gMC->CurrentVolName();
+        if(!strncmp(knamed,"QCVC",4)) fpcVCollC++;
+       else if(!strncmp(knamed,"QCVA",4))  fpcVCollA++;
+       ipr=1;
       }
       //
       //gMC->TrackMomentum(p[0], p[1], p[2], p[3]);
@@ -2341,23 +2304,20 @@ void AliZDCv3::StepManager()
       if(ipr!=0){
         printf("\n\t **********************************\n");
         printf("\t ********** Side C **********\n");
-        printf("\t # of spectators in IT = %d\n",fpLostITC);
-        printf("\t # of spectators in D1 = %d\n",fpLostD1C);
-        printf("\t # of spectators in luminometer = %d\n",fnLumiC);
+        printf("\t # of particles in IT = %d\n",fpLostITC);
+        printf("\t # of particles in D1 = %d\n",fpLostD1C);
+        printf("\t # of particles in VColl = %d\n",fpcVCollC);
         printf("\t ********** Side A **********\n");
-        printf("\t # of spectators in IT = %d\n",fpLostITA);
-        printf("\t # of spectators in D1 = %d\n",fpLostD1A);
-        printf("\t # of spectators in TDI = %d\n",fpLostTDI);
-        printf("\t # of spectators in luminometer = %d\n",fnLumiA);
-        printf("\t # of spectators in trousers = %d\n",fnTrou);
+        printf("\t # of particles in IT = %d\n",fpLostITA);
+        printf("\t # of particles in D1 = %d\n",fpLostD1A);
+        printf("\t # of particles in TDI = %d\n",fpLostTDI);
+        printf("\t # of particles in VColl = %d\n",fpcVCollA);
         printf("\t **********************************\n");
       }
       gMC->StopTrack();
-    }
-    return;
+      return;
   }
   
-
   if((gMC->CurrentMedium() == fMedSensZN) || (gMC->CurrentMedium() == fMedSensZP) ||
      (gMC->CurrentMedium() == fMedSensGR) || (gMC->CurrentMedium() == fMedSensF1) ||
      (gMC->CurrentMedium() == fMedSensF2) || (gMC->CurrentMedium() == fMedSensZEM)){
@@ -2461,86 +2421,85 @@ void AliZDCv3::StepManager()
       }
     }    
     if((vol[1]!=1) && (vol[1]!=2) && (vol[1]!=3) && (vol[1]!=4))
-      AliError(Form("AliZDCv3 -> WRONG tower for det %d: tow %d with xdet=(%f, %f)\n",
+      AliError(Form(" WRONG tower for det %d: tow %d with xdet=(%f, %f)\n",
                vol[0], vol[1], xdet[0], xdet[1]));
     // Ch. debug
     //printf("\t *** det %d vol %d xdet(%f, %f)\n",vol[0], vol[1], xdet[0], xdet[1]);
     
     
-  // Store impact point and kinetic energy of the ENTERING particle
+    // Store impact point and kinetic energy of the ENTERING particle
     
-      if(gMC->IsTrackEntering()){
-        //Particle energy
-        gMC->TrackMomentum(p[0],p[1],p[2],p[3]);
-        hits[3] = p[3];
-        // Impact point on ZDC
-       // X takes into account the LHC x-axis sign
-       // which is opposite to positive x on detcetor front face
-       // for side A detectors (ZNA and ZPA)  
-        if(vol[0]==4 || vol[0]==5) hits[4] = -xdet[0];
-       else hits[4] = xdet[0];
-        hits[5] = xdet[1];
-       hits[6] = 0;
-        hits[7] = 0;
-        hits[8] = 0;
-        hits[9] = 0;
-       //
-       Int_t curTrackN = gAlice->GetMCApp()->GetCurrentTrackNumber();
-        TParticle *part = (gAlice->GetMCApp())->Particle(curTrackN);
-       hits[10] = part->GetPdgCode();
-       //printf("\t PDGCode = %d\n", part->GetPdgCode());
-        //
-       hits[11] = 1.0e09*gMC->TrackTime();
-       //printf("\t TrackTime = %f\n", hits[11]);
-
-       AddHit(curTrackN, vol, hits);
-       
-       if(fNoShower==1){
-         //printf("\t VolName %s -> det %d quad %d - x = %f, y = %f, z = %f\n", 
-           //knamed, vol[0], vol[1], x[0], x[1], x[2]);
-         if(vol[0]==1){
-           fnDetectedC += 1;
-           printf("      # of particles in ZNC = %d\n\n",fnDetectedC);
-         }
-         else if(vol[0]==2){
-           fpDetectedC += 1;
-           printf("      # of particles in ZPC = %d\n\n",fpDetectedC);
-         }
-         else if(vol[0]==4){
-           fnDetectedA += 1;
-           printf("      # of particles in ZNA = %d\n\n",fnDetectedA);     
-         }
-         else if(vol[0]==5){
-           fpDetectedA += 1;
-           printf("      # of particles in ZPA = %d\n\n",fpDetectedA);      
-         }
-          //
-         //printf("\t Particle: mass = %1.3f, E = %1.3f GeV, pz = %1.2f GeV -> stopped in volume %s\n", 
-          //   gMC->TrackMass(), p[3], p[2], gMC->CurrentVolName());
-         //
-         gMC->StopTrack();
-         return;
-       }
+    if(gMC->IsTrackEntering()){
+      //Particle energy
+      gMC->TrackMomentum(p[0],p[1],p[2],p[3]);
+      hits[3] = p[3];
+      
+      // Impact point on ZDC
+      // X takes into account the LHC x-axis sign
+      // which is opposite to positive x on detector front face
+      // for side A detectors (ZNA and ZPA)  
+      if(vol[0]==4 || vol[0]==5){
+        hits[4] = -xdet[0];
       }
-             
-      // Charged particles -> Energy loss
-      if((destep=gMC->Edep())){
-         if(gMC->IsTrackStop()){
-           gMC->TrackMomentum(p[0],p[1],p[2],p[3]);
-          m = gMC->TrackMass();
-          ekin = p[3]-m;
-          hits[9] = ekin;
-          hits[7] = 0.;
-          hits[8] = 0.;
-          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
-          }
-        else{
-          hits[9] = destep;
-          hits[7] = 0.;
-          hits[8] = 0.;
-          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
-          }
+      else{
+        hits[4] = xdet[0];
+      }
+      hits[5] = xdet[1];
+      hits[6] = 0;
+      hits[7] = 0;
+      hits[8] = 0;
+      hits[9] = 0;
+      //
+      Int_t curTrackN = gAlice->GetMCApp()->GetCurrentTrackNumber();
+      TParticle *part = gAlice->GetMCApp()->Particle(curTrackN);
+      hits[10] = part->GetPdgCode();
+      //printf("\t PDGCode = %d\n", part->GetPdgCode());
+      //
+      Int_t imo = part->GetFirstMother();
+      if(imo>0){
+       TParticle * pmot = gAlice->GetMCApp()->Particle(imo);
+       hits[11] = pmot->GetPdgCode();
+      }
+      else hits[11]=0;
+      //
+      hits[12] = 1.0e09*gMC->TrackTime(); // in ns!
+      //printf("\t TrackTime = %f\n", hits[12]);
+
+      AddHit(curTrackN, vol, hits);
+
+      if(fNoShower==1){
+        if(vol[0]==1){
+          fnDetectedC += 1;
+          if(fnDetectedC==1) printf("  ### Particle in ZNC\n\n");
+        }
+        else if(vol[0]==2){
+          fpDetectedC += 1;
+          if(fpDetectedC==1) printf("  ### Particle in ZPC\n\n");
+        }
+        else if(vol[0]==4){
+          fnDetectedA += 1;
+          if(fnDetectedA==1) printf("  ### Particle in ZNA\n\n");        
+        }
+        else if(vol[0]==5){
+          fpDetectedA += 1;
+          if(fpDetectedA==1) printf("  ### Particle in ZPA\n\n");       
+        }
+       //
+        //printf("\t Pc: x %1.2f y %1.2f z %1.2f  E %1.2f GeV pz = %1.2f GeV in volume %s\n", 
+        //   x[0],x[1],x[3],p[3],p[2],gMC->CurrentVolName());
+        //
+        gMC->StopTrack();
+        return;
       }
+    }
+          
+    // Particle energy loss
+    if(gMC->Edep() != 0){
+      hits[9] = gMC->Edep();
+      hits[7] = 0.;
+      hits[8] = 0.;
+      AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
+    }
   }
  
 
@@ -2590,9 +2549,7 @@ void AliZDCv3::StepManager()
        }
  
        ibe = Int_t(be*1000.+1);
-       //if((vol[0]==1))      radius = fFibZN[1];
-       //else if((vol[0]==2)) radius = fFibZP[1];
+  
        //Looking into the light tables 
        Float_t charge = gMC->TrackCharge();
        
@@ -2633,7 +2590,7 @@ void AliZDCv3::StepManager()
           AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
-       else if((vol[0]==3)) {  // (3) ZEM fibres
+       else if(vol[0]==3) {    // (3) ZEM fibres
          if(ibe>fNbep) ibe=fNbep;
          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
         gMC->TrackPosition(s[0],s[1],s[2]);
@@ -2646,6 +2603,10 @@ void AliZDCv3::StepManager()
         Float_t z = -xalic[2]+fPosZEM[2]+2*fZEMLength-xalic[1];
         //z = xalic[2]-fPosZEM[2]-fZEMLength-xalic[1]*(TMath::Tan(45.*kDegrad));
          //printf("    fPosZEM[2]+2*fZEMLength = %f", fPosZEM[2]+2*fZEMLength);
+         //
+        // Parametrization for light guide uniformity
+         // NEW!!! Light guide tilted @ 51 degrees
+         Float_t guiPar[4]={0.31,-0.0006305,0.01337,0.8895};
         Float_t guiEff = guiPar[0]*(guiPar[1]*z*z+guiPar[2]*z+guiPar[3]);
         out = out*guiEff;
         nphe = gRandom->Poisson(out);