]> 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 16ef0df121c633bc0562001c730c94cefbc889ce..9e433b360f37abbbc1a22ccffd21f7c3c607c6be 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.14  2001/11/06 17:19:41  cblume
-Add detailed geometry and simple simulator
-
-Revision 1.13  2001/08/02 08:30:45  cblume
-Fix positions of cooling material
-
-Revision 1.12  2001/05/21 16:45:47  hristov
-Last minute changes (C.Blume)
-
-Revision 1.11  2001/05/11 07:56:12  hristov
-Consistent declarations needed on Alpha
-
-Revision 1.10  2001/05/07 08:08:05  cblume
-Update of TRD code
-
-Revision 1.9  2001/03/27 12:48:33  cblume
-Correct for volume overlaps
-
-Revision 1.8  2001/03/13 09:30:35  cblume
-Update of digitization. Moved digit branch definition to AliTRD
-
-Revision 1.7  2001/02/14 18:22:26  cblume
-Change in the geometry of the padplane
-
-Revision 1.6  2000/11/01 14:53:20  cblume
-Merge with TRD-develop
-
-Revision 1.1.4.7  2000/10/16 01:16:53  cblume
-Changed timebin 0 to be the one closest to the readout
-
-Revision 1.1.4.6  2000/10/15 23:35:57  cblume
-Include geometry constants as static member
-
-Revision 1.1.4.5  2000/10/06 16:49:46  cblume
-Made Getters const
-
-Revision 1.1.4.4  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.1.4.3  2000/09/22 14:43:40  cblume
-Allow the pad/timebin-dimensions to be changed after initialization
-
-Revision 1.1.4.2  2000/09/18 13:37:01  cblume
-Minor coding corrections
-
-Revision 1.5  2000/10/02 21:28:19  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.4  2000/06/08 18:32:58  cblume
-Make code compliant to coding conventions
-
-Revision 1.3  2000/06/07 16:25:37  cblume
-Try to remove compiler warnings on Sun and HP
-
-Revision 1.2  2000/05/08 16:17:27  cblume
-Merge TRD-develop
-
-Revision 1.1.4.1  2000/05/08 14:45:55  cblume
-Bug fix in RotateBack(). Geometry update
-
-Revision 1.4  2000/06/08 18:32:58  cblume
-Make code compliant to coding conventions
-
-Revision 1.3  2000/06/07 16:25:37  cblume
-Try to remove compiler warnings on Sun and HP
-
-Revision 1.2  2000/05/08 16:17:27  cblume
-Merge TRD-develop
-
-Revision 1.1.4.1  2000/05/08 14:45:55  cblume
-Bug fix in RotateBack(). Geometry update
-
-Revision 1.1  2000/02/28 19:00:44  cblume
-Add new TRD classes
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
@@ -98,11 +21,17 @@ Add new TRD classes
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include "AliMC.h"
 
+#include <TError.h>
+
+#include "AliRunLoader.h"
 #include "AliTRDgeometry.h"
-#include "AliTRDrecPoint.h"
-#include "AliMC.h"
+#include "AliTRDpadPlane.h"
+
+#include "AliRun.h"
+#include "AliTRD.h"
+#include "AliTRDcalibDB.h"
+#include "AliTRDCommonParam.h"
 
 ClassImp(AliTRDgeometry)
 
@@ -136,6 +65,10 @@ ClassImp(AliTRDgeometry)
   const Float_t AliTRDgeometry::fgkSlenTR2 = 313.5; 
   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;  
+
   // Height of different chamber parts
   // Radiator
   const Float_t AliTRDgeometry::fgkCraH    =   4.8; 
@@ -144,7 +77,7 @@ ClassImp(AliTRDgeometry)
   // Amplification region
   const Float_t AliTRDgeometry::fgkCamH    =   0.7;
   // Readout
-  const Float_t AliTRDgeometry::fgkCroH    =   2.0;
+  const Float_t AliTRDgeometry::fgkCroH    =   2.316;
   // Total height
   const Float_t AliTRDgeometry::fgkCH      = AliTRDgeometry::fgkCraH
                                            + AliTRDgeometry::fgkCdrH
