]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/AliZDCv2.cxx
Updated macro to generate spectators
[u/mrichter/AliRoot.git] / ZDC / AliZDCv2.cxx
index e7b585118cff741c10588ad6655644aa43c63183..2717488556aed9c86fcafc3c9c6e3875b5883ec2 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////
 //                                                                   //
-//             AliZDCv2 --- new ZDC geometry,                       //
+//             AliZDCv2 --- new ZDC geometry                        //
 //         with the EM ZDC at about 10 m from IP                    //
 //             Just one set of ZDC is inserted                      //
 //      (on the same side of the dimuon arm realtive to IP)         //
+//           Compensator in ZDC geometry (Nov. 2004)                //
 //                                                                   //  
 ///////////////////////////////////////////////////////////////////////
 
@@ -63,8 +63,7 @@ AliZDCv2::AliZDCv2() : AliZDC()
   fMedSensZP  = 0;
   fMedSensZEM = 0;
   fMedSensGR  = 0;
-//  fMedSensPI  = 0;
-//  fMedSensTDI = 0;
+
 }
  
 //_____________________________________________________________________________
@@ -77,11 +76,11 @@ AliZDCv2::AliZDCv2(const char *name, const char *title)
   //
   // Check that DIPO, ABSO, DIPO and SHIL is there (otherwise tracking is wrong!!!)
   
