ROOT logo
/**************************************************************************
 * 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: AliPHOSGeometry.cxx 25590 2008-05-06 07:09:11Z prsnko $ */

//_________________________________________________________________________
// Geometry class  for PHOS 
// PHOS consists of the electromagnetic calorimeter (EMCA)
// and a charged particle veto (CPV)
// The EMCA/CPV modules are parametrized so that any configuration
// can be easily implemented 
// The title is used to identify the version of CPV used.
//                  
// -- Author: Yves Schutz (SUBATECH) & Dmitri Peressounko (RRC "KI" & SUBATECH)

// --- ROOT system ---

#include "TClonesArray.h"
#include "TVector3.h"
#include "TParticle.h"
#include <TGeoManager.h>
#include <TGeoMatrix.h>

// --- Standard library ---

// --- AliRoot header files ---
#include "AliLog.h"
#include "AliPHOSEMCAGeometry.h"
#include "AliPHOSCPVGeometry.h"
#include "AliPHOSSupportGeometry.h"
#include "AliPHOSGeoUtils.h"

ClassImp(AliPHOSGeoUtils)

//____________________________________________________________________________
AliPHOSGeoUtils::AliPHOSGeoUtils():
  fGeometryEMCA(0x0),fGeometryCPV(0x0),fGeometrySUPP(0x0),
  fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0),
  fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0),
  fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0),
  fCrystalShift(0.),fCryCellShift(0.),fCryStripShift(0.),fCellStep(0.),
  fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.),fMisalArray(0x0)
 
{
    // default ctor 
    // must be kept public for root persistency purposes, but should never be called by the outside world
  
  fXtlArrSize[0]=0.;   
  fXtlArrSize[1]=0.;                                                                           
  fXtlArrSize[2]=0.; 
  
  for(Int_t mod=0; mod<5; mod++){
    fEMCMatrix[mod]=0 ;
    for(Int_t istrip=0; istrip<224; istrip++)
      fStripMatrix[mod][istrip]=0 ;
    fCPVMatrix[mod]=0;
    fPHOSMatrix[mod]=0 ;
  }

}  

//____________________________________________________________________________
AliPHOSGeoUtils::AliPHOSGeoUtils(const AliPHOSGeoUtils & rhs)
  : TNamed(rhs),
  fGeometryEMCA(0x0),fGeometryCPV(0x0),fGeometrySUPP(0x0),
  fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0),
  fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0),
  fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0),
  fCrystalShift(0.),fCryCellShift(0.),fCryStripShift(0.),fCellStep(0.),
  fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.),fMisalArray(0x0)
{
  Fatal("cpy ctor", "not implemented") ; 
  for(Int_t mod=0; mod<5; mod++){
    fEMCMatrix[mod]=0 ;
    for(Int_t istrip=0; istrip<224; istrip++)
      fStripMatrix[mod][istrip]=0 ;
    fCPVMatrix[mod]=0;
    fPHOSMatrix[mod]=0 ;
  }
}

//____________________________________________________________________________
AliPHOSGeoUtils::AliPHOSGeoUtils(const Text_t* name, const Text_t* title) 
    : TNamed(name, title),
  fGeometryEMCA(0x0),fGeometryCPV(0x0),fGeometrySUPP(0x0),
  fNModules(0),fNCristalsInModule(0),fNPhi(0),fNZ(0),
  fNumberOfCPVPadsPhi(0),fNumberOfCPVPadsZ(0),
  fNCellsXInStrip(0),fNCellsZInStrip(0),fNStripZ(0),
  fCrystalShift(0.),fCryCellShift(0.),fCryStripShift(0.),fCellStep(0.),
  fPadSizePhi(0.),fPadSizeZ(0.),fCPVBoxSizeY(0.),fMisalArray(0x0)
{ 
  // ctor only for normal usage 

  fGeometryEMCA = new AliPHOSEMCAGeometry() ;
  fGeometryCPV  = new AliPHOSCPVGeometry() ;
  fGeometrySUPP = new AliPHOSSupportGeometry() ;

  fNModules     = 5;
  fNPhi  = fGeometryEMCA->GetNPhi() ;
  fNZ    = fGeometryEMCA->GetNZ() ;
  fNCristalsInModule = fNPhi*fNZ ;
  fNCellsXInStrip= fGeometryEMCA->GetNCellsXInStrip() ;
  fNCellsZInStrip= fGeometryEMCA->GetNCellsZInStrip() ;
  fNStripZ = fGeometryEMCA->GetNStripZ() ;
  fXtlArrSize[0]=fGeometryEMCA->GetInnerThermoHalfSize()[0] ; //Wery close to the zise of the Xtl set
  fXtlArrSize[1]=fGeometryEMCA->GetInnerThermoHalfSize()[1] ; //Wery close to the zise of the Xtl set
  fXtlArrSize[2]=fGeometryEMCA->GetInnerThermoHalfSize()[2] ; //Wery close to the zise of the Xtl set

  //calculate offset to crystal surface
  const Float_t * inthermo = fGeometryEMCA->GetInnerThermoHalfSize() ;
  const Float_t * strip    = fGeometryEMCA->GetStripHalfSize() ;
  const Float_t * splate   = fGeometryEMCA->GetSupportPlateHalfSize();
  const Float_t * crystal  = fGeometryEMCA->GetCrystalHalfSize() ;
  const Float_t * pin      = fGeometryEMCA->GetAPDHalfSize() ;
  const Float_t * preamp   = fGeometryEMCA->GetPreampHalfSize() ;
  fCrystalShift=-inthermo[1]+strip[1]+splate[1]+crystal[1]-fGeometryEMCA->GetAirGapLed()/2.+pin[1]+preamp[1] ;
  fCryCellShift=crystal[1]-(fGeometryEMCA->GetAirGapLed()-2*pin[1]-2*preamp[1])/2;
  fCryStripShift=fCryCellShift+splate[1] ;
  fCellStep = 2.*fGeometryEMCA->GetAirCellHalfSize()[0] ;

  fNumberOfCPVPadsPhi = fGeometryCPV->GetNumberOfCPVPadsPhi() ;
  fNumberOfCPVPadsZ   = fGeometryCPV->GetNumberOfCPVPadsZ() ;
  fPadSizePhi = fGeometryCPV->GetCPVPadSizePhi() ;
  fPadSizeZ   = fGeometryCPV->GetCPVPadSizeZ() ; 
  fCPVBoxSizeY= fGeometryCPV->GetCPVBoxSize(1) ;

  for(Int_t mod=0; mod<5; mod++){
    fEMCMatrix[mod]=0 ;
    for(Int_t istrip=0; istrip<224; istrip++)
      fStripMatrix[mod][istrip]=0 ;
    fCPVMatrix[mod]=0;
    fPHOSMatrix[mod]=0 ;
  }
 
}

//____________________________________________________________________________
AliPHOSGeoUtils & AliPHOSGeoUtils::operator = (const AliPHOSGeoUtils  & /*rvalue*/) { 

  Fatal("assignment operator", "not implemented") ; 
    return *this ;
}

