]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDgeometry.cxx
Move pad planes from AliTRDCommomParam to AliTRDgeometry
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometry.cxx
index 7a622ba64fd668a2cbcf6b74aa7a6e09e5dd45e5..f451be96b3086499ea51aa37e6850980e5be48e4 100644 (file)
@@ -34,7 +34,6 @@
 
 #include "AliTRD.h"
 #include "AliTRDcalibDB.h"
-#include "AliTRDCommonParam.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDpadPlane.h"
 
@@ -164,7 +163,7 @@ AliTRDgeometry::AliTRDgeometry()
   ,fMatrixArray(0)
   ,fMatrixCorrectionArray(0)
   ,fMatrixGeo(0)
-
+  ,fPadPlaneArray(0)
 {
   //
   // AliTRDgeometry default constructor
@@ -177,9 +176,10 @@ AliTRDgeometry::AliTRDgeometry()
 //_____________________________________________________________________________
 AliTRDgeometry::AliTRDgeometry(const AliTRDgeometry &g)
   :AliGeometry(g)
-  ,fMatrixArray(g.fMatrixArray)
-  ,fMatrixCorrectionArray(g.fMatrixCorrectionArray)
-  ,fMatrixGeo(g.fMatrixGeo)
+  ,fMatrixArray(0)
+  ,fMatrixCorrectionArray(0)
+  ,fMatrixGeo(0)
+  ,fPadPlaneArray(0)
 {
   //
   // AliTRDgeometry copy constructor
@@ -197,15 +197,29 @@ AliTRDgeometry::~AliTRDgeometry()
   //
 
   if (fMatrixArray) {
+    fMatrixArray->Delete();
     delete fMatrixArray;
-    fMatrixArray           = 0;
+    fMatrixArray = 0;
   }
 
   if (fMatrixCorrectionArray) {
+    fMatrixCorrectionArray->Delete();
     delete fMatrixCorrectionArray;
     fMatrixCorrectionArray = 0;
   }
 
+  if (fMatrixGeo) {
+    fMatrixGeo->Delete();
+    delete fMatrixGeo;
+    fMatrixGeo = 0;
+  }
+
+  if (fPadPlaneArray) {
+    fPadPlaneArray->Delete();
+    delete fPadPlaneArray;
+    fPadPlaneArray = 0;
+  }
+
 }
 
 //_____________________________________________________________________________
@@ -260,24 +274,260 @@ void AliTRDgeometry::Init()
   // The rotation matrix elements
   Float_t phi = 0.0;
   for (isect = 0; isect < fgkNsect; isect++) {
-    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);
-    fRotA22[isect] = TMath::Cos(phi);
-    phi = -1.0 * phi;
+    phi = 2.0 * TMath::Pi() /  (Float_t) fgkNsect * ((Float_t) isect + 0.5);
     fRotB11[isect] = TMath::Cos(phi);
     fRotB12[isect] = TMath::Sin(phi);
     fRotB21[isect] = TMath::Sin(phi);
     fRotB22[isect] = TMath::Cos(phi);
   }
 
+  // Initialize the SM status
   for (isect = 0; isect < fgkNsect; isect++) {
     SetSMstatus(isect,1);
   }
  
 }
 
