]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDgeometry.cxx
Additional protection. The call to RecWithStack has to be removed in case of raw...
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometry.cxx
index e0925311c6f35e6e0248103a3e85a91692148a1f..9e433b360f37abbbc1a22ccffd21f7c3c607c6be 100644 (file)
 
 #include "AliRunLoader.h"
 #include "AliTRDgeometry.h"
-#include "AliTRDparameter.h"
+#include "AliTRDpadPlane.h"
 
 #include "AliRun.h"
 #include "AliTRD.h"
+#include "AliTRDcalibDB.h"
+#include "AliTRDCommonParam.h"
 
 ClassImp(AliTRDgeometry)
 
@@ -64,8 +66,8 @@ ClassImp(AliTRDgeometry)
   const Float_t AliTRDgeometry::fgkSlenTR3 = 159.5;  
 
   // The super module side plates
-  const Float_t AliTRDgeometry::fgkSMpltT  = 0.2;
-  const Float_t AliTRDgeometry::fgkSMgapT  = 0.5;  
+  const Float_t AliTRDgeometry::fgkSMpltT  =   0.2;
+  const Float_t AliTRDgeometry::fgkSMgapT  =   0.5;  
 
   // Height of different chamber parts
   // Radiator
@@ -135,6 +137,14 @@ ClassImp(AliTRDgeometry)
   const Float_t AliTRDgeometry::fgkFeZpos  =  0.0322;
   const Float_t AliTRDgeometry::fgkCoZpos  =  0.97;
   const Float_t AliTRDgeometry::fgkWaZpos  =  0.99;
+  
+  const Double_t AliTRDgeometry::fgkTime0Base = Rmin() + CraHght() + CdrHght() + CamHght()/2.;
+  const Float_t  AliTRDgeometry::fgkTime0[6]  = { fgkTime0Base + 0 * (Cheight() + Cspace()), 
+                                                  fgkTime0Base + 1 * (Cheight() + Cspace()), 
+                                                  fgkTime0Base + 2 * (Cheight() + Cspace()), 
+                                                  fgkTime0Base + 3 * (Cheight() + Cspace()), 
+                                                  fgkTime0Base + 4 * (Cheight() + Cspace()), 
+                                                  fgkTime0Base + 5 * (Cheight() + Cspace()) };
 
 //_____________________________________________________________________________
 AliTRDgeometry::AliTRDgeometry():AliGeometry()
@@ -144,7 +154,6 @@ AliTRDgeometry::AliTRDgeometry():AliGeometry()
   //
 
   Init();
-
 }
 
 //_____________________________________________________________________________
@@ -153,7 +162,6 @@ AliTRDgeometry::~AliTRDgeometry()
   //
   // AliTRDgeometry destructor
   //
-
 }
 
 //_____________________________________________________________________________
@@ -194,7 +202,7 @@ void AliTRDgeometry::Init()
   // Changed with the introduction of 
   // the new layer 0. The old layer 6
   // is removed.
-  fCwidth[0] =  92.6;
+  fCwidth[0] =  90.4;
   fCwidth[1] =  94.8;
   fCwidth[2] =  99.3;
   fCwidth[3] = 103.7;
@@ -252,9 +260,8 @@ void AliTRDgeometry::CreateGeometry(Int_t* )
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
-                                   , Float_t *global
-                                   , AliTRDparameter *par) const
+Bool_t AliTRDgeometry::Local2Global(Int_t idet, Double_t *local
+                                   , Double_t *global) const
 {
   //
   // Converts local pad-coordinates (row,col,time) into 
@@ -265,44 +272,42 @@ Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local
   Int_t isect = GetSector(idet);     // Sector info  (0-17)
   Int_t iplan = GetPlane(idet);      // Plane info   (0-5)
 
-  return Local2Global(iplan,icham,isect,local,global,par);
+  return Local2Global(iplan,icham,isect,local,global);
 
 }
  
 //_____________________________________________________________________________
 Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
