-//____________________________________________________________________________
-void AliPHOSGeometry::ImpactOnEmc(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 theta and phi in the ALICE global coordinate system
- TVector3 p(TMath::Sin(theta)*TMath::Cos(phi),TMath::Sin(theta)*TMath::Sin(phi),TMath::Cos(theta)) ;
- TVector3 v(vtx[0],vtx[1],vtx[2]) ;
-
- if (!gGeoManager){
- AliFatal("Geo manager not initialized\n");
- }
-
- for(Int_t imod=1; imod<=GetNModules() ; imod++){
- //create vector from (0,0,0) to center of crystal surface of imod module
- Double_t tmp[3]={0.,-fCrystalShift,0.} ;
-
- char path[100] ;
- sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",imod) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
- Double_t posG[3]={0.,0.,0.} ;
- if (m) 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. ;
- Float_t * sz = fGeometryEMCA->GetInnerThermoHalfSize() ; //Wery close to the zise of the Xtl set
- if(TMath::Abs(TMath::Abs(n.Z())<sz[2]) && n.Pt()<sz[0]){
- moduleNumber = imod ;
- z=n.Z() ;
- x=TMath::Sign(n.Pt(),n.X()) ;
- return ;
- }
- }
- //Not in acceptance
- x=0; z=0 ;
- moduleNumber=0 ;
-
-}
-
-//____________________________________________________________________________
-Bool_t AliPHOSGeometry::Impact(const TParticle * particle) const
-{
- // Tells if a particle enters PHOS
- Bool_t in=kFALSE;
- Int_t moduleNumber=0;
- Double_t vtx[3]={particle->Vx(),particle->Vy(),particle->Vz()} ;
- Double_t z,x;
- ImpactOnEmc(vtx,particle->Theta(),particle->Phi(),moduleNumber,z,x);
- if(moduleNumber!=0)
- in=kTRUE;
- return in;
-}
-
-//____________________________________________________________________________
-Bool_t AliPHOSGeometry::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
-
- Bool_t rv = kTRUE ;
-
- if ( relid[1] == 0 ) { // it is a Phos crystal
- AbsId =
- ( relid[0] - 1 ) * GetNPhi() * GetNZ() // the offset of PHOS modules
- + ( relid[2] - 1 ) * GetNZ() // the offset along phi
- + relid[3] ; // the offset along z
- }
- else { // it is a CPV pad
- AbsId = GetNPhi() * GetNZ() * GetNModules() // the offset to separate EMCA crystals from CPV pads
- + ( relid[0] - 1 ) * GetNumberOfCPVPadsPhi() * GetNumberOfCPVPadsZ() // the pads offset of PHOS modules
- + ( relid[2] - 1 ) * GetNumberOfCPVPadsZ() // the pads offset of a CPV row
- + relid[3] ; // the column number
- }
-
- return rv ;
-}
-
-//____________________________________________________________________________
-void AliPHOSGeometry::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
- char path[100] ;
- if(relid[1]==0){ //this is EMC
-
- Double_t ps[3]= {0.0,-fCryCellShift,0.}; //Position incide the crystal
- Double_t psC[3]={0.0,0.0,0.}; //Global position
-
- //Shift and possibly apply misalignment corrections
- Int_t nCellsInStrip=fGeometryEMCA->GetNCellsXInStrip() ;
- Int_t strip=1+(relid[3]-1)/fGeometryEMCA->GetNCellsZInStrip()+((relid[2]-1)/nCellsInStrip)*fGeometryEMCA->GetNStripZ() ;
- Int_t cell=fGeometryEMCA->GetNCellsZInStrip()*(1+(relid[2]-1)%nCellsInStrip)-(relid[3]-1)%fGeometryEMCA->GetNCellsZInStrip() ;
- sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d",
- relid[0],strip,cell) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
- if (m) m->LocalToMaster(ps,psC);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
- 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,GetCPVBoxSize(1)/2.,0.}; //Position on top of CPV
- Double_t psC[3]={0.0,0.0,0.}; //Global position
- pos[0] = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect
- pos[2] = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module
-
- //now apply possible shifts and rotations
- sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
- if (m) m->LocalToMaster(ps,psC);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
- pos.SetXYZ(psC[0],psC[1],-psC[2]) ;
- }
-}
-
-//____________________________________________________________________________
-void AliPHOSGeometry::RelPosToAbsId(Int_t module, Double_t x, Double_t z, Int_t & AbsId) const
-{
- // converts local PHOS-module (x, z) coordinates to absId
-
- //find Global position
- if (!gGeoManager){
- AliFatal("Geo manager not initialized\n");
- }
- Int_t relid[4] ;
- char path[100] ;
- sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",module) ;
- Double_t lpos[3]={x,0.0,z} ;
- Double_t gpos[3]={0.,0.,0.} ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
- if (m) m->LocalToMaster(lpos,gpos);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
- gGeoManager->FindNode(gpos[0],gpos[1],gpos[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/ GetCellStep() + GetNPhi() / 2.) );
- relid[3] = static_cast<Int_t>(TMath::Ceil(-z/ GetCellStep() + GetNZ() / 2.) ) ;
- if(relid[2]<1)relid[2]=1 ;
- if(relid[3]<1)relid[3]=1 ;
- if(relid[2]>GetNPhi())relid[2]=GetNPhi() ;
- if(relid[3]>GetNZ())relid[3]=GetNZ() ;
- }
- 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() ;
- relid[0] = module ;
- relid[1] = 0 ;
- Int_t raw = fGeometryEMCA->GetNCellsXInStrip()*((iStrip-1)/fGeometryEMCA->GetNStripZ()) +
- 1 + (icell-1)/fGeometryEMCA->GetNCellsZInStrip() ;
- Int_t col = fGeometryEMCA->GetNCellsZInStrip()*(1+(iStrip-1)%fGeometryEMCA->GetNStripZ()) -
- (icell-1)%fGeometryEMCA->GetNCellsZInStrip() ;
- if(col==0) col=GetNZ() ;
- relid[2] = raw ;
- relid[3] = col ;
- }
-
- RelToAbsNumbering(relid,AbsId) ;
-}
-
-//____________________________________________________________________________
-void AliPHOSGeometry::RelPosInModule(const Int_t * relid, Float_t & x, Float_t & z) const
-{
- // Converts the relative numbering into the local PHOS-module (x, z) coordinates
- // Note: sign of z differs from that in the previous version (Yu.Kharlov, 12 Oct 2000)
-
-
- if (!gGeoManager){
- AliFatal("Geo manager not initialized\n");
- }
- //construct module name
- char path[100] ;
- if(relid[1]==0){ //this is PHOS
-
-// Calculations using ideal geometry (obsolete)
-// x = - ( GetNPhi()/2. - relid[2] + 0.5 ) * GetCellStep() ; // position of Xtal with respect
-// z = - ( GetNZ() /2. - relid[3] + 0.5 ) * GetCellStep() ; // of center of PHOS module
-
- Double_t pos[3]= {0.0,0.0,0.}; //Position incide the crystal (Y coordinalte is not important)
- Double_t posC[3]={0.0,0.0,0.}; //Global position
-
- //Shift and possibly apply misalignment corrections
- Int_t nCellsInStrip=fGeometryEMCA->GetNCellsXInStrip() ;
- Int_t strip=1+(relid[3]-1)/fGeometryEMCA->GetNCellsZInStrip()+((relid[2]-1)/nCellsInStrip)*fGeometryEMCA->GetNStripZ() ;
- Int_t sellRaw = (relid[2]-1)%nCellsInStrip ;
- Int_t cell=fGeometryEMCA->GetNCellsZInStrip()*(sellRaw+1) -(relid[3]-1)%fGeometryEMCA->GetNCellsZInStrip() ;
- sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d/PCEL_%d",
- relid[0],strip,cell) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
- if (m) m->LocalToMaster(pos,posC);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
- //Return to PHOS local system
- Double_t posL[3]={posC[0],posC[1],posC[2]};
- sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
- if (mPHOS) mPHOS->MasterToLocal(posC,posL);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
-//printf("old: x=%f, z=%f \n",x,z);
- x=posL[0] ;
- z=-posL[1];
-//printf("Geo: x=%f, z=%f \n",x,z);
- 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] = - ( GetNumberOfCPVPadsPhi()/2. - row - 0.5 ) * GetPadSizePhi() ; // position of pad with respect
- pos[2] = - ( GetNumberOfCPVPadsZ() /2. - column - 0.5 ) * GetPadSizeZ() ; // of center of PHOS module
-
- //now apply possible shifts and rotations
- sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",relid[0]) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
- if (m) m->LocalToMaster(pos,posC);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
- //Return to PHOS local system
- Double_t posL[3]={0.,0.,0.,} ;
- sprintf(path,"/ALIC_1/PHOS_%d",relid[0]) ;
- if (!gGeoManager->cd(path)){
- AliFatal("Geo manager can not find path \n");
- }
- TGeoHMatrix *mPHOS = gGeoManager->GetCurrentMatrix();
- if (mPHOS) mPHOS->MasterToLocal(posC,posL);
- else{
- AliFatal("Geo matrixes are not loaded \n") ;
- }
- x=posL[0] ;
- z=posL[1];
- return ;
-
- }
-
-}
-