]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
GlobalToDetector method. Reading transformation form TGeoManager (M.Ivanov)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 12 Apr 2006 09:30:40 +0000 (09:30 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 12 Apr 2006 09:30:40 +0000 (09:30 +0000)
TRD/AliTRDgeometry.cxx
TRD/AliTRDgeometry.h

index 9e433b360f37abbbc1a22ccffd21f7c3c607c6be..ceda788b876ccc31e6f7e0c8bbfc8abe4077e1d7 100644 (file)
 
 
 #include <TError.h>
+#include <TGeoManager.h>
+#include <TGeoPhysicalNode.h>
+#include <TGeoMatrix.h>
+
 
 #include "AliRunLoader.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDpadPlane.h"
 
+#include "AliAlignObj.h"
+#include "AliAlignObjAngles.h"
+
 #include "AliRun.h"
 #include "AliTRD.h"
 #include "AliTRDcalibDB.h"
@@ -152,7 +159,8 @@ AliTRDgeometry::AliTRDgeometry():AliGeometry()
   //
   // AliTRDgeometry default constructor
   //
-
+  fMatrixArray =0;
+  fMatrixCorrectionArray= 0;
   Init();
 }
 
@@ -162,6 +170,8 @@ AliTRDgeometry::~AliTRDgeometry()
   //
   // AliTRDgeometry destructor
   //
+  delete fMatrixArray;
+  delete fMatrixCorrectionArray;
 }
 
 //_____________________________________________________________________________
@@ -332,7 +342,7 @@ Bool_t AliTRDgeometry::Global2Local(Int_t mode, Double_t *local, Double_t *globa
 
   //Int_t    idet    = GetDetector(iplan,icham,isect); // Detector number
   Int_t    idet      = GetDetector(index[0],index[1],index[2]); // Detector number
-  Rotate(idet,global,local);
+  RotateBack(idet,global,local);
   if (mode==0) return kTRUE;
   //
   //  Float_t  row0      = par->GetRow0(iplan,icham,isect);
@@ -357,19 +367,23 @@ Bool_t AliTRDgeometry::Global2Local(Int_t mode, Double_t *local, Double_t *globa
 Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3])
 {
   //  
+  //  Find detector for given global point - Ideal geometry 
+  //  
+  //
   // input    = global position
   // output   = index
   // index[0] = plane number
   // index[1] = chamber number
   // index[2] = sector number
   //
-
-  Float_t fi;
   //
-  fi = TMath::ATan2(global[1],global[0]);
+  // Find sector
+  //
+  Float_t fi = TMath::ATan2(global[1],global[0]);
   if (fi<0) fi += 2*TMath::Pi();
-  index[2] = Int_t(TMath::Nint((fi - GetAlpha()/2.)/GetAlpha()));
+  index[2] = fgkNsect-1-TMath::Nint((fi - GetAlpha()/2.)/GetAlpha());
   //
+  // Find plane
   //
   Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];  
   index[0] = 0;
@@ -381,10 +395,23 @@ Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3])
       max = dist;
     }
   }
-  Float_t theta = TMath::ATan2(global[2],locx);
-  index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
+  //
+  // Find chamber
+  //
+  if (TMath::Abs(global[2]) < 0.5*GetChamberLength(index[0],2)){
+    index[1]=2;
+  }else{
+    Double_t localZ = global[2];
+    if (global[2]>0){
+      localZ -= 0.5*(GetChamberLength(index[0],2)+GetChamberLength(index[0],1));
+      index[1] = (TMath::Abs(localZ) < 0.5*GetChamberLength(index[0],3)) ? 1:0;
+    }
+    else{
+      localZ += 0.5*(GetChamberLength(index[0],2)+GetChamberLength(index[0],3));
+      index[1] = (TMath::Abs(localZ) < 0.5*GetChamberLength(index[0],1)) ? 3:4;
+    }
+  }  
   return kTRUE;
-
 }
 
 
@@ -511,3 +538,66 @@ AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
   saveDir->cd();
   return geom;
 }
