]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/AliZDCv1.cxx
Update of the class ESDMuonFilter. New marcros for creating AOD with muon information...
[u/mrichter/AliRoot.git] / ZDC / AliZDCv1.cxx
index 7cc55b8a7a41cbe6647bc85b28990a7c6743f880..cf030c8086ad8865ee96c1e057531084efb74b15 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.24  2001/05/16 14:57:28  alibrary
-New files for folders and Stack
-
-Revision 1.23  2001/05/14 09:51:50  coppedis
-Change in AddHit suggested by J. Chudoba
-
-Revision 1.22  2001/05/05 13:33:19  coppedis
-Changes in StepManager to speed simulation
-
-Revision 1.21  2001/05/02 11:54:34  enrico
-Minor change
-
-Revision 1.20  2001/05/02 10:33:11  coppedis
-Modify tmaxfd in media definition
-
-Revision 1.19  2001/04/27 08:35:01  coppedis
-Remove some lines for proton acceptance studies
-
-Revision 1.18  2001/04/20 10:08:45  coppedis
-Preliminary version of optics 6.2 - Insertion of TDI
-
-Revision 1.17  2001/03/16 16:18:10  coppedis
-Correction for superposition of ZDC volumes with MUON arm one
-
-Revision 1.16  2001/03/15 16:12:04  coppedis
-Code review
-
-Revision 1.15  2001/03/12 17:47:56  hristov
-Changes needed on Sun with CC 5.0
-
-Revision 1.14  2001/02/23 16:48:28  coppedis
-Correct bug in ZEM hit definition
-
-Revision 1.13  2001/02/07 18:07:41  coppedis
-Modif for splitting
-
-Revision 1.12  2001/01/26 19:56:27  hristov
-Major upgrade of AliRoot code
-
-Revision 1.11  2001/01/16 07:43:33  hristov
-Initialisation of ZDC hits
-
-Revision 1.10  2000/12/14 15:20:02  coppedis
-Hits2Digits method for digitization
-
-Revision 1.9  2000/12/13 10:33:49  coppedis
-Prints only if fDebug==1
-
-Revision 1.8  2000/12/12 14:10:02  coppedis
-Correction suggested by M. Masera
-
-Revision 1.7  2000/11/30 17:23:47  coppedis
-Remove first corrector dipole and introduce digitization
-
-Revision 1.6  2000/11/22 11:33:10  coppedis
-Major code revision
-
-Revision 1.5  2000/10/02 21:28:20  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.3.2.1  2000/08/24 09:25:47  hristov
-Patch by P.Hristov: Bug in ZDC geometry corrected by E.Scomparin
-
-Revision 1.4  2000/08/24 09:23:59  hristov
-Bug in ZDC geometry corrected by E.Scomparin
-
-Revision 1.3  2000/07/12 06:59:16  fca
-Fixing dimension of hits array
-
-Revision 1.2  2000/07/11 11:12:34  fca
-Some syntax corrections for non standard HP aCC
-
-Revision 1.1  2000/07/10 13:58:01  fca
-New version of ZDC from E.Scomparin & C.Oppedisano
-
-Revision 1.7  2000/01/19 17:17:40  fca
-
-Revision 1.6  1999/09/29 09:24:35  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
-//  Zero Degree Calorimeter                                                  //
-//  This class contains the basic functions for the ZDC                      //
-//  Functions specific to one particular geometry are                        //
-//  contained in the derived classes                                         //
+//             AliZDCv1 --- ZDC geometry as designed in TDR (obsolete!)     //
+//                     with the EM ZDC at 116 m from IP                     //
+//  Just one set of ZDC is inserted, on the same side of the dimuon arm      //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
@@ -111,36 +28,27 @@ Introduction of the Copyright and cvs Log
 
 // --- ROOT system
 #include <TBRIK.h>
-#include <TNode.h>
+#include <TLorentzVector.h>
 #include <TMath.h>
+#include <TNode.h>
 #include <TRandom.h>
 #include <TSystem.h>
 #include <TTree.h>
-
+#include <TVirtualMC.h>
 
 // --- AliRoot classes