@@ -152,7 +85,7 @@ ClassImp(AliTRDgeometry)
                                            + AliTRDgeometry::fgkCroH;  
 
   // Vertical spacing of the chambers
-  const Float_t AliTRDgeometry::fgkVspace  =   2.1;
+  const Float_t AliTRDgeometry::fgkVspace  =   1.784;
 
   // Horizontal spacing of the chambers
   const Float_t AliTRDgeometry::fgkHspace  =   2.0;
@@ -173,8 +106,9 @@ ClassImp(AliTRDgeometry)
   const Float_t AliTRDgeometry::fgkCroW    =   0.9;
 
   // Difference of outer chamber width and pad plane width
-  const Float_t AliTRDgeometry::fgkCpadW   =   1.0;
-  const Float_t AliTRDgeometry::fgkRpadW   =   1.5;
+  //const Float_t AliTRDgeometry::fgkCpadW   =   1.0;
+  const Float_t AliTRDgeometry::fgkCpadW   =   0.0;
+  const Float_t AliTRDgeometry::fgkRpadW   =   1.0;
 
   //
   // Thickness of the the material layers
@@ -203,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()
@@ -212,7 +154,6 @@ AliTRDgeometry::AliTRDgeometry():AliGeometry()
   //
 
   Init();
-
 }
 
 //_____________________________________________________________________________
@@ -221,7 +162,6 @@ AliTRDgeometry::~AliTRDgeometry()
   //
   // AliTRDgeometry destructor
   //
-
 }
 
 //_____________________________________________________________________________
@@ -258,20 +198,32 @@ void AliTRDgeometry::Init()
   Int_t isect;
 
   // The outer width of the chambers
-  fCwidth[0] =  95.6;
-  fCwidth[1] = 100.1;
-  fCwidth[2] = 104.5;
-  fCwidth[3] = 108.9;
-  fCwidth[4] = 113.4;
-  fCwidth[5] = 117.8;
+  //
+  // Changed with the introduction of 
+  // the new layer 0. The old layer 6
+  // is removed.
+  fCwidth[0] =  90.4;
+  fCwidth[1] =  94.8;
+  fCwidth[2] =  99.3;
+  fCwidth[3] = 103.7;
+  fCwidth[4] = 108.1;
+  fCwidth[5] = 112.6;
+  // Old layer 6
+  // fCwidth[5] = 117.0;
 
   // The outer lengths of the chambers