+
+
+//_____________________________________________________________________________
+Bool_t   AliTRDgeometry::ReadGeoMatrices(){
+  //
+  // Read geo matrices from current gGeoManager for each TRD sector
+  //
+
+  //
+  // fMatrixArray - 
+  //
+
+  //
+  // fMatrixCorrectionArray - 
+  //
+
+
+  if (!gGeoManager) return kFALSE;
+  fMatrixArray = new TObjArray(kNdet); 
+  fMatrixCorrectionArray = new TObjArray(kNdet);
+  fMatrixGeo   = new TObjArray(kNdet);
+  AliAlignObjAngles o;
+  //
+  for (Int_t iLayer = AliAlignObj::kTRD1; iLayer <= AliAlignObj::kTRD6; iLayer++) {
+    for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) {
+      UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
+      const char *path = AliAlignObj::GetVolPath(volid);
+      if (!gGeoManager->cd(path)) return kFALSE;      
+      TGeoHMatrix* m = gGeoManager->GetCurrentMatrix();
+      Int_t     iLayerTRD    = iLayer-AliAlignObj::kTRD1;
+      Int_t     isector      = Nsect()-1-(iModule/Ncham());
+      Int_t     ichamber     = Ncham()-1-(iModule%Ncham());
+      Int_t     lid          = GetDetector(iLayerTRD,ichamber,isector);    
+      //
+      //
+      //
+      // local geo system z-x-y  to x-y--z 
+      //
+      fMatrixGeo->AddAt(new TGeoHMatrix(*m),lid);
+      
+      TGeoRotation mchange; 
+      mchange.RotateY(90); mchange.RotateX(90);
+      //
+      TGeoHMatrix gMatrix(mchange.Inverse());
+      gMatrix.MultiplyLeft(m);
+      fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid); 
+      //
+      //  Cluster transformation matrix
+      //
+      TGeoHMatrix  rotMatrix(mchange.Inverse());
+      rotMatrix.MultiplyLeft(m);
+      Double_t sectorAngle = 20.*(isector%18)+10;
+      TGeoHMatrix  rotSector;
+      rotSector.RotateZ(sectorAngle);
+      rotMatrix.MultiplyLeft(&rotSector);      
+      //
+      fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid);       
+    }    
+  }
+  return kTRUE;
+}
+
+
index edee8963ce79c1a2576d853489cae06a8a516133..0a84187411b50145738dcd92dac0f054a1c55049 100644 (file)
@@ -12,8 +12,9 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliGeometry.h"
-
+#include "TObjArray.h"
 class AliRunLoader;
+class TGeoHMatrix;
 
 class AliTRDgeometry : public AliGeometry {
 
@@ -39,6 +40,11 @@ class AliTRDgeometry : public AliGeometry {
   virtual Bool_t   Rotate(Int_t d, Double_t *pos, Double_t *rot) const;
   virtual Bool_t   RotateBack(Int_t d, Double_t *rot, Double_t *pos) const;
 
+  Bool_t   ReadGeoMatrices();  
+  TGeoHMatrix *    GetGeoMatrix(Int_t detector){ return (TGeoHMatrix*)fMatrixGeo->At(detector);}
+  TGeoHMatrix *    GetMatrix(Int_t detector){ return (TGeoHMatrix*)fMatrixArray->At(detector);}
+  TGeoHMatrix *    GetCorrectionMatrix(Int_t detector){ return (TGeoHMatrix*)fMatrixCorrectionArray->At(detector);}
+
   static  Int_t    Nsect()   { return fgkNsect; };
   static  Int_t    Nplan()   { return fgkNplan; };
   static  Int_t    Ncham()   { return fgkNcham; };
@@ -180,7 +186,9 @@ class AliTRDgeometry : public AliGeometry {
   Float_t              fChamberUDboxd[3*kNdets][3];         // dimensions (half)
   Float_t              fChamberUFboxd[3*kNdets][3];         // [3] = x, y, z
   Float_t              fChamberUUboxd[3*kNdets][3];
-
+  TObjArray *          fMatrixArray;                        //! array of matrix - Transformation Global to Local
+  TObjArray *          fMatrixCorrectionArray;              //! array of Matrix - Transformation Cluster to  Tracking systerm
+  TObjArray *          fMatrixGeo;                          //! geo matrices
   ClassDef(AliTRDgeometry,7)                                // TRD geometry base class
 
 };