-#include "AliZDCv1.h"
-#include "AliZDCHit.h"
-#include "AliZDCDigit.h"
-#include "AliRun.h"
+#include "AliConst.h"
 #include "AliDetector.h"
 #include "AliMagF.h"
-#include "AliMC.h"
-#include "AliCallf77.h"
-#include "AliConst.h"
 #include "AliPDG.h"
-#include "TLorentzVector.h"
+#include "AliRun.h"
+#include "AliZDCHit.h"
+#include "AliZDCv1.h"
+#include "AliMC.h"
  
  
 ClassImp(AliZDCv1)
  
-
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-//  Zero Degree Calorimeter version 1                                        //
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
-
 //_____________________________________________________________________________
 AliZDCv1::AliZDCv1() : AliZDC()
 {
@@ -156,6 +64,12 @@ AliZDCv1::AliZDCv1() : AliZDC()
   fMedSensGR  = 0;
 //  fMedSensPI  = 0;
 //  fMedSensTDI = 0;
+  Float_t kDimZEMPb  = 0.15*(TMath::Sqrt(2.));  // z-dimension of the Pb slice
+  Float_t kDimZEMAir = 0.001;                  // scotch
+  Float_t kFibRadZEM = 0.0315;                         // External fiber radius (including cladding)
+  Int_t   kDivZEM[3] = {92, 0, 20};            // Divisions for EM detector
+  Float_t kDimZEM0 = 2*kDivZEM[2]*(kDimZEMPb+kDimZEMAir+kFibRadZEM*(TMath::Sqrt(2.)));
+  fZEMLength = kDimZEM0;
 }
  
 //_____________________________________________________________________________
@@ -168,11 +82,11 @@ AliZDCv1::AliZDCv1(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);
   } 
@@ -214,7 +128,7 @@ AliZDCv1::AliZDCv1(const char *name, const char *title)
   fDimZP[1] = 6.;
   fDimZP[2] = 75.;    
   fPosZN[0] = 0.;
-  fPosZN[1] = -1.2;
+  fPosZN[1] = 1.2;
   fPosZN[2] = 11650.;
   fPosZP[0] = -24.;
   fPosZP[1] = 0.;
@@ -231,8 +145,12 @@ AliZDCv1::AliZDCv1(const char *name, const char *title)
   fPosZEM[1] = 5.8;
   fPosZEM[2] = 11600.;
   
-
-  fDigits = new TClonesArray("AliZDCDigit",1000);
+  Float_t kDimZEMPb  = 0.15*(TMath::Sqrt(2.));  // z-dimension of the Pb slice
+  Float_t kDimZEMAir = 0.001;                  // scotch
+  Float_t kFibRadZEM = 0.0315;                         // External fiber radius (including cladding)
+  Int_t   kDivZEM[3] = {92, 0, 20};            // Divisions for EM detector
+  Float_t kDimZEM0 = 2*kDivZEM[2]*(kDimZEMPb+kDimZEMAir+kFibRadZEM*(TMath::Sqrt(2.)));
+  fZEMLength = kDimZEM0;
 }
  
 //_____________________________________________________________________________