-  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 } };
+  // Includes the spacings between the chambers!
+  // Changed with the introduction of 
+  // the new layer 0. The old layer 6
+  // is removed.
+  Float_t length[kNplan][kNcham]   = { { 124.0, 124.0, 110.0, 124.0, 124.0 }
+                                    , { 124.0, 124.0, 110.0, 124.0, 124.0 }
+                                     , { 131.0, 131.0, 110.0, 131.0, 131.0 }
+                                     , { 138.0, 138.0, 110.0, 138.0, 138.0 }
+                                     , { 145.0, 145.0, 110.0, 145.0, 145.0 }
+                                    , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
+  // Old layer 6
+  //                                 , { 147.0, 147.0, 110.0, 147.0, 147.0 } };
 
   for (icham = 0; icham < kNcham; icham++) {
     for (iplan = 0; iplan < kNplan; iplan++) {
@@ -281,28 +233,10 @@ void AliTRDgeometry::Init()
     }
   }
 
-  // The pad size in column direction (rphi-direction)  
-  SetColPadSize(0,0.65);
-  SetColPadSize(1,0.68);
-  SetColPadSize(2,0.71);
-  SetColPadSize(3,0.74);
-  SetColPadSize(4,0.77);
-  SetColPadSize(5,0.80);
-
-  // The pad row (z-direction)
-  SetNRowPad();
-
-  // The number of time bins. Default is 100 ns timbin size
-  SetNTimeBin(15);
-
-  // Additional time bins before and after the drift region.
-  // Default is to only sample the drift region
-  SetExpandTimeBin(0,0);
-
   // The rotation matrix elements
   Float_t phi = 0;
   for (isect = 0; isect < fgkNsect; isect++) {
-    phi = -2.0 * kPI /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
+    phi = -2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
     fRotA11[isect] = TMath::Cos(phi);
     fRotA12[isect] = TMath::Sin(phi);
     fRotA21[isect] = TMath::Sin(phi);
@@ -317,154 +251,145 @@ void AliTRDgeometry::Init()
 }
 
 //_____________________________________________________________________________
-void AliTRDgeometry::SetNRowPad(const Int_t p, const Int_t c, const Int_t npad)
+void AliTRDgeometry::CreateGeometry(Int_t* )
 {
   //
-  // Redefines the number of pads in raw direction for
-  // a given plane and chamber number
+  // Create TRD geometry
   //
 
-  for (Int_t isect = 0; isect < fgkNsect; isect++) {
-
-    fRowMax[p][c][isect] = npad;  
-    fRowPadSize[p][c][isect] = (fClength[p][c] - 2.*fgkRpadW)
-                            / ((Float_t) npad);
-
-  }
-
 }
 
 //_____________________________________________________________________________
-void AliTRDgeometry::SetNRowPad()
+Bool_t AliTRDgeometry::Local2Global(Int_t idet, Double_t *local
+                                   , Double_t *global) const
 {
   //
-  // Defines the number of pads in row direction
+  // Converts local pad-coordinates (row,col,time) into 
+  // global ALICE reference frame coordinates (x,y,z)
   //
 
-  Int_t isect;
-  Int_t icham;
-  Int_t iplan;
-
-  Int_t rowMax[kNplan][kNcham] = { { 16, 16, 12, 16, 16 }
-                                 , { 16, 16, 12, 16, 16 }
-                                 , { 16, 16, 12, 16, 16 }
-                                 , { 16, 16, 12, 16, 16 }
-                                 , { 14, 16, 12, 16, 14 }
-                                 , { 13, 16, 12, 16, 13 } };
-
-  for (isect = 0; isect < kNsect; isect++) {
-    for (icham = 0; icham < kNcham; icham++) {
-      for (iplan = 0; iplan < kNplan; iplan++) {
+  Int_t icham = GetChamber(idet);    // Chamber info (0-4)
+  Int_t isect = GetSector(idet);     // Sector info  (0-17)
+  Int_t iplan = GetPlane(idet);      // Plane info   (0-5)
 
-        fRowMax[iplan][icham][isect]     = rowMax[iplan][icham];
-        fRowPadSize[iplan][icham][isect] = (fClength[iplan][icham] - 2.*fgkRpadW)
-                                        / ((Float_t) rowMax[iplan][icham]);
-
-        Float_t row0 = fgkRpadW - fClength[iplan][0] 
-                                - fClength[iplan][1] 
-                                - fClength[iplan][2]/2.;
-        for (Int_t ic = 0; ic < icham; ic++) {
-          row0 += fClength[iplan][ic];
-       }
-        fRow0[iplan][icham][isect]       = row0;
-
-      }
-    }
-  }
+  return Local2Global(iplan,icham,isect,local,global);
 
 }
-
 //_____________________________________________________________________________
-void AliTRDgeometry::SetColPadSize(const Int_t p, const Float_t s)
+Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
+                                  , Double_t *local, Double_t *global) const
 {
   //
-  // Redefines the pad size in column direction
+  // Converts local pad-coordinates (row,col,time) into 
+  // global ALICE reference frame coordinates (x,y,z)
   //
 
-  fColPadSize[p] = s;
-  fCol0[p]       = - fCwidth[p]/2. + fgkCpadW;
-  fColMax[p]     = ((Int_t) ((fCwidth[p] - 2. * fgkCpadW) / s)); 
+  AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
+  if (!commonParam)
+    return kFALSE;
 
-}
+  AliTRDcalibDB* calibration = AliTRDcalibDB::Instance();
+  if (!calibration)
+    return kFALSE;  
+  
+  AliTRDpadPlane *padPlane = commonParam->GetPadPlane(iplan,icham);
 