-  AliModule* PIPE=gAlice->GetModule("PIPE");
-  AliModule* ABSO=gAlice->GetModule("ABSO");
-  AliModule* DIPO=gAlice->GetModule("DIPO");
-  AliModule* SHIL=gAlice->GetModule("SHIL");
-  if((!PIPE) || (!ABSO) || (!DIPO) || (!SHIL)) {
+  AliModule* pipe=gAlice->GetModule("PIPE");
+  AliModule* abso=gAlice->GetModule("ABSO");
+  AliModule* dipo=gAlice->GetModule("DIPO");
+  AliModule* shil=gAlice->GetModule("SHIL");
+  if((!pipe) || (!abso) || (!dipo) || (!shil)) {
     Error("Constructor","ZDC needs PIPE, ABSO, DIPO and SHIL!!!\n");
     exit(1);
   } 
@@ -127,8 +126,8 @@ AliZDCv2::AliZDCv2(const char *name, const char *title)
   fDimZP[2] = 75.;    
   fPosZN[0] = 0.;
   fPosZN[1] = 1.2;
-  fPosZN[2] = -11680.; 
-  fPosZP[0] = -23.9;
+  fPosZN[2] = -11650.; 
+  fPosZP[0] = 23.9;
   fPosZP[1] = 0.;
   fPosZP[2] = -11600.; 
   fFibZN[0] = 0.;
@@ -141,7 +140,6 @@ AliZDCv2::AliZDCv2(const char *name, const char *title)
   // Parameters for EM calorimeter geometry
   fPosZEM[0] = 8.5;
   fPosZEM[1] = 0.;
-//  fPosZEM[2] = 830.;
   fPosZEM[2] = 735.;
   fZEMLength = 0.;
   
@@ -162,23 +160,27 @@ void AliZDCv2::CreateGeometry()
 //_____________________________________________________________________________
 void AliZDCv2::CreateBeamLine()
 {
+  //
+  // Create the beam line elements
+  //
   
-  Float_t zq, zd1, zd2;
+  Float_t zc, zq, zd1, zd2;
   Float_t conpar[9], tubpar[3], tubspar[5], boxpar[3];
   Int_t im1, im2;
   
   Int_t *idtmed = fIdtmed->GetArray();
   
   // -- Mother of the ZDCs (Vacuum PCON)
-  zd1 = 2092.;
+  // zd1 = 2092.; // (Without compensator in ZDC geometry)
+  zd1 = 1921.6;
   
   conpar[0] = 0.;
   conpar[1] = 360.;
   conpar[2] = 2.;
-  conpar[3] = -zd1;
+  conpar[3] = -13500.;
   conpar[4] = 0.;
   conpar[5] = 55.;
-  conpar[6] = -13500.;
+  conpar[6] = -zd1;
   conpar[7] = 0.;
   conpar[8] = 55.;
   gMC->Gsvolu("ZDC ", "PCON", idtmed[11], conpar, 9);
@@ -186,13 +188,14 @@ void AliZDCv2::CreateBeamLine()
 
   // -- FIRST SECTION OF THE BEAM PIPE (from compensator dipole to 
   //           the beginning of D1) 
-    
   tubpar[0] = 6.3/2.;
   tubpar[1] = 6.7/2.;
   // From beginning of ZDC volumes to beginning of D1
   tubpar[2] = (5838.3-zd1)/2.;
   gMC->Gsvolu("QT01", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT01", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT01 TUBE pipe from z = %f to z= %f (D1 beg.)\n",-zd1,-2*tubpar[2]-zd1);
   
   //-- SECOND SECTION OF THE BEAM PIPE (from the end of D1 to the
   //           beginning of D2) 
@@ -208,16 +211,20 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 958.5/2.;
   gMC->Gsvolu("QT02", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT02", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT02 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
 
   zd1 += 2.*tubpar[2];
   
   conpar[0] = 25./2.;
-  conpar[1] = 6.44/2.;
-  conpar[2] = 6.84/2.;
-  conpar[3] = 10./2.;
-  conpar[4] = 10.4/2.;
+  conpar[1] = 10./2.;
+  conpar[2] = 10.4/2.;
+  conpar[3] = 6.44/2.;
+  conpar[4] = 6.84/2.;
   gMC->Gsvolu("QC01", "CONE", idtmed[7], conpar, 5);
   gMC->Gspos("QC01", 1, "ZDC ", 0., 0., -conpar[0]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QC01 CONE pipe from z = %f to z= %f\n",-zd1,-2*conpar[0]-zd1);
 
   zd1 += 2.*conpar[0];
   
@@ -226,6 +233,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 50./2.;
   gMC->Gsvolu("QT03", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT03", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT03 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2]*2.;
   
@@ -234,6 +243,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 10./2.;
   gMC->Gsvolu("QT04", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT04", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT04 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
@@ -242,6 +253,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 3.16/2.;
   gMC->Gsvolu("QT05", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT05", 1, "ZDC ", 0., 0., -tubpar[0]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT05 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
@@ -250,16 +263,20 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 190./2.;
   gMC->Gsvolu("QT06", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT06", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT06 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
   conpar[0] = 30./2.;
-  conpar[1] = 10./2.;
-  conpar[2] = 10.4/2.;
-  conpar[3] = 20.6/2.;
-  conpar[4] = 21./2.;
+  conpar[1] = 20.6/2.;
+  conpar[2] = 21./2.;
+  conpar[3] = 10./2.;
+  conpar[4] = 10.4/2.;
   gMC->Gsvolu("QC02", "CONE", idtmed[7], conpar, 5);
   gMC->Gspos("QC02", 1, "ZDC ", 0., 0., -conpar[0]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QC02 CONE pipe from z = %f to z= %f\n",-zd1,-2*conpar[0]-zd1);
   
   zd1 += conpar[0] * 2.;
   
@@ -268,16 +285,20 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 450./2.;
   gMC->Gsvolu("QT07", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT07", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT07 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
   conpar[0] = 13.6/2.;
-  conpar[1] = 20.6/2.;
-  conpar[2] = 21./2.;
-  conpar[3] = 25.4/2.;
-  conpar[4] = 25.8/2.;
+  conpar[1] = 25.4/2.;
+  conpar[2] = 25.8/2.;
+  conpar[3] = 20.6/2.;
+  conpar[4] = 21./2.;
   gMC->Gsvolu("QC03", "CONE", idtmed[7], conpar, 5);
   gMC->Gspos("QC03", 1, "ZDC ", 0., 0., -conpar[0]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QC03 CONE pipe from z = %f to z= %f\n",-zd1,-2*conpar[0]-zd1);
   
   zd1 += conpar[0] * 2.;
   
@@ -286,6 +307,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 205.8/2.;
   gMC->Gsvolu("QT08", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT08", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT08 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
@@ -295,34 +318,32 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 515.4/2.;
   gMC->Gsvolu("QT09", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT09", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT09 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   // --- Insert TDI (inside ZDC volume)
-  
   boxpar[0] = 5.6;
   boxpar[1] = 5.6;
   boxpar[2] = 400./2.;
   gMC->Gsvolu("QTD1", "BOX ", idtmed[7], boxpar, 3);
-  gMC->Gspos("QTD1", 1, "ZDC ", 3., 10.6,  -tubpar[2]-zd1-56.3, 0, "ONLY");
-  gMC->Gspos("QTD1", 2, "ZDC ", 3., -10.6, -tubpar[2]-zd1-56.3, 0, "ONLY");
+  gMC->Gspos("QTD1", 1, "ZDC ", -3., 10.6,  -tubpar[2]-zd1-56.3, 0, "ONLY");
+  gMC->Gspos("QTD1", 2, "ZDC ", -3., -10.6, -tubpar[2]-zd1-56.3, 0, "ONLY");
   
   boxpar[0] = 0.2/2.;
   boxpar[1] = 5.6;
   boxpar[2] = 400./2.;
   gMC->Gsvolu("QTD2", "BOX ", idtmed[6], boxpar, 3);
-  gMC->Gspos("QTD2", 1, "ZDC ", 8.6+boxpar[0], 0., -tubpar[2]-zd1-56.3, 0, "ONLY");
+  gMC->Gspos("QTD2", 1, "ZDC ", -8.6-boxpar[0], 0., -tubpar[2]-zd1-56.3, 0, "ONLY");
   
-//  tubspar[0] = 6.2;  // R = 6.2 cm----------------------------------------
-//  tubspar[1] = 6.4;
-//  tubspar[2] = 400./2.;
-//  tubspar[3] = 180.-62.5;
-//  tubspar[4] = 180.+62.5;
   tubspar[0] = 10.5;   // R = 10.5 cm------------------------------------------
   tubspar[1] = 10.7;
   tubspar[2] = 400./2.;
-  tubspar[3] = 180.-75.5;
-  tubspar[4] = 180.+75.5;
+  tubspar[3] = 360.-75.5;
+  tubspar[4] = 75.5; 
   gMC->Gsvolu("QTD3", "TUBS", idtmed[6], tubspar, 5);
   gMC->Gspos("QTD3", 1, "ZDC ", 0., 0., -tubpar[2]-zd1-56.3, 0, "ONLY");
+  // Ch.debug
+  //printf("\n TDI volume from z = %f to z= %f\n",-tubpar[2]-zd1-56.3,-tubpar[2]-zd1-56.3-400.);
 
   zd1 += tubpar[2] * 2.;
   
@@ -332,6 +353,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 690./2.;
   gMC->Gsvolu("QT10", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT10", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT10 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
@@ -340,16 +363,20 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 778.5/2.;
   gMC->Gsvolu("QT11", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT11", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT11 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
   conpar[0] = 14.18/2.;
-  conpar[1] = 50./2.;
-  conpar[2] = 50.4/2.;
-  conpar[3] = 55./2.;
-  conpar[4] = 55.4/2.;
+  conpar[1] = 55./2.;
+  conpar[2] = 55.4/2.;
+  conpar[3] = 50./2.;
+  conpar[4] = 50.4/2.;
   gMC->Gsvolu("QC04", "CONE", idtmed[7], conpar, 5);
   gMC->Gspos("QC04", 1, "ZDC ", 0., 0., -conpar[0]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QC04 CONE pipe from z = %f to z= %f\n",-zd1,-2*conpar[0]-zd1);
   
   zd1 += conpar[0] * 2.;
   
@@ -358,16 +385,20 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 730./2.;
   gMC->Gsvolu("QT12", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT12", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT12 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
   conpar[0] = 36.86/2.;
-  conpar[1] = 55./2.;
-  conpar[2] = 55.4/2.;
-  conpar[3] = 68./2.;
-  conpar[4] = 68.4/2.;
+  conpar[1] = 68./2.;
+  conpar[2] = 68.4/2.;
+  conpar[3] = 55./2.;
+  conpar[4] = 55.4/2.;
   gMC->Gsvolu("QC05", "CONE", idtmed[7], conpar, 5);
   gMC->Gspos("QC05", 1, "ZDC ", 0., 0., -conpar[0]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QC05 CONE pipe from z = %f to z= %f\n",-zd1,-2*conpar[0]-zd1);
   
   zd1 += conpar[0] * 2.;
   
@@ -376,6 +407,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 927.3/2.;
   gMC->Gsvolu("QT13", "TUBE", idtmed[7], tubpar, 3);
   gMC->Gspos("QT13", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT13 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
@@ -384,6 +417,8 @@ void AliZDCv2::CreateBeamLine()
   tubpar[2] = 0.2/2.;
   gMC->Gsvolu("QT14", "TUBE", idtmed[8], tubpar, 3);
   gMC->Gspos("QT14", 1, "ZDC ", 0., 0., -tubpar[2]-zd1, 0, "ONLY");
+  // Ch.debug
+  //printf("\n QT14 TUBE pipe from z = %f to z= %f\n",-zd1,-2*tubpar[2]-zd1);
   
   zd1 += tubpar[2] * 2.;
   
@@ -391,15 +426,10 @@ void AliZDCv2::CreateBeamLine()
   tubpar[1] = 6.4/2.;
   tubpar[2] = 0.2/2.;
   gMC->Gsvolu("QT15", "TUBE", idtmed[11], tubpar, 3);
-  
   //-- Position QT15 inside QT14
   gMC->Gspos("QT15", 1, "QT14", -7.7, 0., 0., 0, "ONLY");
-  
-  tubpar[0] = 0./2.;
-  tubpar[1] = 6.4/2.;
-  tubpar[2] = 0.2/2.;
-  gMC->Gsvolu("QT16", "TUBE", idtmed[11], tubpar, 3);
-  
+
+  gMC->Gsvolu("QT16", "TUBE", idtmed[11], tubpar, 3);  
   //-- Position QT16 inside QT14
   gMC->Gspos("QT16", 1, "QT14", 7.7, 0., 0., 0, "ONLY");
   
@@ -417,50 +447,54 @@ void AliZDCv2::CreateBeamLine()
   gMC->Gsvolu("QT18", "TUBE", idtmed[7], tubpar, 3);
   
   // -- ROTATE PIPES 
-
-  Float_t angle = 0.143*kDegrad;
+  Float_t angle = 0.143*kDegrad; // Rotation angle
   
-  AliMatrix(im1, 90.-0.143, 0., 90., 90., 0.143, 180.);
+  AliMatrix(im1, 90.+0.143, 0., 90., 90., 0.143, 0.); // x<0
   gMC->Gspos("QT17", 1, "ZDC ", TMath::Sin(angle) * 680.8/ 2. - 9.4, 
-             0., -tubpar[2]-zd1, im1, "ONLY");
+             0., -tubpar[2]-zd1, im1, "ONLY"); 
             
-  AliMatrix(im2, 90.+0.143, 0., 90., 90., 0.143, 0.);
+  AliMatrix(im2, 90.-0.143, 0., 90., 90., 0.143, 180.); // x>0 (ZP)
   gMC->Gspos("QT18", 1, "ZDC ", 9.7 - TMath::Sin(angle) * 680.8 / 2., 
-             0., -tubpar[2]-zd1, im2, "ONLY");
-              
-  // -- BEAM PIPE ON THE OTHER SIDE OF I.P. TILL THE EM ZDC 
-  // -- 25 Mar 2003 -> This seem to be no longer needed
-  /*
-  Float_t zb = -800.;          // End of QBPM (from AliPIPEv0.cxx)
-  tubpar[0] = 8.0/2.;
-  tubpar[1] = 8.2/2.;
-  tubpar[2] = (1050+zb)/2.;    // From the end of QBPM to z=1050.
-  gMC->Gsvolu("QT19", "TUBE", idtmed[7], tubpar, 3);
-  gMC->Gspos("QT19", 1, "ALIC", 0., 0., zb - tubpar[2], 0, "ONLY");
-  */
-  
+             0., -tubpar[2]-zd1, im2, "ONLY"); 
+                
   // --  END OF BEAM PIPE VOLUME DEFINITION.  
   // ----------------------------------------------------------------
    
   // ----------------------------------------------------------------
-  // --  MAGNET DEFINITION  -> LHC OPTICS 6.4  
-  // ----------------------------------------------------------------
-  // -- INNER TRIPLET 
+  // --  MAGNET DEFINITION  -> LHC OPTICS 6.5  
+  // ----------------------------------------------------------------      
+  // --  COMPENSATOR DIPOLE (MBXW)
+  zc = 1921.6;   
+  
+  // --  GAP (VACUUM WITH MAGNETIC FIELD)
+  tubpar[0] = 0.;
+  tubpar[1] = 4.5;
+  tubpar[2] = 170./2.;
+  gMC->Gsvolu("MBXW", "TUBE", idtmed[11], tubpar, 3);
+
+  // --  YOKE 
+  tubpar[0] = 4.5;
+  tubpar[1] = 55.;
+  tubpar[2] = 170./2.;
+  gMC->Gsvolu("YMBX", "TUBE", idtmed[7], tubpar, 3);
+
+  gMC->Gspos("MBXW", 1, "ZDC ", 0., 0., -tubpar[2]-zc, 0, "ONLY");
+  gMC->Gspos("YMBX", 1, "ZDC ", 0., 0., -tubpar[2]-zc, 0, "ONLY");
   
-  zq = 2296.5;
   
+  // -- INNER TRIPLET 
+  zq = 2296.5; 
+
   // -- DEFINE MQXL AND MQX QUADRUPOLE ELEMENT 
-  
-  //     MQXL 
+  // --  MQXL 
   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
-  
   tubpar[0] = 0.;
   tubpar[1] = 3.5;
   tubpar[2] = 637./2.;
   gMC->Gsvolu("MQXL", "TUBE", idtmed[11], tubpar, 3);
   
-  // --  YOKE 
   
+  // --  YOKE 
   tubpar[0] = 3.5;
   tubpar[1] = 22.;
   tubpar[2] = 637./2.;
@@ -474,14 +508,12 @@ void AliZDCv2::CreateBeamLine()
   
   // --  MQX 
   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
-  
   tubpar[0] = 0.;
   tubpar[1] = 3.5;
   tubpar[2] = 550./2.;
   gMC->Gsvolu("MQX ", "TUBE", idtmed[11], tubpar, 3);
   
   // --  YOKE 
-  
   tubpar[0] = 3.5;
   tubpar[1] = 22.;
   tubpar[2] = 550./2.;
@@ -494,11 +526,9 @@ void AliZDCv2::CreateBeamLine()
   gMC->Gspos("YMQ ", 2, "ZDC ", 0., 0., -tubpar[2]-zq-1558.5, 0, "ONLY");
   
   // -- SEPARATOR DIPOLE D1 
-  
   zd1 = 5838.3;
   
   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
-  
   tubpar[0] = 0.;
   tubpar[1] = 6.94/2.;
   tubpar[2] = 945./2.;
@@ -506,8 +536,7 @@ void AliZDCv2::CreateBeamLine()
   
   // --  Insert horizontal Cu plates inside D1 
   // --   (to simulate the vacuum chamber)
-  
-  boxpar[0] = TMath::Sqrt(tubpar[1]*tubpar[1]-(2.98+0.2)*(2.98+0.2));
+  boxpar[0] = TMath::Sqrt(tubpar[1]*tubpar[1]-(2.98+0.2)*(2.98+0.2)) - 0.05;
   boxpar[1] = 0.2/2.;
   boxpar[2] =945./2.;
   gMC->Gsvolu("MD1V", "BOX ", idtmed[6], boxpar, 3);
@@ -515,7 +544,6 @@ void AliZDCv2::CreateBeamLine()
   gMC->Gspos("MD1V", 2, "MD1 ", 0., -2.98-boxpar[1], 0., 0, "ONLY");
     
   // --  YOKE 
-  
   tubpar[0] = 0.;
   tubpar[1] = 110./2;
   tubpar[2] = 945./2.;
@@ -525,20 +553,16 @@ void AliZDCv2::CreateBeamLine()
   gMC->Gspos("MD1 ", 1, "YD1 ", 0., 0., 0., 0, "ONLY");
   
   // -- DIPOLE D2 
-  
-  //zd2 = 12147.6;
   // --- LHC optics v6.4
   zd2 = 12147.6;
   
   // --  GAP (VACUUM WITH MAGNETIC FIELD) 
-  
   tubpar[0] = 0.;
   tubpar[1] = 7.5/2.;
   tubpar[2] = 945./2.;
   gMC->Gsvolu("MD2 ", "TUBE", idtmed[11], tubpar, 3);
   
   // --  YOKE 
-  
   tubpar[0] = 0.;
   tubpar[1] = 55.;
   tubpar[2] = 945./2.;
@@ -555,8 +579,11 @@ void AliZDCv2::CreateBeamLine()
 //_____________________________________________________________________________
 void AliZDCv2::CreateZDC()
 {
+ //
+ // Create the various ZDCs (ZN + ZP)
+ //
   
-  Float_t DimPb[6], DimVoid[6];
+  Float_t dimPb[6], dimVoid[6];
   
   Int_t *idtmed = fIdtmed->GetArray();
 
@@ -626,8 +653,9 @@ void AliZDCv2::CreateZDC()
   gMC->Gspos("ZNF4", 1, "ZNG4", 0., 0., 0., 0, "ONLY");
   
   // --- Position the neutron calorimeter in ZDC 
-  gMC->Gspos("ZNEU", 1, "ZDC ", fPosZN[0], fPosZN[1], fPosZN[2] - fDimZN[2], 0, "ONLY");
-  
+  gMC->Gspos("ZNEU", 1, "ZDC ", fPosZN[0], fPosZN[1], fPosZN[2]-fDimZN[2], 0, "ONLY");
+  //Ch debug
+  //printf("\n ZN -> %f < z < %f cm\n",fPosZN[2],fPosZN[2]-2*fDimZN[2]);
 
   // -------------------------------------------------------------------------------
   //--> Proton calorimeter (ZP)  
@@ -673,7 +701,9 @@ void AliZDCv2::CreateZDC()
   
 
   // --- Position the proton calorimeter in ZDC 
-  gMC->Gspos("ZPRO", 1, "ZDC ", fPosZP[0], fPosZP[1], fPosZP[2] - fDimZP[2], 0, "ONLY");
+  gMC->Gspos("ZPRO", 1, "ZDC ", fPosZP[0], fPosZP[1], fPosZP[2]-fDimZP[2], 0, "ONLY");
+  //Ch debug
+  //printf("\n ZP -> %f < z < %f cm\n",fPosZP[2],fPosZP[2]-2*fDimZP[2]);
     
   
   // -------------------------------------------------------------------------------
@@ -682,24 +712,24 @@ void AliZDCv2::CreateZDC()
   gMC->Gsvolu("ZEM ", "PARA", idtmed[10], fDimZEM, 6);
 
   Int_t irot1, irot2;
-  
-  gMC->Matrix(irot1,180.,0.,90.,90.,90.,0.);                  // Rotation matrix 1  
+  gMC->Matrix(irot1,0.,0.,90.,90.,-90.,0.);                   // Rotation matrix 1  
   gMC->Matrix(irot2,180.,0.,90.,fDimZEM[3]+90.,90.,fDimZEM[3]);// Rotation matrix 2
-//  printf("irot1 = %d, irot2 = %d \n", irot1, irot2);
+  //printf("irot1 = %d, irot2 = %d \n", irot1, irot2);
   
-  gMC->Gsvolu("ZEMF", "TUBE", idtmed[3], fFibZEM, 3); // Active material
+  gMC->Gsvolu("ZEMF", "TUBE", idtmed[3], fFibZEM, 3);  // Active material
 
-  gMC->Gsdvn("ZETR", "ZEM ", fDivZEM[2], 1);        // Tranches 
-  
-  DimPb[0] = fDimZEMPb;                        // Lead slices 
-  DimPb[1] = fDimZEM[2];
-  DimPb[2] = fDimZEM[1];
-  DimPb[3] = 90.-fDimZEM[3];
-  DimPb[4] = 0.;
-  DimPb[5] = 0.;
-  gMC->Gsvolu("ZEL0", "PARA", idtmed[5], DimPb, 6);
-  gMC->Gsvolu("ZEL1", "PARA", idtmed[5], DimPb, 6);
-//  gMC->Gsvolu("ZEL2", "PARA", idtmed[5], DimPb, 6);
+  gMC->Gsdvn("ZETR", "ZEM ", fDivZEM[2], 1);           // Tranches 
+  
+  dimPb[0] = fDimZEMPb;                                        // Lead slices 
+  dimPb[1] = fDimZEM[2];
+  dimPb[2] = fDimZEM[1];
+  //dimPb[3] = fDimZEM[3]; //controllare
+  dimPb[3] = 90.-fDimZEM[3]; //originale
+  dimPb[4] = 0.;
+  dimPb[5] = 0.;
+  gMC->Gsvolu("ZEL0", "PARA", idtmed[5], dimPb, 6);
+  gMC->Gsvolu("ZEL1", "PARA", idtmed[5], dimPb, 6);
+  gMC->Gsvolu("ZEL2", "PARA", idtmed[5], dimPb, 6);
   
   // --- Position the lead slices in the tranche 
   Float_t zTran = fDimZEM[0]/fDivZEM[2]; 
@@ -708,14 +738,14 @@ void AliZDCv2::CreateZDC()
   gMC->Gspos("ZEL1", 1, "ZETR", fDimZEMPb, 0., 0., 0, "ONLY");
   
   // --- Vacuum zone (to be filled with fibres)
-  DimVoid[0] = (zTran-2*fDimZEMPb)/2.;
-  DimVoid[1] = fDimZEM[2];
-  DimVoid[2] = fDimZEM[1];
-  DimVoid[3] = 90.-fDimZEM[3];
-  DimVoid[4] = 0.;
-  DimVoid[5] = 0.;
-  gMC->Gsvolu("ZEV0", "PARA", idtmed[10], DimVoid,6);
-  gMC->Gsvolu("ZEV1", "PARA", idtmed[10], DimVoid,6);
+  dimVoid[0] = (zTran-2*fDimZEMPb)/2.;
+  dimVoid[1] = fDimZEM[2];
+  dimVoid[2] = fDimZEM[1];
+  dimVoid[3] = 90.-fDimZEM[3];
+  dimVoid[4] = 0.;
+  dimVoid[5] = 0.;
+  gMC->Gsvolu("ZEV0", "PARA", idtmed[10], dimVoid,6);
+  gMC->Gsvolu("ZEV1", "PARA", idtmed[10], dimVoid,6);
   
   // --- Divide the vacuum slice into sticks along x axis
   gMC->Gsdvn("ZES0", "ZEV0", fDivZEM[0], 3); 
@@ -726,27 +756,30 @@ void AliZDCv2::CreateZDC()
   gMC->Gspos("ZEMF", 1,"ZES1", 0., 0., 0., irot2, "ONLY");
   
   // --- Positioning the vacuum slice into the tranche
-  Float_t DisplFib = fDimZEM[1]/fDivZEM[0];
-  gMC->Gspos("ZEV0", 1,"ZETR", -DimVoid[0], 0., 0., 0, "ONLY");
-  gMC->Gspos("ZEV1", 1,"ZETR", -DimVoid[0]+zTran, 0., DisplFib, 0, "ONLY");
+  Float_t displFib = fDimZEM[1]/fDivZEM[0];
+  gMC->Gspos("ZEV0", 1,"ZETR", -dimVoid[0], 0., 0., 0, "ONLY");
+  gMC->Gspos("ZEV1", 1,"ZETR", -dimVoid[0]+zTran, 0., displFib, 0, "ONLY");
 
   // --- Positioning the ZEM into the ZDC - rotation for 90 degrees  
   // NB -> In AliZDCv2 ZEM is positioned in ALIC (instead of in ZDC) volume
   //      beacause it's impossible to make a ZDC pcon volume to contain
   //      both hadronics and EM calorimeters. 
-  gMC->Gspos("ZEM ", 1,"ALIC", fPosZEM[0], fPosZEM[1], fPosZEM[2]+fDimZEM[0], irot1, "ONLY");
+  gMC->Gspos("ZEM ", 1,"ALIC", -fPosZEM[0], fPosZEM[1], fPosZEM[2]+fDimZEM[0], irot1, "ONLY");
   
   // Second EM ZDC (same side w.r.t. IP, just on the other side w.r.t. beam pipe)
-  gMC->Gspos("ZEM ", 2,"ALIC", -fPosZEM[0], fPosZEM[1], fPosZEM[2]+fDimZEM[0], irot1, "ONLY");
+  gMC->Gspos("ZEM ", 2,"ALIC", fPosZEM[0], fPosZEM[1], fPosZEM[2]+fDimZEM[0], irot1, "ONLY");
   
   // --- Adding last slice at the end of the EM calorimeter 
-//  Float_t zLastSlice = fPosZEM[2]+fDimZEMPb+fDimZEM[0];
-//  gMC->Gspos("ZEL2", 1,"ALIC", fPosZEM[0], fPosZEM[1], zLastSlice, irot1, "ONLY");
+  Float_t zLastSlice = fPosZEM[2]+fDimZEMPb+2*fDimZEM[0];
+  gMC->Gspos("ZEL2", 1,"ALIC", fPosZEM[0], fPosZEM[1], zLastSlice, irot1, "ONLY");
+  //Ch debug
+  //printf("\n ZEM lenght = %f cm\n",2*fZEMLength);
+  //printf("\n ZEM -> %f < z < %f cm\n",fPosZEM[2],fPosZEM[2]+2*fZEMLength+zLastSlice+fDimZEMPb);
   
 }
  
 //_____________________________________________________________________________
-void AliZDCv2::DrawModule()
+void AliZDCv2::DrawModule() const
 {
   //
   // Draw a shaded view of the Zero Degree Calorimeter version 1
@@ -857,7 +890,7 @@ void AliZDCv2::CreateMaterials()
   
   Int_t *idtmed = fIdtmed->GetArray();
   
-  Float_t dens, ubuf[1], wmat[2], a[2], z[2], deemax = -1;
+  Float_t dens, ubuf[1], wmat[2], a[2], z[2];
   Int_t i;
   
   // --- Store in UBUF r0 for nuclear radius calculation R=r0*A**1/3 
@@ -906,14 +939,28 @@ void AliZDCv2::CreateMaterials()
   ubuf[0] = 1.1;
   AliMaterial(8, "IRON", 55.85, 26., 7.87, 1.76, 0., ubuf, 1);
   
+  // ---------------------------------------------------------  
+  Float_t aResGas[3]={1.008,12.0107,15.9994};
+  Float_t zResGas[3]={1.,6.,8.};
+  Float_t wResGas[3]={0.28,0.28,0.44};
+  Float_t dResGas = 3.2E-14;
+
   // --- Vacuum (no magnetic field) 
-  AliMaterial(10, "VOID", 1e-16, 1e-16, 1e-16, 1e16, 1e16, ubuf,0);
+  AliMixture(10, "VOID", aResGas, zResGas, dResGas, 3, wResGas);
+  //AliMaterial(10, "VOID", 1e-16, 1e-16, 1e-16, 1e16, 1e16, ubuf,0);
   
   // --- Vacuum (with magnetic field) 
-  AliMaterial(11, "VOIM", 1e-16, 1e-16, 1e-16, 1e16, 1e16, ubuf,0);
+  AliMixture(11, "VOIM", aResGas, zResGas, dResGas, 3, wResGas);
+  //AliMaterial(11, "VOIM", 1e-16, 1e-16, 1e-16, 1e16, 1e16, ubuf,0);
   
   // --- Air (no magnetic field)
-  AliMaterial(12, "Air    $", 14.61, 7.3, .001205, 30420., 67500., ubuf, 0);
+  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 dAir = 1.20479E-3;
+  //
+  AliMixture(12, "Air    $", aAir, zAir, dAir, 4, wAir);
+  //AliMaterial(12, "Air    $", 14.61, 7.3, .001205, 30420., 67500., ubuf, 0);
   
   // ---  Definition of tracking media: 
   
@@ -929,30 +976,34 @@ void AliZDCv2::CreateMaterials()
   // --- Vacuum (with field) = 11 
   // --- Air (no field) = 12 
   
-  
-  // --- Tracking media parameters 
-  Float_t epsil  = .01, stmin=0.01, stemax = 1.;
-//  Int_t   isxfld = gAlice->Field()->Integ();
-  Float_t fieldm = 0., tmaxfd = 0.;
-  Int_t   ifield = 0, isvolActive = 1, isvol = 0, inofld = 0;
-  
-  AliMedium(1, "ZTANT", 1, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-//  AliMedium(1, "ZW", 1, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(2, "ZBRASS",2, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(3, "ZSIO2", 3, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(4, "ZQUAR", 3, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(5, "ZLEAD", 5, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-//  AliMedium(6, "ZCOPP", 6, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-//  AliMedium(7, "ZIRON", 7, isvolActive, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(6, "ZCOPP", 6, isvol, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(7, "ZIRON", 7, isvol, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(8, "ZIRONN",8, isvol, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(10,"ZVOID",10, isvol, inofld, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  AliMedium(12,"ZAIR", 12, 0, inofld, fieldm, tmaxfd, stemax,deemax, epsil, stmin);
-  
-  ifield =2;
-  fieldm = 45.;
-  AliMedium(11, "ZVOIM", 11, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
+  // **************************************************** 
+  //     Tracking media parameters
+  //
+  Float_t epsil  = 0.01;   // Tracking precision, 
+  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 deemax = -1.;    // Maximum fractional energy loss
+  Float_t nofieldm = 0.;   // Max. field value (no field)
+  Float_t fieldm = 45.;    // Max. field value (with field)
+  Int_t isvol = 0;         // ISVOL =0 -> not sensitive volume
+  Int_t isvolActive = 1;   // ISVOL =1 -> sensitive volume
+  Int_t inofld = 0;        // IFIELD=0 -> no magnetic field
+  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(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);
+  AliMedium(5, "ZLEAD", 5, isvolActive, inofld, nofieldm, tmaxfd, stemax, deemax, epsil, stmin);
+  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(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);
   
   // Thresholds for showering in the ZDCs 
   i = 1; //tantalum
@@ -1055,6 +1106,10 @@ void AliZDCv2::Init()
 //_____________________________________________________________________________
 void AliZDCv2::InitTables()
 {
+ //
+ // Read light tables for Cerenkov light production parameterization 
+ //
+
   Int_t k, j;
 
   char *lightfName1,*lightfName2,*lightfName3,*lightfName4,
@@ -1137,15 +1192,15 @@ void AliZDCv2::StepManager()
   //
   // Routine called at every step in the Zero Degree Calorimeters
   //
-
+    
   Int_t j, vol[2], ibeta=0, ialfa, ibe, nphe;
   Float_t x[3], xdet[3], destep, hits[10], m, ekin, um[3], ud[3], be, radius, out;
-  Float_t xalic[3], z, GuiEff, GuiPar[4]={0.31,-0.0004,0.0197,0.7958};
+  Float_t xalic[3], z, guiEff, guiPar[4]={0.31,-0.0004,0.0197,0.7958};
   TLorentzVector s, p;
   const char *knamed;
 
-  for (j=0;j<10;j++) hits[j]=0;
-
+  for (j=0;j<10;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->GetMedium() == fMedSensPI) || (gMC->GetMedium() == fMedSensTDI)){ 
@@ -1153,14 +1208,18 @@ void AliZDCv2::StepManager()
     if(fNoShower==1) {
       if(gMC->GetMedium() == fMedSensPI) {
         knamed = gMC->CurrentVolName();
-        if((!strncmp(knamed,"MQ",2)) || (!strncmp(knamed,"YM",2)))  fpLostIT += 1;
-        if((!strncmp(knamed,"MD1",3))|| (!strncmp(knamed,"YD1",2))) fpLostD1 += 1;
+       if(!strncmp(knamed,"YMQ",3))  fpLostIT += 1;
+        if(!strncmp(knamed,"YD1",3))   fpLostD1 += 1;
+      }
+      else if(gMC->GetMedium() == fMedSensTDI){ // NB->Cu = TDI or D1 vacuum chamber
+        knamed = gMC->CurrentVolName();
+        if(!strncmp(knamed,"MD1",3)) fpLostD1 += 1;
+        if(!strncmp(knamed,"QTD",3)) fpLostTDI += 1;
       }
-      else if(gMC->GetMedium() == fMedSensTDI) fpLostTDI += 1;
+      printf("\n      # of spectators lost in IT = %d\n",fpLostIT);
+      printf("\n      # of spectators lost in D1  = %d\n",fpLostD1);
+      printf("\n      # of spectators lost in TDI = %d\n\n",fpLostTDI);
       gMC->StopTrack();
-      //printf("\n      # of p lost in Inner Triplet = %d\n",fpLostIT);
-      //printf("\n      # of p lost in D1  = %d\n",fpLostD1);
-      //printf("\n      # of p lost in TDI = %d\n\n",fpLostTDI);
     }
     return;
   }
@@ -1172,27 +1231,18 @@ void AliZDCv2::StepManager()
   
   //Particle coordinates 
     gMC->TrackPosition(s);
-    for(j=0; j<=2; j++){
-       x[j] = s[j];
-    }
+    for(j=0; j<=2; j++) x[j] = s[j];
     hits[0] = x[0];
     hits[1] = x[1];
     hits[2] = x[2];
 
   // Determine in which ZDC the particle is
     knamed = gMC->CurrentVolName();
-    if(!strncmp(knamed,"ZN",2)){
-      vol[0]=1;
-    }
-    else if(!strncmp(knamed,"ZP",2)){
-      vol[0]=2;
-    }
-    else if(!strncmp(knamed,"ZE",2)){
-      vol[0]=3;
-    }
+    if(!strncmp(knamed,"ZN",2))      vol[0]=1;
+    else if(!strncmp(knamed,"ZP",2)) vol[0]=2;
+    else if(!strncmp(knamed,"ZE",2)) vol[0]=3;
   
   // Determine in which quadrant the particle is
-       
     if(vol[0]==1){     //Quadrant in ZN
       // Calculating particle coordinates inside ZN
       xdet[0] = x[0]-fPosZN[0];
@@ -1207,7 +1257,7 @@ void AliZDCv2::StepManager()
         else if(xdet[1]<0.) vol[1]=4;
       }
       if((vol[1]!=1) && (vol[1]!=2) && (vol[1]!=3) && (vol[1]!=4))
-        printf("\n     StepManager->ERROR in ZN!!! vol[1] = %d, xdet[0] = %f,"
+        printf("\n     ZDC StepManager->ERROR in ZN!!! vol[1] = %d, xdet[0] = %f,"
        "xdet[1] = %f\n",vol[1], xdet[0], xdet[1]);
     }
     
@@ -1226,8 +1276,8 @@ void AliZDCv2::StepManager()
         }
       }
       if((vol[1]!=1) && (vol[1]!=2) && (vol[1]!=3) && (vol[1]!=4))
-        printf("       StepManager->ERROR in ZP!!! vol[1] = %d, xdet[0] = %f,"
-       "xdet[1] = %f",vol[1], xdet[0], xdet[1]);
+        printf("       ZDC StepManager->ERROR in ZP!!! vol[1] = %d, xdet[0] = %f,"
+       "xdet[1] = %f\n",vol[1], xdet[0], xdet[1]);
     }
     
     // Quadrant in ZEM: vol[1] = 1 -> particle in 1st ZEM (placed at x = 8.5 cm)
@@ -1248,7 +1298,6 @@ void AliZDCv2::StepManager()
 
   // Store impact point and kinetic energy of the ENTERING particle
     
-//    if(Curtrack==Prim){
       if(gMC->IsTrackEntering()){
         //Particle energy
         gMC->TrackMomentum(p);
@@ -1261,18 +1310,16 @@ void AliZDCv2::StepManager()
         hits[8] = 0;
         hits[9] = 0;
 
-//       Int_t PcID = gMC->TrackPid();
-//       printf("Pc ID -> %d\n",PcID);
        AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
        
        if(fNoShower==1){
          fpDetected += 1;
          gMC->StopTrack();
-         //printf("\n  # of detected p = %d\n\n",fpDetected);
+         if(vol[0]==1) printf("\n      # of detected neutrons = %d\n\n",fpDetected);
+         if(vol[0]==2) printf("\n      # of detected protons = %d\n\n",fpDetected);
          return;
        }
       }
-//    } // Curtrack IF
              
       // Charged particles -> Energy loss
       if((destep=gMC->Edep())){
@@ -1291,9 +1338,8 @@ void AliZDCv2::StepManager()
           hits[8] = 0.;
           AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
-//      printf(" Dep. E = %f \n",hits[9]);
       }
-  }// NB -> Questa parentesi (chiude il primo IF) io la sposterei al fondo!???
+  }
 
 
   // *** Light production in fibres 
@@ -1365,8 +1411,6 @@ void AliZDCv2::StepManager()
          if(ibe>fNben) ibe=fNben;
          out =  charge*charge*fTablen[ibeta][ialfa][ibe];
         nphe = gRandom->Poisson(out);
-//      printf("ZN --- ibeta = %d, ialfa = %d, ibe = %d"
-//             "       -> out = %f, nphe = %d\n", ibeta, ialfa, ibe, out, nphe);
         if(gMC->GetMedium() == fMedSensF1){
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
@@ -1384,8 +1428,6 @@ void AliZDCv2::StepManager()
          if(ibe>fNbep) ibe=fNbep;
          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
         nphe = gRandom->Poisson(out);
-//      printf("ZP --- ibeta = %d, ialfa = %d, ibe = %d"
-//             "       -> out = %f, nphe = %d\n", ibeta, ialfa, ibe, out, nphe);
         if(gMC->GetMedium() == fMedSensF1){
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
@@ -1411,14 +1453,10 @@ void AliZDCv2::StepManager()
         z = -xalic[2]+fPosZEM[2]+2*fZEMLength-xalic[1];
 //      z = xalic[2]-fPosZEM[2]-fZEMLength-xalic[1]*(TMath::Tan(45.*kDegrad));
 //         printf("\n  fPosZEM[2]+2*fZEMLength = %f", fPosZEM[2]+2*fZEMLength);
-        GuiEff = GuiPar[0]*(GuiPar[1]*z*z+GuiPar[2]*z+GuiPar[3]);
-//         printf("\n  xalic[0] = %f   xalic[1] = %f   xalic[2] = %f   z = %f  \n",
-//             xalic[0],xalic[1],xalic[2],z);
-        out = out*GuiEff;
+        guiEff = guiPar[0]*(guiPar[1]*z*z+guiPar[2]*z+guiPar[3]);
+        out = out*guiEff;
         nphe = gRandom->Poisson(out);
-//         printf("    out*GuiEff = %f nphe = %d", out, nphe);
-//      printf("ZEM --- ibeta = %d, ialfa = %d, ibe = %d"
-//             "       -> out = %f, nphe = %d\n", ibeta, ialfa, ibe, out, nphe);
+//         printf("    out*guiEff = %f nphe = %d", out, nphe);
         if(vol[1] == 1){
           hits[7] = 0;         
           hits[8] = nphe;      //fLightPMC (ZEM1)