@@ -250,7 +168,10 @@ void AliZDCv1::CreateGeometry()
 //_____________________________________________________________________________
 void AliZDCv1::CreateBeamLine()
 {
-  
+  //
+  // Create the beam line elements
+  //
   Float_t zq, zd1, zd2;
   Float_t conpar[9], tubpar[3], tubspar[5], boxpar[3];
   Int_t im1, im2;
@@ -382,8 +303,7 @@ void AliZDCv1::CreateBeamLine()
   // QT09 is 10 cm longer to accomodate TDI
   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");
-  
+  gMC->Gspos("QT09", 1, "ZDC ", 0., 0., tubpar[2] + zd1, 0, "ONLY"); 
   
   // --- Insert TDI (inside ZDC volume)
   
@@ -400,16 +320,16 @@ void AliZDCv1::CreateBeamLine()
   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");
   
-  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[0] = 6.2;  // R = 6.2 cm----------------------------------------
+//  tubspar[1] = 6.4;
 //  tubspar[2] = 400./2.;
-//  tubspar[3] = 180.-75.5;
-//  tubspar[4] = 180.+75.5;
+//  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;
   gMC->Gsvolu("QTD3", "TUBS", idtmed[6], tubspar, 5);
   gMC->Gspos("QTD3", 1, "ZDC ", 0., 0., tubpar[2] + zd1 + 56.3, 0, "ONLY");
 
@@ -671,8 +591,11 @@ void AliZDCv1::CreateBeamLine()
 //_____________________________________________________________________________
 void AliZDCv1::CreateZDC()
 {
+ //
+ // Create the various ZDCs (ZN + ZP)
+ //
   
-  Float_t DimPb[6], DimVoid[6];
+  Float_t dimPb[6], dimVoid[6];
   
   Int_t *idtmed = fIdtmed->GetArray();
 
@@ -807,15 +730,15 @@ void AliZDCv1::CreateZDC()
 
   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);
+  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);
   
   // --- Position the lead slices in the tranche 
   Float_t zTran = fDimZEM[0]/fDivZEM[2]; 
@@ -824,14 +747,14 @@ void AliZDCv1::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); 
@@ -842,9 +765,9 @@ void AliZDCv1::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  
   gMC->Gspos("ZEM ", 1,"ZDC ", fPosZEM[0], fPosZEM[1], fPosZEM[2], irot1, "ONLY");
@@ -856,7 +779,7 @@ void AliZDCv1::CreateZDC()
 }
  
 //_____________________________________________________________________________
-void AliZDCv1::DrawModule()
+void AliZDCv1::DrawModule() const
 {
   //
   // Draw a shaded view of the Zero Degree Calorimeter version 1
@@ -1063,8 +986,15 @@ void AliZDCv1::CreateMaterials()
   
   ifield =2;
   fieldm = 45.;
-  AliMedium(11, "ZVOIM", 11, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);
-  
+  AliMedium(11, "ZVOIM", 11, isvol, ifield, fieldm, tmaxfd, stemax, deemax, epsil, stmin);  
+} 
+
+//_____________________________________________________________________________
+void AliZDCv1::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);
@@ -1155,17 +1085,15 @@ void AliZDCv1::CreateMaterials()
 //  fMedSensTDI = idtmed[6];  // Sensitive volume: TDI Cu shield
 //  fMedSensPI  = idtmed[7];  // Sensitive volume: beam pipes
   fMedSensGR  = idtmed[12]; // Sensitive volume: air into the grooves
