// --- Standard library ---
// --- AliRoot header files ---
+#include "AliLog.h"
#include "AliPHOSEMCAGeometry.h"
#include "AliPHOSCPVGeometry.h"
#include "AliPHOSSupportGeometry.h"
{
// 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 ;
+ }
+
}
//____________________________________________________________________________
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
pos[2]=(-(relid[3]-1)%fNCellsZInStrip+fNCellsZInStrip/2-0.5)*fCellStep ;
Int_t mod = relid[0] ;
- TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
+ 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]};
- TGeoHMatrix *mPHOS2 = GetMatrixForModule(mod) ;
+ const TGeoHMatrix *mPHOS2 = GetMatrixForModule(mod) ;
mPHOS2->MasterToLocal(posC,posL2);
x=posL2[0] ;
z=-posL2[2];
pos[2] = - ( fNumberOfCPVPadsZ /2. - column - 0.5 ) * fPadSizeZ ; // of center of PHOS module
//now apply possible shifts and rotations
- TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
+ const TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
m->LocalToMaster(pos,posC);
//Return to PHOS local system
Double_t posL[3]={0.,0.,0.,} ;
- TGeoHMatrix *mPHOS = GetMatrixForPHOS(relid[0]) ;
+ const TGeoHMatrix *mPHOS = GetMatrixForPHOS(relid[0]) ;
mPHOS->MasterToLocal(posC,posL);
x=posL[0] ;
z=posL[1];
//(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] = static_cast<Int_t>(TMath::Ceil(-z/ fCellStep + fNZ / 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 ;
ps[2]=(-(relid[3]-1)%fNCellsZInStrip+fNCellsZInStrip/2-0.5)*fCellStep ;
Int_t mod = relid[0] ;
- TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
+ const TGeoHMatrix * m2 = GetMatrixForStrip(mod, strip) ;
m2->LocalToMaster(ps,psC);
pos.SetXYZ(psC[0],psC[1],psC[2]) ;
pos[2] = - ( fNumberOfCPVPadsZ /2. - column - 0.5 ) * fPadSizeZ ; // of center of PHOS module
//now apply possible shifts and rotations
- TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
+ const TGeoHMatrix *m = GetMatrixForCPV(relid[0]) ;
m->LocalToMaster(ps,psC);
pos.SetXYZ(psC[0],psC[1],-psC[2]) ;
}
{
Double_t posL[3]={x,-fCrystalShift,-z} ; //Only for EMC!!!
Double_t posG[3] ;
- TGeoHMatrix *mPHOS = GetMatrixForModule(mod) ;
+ const TGeoHMatrix *mPHOS = GetMatrixForModule(mod) ;
mPHOS->LocalToMaster(posL,posG);
globalPosition.SetXYZ(posG[0],posG[1],posG[2]) ;
}
//Return to PHOS local system
Double_t posG[3]={globalPosition.X(),globalPosition.Y(),globalPosition.Z()} ;
Double_t posL[3]={0.,0.,0.} ;
- TGeoHMatrix *mPHOS = GetMatrixForModule(module) ;
- mPHOS->MasterToLocal(posG,posL);
- localPosition.SetXYZ(posL[0],posL[1]+fCrystalShift,-posL[2]) ;
+ 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
+ }
}
//____________________________________________________________________________
//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++){
+ 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])){
//create vector from (0,0,0) to center of crystal surface of imod module
Double_t tmp[3]={0.,-fCrystalShift,0.} ;
- TGeoHMatrix *m = GetMatrixForModule(imod) ;
+ 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]) ;
vInc.SetXYZ(vInc.X()+x,vInc.Y(),vInc.Z()+z) ;
}
//____________________________________________________________________________
-TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForModule(Int_t mod)const {
+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] ;
- sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1",mod) ;
+ 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)){
- printf("Geo manager can not find path \n");
- abort();
+ AliWarning(Form("Geo manager can not find path %s \n",path));
+ return 0;
}
return gGeoManager->GetCurrentMatrix();
}
return fEMCMatrix[mod-1] ;
}
else{
- printf("Can not find PHOS misalignment matrixes\n") ;
- printf("Either import TGeoManager from geometry.root or \n");
- printf("read stored matrixes from AliESD Header: \n") ;
- printf("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
- abort() ;
+ 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 ;
}
//____________________________________________________________________________
-TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForStrip(Int_t mod, Int_t strip)const {
+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] ;
- sprintf(path,"/ALIC_1/PHOS_%d/PEMC_1/PCOL_1/PTIO_1/PCOR_1/PAGA_1/PTII_1/PSTR_%d",mod,strip) ;
+ 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)){
- printf("Geo manager can not find path \n");
- abort() ;
+ AliWarning(Form("Geo manager can not find path %s \n",path));
+ return 0 ;
}
return gGeoManager->GetCurrentMatrix();
}
return fStripMatrix[mod-1][strip-1] ;
}
else{
- printf("Can not find PHOS misalignment matrixes\n") ;
- printf("Either import TGeoManager from geometry.root or \n");
- printf("read stored matrixes from AliESD Header: \n") ;
- printf("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
- abort() ;
+ 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 ;
}
//____________________________________________________________________________
-TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForCPV(Int_t mod)const {
+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
- sprintf(path,"/ALIC_1/PHOS_%d/PCPV_1",mod) ;
+ snprintf(path,255,"/ALIC_1/PHOS_%d/PCPV_1",mod) ;
if (!gGeoManager->cd(path)){
- printf("Geo manager can not find path \n");
- abort() ;
+ AliWarning(Form("Geo manager can not find path %s \n",path));
+ return 0 ;
}
return gGeoManager->GetCurrentMatrix();
}
return fCPVMatrix[mod-1] ;
}
else{
- printf("Can not find PHOS misalignment matrixes\n") ;
- printf("Either import TGeoManager from geometry.root or \n");
- printf("read stored matrixes from AliESD Header: \n") ;
- printf("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
- abort() ;
+ 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 ;
}
//____________________________________________________________________________
-TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForPHOS(Int_t mod)const {
+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] ;
- sprintf(path,"/ALIC_1/PHOS_%d",mod) ;
+ snprintf(path,255,"/ALIC_1/PHOS_%d",mod) ;
+
if (!gGeoManager->cd(path)){
- printf("Geo manager can not find path \n");
- abort() ;
+ AliWarning(Form("Geo manager can not find path %s \n",path));
+ return 0 ;
}
return gGeoManager->GetCurrentMatrix();
}
return fPHOSMatrix[mod-1] ;
}
else{
- printf("Can not find PHOS misalignment matrixes\n") ;
- printf("Either import TGeoManager from geometry.root or \n");
- printf("read stored matrixes from AliESD Header: \n") ;
- printf("AliPHOSGeoUtils::SetMisalMatrixes(header->GetPHOSMisalMatrix()) \n") ;
- abort() ;
+ 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(TGeoHMatrix * m, Int_t mod){
+void AliPHOSGeoUtils::SetMisalMatrix(const TGeoHMatrix * m, Int_t mod){
//Fills pointers to geo matrixes
- fPHOSMatrix[mod]=m ;
- //If modules does not exist, make sure all its matrixes are zero
- if(m==NULL){
- fEMCMatrix[mod]=NULL ;
- Int_t istrip=0 ;
- for(Int_t irow = 0; irow < fGeometryEMCA->GetNStripX(); irow ++){
- for(Int_t icol = 0; icol < fGeometryEMCA->GetNStripZ(); icol ++){
- fStripMatrix[mod][istrip]=NULL ;
- }
- }
- fCPVMatrix[mod]=NULL ;
+ if(fPHOSMatrix[mod]){ //have been set already. Can not be changed any more
return ;
}
-
- //Calculate maxtrixes for PTII
+ 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 locTII[3]={0.,0.,z} ;
Double_t globTII[3] ;
- TGeoHMatrix * mTII = new((*fMisalArray)[nr])TGeoHMatrix() ;
- mTII->SetRotation(rotEMC) ;
- mTII->MultiplyLeft(fPHOSMatrix[mod]) ;
+ 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) ;
- mTII->SetTranslation(globTII) ;
- fEMCMatrix[mod]=mTII ;
+ fEMCMatrix[mod]->SetTranslation(globTII) ;
//Now calculate ideal matrixes for strip misalignment.
//For the moment we can not store them in ESDHeader
for(Int_t icol = 0; icol < fGeometryEMCA->GetNStripZ(); icol ++){
loc[2] = (2*icol + 1 - fGeometryEMCA->GetNStripZ()) * strip[2] ;
fEMCMatrix[mod]->LocalToMaster(loc,glob) ;
- TGeoHMatrix * mSTR = new((*fMisalArray)[nr])TGeoHMatrix(*(fEMCMatrix[mod])) ; //Use same rotation as PHOS module
- mSTR->SetTranslation(glob) ;
- fStripMatrix[mod][istrip]=mSTR ;
+ 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++;
}
}
Double_t locCPV[3]={0.,0.,- emcParams[3]} ;
Double_t rot[9]={1.,0.,0.,0.,0.,1.,0.,-1.,0.} ;
- TGeoHMatrix * mCPV = new((*fMisalArray)[nr])TGeoHMatrix() ;
- mCPV->SetRotation(rot) ;
- mCPV->MultiplyLeft(fPHOSMatrix[mod]) ;
- mCPV->ReflectY(kFALSE) ;
+ 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) ;
- mCPV->SetTranslation(globCPV) ;
- fCPVMatrix[mod]=mCPV ;
+ fCPVMatrix[mod]->SetTranslation(globCPV) ;
}