]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDgeometry.cxx
Added methods to list available reports and detectors. Changed Fill(..) method to...
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometry.cxx
index 136a37a0eef93f83791bb3476939eb5115db26a6..4bc3100c09b73414f62d00a4463c9e690dfd9cee 100644 (file)
@@ -34,7 +34,6 @@
 
 #include "AliTRD.h"
 #include "AliTRDcalibDB.h"
-#include "AliTRDCommonParam.h"
 #include "AliTRDgeometry.h"
 #include "AliTRDpadPlane.h"
 
@@ -76,7 +75,7 @@ ClassImp(AliTRDgeometry)
   const Float_t  AliTRDgeometry::fgkCH        = AliTRDgeometry::fgkCraH
                                               + AliTRDgeometry::fgkCdrH
                                               + AliTRDgeometry::fgkCamH
-                                              + AliTRDgeometry::fgkCroH;
+                                              + AliTRDgeometry::fgkCroH;  
 
   // Vertical spacing of the chambers
   const Float_t  AliTRDgeometry::fgkVspace    =   1.784;
@@ -112,13 +111,13 @@ ClassImp(AliTRDgeometry)
   // Thickness of the the material layers
   //
   const Float_t  AliTRDgeometry::fgkMyThick   = 0.005;
-  const Float_t  AliTRDgeometry::fgkRaThick   = 0.3233;
+  const Float_t  AliTRDgeometry::fgkRaThick   = 0.3233;  
   const Float_t  AliTRDgeometry::fgkDrThick   = AliTRDgeometry::fgkCdrH;    
   const Float_t  AliTRDgeometry::fgkAmThick   = AliTRDgeometry::fgkCamH;
   const Float_t  AliTRDgeometry::fgkXeThick   = AliTRDgeometry::fgkDrThick
                                               + AliTRDgeometry::fgkAmThick;
   const Float_t  AliTRDgeometry::fgkWrThick   = 0.0002;
-  const Float_t  AliTRDgeometry::fgkCuThick   = 0.0072;
+  const Float_t  AliTRDgeometry::fgkCuThick   = 0.0072; 
   const Float_t  AliTRDgeometry::fgkGlThick   = 0.05;
   const Float_t  AliTRDgeometry::fgkSuThick   = 0.0919; 
   const Float_t  AliTRDgeometry::fgkRcThick   = 0.0058;
@@ -139,19 +138,18 @@ ClassImp(AliTRDgeometry)
   const Float_t  AliTRDgeometry::fgkRpZpos    =  1.0;
   const Float_t  AliTRDgeometry::fgkRoZpos    =  1.05;
 
-  const Int_t    AliTRDgeometry::fgkMCMmax    = 16;
-  const Int_t    AliTRDgeometry::fgkMCMrow    = 4;  
-  const Int_t    AliTRDgeometry::fgkROBmaxC0  = 6;
-  const Int_t    AliTRDgeometry::fgkROBmaxC1  = 8;
+  const Int_t    AliTRDgeometry::fgkMCMmax    = 16;   
+  const Int_t    AliTRDgeometry::fgkMCMrow    = 4;   
+  const Int_t    AliTRDgeometry::fgkROBmaxC0  = 6; 
+  const Int_t    AliTRDgeometry::fgkROBmaxC1  = 8; 
   const Int_t    AliTRDgeometry::fgkADCmax    = 21;   
   const Int_t    AliTRDgeometry::fgkTBmax     = 60;   
-  const Int_t    AliTRDgeometry::fgkPadmax    = 18;
+  const Int_t    AliTRDgeometry::fgkPadmax    = 18;   
   const Int_t    AliTRDgeometry::fgkColmax    = 144;
   const Int_t    AliTRDgeometry::fgkRowmaxC0  = 12;
   const Int_t    AliTRDgeometry::fgkRowmaxC1  = 16;
 
-//const Double_t AliTRDgeometry::fgkTime0Base = 300.65;
-  const Double_t AliTRDgeometry::fgkTime0Base = 299.95;
+  const Double_t AliTRDgeometry::fgkTime0Base = 300.65;
   const Float_t  AliTRDgeometry::fgkTime0[6]  = { fgkTime0Base + 0 * (Cheight() + Cspace()) 
                                                 , fgkTime0Base + 1 * (Cheight() + Cspace()) 
                                                 , fgkTime0Base + 2 * (Cheight() + Cspace()) 
@@ -165,7 +163,7 @@ AliTRDgeometry::AliTRDgeometry()
   ,fMatrixArray(0)
   ,fMatrixCorrectionArray(0)
   ,fMatrixGeo(0)
-
+  ,fPadPlaneArray(0)
 {
   //
   // AliTRDgeometry default constructor
@@ -178,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
@@ -198,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;
+  }
+
 }
 
 //_____________________________________________________________________________