-                                  , Float_t *local, Float_t *global
-                                  , AliTRDparameter *par) const
+                                  , Double_t *local, Double_t *global) const
 {
   //
   // Converts local pad-coordinates (row,col,time) into 
   // global ALICE reference frame coordinates (x,y,z)
   //
 
-  if (!par) {
-    Error("Local2Global","No parameter defined\n");
+  AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
+  if (!commonParam)
     return kFALSE;
-  }
 
-  Int_t    idet      = GetDetector(iplan,icham,isect); // Detector number
-
-  Float_t  padRow    = local[0]+0.5;                   // Pad Row position
-  Float_t  padCol    = local[1]+0.5;                   // Pad Column position
-  Float_t  timeSlice = local[2]+0.5;                   // Time "position"
+  AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
+  if (!calibration)
+    return kFALSE;  
+  
+  AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
 
-  Float_t  row0      = par->GetRow0(iplan,icham,isect);
-  Float_t  col0      = par->GetCol0(iplan);
-  Float_t  time0     = par->GetTime0(iplan);
+  // calculate (x,y,z) position in rotated chamber
+  Int_t    row       = ((Int_t) local[0]);
+  Int_t    col       = ((Int_t) local[1]);
+  Float_t  timeSlice = local[2] + 0.5;
+  Float_t  time0     = GetTime0(iplan);
 
-  Float_t  rot[3];
+  Int_t idet = GetDetector(iplan, icham, isect);
 
-  // calculate (x,y,z) position in rotated chamber
-  rot[0] = time0 - (timeSlice - par->GetTimeBefore()) 
-         * par->GetDriftVelocity()/par->GetSamplingFrequency();
-  rot[1] = col0  + padCol                    
-         * par->GetColPadSize(iplan);
-  rot[2] = row0  + padRow                    
-         * par->GetRowPadSize(iplan,icham,isect);
+  Double_t  rot[3];
+  rot[0] = time0 - (timeSlice - calibration->GetT0(idet, col, row))
+      * calibration->GetVdrift(idet, col, row)/calibration->GetSamplingFrequency();
+  rot[1] = padPlane->GetColPos(col) - 0.5 * padPlane->GetColSize(col);
+  rot[2] = padPlane->GetRowPos(row) - 0.5 * padPlane->GetRowSize(row);
 
   // Rotate back to original position
   return RotateBack(idet,rot,global);
@@ -310,8 +315,8 @@ Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global
-                                  , Int_t* index,  AliTRDparameter *par) const
+Bool_t AliTRDgeometry::Global2Local(Int_t mode, Double_t *local, Double_t *global
+                                   , Int_t* index) const
 {
   //
   // Converts local pad-coordinates (row,col,time) into 
@@ -325,11 +330,6 @@ Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global
   // mode=2  - local coordinate in pad, and pad row, x - rotated global
   //
 
-  if (!par) {
-    Error("Local2Global","No parameter defined\n");
-    return kFALSE;
-  }
-  
   //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);
@@ -337,7 +337,7 @@ Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global
   //
   //  Float_t  row0      = par->GetRow0(iplan,icham,isect);
   //Float_t  col0      = par->GetCol0(iplan);
-  //Float_t  time0     = par->GetTime0(iplan);
+  //Float_t  time0     = GetTime0(iplan);
   //
   // mode 1 to be implemented later
   // calculate (x,y,z) position in time bin pad row pad
@@ -353,8 +353,8 @@ Bool_t AliTRDgeometry::Global2Local(Int_t mode, Float_t *local, Float_t *global
 
 }
 
-//___________________________________________________________________
-Bool_t   AliTRDgeometry::Global2Detector(Float_t global[3], Int_t index[3], AliTRDparameter *par)
+//_____________________________________________________________________________
+Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3])
 {
   //  
   // input    = global position
@@ -373,9 +373,9 @@ Bool_t   AliTRDgeometry::Global2Detector(Float_t global[3], Int_t index[3], AliT
   //
   Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];  
   index[0] = 0;
-  Float_t max = locx-par->GetTime0(0);
+  Float_t max = locx - GetTime0(0);
   for (Int_t iplane=1; iplane<fgkNplan;iplane++){
-    Float_t dist = TMath::Abs(locx-par->GetTime0(iplane));
+    Float_t dist = TMath::Abs(locx - GetTime0(iplane));
     if (dist < max){
       index[0] = iplane;
       max = dist;
@@ -389,7 +389,7 @@ Bool_t   AliTRDgeometry::Global2Detector(Float_t global[3], Int_t index[3], AliT
 
 
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
+Bool_t AliTRDgeometry::Rotate(Int_t d, Double_t *pos, Double_t *rot) const
 {
   //
   // Rotates all chambers in the position of sector 0 and transforms
@@ -408,7 +408,7 @@ Bool_t AliTRDgeometry::Rotate(Int_t d, Float_t *pos, Float_t *rot) const
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
+Bool_t AliTRDgeometry::RotateBack(Int_t d, Double_t *rot, Double_t *pos) const
 {
   //
   // Rotates a chambers from the position of sector 0 into its
@@ -427,7 +427,7 @@ Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) const
+Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c)
 {
   //
   // Convert plane / chamber into detector number for one single sector
@@ -438,7 +438,7 @@ Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s) const
+Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s)
 {
   //
   // Convert plane / chamber / sector into detector number
@@ -481,31 +481,6 @@ Int_t AliTRDgeometry::GetSector(Int_t d) const
 
 }
 
-//_____________________________________________________________________________
-void AliTRDgeometry::SetOldGeometry()
-{
-  //
-  // Use the old chamber lengths
-  //
-
-  Int_t icham;
-  Int_t iplan;
-
-  Float_t length[kNplan][kNcham]   = { { 123.5, 123.5, 110.0, 123.5, 123.5 }
-                                    , { 131.0, 131.0, 110.0, 131.0, 131.0 }
-                                    , { 134.5, 138.5, 110.0, 138.5, 134.5 }
-                                    , { 142.0, 146.0, 110.0, 146.0, 142.0 }
-                                    , { 142.0, 153.0, 110.0, 153.0, 142.0 }
-                                     , { 134.0, 160.5, 110.0, 160.5, 134.0 } };
-
-  for (icham = 0; icham < kNcham; icham++) {
-    for (iplan = 0; iplan < kNplan; iplan++) {
-      fClength[iplan][icham]   = length[iplan][icham];
-    }
-  }
-
-}
-
 //_____________________________________________________________________________
 AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
 {