]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSGeoUtils.cxx
Merge branch 'master' into LocalDev
[u/mrichter/AliRoot.git] / PHOS / AliPHOSGeoUtils.cxx
index 4d0cc3df6f3277921ebde17fe3b82c224e67a714..c83f48d4925351ad18696af4da1f6f01ba762c45 100644 (file)
@@ -56,6 +56,19 @@ AliPHOSGeoUtils::AliPHOSGeoUtils():
 {
     // 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 ;
+  }
+
 }  
 
 //____________________________________________________________________________
@@ -155,7 +168,7 @@ AliPHOSGeoUtils::~AliPHOSGeoUtils(void)
     for(Int_t istrip=0; istrip<224; istrip++)
       delete fStripMatrix[mod][istrip];
     delete fCPVMatrix[mod];
-    //    delete fPHOSMatrix[mod];
+    delete fPHOSMatrix[mod];
   }
 }
 //____________________________________________________________________________
@@ -363,8 +376,7 @@ void AliPHOSGeoUtils::RelPosInAlice(Int_t id, TVector3 & pos ) const
   // Converts the absolute numbering into the global ALICE coordinate system
   
   if (!gGeoManager){
-    printf("Geo manager not initialized\n");
-    abort();
+    AliFatal("Geo manager not initialized\n");
   }
     
   Int_t relid[4] ;
@@ -526,7 +538,7 @@ const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForModule(Int_t mod)const {
   //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)){
       AliWarning(Form("Geo manager can not find path %s \n",path));
@@ -538,10 +550,10 @@ const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForModule(Int_t mod)const {
     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") ; 
//   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 ;
@@ -553,7 +565,7 @@ const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForStrip(Int_t mod, Int_t strip)co
   //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)){
       AliWarning(Form("Geo manager can not find path %s \n",path));
       return 0 ;
@@ -580,7 +592,7 @@ const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForCPV(Int_t mod)const {
   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)){
       AliWarning(Form("Geo manager can not find path %s \n",path));
       return 0 ;
@@ -605,8 +617,10 @@ const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForPHOS(Int_t mod)const {
 
   //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)){
       AliWarning(Form("Geo manager can not find path %s \n",path));
       return 0 ;
@@ -629,21 +643,13 @@ const TGeoHMatrix * AliPHOSGeoUtils::GetMatrixForPHOS(Int_t mod)const {
 void AliPHOSGeoUtils::SetMisalMatrix(const TGeoHMatrix * m, Int_t mod){
   //Fills pointers to geo matrixes
  
-  fPHOSMatrix[mod]=m ;
-
-  //If module does not exist, make sure all its matrices 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 ;
   }
-
+  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) ;