+//_____________________________________________________________________________
+void AliTRDgeometry::CreatePadPlaneArray()
+{
+  //
+  // Creates the array of AliTRDpadPlane objects
+  //
+
+  if (fPadPlaneArray) {
+    fPadPlaneArray->Delete();
+    delete fPadPlaneArray;
+  }
+
+  fPadPlaneArray = new TObjArray(fgkNplan * fgkNcham);  
+  for (Int_t iplan = 0; iplan < fgkNplan; iplan++) {
+    for (Int_t icham = 0; icham < fgkNcham; icham++) {
+      Int_t ipp = GetDetectorSec(iplan,icham);
+      fPadPlaneArray->AddAt(CreatePadPlane(iplan,icham),ipp);
+    }
+  }
+
+}
+
+//_____________________________________________________________________________
+AliTRDpadPlane *AliTRDgeometry::CreatePadPlane(Int_t iplan, Int_t icham)
+{
+  //
+  // Creates an AliTRDpadPlane object
+  //
+
+  AliTRDpadPlane *padPlane = new AliTRDpadPlane();
+
+  padPlane->SetPlane(iplan);
+  padPlane->SetChamber(icham);
+
+  padPlane->SetRowSpacing(0.0);
+  padPlane->SetColSpacing(0.0);
+
+  padPlane->SetLengthRim(1.0);
+  padPlane->SetWidthRim(0.5);
+
+  padPlane->SetNcols(144);
+
+  //
+  // The pad plane parameter
+  //
+  switch (iplan) {
+  case 0:
+    if (icham == 2) {
+      // L0C0 type
+      padPlane->SetNrows(12);
+      padPlane->SetLength(108.0);
+      padPlane->SetWidth(92.2);
+      padPlane->SetLengthOPad(8.0);
+      padPlane->SetWidthOPad(0.515);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.635);
+      padPlane->SetTiltingAngle(-2.0);
+    }
+    else {
+      // L0C1 type
+      padPlane->SetNrows(16);
+      padPlane->SetLength(122.0);
+      padPlane->SetWidth(92.2);
+      padPlane->SetLengthOPad(7.5);
+      padPlane->SetWidthOPad(0.515);
+      padPlane->SetLengthIPad(7.5);
+      padPlane->SetWidthIPad(0.635);
+      padPlane->SetTiltingAngle(-2.0);
+    }
+    break;
+  case 1:
+    if (icham == 2) {
+      // L1C0 type
+      padPlane->SetNrows(12);
+      padPlane->SetLength(108.0);
+      padPlane->SetWidth(96.6);
+      padPlane->SetLengthOPad(8.0);
+      padPlane->SetWidthOPad(0.585);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.665);
+      padPlane->SetTiltingAngle(2.0);
+    }
+    else {
+      // L1C1 type
+      padPlane->SetNrows(16);
+      padPlane->SetLength(122.0);
+      padPlane->SetWidth(96.6);
+      padPlane->SetLengthOPad(7.5);
+      padPlane->SetWidthOPad(0.585);
+      padPlane->SetLengthIPad(7.5);
+      padPlane->SetWidthIPad(0.665);
+      padPlane->SetTiltingAngle(2.0);
+    }
+    break;
+  case 2:
+    if (icham == 2) {
+      // L2C0 type
+      padPlane->SetNrows(12);
+      padPlane->SetLength(108.0);
+      padPlane->SetWidth(101.1);
+      padPlane->SetLengthOPad(8.0);
+      padPlane->SetWidthOPad(0.705);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.695);
+      padPlane->SetTiltingAngle(-2.0);
+    }
+    else {
+      // L2C1 type
+      padPlane->SetNrows(16);
+      padPlane->SetLength(129.0);
+      padPlane->SetWidth(101.1);
+      padPlane->SetLengthOPad(7.5);
+      padPlane->SetWidthOPad(0.705);
+      padPlane->SetLengthIPad(8.0);
+      padPlane->SetWidthIPad(0.695);
+      padPlane->SetTiltingAngle(-2.0);
+    }
+    break;
+  case 3:
+    if (icham == 2) {
+      // L3C0 type
+      padPlane->SetNrows(12);
+      padPlane->SetLength(108.0);
+      padPlane->SetWidth(105.5);
+      padPlane->SetLengthOPad(8.0);
+      padPlane->SetWidthOPad(0.775);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.725);
+      padPlane->SetTiltingAngle(2.0);
+    }
+    else {
+      // L3C1 type
+      padPlane->SetNrows(16);
+      padPlane->SetLength(136.0);
+      padPlane->SetWidth(105.5);
+      padPlane->SetLengthOPad(7.5);
+      padPlane->SetWidthOPad(0.775);
+      padPlane->SetLengthIPad(8.5);
+      padPlane->SetWidthIPad(0.725);
+      padPlane->SetTiltingAngle(2.0);
+    }
+    break;
+  case 4:
+    if (icham == 2) {
+      // L4C0 type
+      padPlane->SetNrows(12);
+      padPlane->SetLength(108.0);
+      padPlane->SetWidth(109.9);
+      padPlane->SetLengthOPad(8.0);
+      padPlane->SetWidthOPad(0.845);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.755);
+      padPlane->SetTiltingAngle(-2.0);
+    }
+    else {
+      // L4C1 type
+      padPlane->SetNrows(16);
+      padPlane->SetLength(143.0);
+      padPlane->SetWidth(109.9);
+      padPlane->SetLengthOPad(7.5);
+      padPlane->SetWidthOPad(0.845);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.755);
+      padPlane->SetTiltingAngle(-2.0);
+    }
+    break;
+  case 5:
+    if (icham == 2) {
+      // L5C0 type
+      padPlane->SetNrows(12);
+      padPlane->SetLength(108.0);
+      padPlane->SetWidth(114.4);
+      padPlane->SetLengthOPad(8.0);
+      padPlane->SetWidthOPad(0.965);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.785);
+      padPlane->SetTiltingAngle(2.0);
+    }
+    else {
+      // L5C1 type
+      padPlane->SetNrows(16);
+      padPlane->SetLength(145.0);
+      padPlane->SetWidth(114.4);
+      padPlane->SetLengthOPad(8.5);
+      padPlane->SetWidthOPad(0.965);
+      padPlane->SetLengthIPad(9.0);
+      padPlane->SetWidthIPad(0.785);
+      padPlane->SetTiltingAngle(2.0);
+    }
+    break;
+  };
+
+  //
+  // The positions of the borders of the pads
+  //
+  // Row direction
+  //
+  Double_t row = fClength[iplan][icham] / 2.0
+               - fgkRpadW
+               - padPlane->GetLengthRim();
+  for (Int_t ir = 0; ir < padPlane->GetNrows(); ir++) {
+    padPlane->SetPadRow(ir,row);
+    row -= padPlane->GetRowSpacing();
+    if (ir == 0) {
+      row -= padPlane->GetLengthOPad();
+    }
+    else {
+      row -= padPlane->GetLengthIPad();
+    }
+  }
+  //
+  // Column direction
+  //
+  Double_t col = fCwidth[iplan] / 2.0
+               + fgkCroW
+               - padPlane->GetWidthRim();
+  for (Int_t ic = 0; ic < padPlane->GetNcols(); ic++) {
+    padPlane->SetPadCol(ic,col);
+    col -= padPlane->GetColSpacing();
+    if (ic == 0) {
+      col -= padPlane->GetWidthOPad();
+    }
+    else {
+      col -= padPlane->GetWidthIPad();
+    }
+  }
+  // Calculate the offset to translate from the local ROC system into
+  // the local supermodule system, which is used for clusters
+  Double_t rowTmp = fClength[iplan][0]
+                 + fClength[iplan][1]
+                  + fClength[iplan][2] / 2.0;
+  for (Int_t ic = 0; ic < icham; ic++) {
+    rowTmp -= fClength[iplan][ic];
+  }
+  padPlane->SetPadRowSMOffset(rowTmp - fClength[iplan][icham]/2.0);
+
+  return padPlane;
+
+}
+
 //_____________________________________________________________________________
 void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
 {
@@ -587,12 +837,12 @@ void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
 
       // Position the frames of the chambers in the TRD mother volume
       xpos  = 0.0;
-      ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.0;
+      ypos  = fClength[iplan][0] + fClength[iplan][1] + fClength[iplan][2]/2.0;
       for (Int_t ic = 0; ic < icham; ic++) {
-        ypos += fClength[iplan][ic];        
+        ypos -= fClength[iplan][ic];
       }
-      ypos += fClength[iplan][icham]/2.0;
-      zpos  = fgkVrocsm + fgkSMpltT + fgkCraH/2.0 + fgkCdrH/2.0 - fgkSheight/2.0 
+      ypos -= fClength[iplan][icham]/2.0;
+      zpos  = fgkVrocsm + fgkSMpltT + fgkCraH/2.0 + fgkCdrH/2.0 - fgkSheight/2.0
             + iplan * (fgkCH + fgkVspace);
       // The lower aluminum frame, radiator + drift region
       sprintf(cTagV,"UA%02d",iDet);      
@@ -934,12 +1184,6 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
   gMC->Matrix(matrix[1],  80.0,   0.0,  90.0,  90.0,  10.0, 180.0);
   gMC->Matrix(matrix[2],   0.0,   0.0,  90.0,  90.0,  90.0,   0.0);
   gMC->Matrix(matrix[3], 180.0,   0.0,  90.0,  90.0,  90.0, 180.0);
-
-  AliTRDCommonParam *commonParam = AliTRDCommonParam::Instance();
-  if (!commonParam) {
-    AliError("Could not get common parameters\n");
-    return;
-  }
     
   //
   // The cooling arterias
@@ -1043,12 +1287,12 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
       gMC->Gsvolu(cTagV,"BOX",idtmed[1302-1],parServ,kNparServ);
 
       xpos  = 0.0;
-      ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.0;
+      ypos  = fClength[iplan][0] + fClength[iplan][1] + fClength[iplan][2]/2.0;
       for (Int_t ic = 0; ic < icham; ic++) {
-        ypos += fClength[iplan][ic];        
+        ypos -= fClength[iplan][ic];
       }
-      ypos += fClength[iplan][icham]/2.0;
-      zpos  = fgkVrocsm + fgkSMpltT + fgkCH + fgkVspace/2.0 - fgkSheight/2.0 
+      ypos -= fClength[iplan][icham]/2.0;
+      zpos  = fgkVrocsm + fgkSMpltT + fgkCH + fgkVspace/2.0 - fgkSheight/2.0
             + iplan * (fgkCH + fgkVspace);
       zpos -= 0.742/2.0;
       fChamberUUorig[iDet][0] = xpos;
@@ -1087,7 +1331,7 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
     for (iplan = 0; iplan < kNplan; iplan++) {
       Int_t   iDet    = GetDetectorSec(iplan,icham);
       Int_t   iCopy   = GetDetector(iplan,icham,0) * 100;
-      Int_t   nMCMrow = commonParam->GetRowMax(iplan,icham,0);
+      Int_t   nMCMrow = GetRowMax(iplan,icham,0);
       Float_t ySize   = (GetChamberLength(iplan,icham) - 2.0*fgkRpadW) 
                       / ((Float_t) nMCMrow);
       sprintf(cTagV,"UU%02d",iDet);
@@ -1120,7 +1364,7 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
     for (iplan = 0; iplan < kNplan; iplan++) {
       Int_t   iDet    = GetDetectorSec(iplan,icham);
       Int_t   iCopy   = GetDetector(iplan,icham,0) * 100;
-      Int_t   nMCMrow = commonParam->GetRowMax(iplan,icham,0);
+      Int_t   nMCMrow = GetRowMax(iplan,icham,0);
       Float_t ySize   = (GetChamberLength(iplan,icham) - 2.0*fgkRpadW) 
                       / ((Float_t) nMCMrow);
       sprintf(cTagV,"UU%02d",iDet);
@@ -1145,11 +1389,11 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
   const Float_t kMCMx    = 3.0;
   const Float_t kMCMy    = 3.0;
   const Float_t kMCMz    = 0.3;
-
+  
   const Float_t kMCMpcTh = 0.1;
-  const Float_t kMCMcuTh = 0.0215;
-  const Float_t kMCMsiTh = 0.003;
-  const Float_t kMCMcoTh = 0.1549;
+  const Float_t kMCMcuTh = 0.0025;
+  const Float_t kMCMsiTh = 0.03;
+  const Float_t kMCMcoTh = 0.04;
 
   // The mother volume for the MCMs (air)
   const Int_t kNparMCM = 3;
@@ -1197,7 +1441,7 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
     for (iplan = 0; iplan < kNplan; iplan++) {
       Int_t   iDet    = GetDetectorSec(iplan,icham);
       Int_t   iCopy   = GetDetector(iplan,icham,0) * 1000;
-      Int_t   nMCMrow = commonParam->GetRowMax(iplan,icham,0);
+      Int_t   nMCMrow = GetRowMax(iplan,icham,0);
       Float_t ySize   = (GetChamberLength(iplan,icham) - 2.0*fgkRpadW) 
                       / ((Float_t) nMCMrow);
       Int_t   nMCMcol = 8;
@@ -1322,38 +1566,18 @@ void AliTRDgeometry::GroupChamber(Int_t iplan, Int_t icham, Int_t *idtmed)
 }
 
 //_____________________________________________________________________________
-Bool_t AliTRDgeometry::Rotate(Int_t d, Double_t *pos, Double_t *rot) const
+Bool_t AliTRDgeometry::RotateBack(Int_t det, Double_t *loc, Double_t *glb) const
 {
   //
-  // Rotates all chambers in the position of sector 0 and transforms
-  // the coordinates in the ALICE restframe <pos> into the 
-  // corresponding local frame <rot>.
+  // Rotates a chambers to transform the corresponding local frame
+  // coordinates <loc> into the coordinates of the ALICE restframe <glb>.
   //
 
-  Int_t sector = GetSector(d);
+  Int_t sector = GetSector(det);
 
-  rot[0] =  pos[0] * fRotA11[sector] + pos[1] * fRotA12[sector];
-  rot[1] = -pos[0] * fRotA21[sector] + pos[1] * fRotA22[sector];
-  rot[2] =  pos[2];
-
-  return kTRUE;
-
-}
-
-//_____________________________________________________________________________
-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
-  // original position and transforms the corresponding local frame 
-  // coordinates <rot> into the coordinates of the ALICE restframe <pos>.
-  //
-
-  Int_t sector = GetSector(d);
-
-  pos[0] =  rot[0] * fRotB11[sector] + rot[1] * fRotB12[sector];
-  pos[1] = -rot[0] * fRotB21[sector] + rot[1] * fRotB22[sector];
-  pos[2] =  rot[2];
+  glb[0] = loc[0] * fRotB11[sector] - loc[1] * fRotB12[sector];
+  glb[1] = loc[0] * fRotB21[sector] + loc[1] * fRotB22[sector];
+  glb[2] = loc[2];
 
   return kTRUE;
 
@@ -1414,111 +1638,138 @@ Int_t AliTRDgeometry::GetSector(Int_t d) const
 
 }
 
-//CL
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetPadRow(Int_t irob, Int_t imcm) const
+AliTRDpadPlane *AliTRDgeometry::GetPadPlane(Int_t p, Int_t c)
 {
+  //
+  // Returns the pad plane for a given plane <p> and chamber <c> number
+  //
 
-  // return on which row this mcm sits 
+  if (!fPadPlaneArray) {
+    CreatePadPlaneArray();
+  }
 
-  return fgkMCMrow*(irob/2) + imcm/fgkMCMrow;
+  Int_t ipp = GetDetectorSec(p,c);
+  return ((AliTRDpadPlane *) fPadPlaneArray->At(ipp));
 
-;
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetPadCol(Int_t irob, Int_t imcm, Int_t iadc) const
+Int_t AliTRDgeometry::GetRowMax(Int_t p, Int_t c, Int_t /*s*/)
 {
   //
-  // return which pad is connected to this adc channel. return -1 if it
-  // is one of the not directly connected adc channels (0, 1 20)
+  // Returns the number of rows on the pad plane
   //
 
-  if (iadc < 2 || iadc > 19 ) return -1;
-
-  return (iadc-2) + (imcm%fgkMCMrow)*fgkPadmax + GetRobSide(irob)*fgkColmax/2;
+  return GetPadPlane(p,c)->GetNrows();
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetMCM(Int_t irow, Int_t icol) const
+Int_t AliTRDgeometry::GetColMax(Int_t p)
 {
+  //
+  // Returns the number of rows on the pad plane
+  //
 
-  // return on which mcm this pad is
+  return GetPadPlane(p,0)->GetNcols();
 
-  if ( irow < 0 || icol < 0 || irow > fgkRowmaxC1 || icol > fgkColmax ) return -1;
+}
 
-  return (icol%(fgkColmax/2))/fgkPadmax + fgkMCMrow*(irow%fgkMCMrow);
+//_____________________________________________________________________________
+Double_t AliTRDgeometry::GetRow0(Int_t p, Int_t c, Int_t /*s*/)
+{
+  //
+  // Returns the position of the border of the first pad in a row
+  //
+
+  return GetPadPlane(p,c)->GetRow0();
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetROB(Int_t irow, Int_t icol) const
+Double_t AliTRDgeometry::GetCol0(Int_t p)
 {
+  //
+  // Returns the position of the border of the first pad in a column
+  //
 
-  // return on which rob this pad is
-
-  return (irow/fgkMCMrow)*2 + GetColSide(icol);
+  return GetPadPlane(p,0)->GetCol0();
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetRobSide(Int_t irob) const
+Int_t AliTRDgeometry::GetPadRowFromMCM(Int_t irob, Int_t imcm) const
 {
+  //
+  // Return on which row this mcm sits 
+  //
 
-  // return on which side this rob sits (A side = 0, B side = 1)
+  return fgkMCMrow*(irob/2) + imcm/fgkMCMrow;
 
-  if ( irob < 0 || irob >= fgkROBmaxC1 ) return -1;
+}
 
-  return irob%2;
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
+{
+  //
+  // Return which pad is connected to this adc channel. return -1 if it
+  // is one of the not directly connected adc channels (0, 1 20)
+  //
+
+  if (iadc < 2 || iadc > 19 ) return -1;
+
+  return (iadc-2) + (imcm%fgkMCMrow)*fgkPadmax + GetRobSide(irob)*fgkColmax/2;
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetColSide(Int_t icol) const
+Int_t AliTRDgeometry::GetMCMfromPad(Int_t irow, Int_t icol) const
 {
+  //
+  // Return on which mcm this pad is
+  //
+
+  if ( irow < 0 || icol < 0 || irow > fgkRowmaxC1 || icol > fgkColmax ) return -1;
 
-  // return on which side this column sits (A side = 0, B side = 1)
+  return (icol%(fgkColmax/2))/fgkPadmax + fgkMCMrow*(irow%fgkMCMrow);
 
-  if ( icol < 0 || icol >= fgkColmax ) return -1;
+}
 
-  return icol/(fgkColmax/2);
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetROBfromPad(Int_t irow, Int_t icol) const
+{
+  //
+  // Return on which rob this pad is
+  //
+
+  return (irow/fgkMCMrow)*2 + GetColSide(icol);
 
 }
 
 //_____________________________________________________________________________
-AliTRDgeometry *AliTRDgeometry::GetGeometry(AliRunLoader *runLoader)
+Int_t AliTRDgeometry::GetRobSide(Int_t irob) const
 {
   //
-  // Load the geometry from the galice file
+  // Return on which side this rob sits (A side = 0, B side = 1)
   //
 
-  if (!runLoader) {
-    runLoader = AliRunLoader::GetRunLoader();
-  }
-  if (!runLoader) {
-    AliErrorGeneral("AliTRDgeometry::GetGeometry","No run loader");
-    return NULL;
-  }
+  if ( irob < 0 || irob >= fgkROBmaxC1 ) return -1;
 
-  TDirectory *saveDir = gDirectory;
-  runLoader->CdGAFile();
+  return irob%2;
 
-  // Try from the galice.root file
-  AliTRDgeometry *geom = (AliTRDgeometry *) gDirectory->Get("TRDgeometry");
+}
 
-  if (!geom) {
-    // If it is not in the file, try to get it from the run loader 
-    AliTRD *trd = (AliTRD *) runLoader->GetAliRun()->GetDetector("TRD");
-    geom = trd->GetGeometry();
-  }
-  if (!geom) {
-    AliErrorGeneral("AliTRDgeometry::GetGeometry","Geometry not found");
-    return NULL;
-  }
+//_____________________________________________________________________________
+Int_t AliTRDgeometry::GetColSide(Int_t icol) const
+{
+  //
+  // Return on which side this column sits (A side = 0, B side = 1)
+  //
+
+  if ( icol < 0 || icol >= fgkColmax ) return -1;
 
-  saveDir->cd();
-  return geom;
+  return icol/(fgkColmax/2);
 
 }
 
@@ -1538,11 +1789,11 @@ Bool_t AliTRDgeometry::ReadGeoMatrices()
   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++) {
+  for (Int_t iLayer = AliGeomManager::kTRD1; iLayer <= AliGeomManager::kTRD6; iLayer++) {
+    for (Int_t iModule = 0; iModule < AliGeomManager::LayerSize(iLayer); iModule++) {
 
-      UShort_t     volid   = AliAlignObj::LayerToVolUID(iLayer,iModule);
-      const char  *symname = AliAlignObj::SymName(volid);
+      UShort_t     volid   = AliGeomManager::LayerToVolUID(iLayer,iModule);
+      const char  *symname = AliGeomManager::SymName(volid);
       TGeoPNEntry *pne     = gGeoManager->GetAlignableEntry(symname);
       const char  *path    = symname;
       if (pne) {
@@ -1552,9 +1803,9 @@ Bool_t AliTRDgeometry::ReadGeoMatrices()
         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        iLayerTRD = iLayer - AliGeomManager::kTRD1;
+      Int_t        isector   = iModule/Ncham();
+      Int_t        ichamber  = iModule%Ncham();
       Int_t        lid       = GetDetector(iLayerTRD,ichamber,isector);    
 
       //
@@ -1578,7 +1829,7 @@ Bool_t AliTRDgeometry::ReadGeoMatrices()
       Double_t sectorAngle = 20.0 * (isector % 18) + 10.0;
       TGeoHMatrix  rotSector;
       rotSector.RotateZ(sectorAngle);
-      rotMatrix.MultiplyLeft(&rotSector);      
+      rotMatrix.MultiplyLeft(&rotSector.Inverse());
 
       fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid);