<commit_before>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */

///////////////////////////////////////////////////////////////////////
//                                                                   //
//  		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)	     //
//                                                                   //  
///////////////////////////////////////////////////////////////////////

// --- Standard libraries
#include "stdio.h"

// --- ROOT system
#include <TBRIK.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 "AliConst.h"
#include "AliDetector.h"
#include "AliMagF.h"
#include "AliPDG.h"
#include "AliRun.h"
#include "AliZDCHit.h"
#include "AliZDCv2.h"
#include "AliMC.h"
 
 
ClassImp(AliZDCv2)

//_____________________________________________________________________________
AliZDCv2::AliZDCv2() : AliZDC()
{
  //
  // Default constructor for Zero Degree Calorimeter
  //
  
  fMedSensF1  = 0;
  fMedSensF2  = 0;
  fMedSensZN  = 0;
  fMedSensZP  = 0;
  fMedSensZEM = 0;
  fMedSensGR  = 0;
//  fMedSensPI  = 0;
//  fMedSensTDI = 0;
}
 
//_____________________________________________________________________________
AliZDCv2::AliZDCv2(const char *name, const char *title)
  : AliZDC(name,title)
{
  //
  // Standard constructor for Zero Degree Calorimeter 
  //
  //
  // 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)) {
    Error("Constructor","ZDC needs PIPE, ABSO, DIPO and SHIL!!!\n");
    exit(1);
  } 

  fMedSensF1  = 0;
  fMedSensF2  = 0;
  fMedSensZN  = 0;
  fMedSensZP  = 0;
  fMedSensZEM = 0;
  fMedSensGR  = 0;
  fMedSensPI  = 0;
  fMedSensTDI = 0;

  
  // Parameters for light tables
  fNalfan = 90;       // Number of Alfa (neutrons)
  fNalfap = 90;       // Number of Alfa (protons)
  fNben = 18;         // Number of beta (neutrons)
  fNbep = 28;         // Number of beta (protons)
  Int_t ip,jp,kp;
  for(ip=0; ip<4; ip++){
     for(kp=0; kp<fNalfap; kp++){
        for(jp=0; jp<fNbep; jp++){
           fTablep[ip][kp][jp] = 0;
        } 
     }
  }
  Int_t in,jn,kn;
  for(in=0; in<4; in++){
     for(kn=0; kn<fNalfan; kn++){
        for(jn=0; jn<fNben; jn++){
           fTablen[in][kn][jn] = 0;
        } 
     }
  }

  // Parameters for hadronic calorimeters geometry
  fDimZN[0] = 3.52;
  fDimZN[1] = 3.52;
  fDimZN[2] = 50.;  
  fDimZP[0] = 11.2;
  fDimZP[1] = 6.;
  fDimZP[2] = 75.;    
  fPosZN[0] = 0.;
  fPosZN[1] = 1.2;
  fPosZN[2] = 11650.; 
  fPosZP[0] = -23.9;
  fPosZP[1] = 0.;
  fPosZP[2] = 11600.; 
  fFibZN[0] = 0.;
  fFibZN[1] = 0.01825;
  fFibZN[2] = 50.;
  fFibZP[0] = 0.;
  fFibZP[1] = 0.0275;
  fFibZP[2] = 75.;
  
  // Parameters for EM calorimeter geometry
  fPosZEM[0] = 8.5;
  fPosZEM[1] = 0.;
  fPosZEM[2] = 735.;
  fZEMLength = 0.;
  
}
 
//_____________________________________________________________________________
void AliZDCv2::CreateGeometry()
{
  //
  // Create the geometry for the Zero Degree Calorimeter version 2
  //* Initialize COMMON block ZDC_CGEOM
  //*

  CreateBeamLine();
  CreateZDC();
}
  