//____________________________________________________________________________
AliPHOSGeoUtils::~AliPHOSGeoUtils(void)
{
  // dtor
  if(fGeometryEMCA){
    delete fGeometryEMCA; fGeometryEMCA = 0 ;
  }
  if(fGeometryCPV){
    delete fGeometryCPV; fGeometryCPV=0 ;
  }
  if(fGeometrySUPP){
    delete fGeometrySUPP ; fGeometrySUPP=0 ;
  }
  if(fMisalArray){
    delete fMisalArray; fMisalArray=0 ;
  }

  for(Int_t mod=0; mod<5; mod++){
    delete fEMCMatrix[mod] ;
    for(Int_t istrip=0; istrip<224; istrip++)
      delete fStripMatrix[mod][istrip];
    delete fCPVMatrix[mod];
    delete fPHOSMatrix[mod];
  }
}
//____________________________________________________________________________
Bool_t AliPHOSGeoUtils::AbsToRelNumbering(Int_t absId, Int_t * relid) const
{
  // Converts the absolute numbering into the following array
  //  relid[0] = PHOS Module number 1:fNModules 
  //  relid[1] = 0 if PbW04
  //           = -1 if CPV
  //  relid[2] = Row number inside a PHOS module
  //  relid[3] = Column number inside a PHOS module

  Float_t id = absId ;

  Int_t phosmodulenumber = (Int_t)TMath:: Ceil( id / fNCristalsInModule ) ; 
  
  if ( phosmodulenumber >  fNModules ) { // it is a CPV pad
    
    id -=  fNPhi * fNZ *  fNModules ; 
    Float_t nCPV  = fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ ;
    relid[0] = (Int_t) TMath::Ceil( id / nCPV ) ;
    relid[1] = -1 ;
    id -= ( relid[0] - 1 ) * nCPV ; 
    relid[2] = (Int_t) TMath::Ceil( id / fNumberOfCPVPadsZ ) ;
    relid[3] = (Int_t) ( id - ( relid[2] - 1 ) * fNumberOfCPVPadsZ ) ; 
  } 
  else { // it is a PW04 crystal

    relid[0] = phosmodulenumber ;
    relid[1] = 0 ;
    id -= ( phosmodulenumber - 1 ) *  fNPhi * fNZ ; 
    relid[2] = (Int_t)TMath::Ceil( id / fNZ )  ;
    relid[3] = (Int_t)( id - ( relid[2] - 1 ) * fNZ ) ; 
  } 
  return kTRUE ; 
}
//____________________________________________________________________________
Bool_t AliPHOSGeoUtils::RelToAbsNumbering(const Int_t * relid, Int_t &  absId) const
{
  // Converts the relative numbering into the absolute numbering
  // EMCA crystals:
  //  absId = from 1 to fNModules * fNPhi * fNZ
  // CPV pad:
  //  absId = from N(total PHOS crystals) + 1
  //          to NCPVModules * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ

  if ( relid[1] ==  0 ) {                            // it is a Phos crystal
    absId =
      ( relid[0] - 1 ) * fNPhi * fNZ         // the offset of PHOS modules
      + ( relid[2] - 1 ) * fNZ                   // the offset along phi
      +   relid[3] ;                                 // the offset along z
  }
  else { // it is a CPV pad
    absId =    fNPhi * fNZ *  fNModules         // the offset to separate EMCA crystals from CPV pads
      + ( relid[0] - 1 ) * fNumberOfCPVPadsPhi * fNumberOfCPVPadsZ   // the pads offset of PHOS modules 
      + ( relid[2] - 1 ) * fNumberOfCPVPadsZ                            // the pads offset of a CPV row
      +   relid[3] ;                                                         // the column number
  }
  
  return kTRUE ; 
}

//____________________________________________________________________________
void AliPHOSGeoUtils::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const 
{
  // Converts the relative numbering into the local PHOS-module (x, z) coordinates

  if(relid[1]==0){ //this is PHOS

    Double_t pos[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal 
    Double_t posC[3]={0.0,0.0,0.}; //Global position

    //Shift and possibly apply misalignment corrections
    Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/fNCellsXInStrip))*fNStripZ-
                (Int_t) TMath::Ceil((Double_t)relid[3]/fNCellsZInStrip) ;
    pos[0]=((relid[2]-1)%fNCellsXInStrip-fNCellsXInStrip/2+0.5)*fCellStep ;
    pos[2]=(-(relid[3]-1)%fNCellsZInStrip+fNCellsZInStrip/2-0.5)*fCellStep ;

    Int_t mod = relid[0] ;
    const TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
    m2->LocalToMaster(pos,posC);

    //Return to PHOS local system  
    Double_t posL2[3]={posC[0],posC[1],posC[2]};
    const TGeoHMatrix *mPHOS2 = GetMatrixForModule(mod) ;
    mPHOS2->MasterToLocal(posC,posL2);
    x=posL2[0] ;
    z=-posL2[2];
    return ;
  }
  else{//CPV
    //first calculate position with respect to CPV plain 
    Int_t row        = relid[2] ; //offset along x axis
    Int_t column     = relid[3] ; //offset along z axis
    Double_t pos[3]= {0.0,0.0,0.}; //Position incide the CPV printed circuit
    Double_t posC[3]={0.0,0.0,0.}; //Global position
    pos[0] = - ( fNumberOfCPVPadsPhi/2. - row    - 0.5 ) * fPadSizePhi  ; // position of pad  with respect
    pos[2] = - ( fNumberOfCPVPadsZ  /2. - column - 0.5 ) * fPadSizeZ  ; // of center of PHOS module

    //now apply possible shifts and rotations
    const TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
    m->LocalToMaster(pos,posC);
    //Return to PHOS local system
    Double_t posL[3]={0.,0.,0.,} ;
    const TGeoHMatrix *mPHOS = GetMatrixForPHOS(relid[0]) ;
    mPHOS->MasterToLocal(posC,posL);
    x=posL[0] ;
    z=posL[1];
    return ;
 
  }
  
}
//____________________________________________________________________________
void AliPHOSGeoUtils::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & absId) const
{
  // converts local PHOS-module (x, z) coordinates to absId 

  //Calculate AbsId using ideal geometry. Should be sufficient for primary particles calculation
  //(the only place where this method used currently)
  Int_t relid[4]={module,0,1,1} ;
  relid[2] = static_cast<Int_t>(TMath::Ceil( x/ fCellStep + fNPhi / 2.) );
  relid[3] = fNZ+1-static_cast<Int_t>(TMath::Ceil(-z/ fCellStep + fNZ   / 2.) ) ;
  if(relid[2]<1)relid[2]=1 ;
  if(relid[3]<1)relid[3]=1 ;
  if(relid[2]>fNPhi)relid[2]=fNPhi ;
  if(relid[3]>fNZ)relid[3]=fNZ ;
  RelToAbsNumbering(relid,absId) ;

/*
  //find Global position
  if (!gGeoManager){
    printf("Geo manager not initialized\n");
    abort() ;
  }
  Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!!
  Double_t posG[3] ;
  char path[100] ;
  sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ;
  if (!gGeoManager->cd(path)){
    printf("Geo manager can not find path \n");
    abort() ;
  }
  TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
  if (mPHOS){
     mPHOS->LocalToMaster(posL,posG);
  }
  else{
    printf("Geo matrixes are not loaded \n") ;
    abort() ;
  }

  Int_t relid[4] ;
  gGeoManager->FindNode(posG[0],posG[1],posG[2]) ;
  //Check that path contains PSTR and extract strip number
  TString cpath(gGeoManager->GetPath()) ;
  Int_t indx = cpath.Index("PCEL") ;
  if(indx==-1){ //for the few events when particle hits between srips use ideal geometry
    relid[0] = module ;
    relid[1] = 0 ;
    relid[2] = static_cast<Int_t>(TMath::Ceil( x/ fCellStep + fNPhi / 2.) );
    relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ fCellStep + fNZ   / 2.) ) ;
    if(relid[2]<1)relid[2]=1 ;
    if(relid[3]<1)relid[3]=1 ;
    if(relid[2]>fNPhi)relid[2]=fNPhi ;
    if(relid[3]>fNZ)relid[3]=fNZ ;
    RelToAbsNumbering(relid,absId) ;
  }
  else{
    Int_t indx2 = cpath.Index("/",indx) ;
    if(indx2==-1)
      indx2=cpath.Length() ;
    TString cell=cpath(indx+5,indx2-indx-5) ;
    Int_t icell=cell.Atoi() ;
    indx = cpath.Index("PSTR") ;
    indx2 = cpath.Index("/",indx) ;
    TString strip=cpath(indx+5,indx2-indx-5) ;
    Int_t iStrip = strip.Atoi() ; 

    Int_t row = fNStripZ - (iStrip - 1) % (fNStripZ) ;
    Int_t col = (Int_t) TMath::Ceil((Double_t) iStrip/(fNStripZ)) -1 ;
 
    // Absid for 8x2-strips. Looks nice :)
    absId = (module-1)*fNCristalsInModule +
                  row * 2 + (col*fNCellsXInStrip + (icell - 1) / 2)*fNZ - (icell & 1 ? 1 : 0);
 
  }
*/
 
}

//____________________________________________________________________________
void AliPHOSGeoUtils::RelPosToRelId(Int_t module, Double_t x, Double_t z, Int_t * relId) const
{
  //Evaluates RelId of the crystall with given coordinates

  Int_t absId ;
  RelPosToAbsId(module, x,z,absId) ;
  AbsToRelNumbering(absId,relId) ;
}