@@ -268,12 +281,253 @@ void AliTRDgeometry::Init()
     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)
 {
@@ -585,10 +839,10 @@ void AliTRDgeometry::CreateGeometry(Int_t *idtmed)
       xpos  = 0.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 
+      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);      
@@ -930,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
@@ -1041,10 +1289,10 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
       xpos  = 0.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 
+      zpos  = fgkVrocsm + fgkSMpltT + fgkCH + fgkVspace/2.0 - fgkSheight/2.0
             + iplan * (fgkCH + fgkVspace);
       zpos -= 0.742/2.0;
       fChamberUUorig[iDet][0] = xpos;
@@ -1068,7 +1316,7 @@ void AliTRDgeometry::CreateServices(Int_t *idtmed)
   // The cooling water
   parTube[0] =  0.0;
   parTube[1] =  0.2/2.0;
-  parTube[2] = -1.;
+  parTube[2] =  fCwidth[iplan]/2.0;
   gMC->Gsvolu("UTCH","TUBE",idtmed[1314-1],parTube,kNparTube);
   // Water inside the cooling pipe
   xpos = 0.0;
@@ -1083,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);
@@ -1116,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);
@@ -1141,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;
@@ -1193,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;
@@ -1321,7 +1569,7 @@ void AliTRDgeometry::GroupChamber(Int_t iplan, Int_t icham, Int_t *idtmed)
 Bool_t AliTRDgeometry::RotateBack(Int_t det, Double_t *loc, Double_t *glb) const
 {
   //
-  // Rotates a chambers to transform the corresponding local frame 
+  // Rotates a chambers to transform the corresponding local frame
   // coordinates <loc> into the coordinates of the ALICE restframe <glb>.
   //
 
@@ -1358,7 +1606,7 @@ Int_t AliTRDgeometry::GetDetector(Int_t p, Int_t c, Int_t s)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetPlane(Int_t d) const
+Int_t AliTRDgeometry::GetPlane(Int_t d)
 {
   //
   // Reconstruct the plane number from the detector number
@@ -1391,123 +1639,139 @@ Int_t AliTRDgeometry::GetSector(Int_t d) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetPadRowFromMCM(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::GetPadColFromADC(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.
-  //
-  // ADC channels 2 to 19 are connected directly to a pad via PASA.
-  // ADC channels 0, 1 and 20 are not connected to the PASA on this MCM.
-  // So the mapping (for MCM 0 on ROB 0 at least) is
-  //
-  // ADC channel  :   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
-  // Pad          :   x  x 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0  x
-  // Func. returns:  19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 -1
-  //
-  // Here we assume that 21 ADC channels are transmitted. Maybe it will only be
-  // 18 later on!!!
-  //
-  // This function maps also correctly the channels that cross from MCM to MCM
-  // (ADC channels 0, 1, 20).
+  // Returns the number of rows on the pad plane
   //
 
-  return (17-(iadc-2)) + (imcm%fgkMCMrow)*fgkPadmax + GetRobSide(irob)*fgkColmax/2;
+  return GetPadPlane(p,c)->GetNrows();
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetMCMfromPad(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
-
-  if ( irow < 0 || icol < 0 || irow > fgkRowmaxC1 || icol > fgkColmax ) return -1;
-
-  return (icol%(fgkColmax/2))/fgkPadmax + fgkMCMrow*(irow%fgkMCMrow);
+  return GetPadPlane(p,0)->GetNcols();
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetROBfromPad(Int_t irow, Int_t icol) const
+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 on which rob this pad is
-
-  return (irow/fgkMCMrow)*2 + GetColSide(icol);
+  return GetPadPlane(p,c)->GetRow0();
 
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDgeometry::GetRobSide(Int_t irob) const
+Double_t AliTRDgeometry::GetCol0(Int_t p)
 {
+  //
+  // Returns the position of the border of the first pad in a column
+  //
 
-  // return on which side this rob sits (A side = 0, B side = 1)
-
-  if ( irob < 0 || irob >= fgkROBmaxC1 ) return -1;
-
-  return irob%2;
+  return GetPadPlane(p,0)->GetCol0();
 
 }
 
 //_____________________________________________________________________________
-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;
-
-  return icol/(fgkColmax/2);
-
-}
+//Int_t AliTRDgeometry::GetPadRowFromMCM(Int_t irob, Int_t imcm) const
+//{
+  //
+  // Return on which row this mcm sits 
+  //
+//
+//  return fgkMCMrow*(irob/2) + imcm/fgkMCMrow;
+//
+//}
 
 //_____________________________________________________________________________
-AliTRDgeometry *AliTRDgeometry::GetGeometry(AliRunLoader *runLoader)
-{
+//Int_t AliTRDgeometry::GetPadColFromADC(Int_t irob, Int_t imcm, Int_t iadc) const
+//{
   //
-  // Load the geometry from the galice file
+  // 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;
+//
+//}
 
-  if (!runLoader) {
-    runLoader = AliRunLoader::GetRunLoader();
-  }
-  if (!runLoader) {
-    AliErrorGeneral("AliTRDgeometry::GetGeometry","No run loader");
-    return NULL;
-  }
-
-  TDirectory *saveDir = gDirectory;
-  runLoader->CdGAFile();
-
-  // Try from the galice.root file
-  AliTRDgeometry *geom = (AliTRDgeometry *) gDirectory->Get("TRDgeometry");
+//_____________________________________________________________________________
+//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 (icol%(fgkColmax/2))/fgkPadmax + fgkMCMrow*(irow%fgkMCMrow);
+//
+//}
 
-  if (!geom) {
-    // If it is not in the file, try to get it from the run loader 
-    if (runLoader->GetAliRun()) {
-      AliTRD *trd = (AliTRD *) runLoader->GetAliRun()->GetDetector("TRD");
-      if (trd) geom = trd->GetGeometry();
-    }
-  }
-  if (!geom) {
-    AliErrorGeneral("AliTRDgeometry::GetGeometry","Geometry not found");
-    return NULL;
-  }
+//_____________________________________________________________________________
+//Int_t AliTRDgeometry::GetROBfromPad(Int_t irow, Int_t icol) const
+//{
+  //
+  // Return on which rob this pad is
+  //
+//
+//  return (irow/fgkMCMrow)*2 + GetColSide(icol);
+//
+//}
 
-  saveDir->cd();
-  return geom;
+//_____________________________________________________________________________
+//Int_t AliTRDgeometry::GetRobSide(Int_t irob) const
+//{
+  //
+  // Return on which side this rob sits (A side = 0, B side = 1)
+  //
+//
+//  if ( irob < 0 || irob >= fgkROBmaxC1 ) return -1;
+//
+//  return irob%2;
+//
+//}
 
-}
+//_____________________________________________________________________________
+//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;
+//
+//  return icol/(fgkColmax/2);
+//
+//}
 
 //_____________________________________________________________________________
 Bool_t AliTRDgeometry::ReadGeoMatrices()
@@ -1520,16 +1784,16 @@ Bool_t AliTRDgeometry::ReadGeoMatrices()
     return kFALSE;
   }
 
-  fMatrixArray           = new TObjArray(kNdet);
+  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++) {
+  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) {
@@ -1539,23 +1803,23 @@ 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        lid       = GetDetector(iLayerTRD,ichamber,isector);
+      Int_t        iLayerTRD = iLayer - AliGeomManager::kTRD1;
+      Int_t        isector   = iModule/Ncham();
+      Int_t        ichamber  = iModule%Ncham();
+      Int_t        lid       = GetDetector(iLayerTRD,ichamber,isector);    
 
       //
-      // Local geo system z-x-y  to x-y--z
+      // Local geo system z-x-y  to x-y--z 
       //
       fMatrixGeo->AddAt(new TGeoHMatrix(*m),lid);
-
-      TGeoRotation mchange;
-      mchange.RotateY(90);
+      
+      TGeoRotation mchange; 
+      mchange.RotateY(90); 
       mchange.RotateX(90);
 
       TGeoHMatrix gMatrix(mchange.Inverse());
       gMatrix.MultiplyLeft(m);
-      fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid);
+      fMatrixArray->AddAt(new TGeoHMatrix(gMatrix),lid); 
 
       //
       // Cluster transformation matrix
@@ -1565,13 +1829,14 @@ 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);
+      fMatrixCorrectionArray->AddAt(new TGeoHMatrix(rotMatrix),lid);       
 
-    }
+    }    
   }
 
   return kTRUE;
 
 }
+