//_____________________________________________________________________________
void AliZDCv2::CreateBeamLine()
{
  
  Float_t 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)
  Int_t irotM;
  gMC->Matrix(irotM,90.,180.,90.,90.,180.,0.); 	

  zd1 = 2092.;
  
  conpar[0] = 0.;
  conpar[1] = 360.;
  conpar[2] = 2.;
  conpar[3] = zd1;
  conpar[4] = 0.;
  conpar[5] = 55.;
  conpar[6] = 13500.;
  conpar[7] = 0.;
  conpar[8] = 55.;
  gMC->Gsvolu("ZDC ", "PCON", idtmed[11], conpar, 9);
  gMC->Gspos("ZDC ", 1, "ALIC", 0., 0., 0., irotM, "ONLY");

  // -- 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");
  
  //-- SECOND SECTION OF THE BEAM PIPE (from the end of D1 to the
  //    	beginning of D2) 
  
  //-- FROM MAGNETIC BEGINNING OF D1 TO MAGNETIC END OF D1 + 13.5 cm
  //-- 	Cylindrical pipe (r = 3.47) + conical flare
  
  // -> Beginning of D1
  zd1 += 2.*tubpar[2];
  
  tubpar[0] = 3.47;
  tubpar[1] = 3.47+0.2;
  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");

  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.;
  gMC->Gsvolu("QC01", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC01", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");

  zd1 += 2.*conpar[0];
  
  tubpar[0] = 10./2.;
  tubpar[1] = 10.4/2.;
  tubpar[2] = 50./2.;
  gMC->Gsvolu("QT03", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT03", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  zd1 += tubpar[2]*2.;
  
  tubpar[0] = 10./2.;
  tubpar[1] = 10.4/2.;
  tubpar[2] = 10./2.;
  gMC->Gsvolu("QT04", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT04", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 10./2.;
  tubpar[1] = 10.4/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 10.0/2.;
  tubpar[1] = 10.4/2;
  tubpar[2] = 190./2.;
  gMC->Gsvolu("QT06", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT06", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  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.;
  gMC->Gsvolu("QC02", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC02", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 20.6/2.;
  tubpar[1] = 21./2.;
  tubpar[2] = 450./2.;
  gMC->Gsvolu("QT07", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT07", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  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.;
  gMC->Gsvolu("QC03", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC03", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 25.4/2.;
  tubpar[1] = 25.8/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 50./2.;
  tubpar[1] = 50.4/2.;
  // 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");
  
  // --- 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");
  
  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");
  
//  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;
  gMC->Gsvolu("QTD3", "TUBS", idtmed[6], tubspar, 5);
  gMC->Gspos("QTD3", 1, "ZDC ", 0., 0., tubpar[2]+zd1+56.3, 0, "ONLY");

  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 50./2.;
  tubpar[1] = 50.4/2.;
  // QT10 is 10 cm shorter
  tubpar[2] = 690./2.;
  gMC->Gsvolu("QT10", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT10", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 50./2.;
  tubpar[1] = 50.4/2.;
  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");
  
  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.;
  gMC->Gsvolu("QC04", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC04", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 55./2.;
  tubpar[1] = 55.4/2.;
  tubpar[2] = 730./2.;
  gMC->Gsvolu("QT12", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT12", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  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.;
  gMC->Gsvolu("QC05", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC05", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 68./2.;
  tubpar[1] = 68.4/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 0./2.;
  tubpar[1] = 68.4/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 0./2.;
  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);
  
  //-- Position QT16 inside QT14
  gMC->Gspos("QT16", 1, "QT14", 7.7, 0., 0., 0, "ONLY");
  
  
  //-- BEAM PIPE BETWEEN END OF CONICAL PIPE AND BEGINNING OF D2 
  
  tubpar[0] = 6.4/2.;
  tubpar[1] = 6.8/2.;
  tubpar[2] = 680.8/2.;
  gMC->Gsvolu("QT17", "TUBE", idtmed[7], tubpar, 3);

  tubpar[0] = 6.4/2.;
  tubpar[1] = 6.8/2.;
  tubpar[2] = 680.8/2.;
  gMC->Gsvolu("QT18", "TUBE", idtmed[7], tubpar, 3);
  
  // -- ROTATE PIPES 

  Float_t angle = 0.143*kDegrad;
  
  AliMatrix(im1, 90.-0.143, 0., 90., 90., 0.143, 180.);
  gMC->Gspos("QT17", 1, "ZDC ", TMath::Sin(angle) * 680.8/ 2. - 9.4, 
             0., tubpar[2]+zd1, im1, "ONLY");
	     
  AliMatrix(im2, 90.+0.143, 0., 90., 90., 0.143, 0.);
  gMC->Gspos("QT18", 1, "ZDC ", 9.7 - TMath::Sin(angle) * 680.8 / 2., 
             0., tubpar[2]+zd1, im2, "ONLY");
	         
  // --  END OF BEAM PIPE VOLUME DEFINITION.  
  // ----------------------------------------------------------------
   
  // ----------------------------------------------------------------
  // --  MAGNET DEFINITION  -> LHC OPTICS 6.4  
  // ----------------------------------------------------------------
  // -- INNER TRIPLET 
  
  zq = 2296.5;
  
  // -- DEFINE MQXL AND MQX QUADRUPOLE ELEMENT 
  
  //     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 
  
  tubpar[0] = 3.5;
  tubpar[1] = 22.;
  tubpar[2] = 637./2.;
  gMC->Gsvolu("YMQL", "TUBE", idtmed[7], tubpar, 3);
  
  gMC->Gspos("MQXL", 1, "ZDC ", 0., 0., tubpar[2]+zq, 0, "ONLY");
  gMC->Gspos("YMQL", 1, "ZDC ", 0., 0., tubpar[2]+zq, 0, "ONLY");
  
  gMC->Gspos("MQXL", 2, "ZDC ", 0., 0., tubpar[2]+zq+2430., 0, "ONLY");
  gMC->Gspos("YMQL", 2, "ZDC ", 0., 0., tubpar[2]+zq+2430., 0, "ONLY");
  
  // --  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.;
  gMC->Gsvolu("YMQ ", "TUBE", idtmed[7], tubpar, 3);
  
  gMC->Gspos("MQX ", 1, "ZDC ", 0., 0., tubpar[2]+zq+908.5,  0, "ONLY");
  gMC->Gspos("YMQ ", 1, "ZDC ", 0., 0., tubpar[2]+zq+908.5,  0, "ONLY");
  
  gMC->Gspos("MQX ", 2, "ZDC ", 0., 0., tubpar[2]+zq+1558.5, 0, "ONLY");
  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.;
  gMC->Gsvolu("MD1 ", "TUBE", idtmed[11], tubpar, 3);
  
  // --  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[1] = 0.2/2.;
  boxpar[2] =945./2.;
  gMC->Gsvolu("MD1V", "BOX ", idtmed[6], boxpar, 3);
  gMC->Gspos("MD1V", 1, "MD1 ", 0., 2.98+boxpar[1], 0., 0, "ONLY");
  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.;
  gMC->Gsvolu("YD1 ", "TUBE", idtmed[7], tubpar, 3);
  
  gMC->Gspos("YD1 ", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  gMC->Gspos("MD1 ", 1, "YD1 ", 0., 0., 0., 0, "ONLY");
  
  // -- DIPOLE D2 
  <commit_msg>Using small security distance to avoid FPE (A.Morsch)<commit_after>/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */

///////////////////////////////////////////////////////////////////////
//                                                                   //
//  		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)	     //
//                                                                   //  
///////////////////////////////////////////////////////////////////////

// --- Standard libraries
#include "stdio.h"

// --- ROOT system
#include <TBRIK.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 "AliConst.h"
#include "AliDetector.h"
#include "AliMagF.h"
#include "AliPDG.h"
#include "AliRun.h"
#include "AliZDCHit.h"
#include "AliZDCv2.h"
#include "AliMC.h"
 
 
ClassImp(AliZDCv2)

//_____________________________________________________________________________
AliZDCv2::AliZDCv2() : AliZDC()
{
  //
  // Default constructor for Zero Degree Calorimeter
  //
  
  fMedSensF1  = 0;
  fMedSensF2  = 0;
  fMedSensZN  = 0;
  fMedSensZP  = 0;
  fMedSensZEM = 0;
  fMedSensGR  = 0;
//  fMedSensPI  = 0;
//  fMedSensTDI = 0;
}
 
//_____________________________________________________________________________
AliZDCv2::AliZDCv2(const char *name, const char *title)
  : AliZDC(name,title)
{
  //
  // Standard constructor for Zero Degree Calorimeter 
  //
  //
  // 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)) {
    Error("Constructor","ZDC needs PIPE, ABSO, DIPO and SHIL!!!\n");
    exit(1);
  } 

  fMedSensF1  = 0;
  fMedSensF2  = 0;
  fMedSensZN  = 0;
  fMedSensZP  = 0;
  fMedSensZEM = 0;
  fMedSensGR  = 0;
  fMedSensPI  = 0;
  fMedSensTDI = 0;

  
  // Parameters for light tables
  fNalfan = 90;       // Number of Alfa (neutrons)
  fNalfap = 90;       // Number of Alfa (protons)
  fNben = 18;         // Number of beta (neutrons)
  fNbep = 28;         // Number of beta (protons)
  Int_t ip,jp,kp;
  for(ip=0; ip<4; ip++){
     for(kp=0; kp<fNalfap; kp++){
        for(jp=0; jp<fNbep; jp++){
           fTablep[ip][kp][jp] = 0;
        } 
     }
  }
  Int_t in,jn,kn;
  for(in=0; in<4; in++){
     for(kn=0; kn<fNalfan; kn++){
        for(jn=0; jn<fNben; jn++){
           fTablen[in][kn][jn] = 0;
        } 
     }
  }

  // Parameters for hadronic calorimeters geometry
  fDimZN[0] = 3.52;
  fDimZN[1] = 3.52;
  fDimZN[2] = 50.;  
  fDimZP[0] = 11.2;
  fDimZP[1] = 6.;
  fDimZP[2] = 75.;    
  fPosZN[0] = 0.;
  fPosZN[1] = 1.2;
  fPosZN[2] = 11650.; 
  fPosZP[0] = -23.9;
  fPosZP[1] = 0.;
  fPosZP[2] = 11600.; 
  fFibZN[0] = 0.;
  fFibZN[1] = 0.01825;
  fFibZN[2] = 50.;
  fFibZP[0] = 0.;
  fFibZP[1] = 0.0275;
  fFibZP[2] = 75.;
  
  // Parameters for EM calorimeter geometry
  fPosZEM[0] = 8.5;
  fPosZEM[1] = 0.;
  fPosZEM[2] = 735.;
  fZEMLength = 0.;
  
}
 
//_____________________________________________________________________________
void AliZDCv2::CreateGeometry()
{
  //
  // Create the geometry for the Zero Degree Calorimeter version 2
  //* Initialize COMMON block ZDC_CGEOM
  //*

  CreateBeamLine();
  CreateZDC();
}
  
//_____________________________________________________________________________
void AliZDCv2::CreateBeamLine()
{
  
  Float_t 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)
  Int_t irotM;
  gMC->Matrix(irotM,90.,180.,90.,90.,180.,0.); 	

  zd1 = 2092.;
  
  conpar[0] = 0.;
  conpar[1] = 360.;
  conpar[2] = 2.;
  conpar[3] = zd1;
  conpar[4] = 0.;
  conpar[5] = 55.;
  conpar[6] = 13500.;
  conpar[7] = 0.;
  conpar[8] = 55.;
  gMC->Gsvolu("ZDC ", "PCON", idtmed[11], conpar, 9);
  gMC->Gspos("ZDC ", 1, "ALIC", 0., 0., 0., irotM, "ONLY");

  // -- 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");
  
  //-- SECOND SECTION OF THE BEAM PIPE (from the end of D1 to the
  //    	beginning of D2) 
  
  //-- FROM MAGNETIC BEGINNING OF D1 TO MAGNETIC END OF D1 + 13.5 cm
  //-- 	Cylindrical pipe (r = 3.47) + conical flare
  
  // -> Beginning of D1
  zd1 += 2.*tubpar[2];
  
  tubpar[0] = 3.47;
  tubpar[1] = 3.47+0.2;
  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");

  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.;
  gMC->Gsvolu("QC01", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC01", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");

  zd1 += 2.*conpar[0];
  
  tubpar[0] = 10./2.;
  tubpar[1] = 10.4/2.;
  tubpar[2] = 50./2.;
  gMC->Gsvolu("QT03", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT03", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  zd1 += tubpar[2]*2.;
  
  tubpar[0] = 10./2.;
  tubpar[1] = 10.4/2.;
  tubpar[2] = 10./2.;
  gMC->Gsvolu("QT04", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT04", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 10./2.;
  tubpar[1] = 10.4/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 10.0/2.;
  tubpar[1] = 10.4/2;
  tubpar[2] = 190./2.;
  gMC->Gsvolu("QT06", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT06", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  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.;
  gMC->Gsvolu("QC02", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC02", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 20.6/2.;
  tubpar[1] = 21./2.;
  tubpar[2] = 450./2.;
  gMC->Gsvolu("QT07", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT07", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  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.;
  gMC->Gsvolu("QC03", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC03", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 25.4/2.;
  tubpar[1] = 25.8/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 50./2.;
  tubpar[1] = 50.4/2.;
  // 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");
  
  // --- 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");
  
  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");
  
//  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;
  gMC->Gsvolu("QTD3", "TUBS", idtmed[6], tubspar, 5);
  gMC->Gspos("QTD3", 1, "ZDC ", 0., 0., tubpar[2]+zd1+56.3, 0, "ONLY");

  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 50./2.;
  tubpar[1] = 50.4/2.;
  // QT10 is 10 cm shorter
  tubpar[2] = 690./2.;
  gMC->Gsvolu("QT10", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT10", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 50./2.;
  tubpar[1] = 50.4/2.;
  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");
  
  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.;
  gMC->Gsvolu("QC04", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC04", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 55./2.;
  tubpar[1] = 55.4/2.;
  tubpar[2] = 730./2.;
  gMC->Gsvolu("QT12", "TUBE", idtmed[7], tubpar, 3);
  gMC->Gspos("QT12", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  
  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.;
  gMC->Gsvolu("QC05", "CONE", idtmed[7], conpar, 5);
  gMC->Gspos("QC05", 1, "ZDC ", 0., 0., conpar[0]+zd1, 0, "ONLY");
  
  zd1 += conpar[0] * 2.;
  
  tubpar[0] = 68./2.;
  tubpar[1] = 68.4/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 0./2.;
  tubpar[1] = 68.4/2.;
  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");
  
  zd1 += tubpar[2] * 2.;
  
  tubpar[0] = 0./2.;
  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);
  
  //-- Position QT16 inside QT14
  gMC->Gspos("QT16", 1, "QT14", 7.7, 0., 0., 0, "ONLY");
  
  
  //-- BEAM PIPE BETWEEN END OF CONICAL PIPE AND BEGINNING OF D2 
  
  tubpar[0] = 6.4/2.;
  tubpar[1] = 6.8/2.;
  tubpar[2] = 680.8/2.;
  gMC->Gsvolu("QT17", "TUBE", idtmed[7], tubpar, 3);

  tubpar[0] = 6.4/2.;
  tubpar[1] = 6.8/2.;
  tubpar[2] = 680.8/2.;
  gMC->Gsvolu("QT18", "TUBE", idtmed[7], tubpar, 3);
  
  // -- ROTATE PIPES 

  Float_t angle = 0.143*kDegrad;
  
  AliMatrix(im1, 90.-0.143, 0., 90., 90., 0.143, 180.);
  gMC->Gspos("QT17", 1, "ZDC ", TMath::Sin(angle) * 680.8/ 2. - 9.4, 
             0., tubpar[2]+zd1, im1, "ONLY");
	     
  AliMatrix(im2, 90.+0.143, 0., 90., 90., 0.143, 0.);
  gMC->Gspos("QT18", 1, "ZDC ", 9.7 - TMath::Sin(angle) * 680.8 / 2., 
             0., tubpar[2]+zd1, im2, "ONLY");
	         
  // --  END OF BEAM PIPE VOLUME DEFINITION.  
  // ----------------------------------------------------------------
   
  // ----------------------------------------------------------------
  // --  MAGNET DEFINITION  -> LHC OPTICS 6.4  
  // ----------------------------------------------------------------
  // -- INNER TRIPLET 
  
  zq = 2296.5;
  
  // -- DEFINE MQXL AND MQX QUADRUPOLE ELEMENT 
  
  //     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 
  
  tubpar[0] = 3.5;
  tubpar[1] = 22.;
  tubpar[2] = 637./2.;
  gMC->Gsvolu("YMQL", "TUBE", idtmed[7], tubpar, 3);
  
  gMC->Gspos("MQXL", 1, "ZDC ", 0., 0., tubpar[2]+zq, 0, "ONLY");
  gMC->Gspos("YMQL", 1, "ZDC ", 0., 0., tubpar[2]+zq, 0, "ONLY");
  
  gMC->Gspos("MQXL", 2, "ZDC ", 0., 0., tubpar[2]+zq+2430., 0, "ONLY");
  gMC->Gspos("YMQL", 2, "ZDC ", 0., 0., tubpar[2]+zq+2430., 0, "ONLY");
  
  // --  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.;
  gMC->Gsvolu("YMQ ", "TUBE", idtmed[7], tubpar, 3);
  
  gMC->Gspos("MQX ", 1, "ZDC ", 0., 0., tubpar[2]+zq+908.5,  0, "ONLY");
  gMC->Gspos("YMQ ", 1, "ZDC ", 0., 0., tubpar[2]+zq+908.5,  0, "ONLY");
  
  gMC->Gspos("MQX ", 2, "ZDC ", 0., 0., tubpar[2]+zq+1558.5, 0, "ONLY");
  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.;
  gMC->Gsvolu("MD1 ", "TUBE", idtmed[11], tubpar, 3);
  
  // --  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)) - 0.05;
  boxpar[1] = 0.2/2.;
  boxpar[2] =945./2.;
  gMC->Gsvolu("MD1V", "BOX ", idtmed[6], boxpar, 3);
  gMC->Gspos("MD1V", 1, "MD1 ", 0., 2.98+boxpar[1], 0., 0, "ONLY");
  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.;
  gMC->Gsvolu("YD1 ", "TUBE", idtmed[7], tubpar, 3);
  
  gMC->Gspos("YD1 ", 1, "ZDC ", 0., 0., tubpar[2]+zd1, 0, "ONLY");
  gMC->Gspos("MD1 ", 1, "YD1 ", 0., 0., 0., 0, "ONLY");
  
  // -- DIPOLE D2 
  
{'fraction_non_alphanumeric': 0.2592467716376142, 'fraction_numerical': 0.0906638794295155, 'mean_word_length': 2.1650837690748053, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 183, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1150774', 'n_tokens_mistral': 15297, 'n_tokens_neox': 13393, 'n_words': 2782}