//____________________________________________________________________________
void AliPHOSGeoUtils::RelPosInAlice(Int_t id, TVector3 & pos ) const
{
  // Converts the absolute numbering into the global ALICE coordinate system
  
  if (!gGeoManager){
    AliFatal("Geo manager not initialized\n");
  }
    
  Int_t relid[4] ;
    
  AbsToRelNumbering(id , relid) ;
    
  //construct module name
  if(relid[1]==0){ //this is EMC
 
    Double_t ps[3]= {0.0,-fCryStripShift,0.}; //Position incide the crystal
    Double_t psC[3]={0.0,0.0,0.}; //Global position
 
    //Shift and possibly apply misalignment corrections
    Int_t strip=1+((Int_t) TMath::Ceil((Double_t)relid[2]/fNCellsXInStrip))*fNStripZ-
                (Int_t) TMath::Ceil((Double_t)relid[3]/fNCellsZInStrip) ;
    ps[0]=((relid[2]-1)%fNCellsXInStrip-fNCellsXInStrip/2+0.5)*fCellStep ;
    ps[2]=(-(relid[3]-1)%fNCellsZInStrip+fNCellsZInStrip/2-0.5)*fCellStep ;
 
    Int_t mod = relid[0] ;
    const TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
    m2->LocalToMaster(ps,psC);
    pos.SetXYZ(psC[0],psC[1],psC[2]) ; 
 
  }
  else{
    //first calculate position with respect to CPV plain
    Int_t row        = relid[2] ; //offset along x axis
    Int_t column     = relid[3] ; //offset along z axis
    Double_t ps[3]= {0.0,fCPVBoxSizeY/2.,0.}; //Position on top of CPV
    Double_t psC[3]={0.0,0.0,0.}; //Global position
    pos[0] = - ( fNumberOfCPVPadsPhi/2. - row    - 0.5 ) * fPadSizePhi  ; // position of pad  with respect
    pos[2] = - ( fNumberOfCPVPadsZ  /2. - column - 0.5 ) * fPadSizeZ  ; // of center of PHOS module
 
    //now apply possible shifts and rotations
    const TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
    m->LocalToMaster(ps,psC);
    pos.SetXYZ(psC[0],psC[1],-psC[2]) ; 
  }
} 

//____________________________________________________________________________
void AliPHOSGeoUtils::Local2Global(Int_t mod, Float_t x, Float_t z,
				   TVector3& globalPosition) const 
{
  Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!!
  Double_t posG[3] ;
  const TGeoHMatrix *mPHOS = GetMatrixForModule(mod) ;
  mPHOS->LocalToMaster(posL,posG);
  globalPosition.SetXYZ(posG[0],posG[1],posG[2]) ;
}
//____________________________________________________________________________
void AliPHOSGeoUtils::Global2Local(TVector3& localPosition,
				   const TVector3& globalPosition,
				   Int_t module) const
{
  // Transforms a global position to the local coordinate system
  // of the module 
  //Return to PHOS local system
  Double_t posG[3]={globalPosition.X(),globalPosition.Y(),globalPosition.Z()} ;
  Double_t posL[3]={0.,0.,0.} ;
  const TGeoHMatrix *mPHOS = GetMatrixForModule(module) ;
  if(mPHOS){
    mPHOS->MasterToLocal(posG,posL);
    localPosition.SetXYZ(posL[0],posL[1]+fCrystalShift,-posL[2]) ;  
  }
  else{
    localPosition.SetXYZ(999.,999.,999.) ; //module does not exist in given configuration
  }
 
}
//____________________________________________________________________________
Bool_t AliPHOSGeoUtils::GlobalPos2RelId(TVector3 & global, Int_t * relId){
  //Converts position in global ALICE coordinates to relId 
  //returns false if x,z coordinates are beyond PHOS
  //distande to PHOS surface is NOT calculated 
  TVector3 loc ;
  for(Int_t mod=1; mod<=fNModules; mod++){
    Global2Local(loc,global,mod) ;
    //If in Acceptance
    if((TMath::Abs(loc.Z())<fXtlArrSize[2]) && (TMath::Abs(loc.X())<fXtlArrSize[0])){
       RelPosToRelId(mod,loc.X(),loc.Z(),relId);
       return kTRUE ;
    }
  }
  return kFALSE ; 

}
//____________________________________________________________________________
Bool_t AliPHOSGeoUtils::ImpactOnEmc(const TParticle * particle,
       Int_t & moduleNumber, Double_t & z, Double_t & x) const
{
  // Tells if a particle enters PHOS and evaluates hit position
  Double_t vtx[3]={particle->Vx(),particle->Vy(),particle->Vz()} ;
  return ImpactOnEmc(vtx,particle->Theta(),particle->Phi(),moduleNumber,z,x);
}
 