-//_____________________________________________________________________________
-void AliTRDgeometry::SetNTimeBin(const Int_t nbin)
-{
-  //
-  // Redefines the number of time bins in the drift region.
-  // The time bin width is defined by the length of the
-  // drift region divided by <nbin>.
-  //
+  // 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);
 
-  fTimeMax     = nbin;
-  fTimeBinSize = fgkDrThick / ((Float_t) fTimeMax);
-  for (Int_t iplan = 0; iplan < fgkNplan; iplan++) {
-    fTime0[iplan]  = fgkRmin + fgkCraH + fgkCdrH
-                             + iplan * (fgkCH + fgkVspace);
-  }
+  Int_t idet = GetDetector(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);
 
-//_____________________________________________________________________________
-void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
-{
-  //
-  // Create TRD geometry
-  //
+  // Rotate back to original position
+  return RotateBack(idet,rot,global);
 
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::Local2Global(Int_t idet, Float_t *local, Float_t *global) 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 
   // global ALICE reference frame coordinates (x,y,z)
   //
+  // index[0] = plane number
+  // index[1] = chamber number
+  // index[2] = sector number
+  //
+  // mode=0  - local coordinate in y, z,             x - rotated global   
+  // mode=2  - local coordinate in pad, and pad row, x - rotated global
+  //
 
-  Int_t icham = GetChamber(idet);    // Chamber info (0-4)
-  Int_t isect = GetSector(idet);     // Sector info  (0-17)
-  Int_t iplan = GetPlane(idet);      // Plane info   (0-5)
+  //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);
+  if (mode==0) return kTRUE;
+  //
+  //  Float_t  row0      = par->GetRow0(iplan,icham,isect);
+  //Float_t  col0      = par->GetCol0(iplan);
+  //Float_t  time0     = GetTime0(iplan);
+  //
+  // mode 1 to be implemented later
+  // calculate (x,y,z) position in time bin pad row pad
+  //
+  //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);
 
-  return Local2Global(iplan,icham,isect,local,global);
+  return kTRUE;
 
 }
+
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::Local2Global(Int_t iplan, Int_t icham, Int_t isect
-                                  , Float_t *local, Float_t *global) const
+Bool_t AliTRDgeometry::Global2Detector(Double_t global[3], Int_t index[3])
 {
+  //  
+  // input    = global position
+  // output   = index
+  // index[0] = plane number
+  // index[1] = chamber number
+  // index[2] = sector number
   //
-  // Converts local pad-coordinates (row,col,time) into 
-  // global ALICE reference frame coordinates (x,y,z)
-  //
-
-  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"
 
-  Float_t  row0      = GetRow0(iplan,icham,isect);
-  Float_t  col0      = GetCol0(iplan);
-  Float_t  time0     = GetTime0(iplan);
-
-  Float_t  rot[3];
-
-  // calculate (x,y,z) position in rotated chamber
-  rot[0] = time0 - (timeSlice - fTimeBefore) * fTimeBinSize;
-  rot[1] = col0  + padCol                    * fColPadSize[iplan];
-  rot[2] = row0  + padRow                    * fRowPadSize[iplan][icham][isect];
-
-  // Rotate back to original position
-  return RotateBack(idet,rot,global);
+  Float_t fi;
+  //
+  fi = TMath::ATan2(global[1],global[0]);
+  if (fi<0) fi += 2*TMath::Pi();
+  index[2] = Int_t(TMath::Nint((fi - GetAlpha()/2.)/GetAlpha()));
+  //
+  //
+  Float_t locx = global[0] * fRotA11[index[2]] + global[1] * fRotA12[index[2]];  
+  index[0] = 0;
+  Float_t max = locx - GetTime0(0);
+  for (Int_t iplane=1; iplane<fgkNplan;iplane++){
+    Float_t dist = TMath::Abs(locx - GetTime0(iplane));
+    if (dist < max){
+      index[0] = iplane;
+      max = dist;
+    }
+  }
+  Float_t theta = TMath::ATan2(global[2],locx);
+  index[1] = TMath::Nint(float(fgkNcham)*theta/(0.25*TMath::Pi()));
+  return kTRUE;
 
 }
 
+
 //_____________________________________________________________________________
-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
@@ -483,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
@@ -502,7 +427,7 @@ Bool_t AliTRDgeometry::RotateBack(Int_t d, Float_t *rot, Float_t *pos) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetDetectorSec(const Int_t p, const Int_t c) const
+Int_t AliTRDgeometry::GetDetectorSec(Int_t p, Int_t c)
 {
   //
   // Convert plane / chamber into detector number for one single sector
@@ -513,7 +438,7 @@ Int_t AliTRDgeometry::GetDetectorSec(const Int_t p, const Int_t c) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetDetector(const Int_t p, const Int_t c, const Int_t s) const
+Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s)
 {
   //
   // Convert plane / chamber / sector into detector number
@@ -524,7 +449,7 @@ Int_t AliTRDgeometry::GetDetector(const Int_t p, const Int_t c, const Int_t s) c
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetPlane(const Int_t d) const
+Int_t AliTRDgeometry::GetPlane(Int_t d) const
 {
   //
   // Reconstruct the plane number from the detector number
@@ -535,7 +460,7 @@ Int_t AliTRDgeometry::GetPlane(const Int_t d) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetChamber(const Int_t d) const
+Int_t AliTRDgeometry::GetChamber(Int_t d) const
 {
   //
   // Reconstruct the chamber number from the detector number
@@ -546,7 +471,7 @@ Int_t AliTRDgeometry::GetChamber(const Int_t d) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetSector(const Int_t d) const
+Int_t AliTRDgeometry::GetSector(Int_t d) const
 {
   //
   // Reconstruct the sector number from the detector number
@@ -557,42 +482,32 @@ Int_t AliTRDgeometry::GetSector(const Int_t d) const
 }
 
 //_____________________________________________________________________________
-void AliTRDgeometry::GetGlobal(const AliRecPoint *p, TVector3 &pos
-                             , TMatrix &mat) const
+AliTRDgeometry* AliTRDgeometry::GetGeometry(AliRunLoader* runLoader)
 {
-  // 
-  // Returns the global coordinate and error matrix of a AliTRDrecPoint
   //
-
-  GetGlobal(p,pos);
-  mat.Zero();
-
-}
-
-//_____________________________________________________________________________
-void AliTRDgeometry::GetGlobal(const AliRecPoint *p, TVector3 &pos) const
-{
-  // 
-  // Returns the global coordinate and error matrix of a AliTRDrecPoint
+  // load the geometry from the galice file
   //
 
-  Int_t detector = ((AliTRDrecPoint *) p)->GetDetector();
+  if (!runLoader) runLoader = AliRunLoader::GetRunLoader();
+  if (!runLoader) {
+    ::Error("AliTRDgeometry::GetGeometry", "No run loader");
+    return NULL;
+  }
 
-  Float_t global[3];
-  Float_t local[3];
-  local[0] = ((AliTRDrecPoint *) p)->GetLocalRow();
-  local[1] = ((AliTRDrecPoint *) p)->GetLocalCol();
-  local[2] = ((AliTRDrecPoint *) p)->GetLocalTime();
+  TDirectory* saveDir = gDirectory;
+  runLoader->CdGAFile();
 
-  if (Local2Global(detector,local,global)) {
-    pos.SetX(global[0]);
-    pos.SetY(global[1]);
-    pos.SetZ(global[2]);
-  }
-  else {
-    pos.SetX(0.0);
-    pos.SetY(0.0);
-    pos.SetZ(0.0);
+  // Try from the galice.root file
+  AliTRDgeometry* geom = (AliTRDgeometry*) gDirectory->Get("TRDgeometry");
+
+  if (!geom) {
+    // It is not in the file, try to get it from gAlice, 
+    // which corresponds to the run loader 
+    AliTRD * trd = (AliTRD*)runLoader->GetAliRun()->GetDetector("TRD");
+    geom = trd->GetGeometry();
   }
+  if (!geom) ::Error("AliTRDgeometry::GetGeometry", "Geometry not found");
 
+  saveDir->cd();
+  return geom;
 }