-} 
-
-//_____________________________________________________________________________
-void AliZDCv1::Init()
-{
- InitTables();
 }
 
 //_____________________________________________________________________________
 void AliZDCv1::InitTables()
 {
+ //
+ // Read light tables for Cerenkov light production parameterization 
+ //
+
   Int_t k, j;
 
   char *lightfName1,*lightfName2,*lightfName3,*lightfName4,
@@ -1173,22 +1101,22 @@ void AliZDCv1::InitTables()
   FILE *fp1, *fp2, *fp3, *fp4, *fp5, *fp6, *fp7, *fp8;
 
   //  --- Reading light tables for ZN 
-  lightfName1 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362207s");
+  lightfName1 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362207s");
   if((fp1 = fopen(lightfName1,"r")) == NULL){
      printf("Cannot open file fp1 \n");
      return;
   }
-  lightfName2 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362208s");
+  lightfName2 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362208s");
   if((fp2 = fopen(lightfName2,"r")) == NULL){
      printf("Cannot open file fp2 \n");
      return;
   }  
-  lightfName3 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362209s");
+  lightfName3 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362209s");
   if((fp3 = fopen(lightfName3,"r")) == NULL){
      printf("Cannot open file fp3 \n");
      return;
   }
-  lightfName4 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620362210s");
+  lightfName4 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620362210s");
   if((fp4 = fopen(lightfName4,"r")) == NULL){
      printf("Cannot open file fp4 \n");
      return;
@@ -1208,22 +1136,22 @@ void AliZDCv1::InitTables()
   fclose(fp4);
   
   //  --- Reading light tables for ZP and ZEM
-  lightfName5 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552207s");
+  lightfName5 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552207s");
   if((fp5 = fopen(lightfName5,"r")) == NULL){
      printf("Cannot open file fp5 \n");
      return;
   }
-  lightfName6 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552208s");
+  lightfName6 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552208s");
   if((fp6 = fopen(lightfName6,"r")) == NULL){
      printf("Cannot open file fp6 \n");
      return;
   }
-  lightfName7 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552209s");
+  lightfName7 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552209s");
   if((fp7 = fopen(lightfName7,"r")) == NULL){
      printf("Cannot open file fp7 \n");
      return;
   }
-  lightfName8 = gSystem->ExpandPathName("$ALICE/$ALICE_LEVEL/ZDC/light22620552210s");
+  lightfName8 = gSystem->ExpandPathName("$ALICE_ROOT/ZDC/light22620552210s");
   if((fp8 = fopen(lightfName8,"r")) == NULL){
      printf("Cannot open file fp8 \n");
      return;
@@ -1242,165 +1170,6 @@ void AliZDCv1::InitTables()
   fclose(fp7);
   fclose(fp8);
 }
-
-//_____________________________________________________________________________
-Int_t AliZDCv1::Digitize(Int_t Det, Int_t Quad, Int_t Light)
-{
-  // Evaluation of the ADC channel corresponding to the light yield Light
-
-  if(fDebug == 1){
-    printf("\n Digitize -> Det = %d, Quad = %d, Light = %d\n", Det, Quad, Light);
-  }   
-  
-  // Parameters for conversion of light yield in ADC channels
-  Float_t fPMGain[3][5];      // PM gain
-  Float_t fADCRes;            // ADC conversion factor
-  
-  Int_t j,i;
-  for(i=0; i<3; i++){
-     for(j=0; j<5; j++){
-        fPMGain[i][j]   = 100000.;
-     }
-  }
-  fADCRes   = 0.00000064; // ADC Resolution: 250 fC/ADCch
-  
-  Int_t ADCch = Int_t(Light*fPMGain[Det-1][Quad]*fADCRes);
-     
-  return ADCch;
-}
-
-
-//_____________________________________________________________________________
-void AliZDCv1::SDigits2Digits()
-{
-   Hits2Digits(gAlice->GetNtrack());
-}
-
-//_____________________________________________________________________________
-void AliZDCv1::Hits2Digits(Int_t ntracks)
-{
-  AliZDCDigit *newdigit;
-  AliZDCHit   *hit;
-
-  Int_t PMCZN = 0, PMCZP = 0, PMQZN[4], PMQZP[4], PMZEM = 0;
-  
-  Int_t i;
-  for(i=0; i<4; i++){
-     PMQZN[i] =0;
-     PMQZP[i] =0;
-  }
-  
-  Int_t itrack = 0;
-  for(itrack=0; itrack<ntracks; itrack++){
-     gAlice->ResetHits();
-     gAlice->TreeH()->GetEvent(itrack);
-     for(i=0; i<fHits->GetEntries(); i++){
-        hit = (AliZDCHit*)fHits->At(i);
-        Int_t det   = hit->GetVolume(0);
-        Int_t quad  = hit->GetVolume(1);
-        Int_t lightQ = Int_t(hit->GetLightPMQ());
-        Int_t lightC = Int_t(hit->GetLightPMC());
-       if(fDebug == 1)
-          printf("        \n itrack = %d, fNhits = %d, det = %d, quad = %d,"
-         "lightC = %d lightQ = %d\n", itrack, fNhits, det, quad, lightC, lightQ);
-           
-        if(det == 1){   //ZN 
-          PMCZN = PMCZN + lightC;
-          PMQZN[quad-1] = PMQZN[quad-1] + lightQ;
-        }
-
-        if(det == 2){   //ZP 
-          PMCZP = PMCZP + lightC;
-          PMQZP[quad-1] = PMQZP[quad-1] + lightQ;
-        }
-
-        if(det == 3){   //ZEM 
-          PMZEM = PMZEM + lightC;
-        }
-     } // Hits loop
-  
-  } // Tracks loop
-  
-     if(fDebug == 1){
-       printf("\n       PMCZN = %d, PMQZN[0] = %d, PMQZN[1] = %d, PMQZN[2] = %d, PMQZN[3] = %d\n"
-           , PMCZN, PMQZN[0], PMQZN[1], PMQZN[2], PMQZN[3]);
-       printf("\n       PMCZP = %d, PMQZP[0] = %d, PMQZP[1] = %d, PMQZP[2] = %d, PMQZP[3] = %d\n"
-           , PMCZP, PMQZP[0], PMQZP[1], PMQZP[2], PMQZP[3]);
-       printf("\n       PMZEM = %d\n", PMZEM);
-     }
-
-  // ------------------------------------    Hits2Digits
-  // Digits for ZN
-     newdigit = new AliZDCDigit(1, 0, Digitize(1, 0, PMCZN));
-     new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
-     fNdigits++;
-     delete newdigit;
-  
-     Int_t j;
-     for(j=0; j<4; j++){
-        newdigit = new AliZDCDigit(1, j+1, Digitize(1, j+1, PMQZN[j]));
-        new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
-        fNdigits++;
-        delete newdigit;
-     }
-  
-     // Digits for ZP
-     newdigit = new AliZDCDigit(2, 0, Digitize(2, 0, PMCZP));
-     new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
-     fNdigits++;
-     delete newdigit;
-  
-     Int_t k;
-     for(k=0; k<4; k++){
-        newdigit = new AliZDCDigit(2, k+1, Digitize(2, k+1, PMQZP[k]));
-        new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
-        fNdigits++;
-        delete newdigit;
-     }
-  
-     // Digits for ZEM
-     newdigit = new AliZDCDigit(3, 0, Digitize(3, 0, PMZEM));
-     new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
-     fNdigits++;
-     delete newdigit;
-      
-  
-  gAlice->TreeD()->Fill();
-  gAlice->TreeD()->Write(0,TObject::kOverwrite);
-
-//  if(fDebug == 1){
-//    printf("\n  Event Digits -----------------------------------------------------\n");  
-//    fDigits->Print("");
-//  }
-  
-}
-//_____________________________________________________________________________
- void AliZDCv1::MakeBranch(Option_t *opt, const char *file)
-{
-  //
-  // Create a new branch in the current Root Tree
-  //
-
-  AliDetector::MakeBranch(opt);
-  
-  Char_t branchname[10];
-  sprintf(branchname,"%s",GetName());
-  const char *cD = strstr(opt,"D");
-
-  if (gAlice->TreeD() && cD) {
-
-    // Creation of the digits from hits 
-
-    if(fDigits!=0) fDigits->Clear();
-    else fDigits = new TClonesArray ("AliZDCDigit",1000);
-    char branchname[10];
-    sprintf(branchname,"%s",GetName());
-    MakeBranchInTree(gAlice->TreeD(), 
-                     branchname, &fDigits, fBufferSize, file) ;
-    printf("* AliZDCv1::MakeBranch    * Making Branch %s for digits\n\n",branchname);
-  }
-       
-}
 //_____________________________________________________________________________
 void AliZDCv1::StepManager()
 {
@@ -1410,26 +1179,29 @@ void AliZDCv1::StepManager()
 
   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};
   TLorentzVector s, p;
   const char *knamed;
 
   for (j=0;j<10;j++) hits[j]=0;
 
-  if((gMC->GetMedium() == fMedSensZN) || (gMC->GetMedium() == fMedSensZP) ||
-     (gMC->GetMedium() == fMedSensGR) || (gMC->GetMedium() == fMedSensF1) ||
-     (gMC->GetMedium() == fMedSensF2) || (gMC->GetMedium() == fMedSensZEM)){
-//     (gMC->GetMedium() == fMedSensPI) || (gMC->GetMedium() == fMedSensTDI)){
+  if((gMC->CurrentMedium() == fMedSensZN) || (gMC->CurrentMedium() == fMedSensZP) ||
+     (gMC->CurrentMedium() == fMedSensGR) || (gMC->CurrentMedium() == fMedSensF1) ||
+     (gMC->CurrentMedium() == fMedSensF2) || (gMC->CurrentMedium() == fMedSensZEM)){
+
+//   --- This part is for no shower developement in beam pipe and TDI
+//     (gMC->CurrentMedium() == fMedSensPI) || (gMC->CurrentMedium() == fMedSensTDI)){
        
   // If particle interacts with beam pipe -> return
-//    if((gMC->GetMedium() == fMedSensPI) || (gMC->GetMedium() == fMedSensTDI)){ 
+//    if((gMC->CurrentMedium() == fMedSensPI) || (gMC->CurrentMedium() == fMedSensTDI)){ 
       // If option NoShower is set -> StopTrack
 //      if(fNoShower==1) {
-//     if(gMC->GetMedium() == fMedSensPI) {
+//     if(gMC->CurrentMedium() == 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(gMC->GetMedium() == fMedSensTDI) fpLostTDI += 1;
+//     if(gMC->CurrentMedium() == fMedSensTDI) fpLostTDI += 1;
 //        gMC->StopTrack();
 //     printf("\n      # of p lost in Inner Triplet = %d\n",fpLostIT);
 //     printf("\n      # of p lost in D1  = %d\n",fpLostD1);
@@ -1449,14 +1221,19 @@ void AliZDCv1::StepManager()
 
   // Determine in which ZDC the particle is
     knamed = gMC->CurrentVolName();
-    if(!strncmp(knamed,"ZN",2))vol[0]=1;
-    if(!strncmp(knamed,"ZP",2))vol[0]=2;
-    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
-    
-    //Quadrant in ZN
-    if(vol[0]==1){
+       
+    if(vol[0]==1){     //Quadrant in ZN
       xdet[0] = x[0]-fPosZN[0];
       xdet[1] = x[1]-fPosZN[1];
       if((xdet[0]<=0.) && (xdet[1]>=0.))  vol[1]=1;
@@ -1464,9 +1241,7 @@ void AliZDCv1::StepManager()
       if((xdet[0]<0.)  && (xdet[1]<0.))   vol[1]=3;
       if((xdet[0]>0.)  && (xdet[1]<0.))   vol[1]=4;
     }
-    
-    //Quadrant in ZP
-    if(vol[0]==2){
+    else if(vol[0]==2){        //Quadrant in ZP
       xdet[0] = x[0]-fPosZP[0];
       xdet[1] = x[1]-fPosZP[1];
       if(xdet[0]>fDimZP[0])xdet[0]=fDimZP[0]-0.01;
@@ -1475,14 +1250,11 @@ void AliZDCv1::StepManager()
       for(int i=1; i<=4; i++){
          if(xqZP>=(i-3) && xqZP<(i-2)){
           vol[1] = i;
-          if(i==0) printf("\n!!! vol[1] = 0 -> xqZP = %f\n", xqZP);
           break;
         }
       }
     }
-    
-    //ZEM has only 1 quadrant
-    if(vol[0] == 3){
+    else if(vol[0] == 3){      //ZEM has only 1 quadrant
       vol[1] = 1;
       xdet[0] = x[0]-fPosZEM[0];
       xdet[1] = x[1]-fPosZEM[1];
@@ -1505,7 +1277,7 @@ void AliZDCv1::StepManager()
 
 //       Int_t PcID = gMC->TrackPid();
 //       printf("Pc ID -> %d\n",PcID);
-       AddHit(gAlice->CurrentTrack(), vol, hits);
+       AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
        
        if(fNoShower==1){
 //       fpDetected += 1;
@@ -1525,13 +1297,13 @@ void AliZDCv1::StepManager()
           hits[9] = ekin;
           hits[7] = 0.;
           hits[8] = 0.;
-          AddHit(gAlice->CurrentTrack(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
         else{
           hits[9] = destep;
           hits[7] = 0.;
           hits[8] = 0.;
-          AddHit(gAlice->CurrentTrack(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
           }
 //      printf(" Dep. E = %f \n",hits[9]);
       }
@@ -1539,7 +1311,7 @@ void AliZDCv1::StepManager()
 
 
   // *** Light production in fibres 
-  if((gMC->GetMedium() == fMedSensF1) || (gMC->GetMedium() == fMedSensF2)){
+  if((gMC->CurrentMedium() == fMedSensF1) || (gMC->CurrentMedium() == fMedSensF2)){
 
      //Select charged particles
      if((destep=gMC->Edep())){
@@ -1548,11 +1320,21 @@ void AliZDCv1::StepManager()
        gMC->TrackMomentum(p);
        Float_t ptot=TMath::Sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
        Float_t beta =  ptot/p[3];
-       if(beta<0.67) return;
-       if((beta>=0.67) && (beta<=0.75)) ibeta = 0;
-       if((beta>0.75)  && (beta<=0.85)) ibeta = 1;
-       if((beta>0.85)  && (beta<=0.95)) ibeta = 2;
-       if(beta>0.95)   ibeta = 3;
+       if(beta<0.67){
+         return;
+       }
+       else if((beta>=0.67) && (beta<=0.75)){
+         ibeta = 0;
+       }
+       if((beta>0.75)  && (beta<=0.85)){
+         ibeta = 1;
+       }
+       if((beta>0.85)  && (beta<=0.95)){
+         ibeta = 2;
+       }
+       if(beta>0.95){
+         ibeta = 3;
+       }
  
        // Angle between particle trajectory and fibre axis
        // 1 -> Momentum directions
@@ -1580,65 +1362,79 @@ void AliZDCv1::StepManager()
          be = TMath::Abs(ud[0]);
        }
  
-       if((vol[0]==1)) radius = fFibZN[1];
-       if((vol[0]==2)) radius = fFibZP[1];
+       if((vol[0]==1)){
+         radius = fFibZN[1];
+       }
+       else if((vol[0]==2)){
+         radius = fFibZP[1];
+       }
        ibe = Int_t(be*1000.+1);
  
        //Looking into the light tables 
        Float_t charge = gMC->TrackCharge();
        
-       // (1)  ZN
-       if((vol[0]==1)) {
+       if((vol[0]==1)) {       // (1)  ZN fibres
          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){
+        if(gMC->CurrentMedium() == fMedSensF1){
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
           hits[9] = 0;
-          AddHit(gAlice->CurrentTrack(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = 0;
           hits[8] = nphe;      //fLightPMC
           hits[9] = 0;
-          AddHit(gAlice->CurrentTrack(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
-       
-       // (2) ZP
-       if((vol[0]==2)) {
+       else if((vol[0]==2)) {  // (2) ZP fibres
          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){
+        if(gMC->CurrentMedium() == fMedSensF1){
           hits[7] = nphe;      //fLightPMQ
           hits[8] = 0;
           hits[9] = 0;
-          AddHit(gAlice->CurrentTrack(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
         else{
           hits[7] = 0;
           hits[8] = nphe;      //fLightPMC
           hits[9] = 0;
-          AddHit(gAlice->CurrentTrack(), vol, hits);
+          AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
         }
        } 
-       // (3) ZEM
-       if((vol[0]==3)) {
+       else if((vol[0]==3)) {  // (3) ZEM fibres
          if(ibe>fNbep) ibe=fNbep;
          out =  charge*charge*fTablep[ibeta][ialfa][ibe];
+        gMC->TrackPosition(s);
+         for(j=0; j<=2; j++){
+            xalic[j] = s[j];
+         }
+        // z-coordinate from ZEM front face 
+        // NB-> fPosZEM[2]+fZEMLength = -1000.+2*10.3 = 979.69 cm
+        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;
         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);
         hits[7] = 0;   
         hits[8] = nphe;        //fLightPMC
         hits[9] = 0;
-        AddHit(gAlice->CurrentTrack(), vol, hits);
+        AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(), vol, hits);
        }
      }
    }