//____________________________________________________________________________
Bool_t AliPHOSGeoUtils::ImpactOnEmc(const Double_t * vtx, Double_t theta, Double_t phi, 
                                  Int_t & moduleNumber, Double_t & z, Double_t & x) const
{
  // calculates the impact coordinates on PHOS of a neutral particle  
  // emitted in the vertex vtx[3] with direction vec(p) in the ALICE global coordinate system
  TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ;
  return ImpactOnEmc(vtx,p,moduleNumber,z,x) ;

}
//____________________________________________________________________________
Bool_t AliPHOSGeoUtils::ImpactOnEmc(const Double_t * vtx, const TVector3 &p,
                                  Int_t & moduleNumber, Double_t & z, Double_t & x) const
{
  // calculates the impact coordinates on PHOS of a neutral particle  
  // emitted in the vertex vtx[3] with direction theta and phi in the ALICE global coordinate system
  TVector3 v(vtx[0],vtx[1],vtx[2]) ;

  for(Int_t imod=1; imod<=fNModules ; imod++){
    //create vector from (0,0,0) to center of crystal surface of imod module
    Double_t tmp[3]={0.,-fCrystalShift,0.} ;
 
    const TGeoHMatrix *m = GetMatrixForModule(imod) ;
    if(!m) //module does not exist in given configuration
      continue ; 
    Double_t posG[3]={0.,0.,0.} ;
    m->LocalToMaster(tmp,posG);
    TVector3 n(posG[0],posG[1],posG[2]) ; 
    Double_t direction=n.Dot(p) ;
    if(direction<=0.)
      continue ; //momentum directed FROM module
    Double_t fr = (n.Mag2()-n.Dot(v))/direction ;  
    //Calculate direction in module plain
    n-=v+fr*p ;
    n*=-1. ;
    if(TMath::Abs(TMath::Abs(n.Z())<fXtlArrSize[2]) && n.Pt()<fXtlArrSize[0]){
      moduleNumber = imod ;
      z=n.Z() ;
      x=TMath::Sign(n.Pt(),n.X()) ;
      //no need to return to local system since we calcilated distance from module center
      //and tilts can not be significant.
      return kTRUE ;
    }
  }
  //Not in acceptance
  x=0; z=0 ;
  moduleNumber=0 ;
  return kFALSE ;

}
//____________________________________________________________________________
void AliPHOSGeoUtils::GetIncidentVector(const TVector3 &vtx, Int_t module, Float_t x,Float_t z, TVector3 &vInc) const {
  //Calculates vector pointing from vertex to current poisition in module local frame
  //Note that PHOS local system and ALICE global have opposite z directions

  Global2Local(vInc,vtx,module) ; 
  vInc.SetXYZ(vInc.X()+x,vInc.Y(),vInc.Z()+z) ;
}
//____________________________________________________________________________
const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForModule(Int_t mod)const {
  //Provides shift-rotation matrix for module mod

  //If GeoManager exists, take matrixes from it
  if(gGeoManager){
    char path[255] ;
    snprintf(path,255,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",mod) ;
    //    sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ;
    if (!gGeoManager->cd(path)){
      AliWarning(Form("Geo manager can not find path %s \n",path));
      return 0;
    }
    return gGeoManager->GetCurrentMatrix();
  }
  if(fEMCMatrix[mod-1]){
    return fEMCMatrix[mod-1] ;
  }
  else{
 //   AliWarning("Can not find PHOS misalignment matrixes\n") ;
 //   AliWarning("Either import TGeoManager from geometry.root or \n");
 //   AliWarning("read stored matrixes from AliESD Header: \n") ;
 //   AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ; 
    return 0 ;
  }
  return 0 ;
}
//____________________________________________________________________________
const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForStrip(Int_t mod, Int_t strip)const {
  //Provides shift-rotation matrix for strip unit of the module mod

  //If GeoManager exists, take matrixes from it
  if(gGeoManager){
    char path[255] ;
    snprintf(path,255,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d",mod,strip) ;
    if (!gGeoManager->cd(path)){
      AliWarning(Form("Geo manager can not find path %s \n",path));
      return 0 ;
    }
    return gGeoManager->GetCurrentMatrix();
  } 
  if(fStripMatrix[mod-1][strip-1]){
    return fStripMatrix[mod-1][strip-1] ;
  }
  else{
    AliWarning("Can not find PHOS misalignment matrixes\n") ;
    AliWarning("Either import TGeoManager from geometry.root or \n");
    AliWarning("read stored matrixes from AliESD Header: \n") ; 
    AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
    return 0 ;
  } 
  return 0 ;
}
//____________________________________________________________________________
const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForCPV(Int_t mod)const {
  //Provides shift-rotation matrix for CPV of the module mod

  //If GeoManager exists, take matrixes from it
  if(gGeoManager){ 
    char path[255] ;
    //now apply possible shifts and rotations
    snprintf(path,255,"/ALIC_1/PHOS_%d/PCPV_1",mod) ;
    if (!gGeoManager->cd(path)){
      AliWarning(Form("Geo manager can not find path %s \n",path));
      return 0 ;
    }
    return gGeoManager->GetCurrentMatrix();
  }
  if(fCPVMatrix[mod-1]){
    return fCPVMatrix[mod-1] ;
  }
  else{
    AliWarning("Can not find PHOS misalignment matrixes\n") ;
    AliWarning("Either import TGeoManager from geometry.root or \n");
    AliWarning("read stored matrixes from AliESD Header: \n") ;  
    AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
    return 0 ;
  }
  return 0 ;
} 
//____________________________________________________________________________
const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForPHOS(Int_t mod)const {
  //Provides shift-rotation matrix for PHOS (EMC+CPV) 

  //If GeoManager exists, take matrixes from it
  if(gGeoManager){

    char path[255] ;
    snprintf(path,255,"/ALIC_1/PHOS_%d",mod) ;
    
    if (!gGeoManager->cd(path)){
      AliWarning(Form("Geo manager can not find path %s \n",path));
      return 0 ;
    }
    return gGeoManager->GetCurrentMatrix();
  }
  if(fPHOSMatrix[mod-1]){
    return fPHOSMatrix[mod-1] ;
  }
  else{
    AliWarning("Can not find PHOS misalignment matrixes\n") ;
    AliWarning("Either import TGeoManager from geometry.root or \n");
    AliWarning("read stored matrixes from AliESD Header:  \n") ;   
    AliWarning("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
    return 0 ;
  }
  return 0 ;
}
//____________________________________________________________________________
void AliPHOSGeoUtils::SetMisalMatrix(const TGeoHMatrix * m, Int_t mod){
  //Fills pointers to geo matrixes
 
  if(fPHOSMatrix[mod]){ //have been set already. Can not be changed any more
    return ;
  }
  if(m==NULL) //Matrix for non-existing modules? Remain zero, no need to re-set
    return ;
  fPHOSMatrix[mod]= new TGeoHMatrix(*m) ;
  
  //Calculate maxtrices for PTII
  if(!fMisalArray)
    fMisalArray = new TClonesArray("TGeoHMatrix",1120+10) ;
  Int_t nr = fMisalArray->GetEntriesFast() ;
  Double_t rotEMC[9]={1.,0.,0.,0.,0.,-1.,0.,1.,0.} ;
  const Float_t * inthermo = fGeometryEMCA->GetInnerThermoHalfSize() ;
  const Float_t * strip    = fGeometryEMCA->GetStripHalfSize() ;
  const Float_t * covparams = fGeometryEMCA->GetAlCoverParams() ;
  const Float_t * warmcov = fGeometryEMCA->GetWarmAlCoverHalfSize() ;
  Float_t z = fGeometryCPV->GetCPVBoxSize(1) / 2. - warmcov[2] + covparams[3]-inthermo[1] ;
  Double_t locTII[3]={0.,0.,z} ; 
  Double_t globTII[3] ;

  if (fEMCMatrix[mod] == NULL)
    fEMCMatrix[mod] = new((*fMisalArray)[nr])TGeoHMatrix() ;
  nr++ ;
  fEMCMatrix[mod]->SetRotation(rotEMC) ;
  fEMCMatrix[mod]->MultiplyLeft(fPHOSMatrix[mod]) ;
  fPHOSMatrix[mod]->LocalToMaster(locTII,globTII) ;
  fEMCMatrix[mod]->SetTranslation(globTII) ;
 
  //Now calculate ideal matrixes for strip misalignment.
  //For the moment we can not store them in ESDHeader

  Double_t loc[3]={0.,inthermo[1] - strip[1],0.} ; 
  Double_t glob[3] ;

  Int_t istrip=0 ;
  for(Int_t irow = 0; irow < fGeometryEMCA->GetNStripX(); irow ++){
    loc[0] = (2*irow + 1 - fGeometryEMCA->GetNStripX())* strip[0] ;
    for(Int_t icol = 0; icol < fGeometryEMCA->GetNStripZ(); icol ++){
      loc[2] = (2*icol + 1 - fGeometryEMCA->GetNStripZ()) * strip[2] ;
      fEMCMatrix[mod]->LocalToMaster(loc,glob) ;
      if (fStripMatrix[mod][istrip] == NULL)
	fStripMatrix[mod][istrip] = new((*fMisalArray)[nr])TGeoHMatrix(*(fEMCMatrix[mod])) ; //Use same rotation as PHOS module
      nr++ ;
      fStripMatrix[mod][istrip]->SetTranslation(glob) ;
      istrip++;
    }
  }
 
  //Now calculate CPV matrixes
  const Float_t * emcParams = fGeometryEMCA->GetEMCParams() ;
  Double_t globCPV[3] ;
  Double_t locCPV[3]={0.,0.,- emcParams[3]} ;
  Double_t rot[9]={1.,0.,0.,0.,0.,1.,0.,-1.,0.} ;

  if (fCPVMatrix[mod] == NULL)
    fCPVMatrix[mod] = new((*fMisalArray)[nr])TGeoHMatrix() ;
  nr++ ;
  fCPVMatrix[mod]->SetRotation(rot) ;
  fCPVMatrix[mod]->MultiplyLeft(fPHOSMatrix[mod]) ;
  fCPVMatrix[mod]->ReflectY(kFALSE) ;
  fPHOSMatrix[mod]->LocalToMaster(locCPV,globCPV) ;
  fCPVMatrix[mod]->SetTranslation(globCPV) ;

}
 
 AliPHOSGeoUtils.cxx:1
 AliPHOSGeoUtils.cxx:2
 AliPHOSGeoUtils.cxx:3
 AliPHOSGeoUtils.cxx:4
 AliPHOSGeoUtils.cxx:5
 AliPHOSGeoUtils.cxx:6
 AliPHOSGeoUtils.cxx:7
 AliPHOSGeoUtils.cxx:8
 AliPHOSGeoUtils.cxx:9
 AliPHOSGeoUtils.cxx:10
 AliPHOSGeoUtils.cxx:11
 AliPHOSGeoUtils.cxx:12
 AliPHOSGeoUtils.cxx:13
 AliPHOSGeoUtils.cxx:14
 AliPHOSGeoUtils.cxx:15
 AliPHOSGeoUtils.cxx:16
 AliPHOSGeoUtils.cxx:17
 AliPHOSGeoUtils.cxx:18
 AliPHOSGeoUtils.cxx:19
 AliPHOSGeoUtils.cxx:20
 AliPHOSGeoUtils.cxx:21
 AliPHOSGeoUtils.cxx:22
 AliPHOSGeoUtils.cxx:23
 AliPHOSGeoUtils.cxx:24
 AliPHOSGeoUtils.cxx:25
 AliPHOSGeoUtils.cxx:26
 AliPHOSGeoUtils.cxx:27
 AliPHOSGeoUtils.cxx:28
 AliPHOSGeoUtils.cxx:29
 AliPHOSGeoUtils.cxx:30
 AliPHOSGeoUtils.cxx:31
 AliPHOSGeoUtils.cxx:32
 AliPHOSGeoUtils.cxx:33
 AliPHOSGeoUtils.cxx:34
 AliPHOSGeoUtils.cxx:35
 AliPHOSGeoUtils.cxx:36
 AliPHOSGeoUtils.cxx:37
 AliPHOSGeoUtils.cxx:38
 AliPHOSGeoUtils.cxx:39
 AliPHOSGeoUtils.cxx:40
 AliPHOSGeoUtils.cxx:41
 AliPHOSGeoUtils.cxx:42
 AliPHOSGeoUtils.cxx:43
 AliPHOSGeoUtils.cxx:44
 AliPHOSGeoUtils.cxx:45
 AliPHOSGeoUtils.cxx:46
 AliPHOSGeoUtils.cxx:47
 AliPHOSGeoUtils.cxx:48
 AliPHOSGeoUtils.cxx:49
 AliPHOSGeoUtils.cxx:50
 AliPHOSGeoUtils.cxx:51
 AliPHOSGeoUtils.cxx:52
 AliPHOSGeoUtils.cxx:53
 AliPHOSGeoUtils.cxx:54
 AliPHOSGeoUtils.cxx:55
 AliPHOSGeoUtils.cxx:56
 AliPHOSGeoUtils.cxx:57
 AliPHOSGeoUtils.cxx:58
 AliPHOSGeoUtils.cxx:59
 AliPHOSGeoUtils.cxx:60
 AliPHOSGeoUtils.cxx:61
 AliPHOSGeoUtils.cxx:62
 AliPHOSGeoUtils.cxx:63
 AliPHOSGeoUtils.cxx:64
 AliPHOSGeoUtils.cxx:65
 AliPHOSGeoUtils.cxx:66
 AliPHOSGeoUtils.cxx:67
 AliPHOSGeoUtils.cxx:68
 AliPHOSGeoUtils.cxx:69
 AliPHOSGeoUtils.cxx:70
 AliPHOSGeoUtils.cxx:71
 AliPHOSGeoUtils.cxx:72
 AliPHOSGeoUtils.cxx:73
 AliPHOSGeoUtils.cxx:74
 AliPHOSGeoUtils.cxx:75
 AliPHOSGeoUtils.cxx:76
 AliPHOSGeoUtils.cxx:77
 AliPHOSGeoUtils.cxx:78
 AliPHOSGeoUtils.cxx:79
 AliPHOSGeoUtils.cxx:80
 AliPHOSGeoUtils.cxx:81
 AliPHOSGeoUtils.cxx:82
 AliPHOSGeoUtils.cxx:83
 AliPHOSGeoUtils.cxx:84
 AliPHOSGeoUtils.cxx:85
 AliPHOSGeoUtils.cxx:86
 AliPHOSGeoUtils.cxx:87
 AliPHOSGeoUtils.cxx:88
 AliPHOSGeoUtils.cxx:89
 AliPHOSGeoUtils.cxx:90
 AliPHOSGeoUtils.cxx:91
 AliPHOSGeoUtils.cxx:92
 AliPHOSGeoUtils.cxx:93
 AliPHOSGeoUtils.cxx:94
 AliPHOSGeoUtils.cxx:95
 AliPHOSGeoUtils.cxx:96
 AliPHOSGeoUtils.cxx:97
 AliPHOSGeoUtils.cxx:98
 AliPHOSGeoUtils.cxx:99
 AliPHOSGeoUtils.cxx:100
 AliPHOSGeoUtils.cxx:101
 AliPHOSGeoUtils.cxx:102
 AliPHOSGeoUtils.cxx:103
 AliPHOSGeoUtils.cxx:104
 AliPHOSGeoUtils.cxx:105
 AliPHOSGeoUtils.cxx:106
 AliPHOSGeoUtils.cxx:107
 AliPHOSGeoUtils.cxx:108
 AliPHOSGeoUtils.cxx:109
 AliPHOSGeoUtils.cxx:110
 AliPHOSGeoUtils.cxx:111
 AliPHOSGeoUtils.cxx:112
 AliPHOSGeoUtils.cxx:113
 AliPHOSGeoUtils.cxx:114
 AliPHOSGeoUtils.cxx:115
 AliPHOSGeoUtils.cxx:116
 AliPHOSGeoUtils.cxx:117
 AliPHOSGeoUtils.cxx:118
 AliPHOSGeoUtils.cxx:119
 AliPHOSGeoUtils.cxx:120
 AliPHOSGeoUtils.cxx:121
 AliPHOSGeoUtils.cxx:122
 AliPHOSGeoUtils.cxx:123
 AliPHOSGeoUtils.cxx:124
 AliPHOSGeoUtils.cxx:125
 AliPHOSGeoUtils.cxx:126
 AliPHOSGeoUtils.cxx:127
 AliPHOSGeoUtils.cxx:128
 AliPHOSGeoUtils.cxx:129
 AliPHOSGeoUtils.cxx:130
 AliPHOSGeoUtils.cxx:131
 AliPHOSGeoUtils.cxx:132
 AliPHOSGeoUtils.cxx:133
 AliPHOSGeoUtils.cxx:134
 AliPHOSGeoUtils.cxx:135
 AliPHOSGeoUtils.cxx:136
 AliPHOSGeoUtils.cxx:137
 AliPHOSGeoUtils.cxx:138
 AliPHOSGeoUtils.cxx:139
 AliPHOSGeoUtils.cxx:140
 AliPHOSGeoUtils.cxx:141
 AliPHOSGeoUtils.cxx:142
 AliPHOSGeoUtils.cxx:143
 AliPHOSGeoUtils.cxx:144
 AliPHOSGeoUtils.cxx:145
 AliPHOSGeoUtils.cxx:146
 AliPHOSGeoUtils.cxx:147
 AliPHOSGeoUtils.cxx:148
 AliPHOSGeoUtils.cxx:149
 AliPHOSGeoUtils.cxx:150
 AliPHOSGeoUtils.cxx:151
 AliPHOSGeoUtils.cxx:152
 AliPHOSGeoUtils.cxx:153
 AliPHOSGeoUtils.cxx:154
 AliPHOSGeoUtils.cxx:155
 AliPHOSGeoUtils.cxx:156
 AliPHOSGeoUtils.cxx:157
 AliPHOSGeoUtils.cxx:158
 AliPHOSGeoUtils.cxx:159
 AliPHOSGeoUtils.cxx:160
 AliPHOSGeoUtils.cxx:161
 AliPHOSGeoUtils.cxx:162
 AliPHOSGeoUtils.cxx:163
 AliPHOSGeoUtils.cxx:164
 AliPHOSGeoUtils.cxx:165
 AliPHOSGeoUtils.cxx:166
 AliPHOSGeoUtils.cxx:167
 AliPHOSGeoUtils.cxx:168
 AliPHOSGeoUtils.cxx:169
 AliPHOSGeoUtils.cxx:170
 AliPHOSGeoUtils.cxx:171
 AliPHOSGeoUtils.cxx:172
 AliPHOSGeoUtils.cxx:173
 AliPHOSGeoUtils.cxx:174
 AliPHOSGeoUtils.cxx:175
 AliPHOSGeoUtils.cxx:176
 AliPHOSGeoUtils.cxx:177
 AliPHOSGeoUtils.cxx:178
 AliPHOSGeoUtils.cxx:179
 AliPHOSGeoUtils.cxx:180
 AliPHOSGeoUtils.cxx:181
 AliPHOSGeoUtils.cxx:182
 AliPHOSGeoUtils.cxx:183
 AliPHOSGeoUtils.cxx:184
 AliPHOSGeoUtils.cxx:185
 AliPHOSGeoUtils.cxx:186
 AliPHOSGeoUtils.cxx:187
 AliPHOSGeoUtils.cxx:188
 AliPHOSGeoUtils.cxx:189
 AliPHOSGeoUtils.cxx:190
 AliPHOSGeoUtils.cxx:191
 AliPHOSGeoUtils.cxx:192
 AliPHOSGeoUtils.cxx:193
 AliPHOSGeoUtils.cxx:194
 AliPHOSGeoUtils.cxx:195
 AliPHOSGeoUtils.cxx:196
 AliPHOSGeoUtils.cxx:197
 AliPHOSGeoUtils.cxx:198
 AliPHOSGeoUtils.cxx:199
 AliPHOSGeoUtils.cxx:200
 AliPHOSGeoUtils.cxx:201
 AliPHOSGeoUtils.cxx:202
 AliPHOSGeoUtils.cxx:203
 AliPHOSGeoUtils.cxx:204
 AliPHOSGeoUtils.cxx:205
 AliPHOSGeoUtils.cxx:206
 AliPHOSGeoUtils.cxx:207
 AliPHOSGeoUtils.cxx:208
 AliPHOSGeoUtils.cxx:209
 AliPHOSGeoUtils.cxx:210
 AliPHOSGeoUtils.cxx:211
 AliPHOSGeoUtils.cxx:212
 AliPHOSGeoUtils.cxx:213
 AliPHOSGeoUtils.cxx:214
 AliPHOSGeoUtils.cxx:215
 AliPHOSGeoUtils.cxx:216
 AliPHOSGeoUtils.cxx:217
 AliPHOSGeoUtils.cxx:218
 AliPHOSGeoUtils.cxx:219
 AliPHOSGeoUtils.cxx:220
 AliPHOSGeoUtils.cxx:221
 AliPHOSGeoUtils.cxx:222
 AliPHOSGeoUtils.cxx:223
 AliPHOSGeoUtils.cxx:224
 AliPHOSGeoUtils.cxx:225
 AliPHOSGeoUtils.cxx:226
 AliPHOSGeoUtils.cxx:227
 AliPHOSGeoUtils.cxx:228
 AliPHOSGeoUtils.cxx:229
 AliPHOSGeoUtils.cxx:230
 AliPHOSGeoUtils.cxx:231
 AliPHOSGeoUtils.cxx:232
 AliPHOSGeoUtils.cxx:233
 AliPHOSGeoUtils.cxx:234
 AliPHOSGeoUtils.cxx:235
 AliPHOSGeoUtils.cxx:236
 AliPHOSGeoUtils.cxx:237
 AliPHOSGeoUtils.cxx:238
 AliPHOSGeoUtils.cxx:239
 AliPHOSGeoUtils.cxx:240
 AliPHOSGeoUtils.cxx:241
 AliPHOSGeoUtils.cxx:242
 AliPHOSGeoUtils.cxx:243
 AliPHOSGeoUtils.cxx:244
 AliPHOSGeoUtils.cxx:245
 AliPHOSGeoUtils.cxx:246
 AliPHOSGeoUtils.cxx:247
 AliPHOSGeoUtils.cxx:248
 AliPHOSGeoUtils.cxx:249
 AliPHOSGeoUtils.cxx:250
 AliPHOSGeoUtils.cxx:251
 AliPHOSGeoUtils.cxx:252
 AliPHOSGeoUtils.cxx:253
 AliPHOSGeoUtils.cxx:254
 AliPHOSGeoUtils.cxx:255
 AliPHOSGeoUtils.cxx:256
 AliPHOSGeoUtils.cxx:257
 AliPHOSGeoUtils.cxx:258
 AliPHOSGeoUtils.cxx:259
 AliPHOSGeoUtils.cxx:260
 AliPHOSGeoUtils.cxx:261
 AliPHOSGeoUtils.cxx:262
 AliPHOSGeoUtils.cxx:263
 AliPHOSGeoUtils.cxx:264
 AliPHOSGeoUtils.cxx:265
 AliPHOSGeoUtils.cxx:266
 AliPHOSGeoUtils.cxx:267
 AliPHOSGeoUtils.cxx:268
 AliPHOSGeoUtils.cxx:269
 AliPHOSGeoUtils.cxx:270
 AliPHOSGeoUtils.cxx:271
 AliPHOSGeoUtils.cxx:272
 AliPHOSGeoUtils.cxx:273
 AliPHOSGeoUtils.cxx:274
 AliPHOSGeoUtils.cxx:275
 AliPHOSGeoUtils.cxx:276
 AliPHOSGeoUtils.cxx:277
 AliPHOSGeoUtils.cxx:278
 AliPHOSGeoUtils.cxx:279
 AliPHOSGeoUtils.cxx:280
 AliPHOSGeoUtils.cxx:281
 AliPHOSGeoUtils.cxx:282
 AliPHOSGeoUtils.cxx:283
 AliPHOSGeoUtils.cxx:284
 AliPHOSGeoUtils.cxx:285
 AliPHOSGeoUtils.cxx:286
 AliPHOSGeoUtils.cxx:287
 AliPHOSGeoUtils.cxx:288
 AliPHOSGeoUtils.cxx:289
 AliPHOSGeoUtils.cxx:290
 AliPHOSGeoUtils.cxx:291
 AliPHOSGeoUtils.cxx:292
 AliPHOSGeoUtils.cxx:293
 AliPHOSGeoUtils.cxx:294
 AliPHOSGeoUtils.cxx:295
 AliPHOSGeoUtils.cxx:296
 AliPHOSGeoUtils.cxx:297
 AliPHOSGeoUtils.cxx:298
 AliPHOSGeoUtils.cxx:299
 AliPHOSGeoUtils.cxx:300
 AliPHOSGeoUtils.cxx:301
 AliPHOSGeoUtils.cxx:302
 AliPHOSGeoUtils.cxx:303
 AliPHOSGeoUtils.cxx:304
 AliPHOSGeoUtils.cxx:305
 AliPHOSGeoUtils.cxx:306
 AliPHOSGeoUtils.cxx:307
 AliPHOSGeoUtils.cxx:308
 AliPHOSGeoUtils.cxx:309
 AliPHOSGeoUtils.cxx:310
 AliPHOSGeoUtils.cxx:311
 AliPHOSGeoUtils.cxx:312
 AliPHOSGeoUtils.cxx:313
 AliPHOSGeoUtils.cxx:314
 AliPHOSGeoUtils.cxx:315
 AliPHOSGeoUtils.cxx:316
 AliPHOSGeoUtils.cxx:317
 AliPHOSGeoUtils.cxx:318
 AliPHOSGeoUtils.cxx:319
 AliPHOSGeoUtils.cxx:320
 AliPHOSGeoUtils.cxx:321
 AliPHOSGeoUtils.cxx:322
 AliPHOSGeoUtils.cxx:323
 AliPHOSGeoUtils.cxx:324
 AliPHOSGeoUtils.cxx:325
 AliPHOSGeoUtils.cxx:326
 AliPHOSGeoUtils.cxx:327
 AliPHOSGeoUtils.cxx:328
 AliPHOSGeoUtils.cxx:329
 AliPHOSGeoUtils.cxx:330
 AliPHOSGeoUtils.cxx:331
 AliPHOSGeoUtils.cxx:332
 AliPHOSGeoUtils.cxx:333
 AliPHOSGeoUtils.cxx:334
 AliPHOSGeoUtils.cxx:335
 AliPHOSGeoUtils.cxx:336
 AliPHOSGeoUtils.cxx:337
 AliPHOSGeoUtils.cxx:338
 AliPHOSGeoUtils.cxx:339
 AliPHOSGeoUtils.cxx:340
 AliPHOSGeoUtils.cxx:341
 AliPHOSGeoUtils.cxx:342
 AliPHOSGeoUtils.cxx:343
 AliPHOSGeoUtils.cxx:344
 AliPHOSGeoUtils.cxx:345
 AliPHOSGeoUtils.cxx:346
 AliPHOSGeoUtils.cxx:347
 AliPHOSGeoUtils.cxx:348
 AliPHOSGeoUtils.cxx:349
 AliPHOSGeoUtils.cxx:350
 AliPHOSGeoUtils.cxx:351
 AliPHOSGeoUtils.cxx:352
 AliPHOSGeoUtils.cxx:353
 AliPHOSGeoUtils.cxx:354
 AliPHOSGeoUtils.cxx:355
 AliPHOSGeoUtils.cxx:356
 AliPHOSGeoUtils.cxx:357
 AliPHOSGeoUtils.cxx:358
 AliPHOSGeoUtils.cxx:359
 AliPHOSGeoUtils.cxx:360
 AliPHOSGeoUtils.cxx:361
 AliPHOSGeoUtils.cxx:362
 AliPHOSGeoUtils.cxx:363
 AliPHOSGeoUtils.cxx:364
 AliPHOSGeoUtils.cxx:365
 AliPHOSGeoUtils.cxx:366
 AliPHOSGeoUtils.cxx:367
 AliPHOSGeoUtils.cxx:368
 AliPHOSGeoUtils.cxx:369
 AliPHOSGeoUtils.cxx:370
 AliPHOSGeoUtils.cxx:371
 AliPHOSGeoUtils.cxx:372
 AliPHOSGeoUtils.cxx:373
 AliPHOSGeoUtils.cxx:374
 AliPHOSGeoUtils.cxx:375
 AliPHOSGeoUtils.cxx:376
 AliPHOSGeoUtils.cxx:377
 AliPHOSGeoUtils.cxx:378
 AliPHOSGeoUtils.cxx:379
 AliPHOSGeoUtils.cxx:380
 AliPHOSGeoUtils.cxx:381
 AliPHOSGeoUtils.cxx:382
 AliPHOSGeoUtils.cxx:383
 AliPHOSGeoUtils.cxx:384
 AliPHOSGeoUtils.cxx:385
 AliPHOSGeoUtils.cxx:386
 AliPHOSGeoUtils.cxx:387
 AliPHOSGeoUtils.cxx:388
 AliPHOSGeoUtils.cxx:389
 AliPHOSGeoUtils.cxx:390
 AliPHOSGeoUtils.cxx:391
 AliPHOSGeoUtils.cxx:392
 AliPHOSGeoUtils.cxx:393
 AliPHOSGeoUtils.cxx:394
 AliPHOSGeoUtils.cxx:395
 AliPHOSGeoUtils.cxx:396
 AliPHOSGeoUtils.cxx:397
 AliPHOSGeoUtils.cxx:398
 AliPHOSGeoUtils.cxx:399
 AliPHOSGeoUtils.cxx:400
 AliPHOSGeoUtils.cxx:401
 AliPHOSGeoUtils.cxx:402
 AliPHOSGeoUtils.cxx:403
 AliPHOSGeoUtils.cxx:404
 AliPHOSGeoUtils.cxx:405
 AliPHOSGeoUtils.cxx:406
 AliPHOSGeoUtils.cxx:407
 AliPHOSGeoUtils.cxx:408
 AliPHOSGeoUtils.cxx:409
 AliPHOSGeoUtils.cxx:410
 AliPHOSGeoUtils.cxx:411
 AliPHOSGeoUtils.cxx:412
 AliPHOSGeoUtils.cxx:413
 AliPHOSGeoUtils.cxx:414
 AliPHOSGeoUtils.cxx:415
 AliPHOSGeoUtils.cxx:416
 AliPHOSGeoUtils.cxx:417
 AliPHOSGeoUtils.cxx:418
 AliPHOSGeoUtils.cxx:419
 AliPHOSGeoUtils.cxx:420
 AliPHOSGeoUtils.cxx:421
 AliPHOSGeoUtils.cxx:422
 AliPHOSGeoUtils.cxx:423
 AliPHOSGeoUtils.cxx:424
 AliPHOSGeoUtils.cxx:425
 AliPHOSGeoUtils.cxx:426
 AliPHOSGeoUtils.cxx:427
 AliPHOSGeoUtils.cxx:428
 AliPHOSGeoUtils.cxx:429
 AliPHOSGeoUtils.cxx:430
 AliPHOSGeoUtils.cxx:431
 AliPHOSGeoUtils.cxx:432
 AliPHOSGeoUtils.cxx:433
 AliPHOSGeoUtils.cxx:434
 AliPHOSGeoUtils.cxx:435
 AliPHOSGeoUtils.cxx:436
 AliPHOSGeoUtils.cxx:437
 AliPHOSGeoUtils.cxx:438
 AliPHOSGeoUtils.cxx:439
 AliPHOSGeoUtils.cxx:440
 AliPHOSGeoUtils.cxx:441
 AliPHOSGeoUtils.cxx:442
 AliPHOSGeoUtils.cxx:443
 AliPHOSGeoUtils.cxx:444
 AliPHOSGeoUtils.cxx:445
 AliPHOSGeoUtils.cxx:446
 AliPHOSGeoUtils.cxx:447
 AliPHOSGeoUtils.cxx:448
 AliPHOSGeoUtils.cxx:449
 AliPHOSGeoUtils.cxx:450
 AliPHOSGeoUtils.cxx:451
 AliPHOSGeoUtils.cxx:452
 AliPHOSGeoUtils.cxx:453
 AliPHOSGeoUtils.cxx:454
 AliPHOSGeoUtils.cxx:455
 AliPHOSGeoUtils.cxx:456
 AliPHOSGeoUtils.cxx:457
 AliPHOSGeoUtils.cxx:458
 AliPHOSGeoUtils.cxx:459
 AliPHOSGeoUtils.cxx:460
 AliPHOSGeoUtils.cxx:461
 AliPHOSGeoUtils.cxx:462
 AliPHOSGeoUtils.cxx:463
 AliPHOSGeoUtils.cxx:464
 AliPHOSGeoUtils.cxx:465
 AliPHOSGeoUtils.cxx:466
 AliPHOSGeoUtils.cxx:467
 AliPHOSGeoUtils.cxx:468
 AliPHOSGeoUtils.cxx:469
 AliPHOSGeoUtils.cxx:470
 AliPHOSGeoUtils.cxx:471
 AliPHOSGeoUtils.cxx:472
 AliPHOSGeoUtils.cxx:473
 AliPHOSGeoUtils.cxx:474
 AliPHOSGeoUtils.cxx:475
 AliPHOSGeoUtils.cxx:476
 AliPHOSGeoUtils.cxx:477
 AliPHOSGeoUtils.cxx:478
 AliPHOSGeoUtils.cxx:479
 AliPHOSGeoUtils.cxx:480
 AliPHOSGeoUtils.cxx:481
 AliPHOSGeoUtils.cxx:482
 AliPHOSGeoUtils.cxx:483
 AliPHOSGeoUtils.cxx:484
 AliPHOSGeoUtils.cxx:485
 AliPHOSGeoUtils.cxx:486
 AliPHOSGeoUtils.cxx:487
 AliPHOSGeoUtils.cxx:488
 AliPHOSGeoUtils.cxx:489
 AliPHOSGeoUtils.cxx:490
 AliPHOSGeoUtils.cxx:491
 AliPHOSGeoUtils.cxx:492
 AliPHOSGeoUtils.cxx:493
 AliPHOSGeoUtils.cxx:494
 AliPHOSGeoUtils.cxx:495
 AliPHOSGeoUtils.cxx:496
 AliPHOSGeoUtils.cxx:497
 AliPHOSGeoUtils.cxx:498
 AliPHOSGeoUtils.cxx:499
 AliPHOSGeoUtils.cxx:500
 AliPHOSGeoUtils.cxx:501
 AliPHOSGeoUtils.cxx:502
 AliPHOSGeoUtils.cxx:503
 AliPHOSGeoUtils.cxx:504
 AliPHOSGeoUtils.cxx:505
 AliPHOSGeoUtils.cxx:506
 AliPHOSGeoUtils.cxx:507
 AliPHOSGeoUtils.cxx:508
 AliPHOSGeoUtils.cxx:509
 AliPHOSGeoUtils.cxx:510
 AliPHOSGeoUtils.cxx:511
 AliPHOSGeoUtils.cxx:512
 AliPHOSGeoUtils.cxx:513
 AliPHOSGeoUtils.cxx:514
 AliPHOSGeoUtils.cxx:515
 AliPHOSGeoUtils.cxx:516
 AliPHOSGeoUtils.cxx:517
 AliPHOSGeoUtils.cxx:518
 AliPHOSGeoUtils.cxx:519
 AliPHOSGeoUtils.cxx:520
 AliPHOSGeoUtils.cxx:521
 AliPHOSGeoUtils.cxx:522
 AliPHOSGeoUtils.cxx:523
 AliPHOSGeoUtils.cxx:524
 AliPHOSGeoUtils.cxx:525
 AliPHOSGeoUtils.cxx:526
 AliPHOSGeoUtils.cxx:527
 AliPHOSGeoUtils.cxx:528
 AliPHOSGeoUtils.cxx:529
 AliPHOSGeoUtils.cxx:530
 AliPHOSGeoUtils.cxx:531
 AliPHOSGeoUtils.cxx:532
 AliPHOSGeoUtils.cxx:533
 AliPHOSGeoUtils.cxx:534
 AliPHOSGeoUtils.cxx:535
 AliPHOSGeoUtils.cxx:536
 AliPHOSGeoUtils.cxx:537
 AliPHOSGeoUtils.cxx:538
 AliPHOSGeoUtils.cxx:539
 AliPHOSGeoUtils.cxx:540
 AliPHOSGeoUtils.cxx:541
 AliPHOSGeoUtils.cxx:542
 AliPHOSGeoUtils.cxx:543
 AliPHOSGeoUtils.cxx:544
 AliPHOSGeoUtils.cxx:545
 AliPHOSGeoUtils.cxx:546
 AliPHOSGeoUtils.cxx:547
 AliPHOSGeoUtils.cxx:548
 AliPHOSGeoUtils.cxx:549
 AliPHOSGeoUtils.cxx:550
 AliPHOSGeoUtils.cxx:551
 AliPHOSGeoUtils.cxx:552
 AliPHOSGeoUtils.cxx:553
 AliPHOSGeoUtils.cxx:554
 AliPHOSGeoUtils.cxx:555
 AliPHOSGeoUtils.cxx:556
 AliPHOSGeoUtils.cxx:557
 AliPHOSGeoUtils.cxx:558
 AliPHOSGeoUtils.cxx:559
 AliPHOSGeoUtils.cxx:560
 AliPHOSGeoUtils.cxx:561
 AliPHOSGeoUtils.cxx:562
 AliPHOSGeoUtils.cxx:563
 AliPHOSGeoUtils.cxx:564
 AliPHOSGeoUtils.cxx:565
 AliPHOSGeoUtils.cxx:566
 AliPHOSGeoUtils.cxx:567
 AliPHOSGeoUtils.cxx:568
 AliPHOSGeoUtils.cxx:569
 AliPHOSGeoUtils.cxx:570
 AliPHOSGeoUtils.cxx:571
 AliPHOSGeoUtils.cxx:572
 AliPHOSGeoUtils.cxx:573
 AliPHOSGeoUtils.cxx:574
 AliPHOSGeoUtils.cxx:575
 AliPHOSGeoUtils.cxx:576
 AliPHOSGeoUtils.cxx:577
 AliPHOSGeoUtils.cxx:578
 AliPHOSGeoUtils.cxx:579
 AliPHOSGeoUtils.cxx:580
 AliPHOSGeoUtils.cxx:581
 AliPHOSGeoUtils.cxx:582
 AliPHOSGeoUtils.cxx:583
 AliPHOSGeoUtils.cxx:584
 AliPHOSGeoUtils.cxx:585
 AliPHOSGeoUtils.cxx:586
 AliPHOSGeoUtils.cxx:587
 AliPHOSGeoUtils.cxx:588
 AliPHOSGeoUtils.cxx:589
 AliPHOSGeoUtils.cxx:590
 AliPHOSGeoUtils.cxx:591
 AliPHOSGeoUtils.cxx:592
 AliPHOSGeoUtils.cxx:593
 AliPHOSGeoUtils.cxx:594
 AliPHOSGeoUtils.cxx:595
 AliPHOSGeoUtils.cxx:596
 AliPHOSGeoUtils.cxx:597
 AliPHOSGeoUtils.cxx:598
 AliPHOSGeoUtils.cxx:599
 AliPHOSGeoUtils.cxx:600
 AliPHOSGeoUtils.cxx:601
 AliPHOSGeoUtils.cxx:602
 AliPHOSGeoUtils.cxx:603
 AliPHOSGeoUtils.cxx:604
 AliPHOSGeoUtils.cxx:605
 AliPHOSGeoUtils.cxx:606
 AliPHOSGeoUtils.cxx:607
 AliPHOSGeoUtils.cxx:608
 AliPHOSGeoUtils.cxx:609
 AliPHOSGeoUtils.cxx:610
 AliPHOSGeoUtils.cxx:611
 AliPHOSGeoUtils.cxx:612
 AliPHOSGeoUtils.cxx:613
 AliPHOSGeoUtils.cxx:614
 AliPHOSGeoUtils.cxx:615
 AliPHOSGeoUtils.cxx:616
 AliPHOSGeoUtils.cxx:617
 AliPHOSGeoUtils.cxx:618
 AliPHOSGeoUtils.cxx:619
 AliPHOSGeoUtils.cxx:620
 AliPHOSGeoUtils.cxx:621
 AliPHOSGeoUtils.cxx:622
 AliPHOSGeoUtils.cxx:623
 AliPHOSGeoUtils.cxx:624
 AliPHOSGeoUtils.cxx:625
 AliPHOSGeoUtils.cxx:626
 AliPHOSGeoUtils.cxx:627
 AliPHOSGeoUtils.cxx:628
 AliPHOSGeoUtils.cxx:629
 AliPHOSGeoUtils.cxx:630
 AliPHOSGeoUtils.cxx:631
 AliPHOSGeoUtils.cxx:632
 AliPHOSGeoUtils.cxx:633
 AliPHOSGeoUtils.cxx:634
 AliPHOSGeoUtils.cxx:635
 AliPHOSGeoUtils.cxx:636
 AliPHOSGeoUtils.cxx:637
 AliPHOSGeoUtils.cxx:638
 AliPHOSGeoUtils.cxx:639
 AliPHOSGeoUtils.cxx:640
 AliPHOSGeoUtils.cxx:641
 AliPHOSGeoUtils.cxx:642
 AliPHOSGeoUtils.cxx:643
 AliPHOSGeoUtils.cxx:644
 AliPHOSGeoUtils.cxx:645
 AliPHOSGeoUtils.cxx:646
 AliPHOSGeoUtils.cxx:647
 AliPHOSGeoUtils.cxx:648
 AliPHOSGeoUtils.cxx:649
 AliPHOSGeoUtils.cxx:650
 AliPHOSGeoUtils.cxx:651
 AliPHOSGeoUtils.cxx:652
 AliPHOSGeoUtils.cxx:653
 AliPHOSGeoUtils.cxx:654
 AliPHOSGeoUtils.cxx:655
 AliPHOSGeoUtils.cxx:656
 AliPHOSGeoUtils.cxx:657
 AliPHOSGeoUtils.cxx:658
 AliPHOSGeoUtils.cxx:659
 AliPHOSGeoUtils.cxx:660
 AliPHOSGeoUtils.cxx:661
 AliPHOSGeoUtils.cxx:662
 AliPHOSGeoUtils.cxx:663
 AliPHOSGeoUtils.cxx:664
 AliPHOSGeoUtils.cxx:665
 AliPHOSGeoUtils.cxx:666
 AliPHOSGeoUtils.cxx:667
 AliPHOSGeoUtils.cxx:668
 AliPHOSGeoUtils.cxx:669
 AliPHOSGeoUtils.cxx:670
 AliPHOSGeoUtils.cxx:671
 AliPHOSGeoUtils.cxx:672
 AliPHOSGeoUtils.cxx:673
 AliPHOSGeoUtils.cxx:674
 AliPHOSGeoUtils.cxx:675
 AliPHOSGeoUtils.cxx:676
 AliPHOSGeoUtils.cxx:677
 AliPHOSGeoUtils.cxx:678
 AliPHOSGeoUtils.cxx:679
 AliPHOSGeoUtils.cxx:680
 AliPHOSGeoUtils.cxx:681
 AliPHOSGeoUtils.cxx:682
 AliPHOSGeoUtils.cxx:683
 AliPHOSGeoUtils.cxx:684
 AliPHOSGeoUtils.cxx:685
 AliPHOSGeoUtils.cxx:686
 AliPHOSGeoUtils.cxx:687
 AliPHOSGeoUtils.cxx:688
 AliPHOSGeoUtils.cxx:689
 AliPHOSGeoUtils.cxx:690
 AliPHOSGeoUtils.cxx:691
 AliPHOSGeoUtils.cxx:692
 AliPHOSGeoUtils.cxx:693
 AliPHOSGeoUtils.cxx:694
 AliPHOSGeoUtils.cxx:695
 AliPHOSGeoUtils.cxx:696
 AliPHOSGeoUtils.cxx:697
 AliPHOSGeoUtils.cxx:698
 AliPHOSGeoUtils.cxx:699
 AliPHOSGeoUtils.cxx:700
 AliPHOSGeoUtils.cxx:701
 AliPHOSGeoUtils.cxx:702
 AliPHOSGeoUtils.cxx:703
 AliPHOSGeoUtils.cxx:704
 AliPHOSGeoUtils.cxx:705
 AliPHOSGeoUtils.cxx:706
 AliPHOSGeoUtils.cxx:707
 AliPHOSGeoUtils.cxx:708
 AliPHOSGeoUtils.cxx:709
 AliPHOSGeoUtils.cxx:710
 AliPHOSGeoUtils.cxx:711
 AliPHOSGeoUtils.cxx:712
 AliPHOSGeoUtils.cxx:713
 AliPHOSGeoUtils.cxx:714
 AliPHOSGeoUtils.cxx:715
 AliPHOSGeoUtils.cxx:716
 AliPHOSGeoUtils.cxx:717