]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCParam.cxx
overwrite select collision cand
[u/mrichter/AliRoot.git] / TPC / AliTPCParam.cxx
index ff15faf3143444b283c9ec804a8548999b49fdd9..0a3c340f1c7e64c456a93ca0a6864a0c6984b886 100644 (file)
@@ -143,29 +143,10 @@ AliTPCParam::~AliTPCParam()
   if (fResponseWeight!=0) delete [] fResponseWeight;
   if (fRotAngle      !=0) delete [] fRotAngle;
 
-  if (fTrackingMatrix) {
-    for(Int_t i = 0; i < fNSector; i++)
-      delete fTrackingMatrix[i];
-    delete [] fTrackingMatrix;
-  }
-
-  if (fClusterMatrix) {
-    for(Int_t i = 0; i < fNSector; i++)
-      delete fClusterMatrix[i];
-    delete [] fClusterMatrix;
-  }
-
-  if (fGlobalMatrix) {
-    for(Int_t i = 0; i < fNSector; i++)
-      delete fGlobalMatrix[i];
-    delete [] fGlobalMatrix;
-  }
+  CleanGeoMatrices();
 
 }
 
-
-
-
 Int_t  AliTPCParam::Transform0to1(Float_t *xyz, Int_t * index)  const
 {
   //
@@ -196,7 +177,8 @@ Int_t  AliTPCParam::Transform0to1(Float_t *xyz, Int_t * index)  const
       if (xyz[2]<0)    sector+=(fNOuterSector>>1);            
     }
     else   
-      if (xyz[2]<0) sector+=(fNInnerSector>>1);    
+      if (xyz[2]<0) sector+=(fNInnerSector>>1);  
+  if (sector<0 || sector>=fNSector) AliError(Form("Wrong sector %d",sector));
   index[1]=sector; // calculated sector number
   index[0]=1; // indicates system after transformation
   return sector;
@@ -606,7 +588,31 @@ Bool_t AliTPCParam::Update()
   return kTRUE;
 }
 
+void AliTPCParam::CleanGeoMatrices(){
+  //
+  // clean geo matrices
+  //
 
+  if (fTrackingMatrix) {
+    for(Int_t i = 0; i < fNSector; i++)
+      delete fTrackingMatrix[i];
+    delete [] fTrackingMatrix;
+  }
+  
+  if (fClusterMatrix) {
+    for(Int_t i = 0; i < fNSector; i++)
+      delete fClusterMatrix[i];
+    delete [] fClusterMatrix;
+  }
+  
+  if (fGlobalMatrix) {
+    for(Int_t i = 0; i < fNSector; i++)
+      delete fGlobalMatrix[i];
+    delete [] fGlobalMatrix;
+  }
+  
+  return;
+}
 
 Bool_t AliTPCParam::ReadGeoMatrices(){
   //
@@ -617,12 +623,19 @@ Bool_t AliTPCParam::ReadGeoMatrices(){
   }
   AliAlignObjParams o;
   //
-  if (fTrackingMatrix) delete [] fTrackingMatrix;
+
+  // clean geo matrices
+  CleanGeoMatrices();
+
+  // create new geo matrices
   fTrackingMatrix = new TGeoHMatrix*[fNSector];
-  if (fClusterMatrix) delete [] fClusterMatrix;
   fClusterMatrix = new TGeoHMatrix*[fNSector];
-  if (fGlobalMatrix) delete [] fGlobalMatrix;
   fGlobalMatrix = new TGeoHMatrix*[fNSector];
+  for (Int_t isec=0; isec<fNSector; isec++) {
+    fGlobalMatrix[isec] = 0;
+    fClusterMatrix[isec]= 0;
+    fTrackingMatrix[isec]=0;
+  }   
   //
   for (Int_t isec=0; isec<fNSector; isec++) {
     fGlobalMatrix[isec] = 0;
@@ -641,13 +654,19 @@ Bool_t AliTPCParam::ReadGeoMatrices(){
     }
 
     UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
-    const char *symname = AliGeomManager::SymName(volid);
-    TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
-    const char *path = symname;
-    if(pne) path=pne->GetTitle();
-    if (!gGeoManager->cd(path)) return kFALSE;      
+    TGeoPNEntry* pne = gGeoManager->GetAlignableEntryByUID(volid);
+    if(!pne)
+    {
+      AliError(Form("Alignable entry for volume ID %d not in geometry. Exiting!",volid));
+      return kFALSE;
+    }
+    const char *path = pne->GetTitle();
+    if (!gGeoManager->cd(path)) return kFALSE;
     TGeoHMatrix *m = gGeoManager->GetCurrentMatrix();
+    // Since GEANT4 does not allow reflections, in this case the reflection
+    // component if the matrix is embedded by TGeo inside TGeoScaledShape
+    if (gGeoManager->GetCurrentVolume()->GetShape()->IsReflected()) 
+       m->ReflectZ(kFALSE, kTRUE);
     //
     TGeoRotation mchange; 
     mchange.RotateY(90); mchange.RotateX(90);