]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDpadPlane.cxx
More code clean up.
[u/mrichter/AliRoot.git] / TRD / AliTRDpadPlane.cxx
index 36ea6d5fb3cc21473d26c69bcb5af2c892e34440..beba8be59d8601d900a4cf0949aed633f7d31564 100644 (file)
 //  tilting angle, etc.                                                      //
 //  It also provides methods to identify the current pad number from         //
 //  global coordinates.                                                      //
+//  The numbering and coordinates should follow the official convention      //
+//  (see David Emschermanns note on TRD convention                           //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <TMath.h>
+
 #include "AliTRDpadPlane.h"
-#include "AliTRDgeometryFull.h"
 
 ClassImp(AliTRDpadPlane)
 
 //_____________________________________________________________________________
-AliTRDpadPlane::AliTRDpadPlane():TObject()
+AliTRDpadPlane::AliTRDpadPlane()
+  :TObject()
+  ,fLayer(0)
+  ,fStack(0)
+  ,fLength(0)
+  ,fWidth(0)
+  ,fLengthRim(0)
+  ,fWidthRim(0)
+  ,fLengthOPad(0)
+  ,fWidthOPad(0)
+  ,fLengthIPad(0)
+  ,fWidthIPad(0)
+  ,fRowSpacing(0)
+  ,fColSpacing(0)
+  ,fNrows(0)
+  ,fNcols(0)
+  ,fTiltingAngle(0)
+  ,fTiltingTan(0)
+  ,fPadRow(0)
+  ,fPadCol(0)
+  ,fPadRowSMOffset(0)
+  ,fAnodeWireOffset(0)
 {
   //
   // Default constructor
   //
 
-  fGeo          = 0;
-
-  fPla          = 0;
-  fCha          = 0;
-
-  fLength       = 0.0;
-  fWidth        = 0.0;
-  fLengthRim    = 0.0;
-  fWidthRim     = 0.0;
-  fLengthOPad   = 0.0;
-  fWidthOPad    = 0.0;
-  fLengthIPad   = 0.0;
-  fWidthIPad    = 0.0;
-
-  fRowSpacing   = 0.0;
-  fColSpacing   = 0.0;
-
-  fNrows        = 0;
-  fNcols        = 0;
-
-  fPadRow       = 0;
-  fPadCol       = 0;
-
-  fTiltingAngle = 0.0;
-  fTiltingTan   = 0.0;
-
 }
 
 //_____________________________________________________________________________
-AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c):TObject(),fPadRow(0),fPadCol(0)
+AliTRDpadPlane::AliTRDpadPlane(Int_t layer, Int_t stack)
+  :TObject()
+  ,fLayer(layer)
+  ,fStack(stack)
+  ,fLength(0)
+  ,fWidth(0)
+  ,fLengthRim(0)
+  ,fWidthRim(0)
+  ,fLengthOPad(0)
+  ,fWidthOPad(0)
+  ,fLengthIPad(0)
+  ,fWidthIPad(0)
+  ,fRowSpacing(0)
+  ,fColSpacing(0)
+  ,fNrows(0)
+  ,fNcols(0)
+  ,fTiltingAngle(0)
+  ,fTiltingTan(0)
+  ,fPadRow(0)
+  ,fPadCol(0)
+  ,fPadRowSMOffset(0)
+  ,fAnodeWireOffset(0)
 {
   //
-  // Constructor that initializes a given pad plane type
+  // Constructor
   //
 
-  fGeo = new AliTRDgeometryFull();
-
-  fPla = p;
-  fCha = c;
-
-  fRowSpacing = 0.0;
-  fColSpacing = 0.0;
-
-  fLengthRim  = 1.0;
-  fWidthRim   = 0.5;
-
-  fNcols      = 144;
-
-  //
-  // The pad plane parameter
-  //
-  switch (p) {
-  case 0:
-    if (c == 2) {
-      // L0C0 type
-      fNrows        =  12;
-      fLength       = 108.0;
-      fWidth        =  92.2;
-      fLengthOPad   =   8.0;
-      fWidthOPad    =   0.515;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.635;
-      fTiltingAngle =  -2.0;
-    }
-    else {
-      // L0C1 type
-      fNrows        =  16;
-      fLength       = 122.0;
-      fWidth        =  92.2;
-      fLengthOPad   =   7.5;
-      fWidthOPad    =   0.515;
-      fLengthIPad   =   7.5;
-      fWidthIPad    =   0.635;
-      fTiltingAngle =  -2.0;
-    }
-    break;
-  case 1:
-    if (c == 2) {
-      // L1C0 type
-      fNrows        =  12;
-      fLength       = 108.0;
-      fWidth        =  96.6;
-      fLengthOPad   =   8.0;
-      fWidthOPad    =   0.585;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.665;
-      fTiltingAngle =   2.0;
-    }
-    else {
-      // L1C1 type
-      fNrows        =  16;
-      fLength       = 122.0;
-      fWidth        =  96.6;
-      fLengthOPad   =   7.5;
-      fWidthOPad    =   0.585;
-      fLengthIPad   =   7.5;
-      fWidthIPad    =   0.665;
-      fTiltingAngle =   2.0;
-    }
-    break;
-  case 2:
-    if (c == 2) {
-      // L2C0 type
-      fNrows        =  12;
-      fLength       = 108.0;
-      fWidth        = 101.1;
-      fLengthOPad   =   8.0;
-      fWidthOPad    =   0.705;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.695;
-      fTiltingAngle =  -2.0;
-    }
-    else {
-      // L2C1 type
-      fNrows        =  16;
-      fLength       = 129.0;
-      fWidth        = 101.1;
-      fLengthOPad   =   7.5;
-      fWidthOPad    =   0.705;
-      fLengthIPad   =   8.0;
-      fWidthIPad    =   0.695;
-      fTiltingAngle =  -2.0;
-    }
-    break;
-  case 3:
-    if (c == 2) {
-      // L3C0 type
-      fNrows        =  12;
-      fLength       = 108.0;
-      fWidth        = 105.5;
-      fLengthOPad   =   8.0;
-      fWidthOPad    =   0.775;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.725;
-      fTiltingAngle =   2.0;
-    }
-    else {
-      // L3C1 type
-      fNrows        =  16;
-      fLength       = 136.0;
-      fWidth        = 105.5;
-      fLengthOPad   =   7.5;
-      fWidthOPad    =   0.775;
-      fLengthIPad   =   8.5;
-      fWidthIPad    =   0.725;
-      fTiltingAngle =   2.0;
-    }
-    break;
-  case 4:
-    if (c == 2) {
-      // L4C0 type
-      fNrows        =  12;
-      fLength       = 108.0;
-      fWidth        = 109.9;
-      fLengthOPad   =   8.0;
-      fWidthOPad    =   0.845;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.755;
-      fTiltingAngle =  -2.0;
-    }
-    else {
-      // L4C1 type
-      fNrows        =  16;
-      fLength       = 143.0;
-      fWidth        = 109.9;
-      fLengthOPad   =   7.5;
-      fWidthOPad    =   0.845;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.755;
-      fTiltingAngle =  -2.0;
-    }
-    break;
-  case 5:
-    if (c == 2) {
-      // L5C0 type
-      fNrows        =  12;
-      fLength       = 108.0;
-      fWidth        = 114.4;
-      fLengthOPad   =   8.0;
-      fWidthOPad    =   0.965;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.785;
-      fTiltingAngle =   2.0;
-    }
-    else {
-      // L5C1 type
-      fNrows        =  16;
-      fLength       = 145.0;
-      fWidth        = 114.4;
-      fLengthOPad   =   8.5;
-      fWidthOPad    =   0.965;
-      fLengthIPad   =   9.0;
-      fWidthIPad    =   0.785;
-      fTiltingAngle =   2.0;
-    }
-    break;
-  };
-
-  //
-  // Store tilting angle as tangens (opposite direction!)
-  //
-  fTiltingTan = TMath::Tan(TMath::Pi()/180.0 * -fTiltingAngle);
-
-  //
-  // The positions of the borders of the pads
-  //
-  // Row direction
-  //
-  fPadRow = new Double_t[fNrows];
-  Double_t row = fGeo->GetChamberLength(p,0)
-              + fGeo->GetChamberLength(p,1)
-               + fGeo->GetChamberLength(p,2) / 2.
-               - fGeo->RpadW()
-               - fLengthRim;
-  for (Int_t ic = 0; ic < c; ic++) {
-    row -= fGeo->GetChamberLength(p,ic);
-  }
-  for (Int_t ir = 0; ir < fNrows; ir++) {
-    fPadRow[ir] = row;
-    row -= fRowSpacing;
-    if (ir == 0) {
-      row -= fLengthOPad;
-    }
-    else {
-      row -= fLengthIPad;
-    }
-  }
-  //
-  // Column direction
-  //
-  fPadCol = new Double_t[fNcols];
-  Double_t col = fGeo->GetChamberWidth(p) / 2. 
-               + fGeo->CroWid()
-               - fWidthRim;
-  for (Int_t ic = 0; ic < fNcols; ic++) {
-    fPadCol[ic] = col;
-    col -= fColSpacing;
-    if (ic == 0) {
-      col -= fWidthOPad;
-    }
-    else {
-      col -= fWidthIPad;
-    }
-  }
-
 }
 
 //_____________________________________________________________________________
-AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p):TObject(p)
+AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
+  :TObject(p)
+  ,fLayer(p.fLayer)
+  ,fStack(p.fStack)
+  ,fLength(p.fLength)
+  ,fWidth(p.fWidth)
+  ,fLengthRim(p.fLengthRim)
+  ,fWidthRim(p.fLengthRim)
+  ,fLengthOPad(p.fLengthOPad)
+  ,fWidthOPad(p.fWidthOPad)
+  ,fLengthIPad(p.fLengthIPad)
+  ,fWidthIPad(p.fWidthIPad)
+  ,fRowSpacing(p.fRowSpacing)
+  ,fColSpacing(p.fColSpacing)
+  ,fNrows(p.fNrows)
+  ,fNcols(p.fNcols)
+  ,fTiltingAngle(p.fTiltingAngle)
+  ,fTiltingTan(p.fTiltingTan)
+  ,fPadRow(0)
+  ,fPadCol(0)
+  ,fPadRowSMOffset(p.fPadRowSMOffset)
+  ,fAnodeWireOffset(p.fAnodeWireOffset)
 {
   //
   // AliTRDpadPlane copy constructor
   //
 
-  ((AliTRDpadPlane &) p).Copy(*this);
+  Int_t iBin = 0;
+
+  fPadRow = new Double_t[fNrows];
+  for (iBin = 0; iBin < fNrows; iBin++) {
+    fPadRow[iBin] = ((AliTRDpadPlane &) p).fPadRow[iBin];
+  }                                                                             
+
+  fPadCol = new Double_t[fNrows];
+  for (iBin = 0; iBin < fNrows; iBin++) {
+    fPadCol[iBin] = ((AliTRDpadPlane &) p).fPadCol[iBin];
+  }                                                                             
 
 }
 
@@ -303,11 +143,6 @@ AliTRDpadPlane::~AliTRDpadPlane()
   // AliTRDpadPlane destructor
   //
 
-  if (fGeo) {
-    delete fGeo;
-    fGeo    = 0;
-  }
-
   if (fPadRow) {
     delete [] fPadRow;
     fPadRow = 0;
@@ -327,7 +162,10 @@ AliTRDpadPlane &AliTRDpadPlane::operator=(const AliTRDpadPlane &p)
   // Assignment operator
   //
 
-  if (this != &p) ((AliTRDpadPlane &) p).Copy(*this);
+  if (this != &p) {
+    ((AliTRDpadPlane &) p).Copy(*this);
+  }
+
   return *this;
 
 }
@@ -341,36 +179,41 @@ void AliTRDpadPlane::Copy(TObject &p) const
 
   Int_t iBin = 0;
 
-  ((AliTRDpadPlane &) p).fGeo          = 0;
+  ((AliTRDpadPlane &) p).fLayer           = fLayer;
+  ((AliTRDpadPlane &) p).fStack           = fStack;
 
-  ((AliTRDpadPlane &) p).fPla          = fPla;
-  ((AliTRDpadPlane &) p).fCha          = fCha;
+  ((AliTRDpadPlane &) p).fLength          = fLength;
+  ((AliTRDpadPlane &) p).fWidth           = fWidth;
+  ((AliTRDpadPlane &) p).fLengthRim       = fLengthRim;
+  ((AliTRDpadPlane &) p).fWidthRim        = fWidthRim;
+  ((AliTRDpadPlane &) p).fLengthOPad      = fLengthOPad;
+  ((AliTRDpadPlane &) p).fWidthOPad       = fWidthOPad;
+  ((AliTRDpadPlane &) p).fLengthIPad      = fLengthIPad;
+  ((AliTRDpadPlane &) p).fWidthIPad       = fWidthIPad;
 
-  ((AliTRDpadPlane &) p).fLength       = fLength;
-  ((AliTRDpadPlane &) p).fWidth        = fWidth;
-  ((AliTRDpadPlane &) p).fLengthRim    = fLengthRim;
-  ((AliTRDpadPlane &) p).fWidthRim     = fWidthRim;
-  ((AliTRDpadPlane &) p).fLengthOPad   = fLengthOPad;
-  ((AliTRDpadPlane &) p).fWidthOPad    = fWidthOPad;
-  ((AliTRDpadPlane &) p).fLengthIPad   = fLengthIPad;
-  ((AliTRDpadPlane &) p).fWidthIPad    = fWidthIPad;
+  ((AliTRDpadPlane &) p).fRowSpacing      = fRowSpacing;
+  ((AliTRDpadPlane &) p).fColSpacing      = fColSpacing;
 
-  ((AliTRDpadPlane &) p).fRowSpacing   = fRowSpacing;
-  ((AliTRDpadPlane &) p).fColSpacing   = fColSpacing;
+  ((AliTRDpadPlane &) p).fNrows           = fNrows;
+  ((AliTRDpadPlane &) p).fNcols           = fNcols;
 
-  ((AliTRDpadPlane &) p).fNrows        = fNrows;
-  ((AliTRDpadPlane &) p).fNcols        = fNcols;
+  ((AliTRDpadPlane &) p).fTiltingAngle    = fTiltingAngle;
+  ((AliTRDpadPlane &) p).fTiltingTan      = fTiltingTan;
 
-  ((AliTRDpadPlane &) p).fTiltingAngle = fTiltingAngle;
-  ((AliTRDpadPlane &) p).fTiltingTan   = fTiltingTan;
+  ((AliTRDpadPlane &) p).fPadRowSMOffset  = fPadRowSMOffset;
+  ((AliTRDpadPlane &) p).fAnodeWireOffset = fAnodeWireOffset;
 
-  if (((AliTRDpadPlane &) p).fPadRow) delete [] ((AliTRDpadPlane &) p).fPadRow;
+  if (((AliTRDpadPlane &) p).fPadRow) {
+    delete [] ((AliTRDpadPlane &) p).fPadRow;
+  }
   ((AliTRDpadPlane &) p).fPadRow = new Double_t[fNrows];
   for (iBin = 0; iBin < fNrows; iBin++) {
     ((AliTRDpadPlane &) p).fPadRow[iBin] = fPadRow[iBin];
   }                                                                             
 
-  if (((AliTRDpadPlane &) p).fPadCol) delete [] ((AliTRDpadPlane &) p).fPadCol;
+  if (((AliTRDpadPlane &) p).fPadCol) {
+    delete [] ((AliTRDpadPlane &) p).fPadCol;
+  }
   ((AliTRDpadPlane &) p).fPadCol = new Double_t[fNrows];
   for (iBin = 0; iBin < fNrows; iBin++) {
     ((AliTRDpadPlane &) p).fPadCol[iBin] = fPadCol[iBin];
@@ -381,10 +224,22 @@ void AliTRDpadPlane::Copy(TObject &p) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDpadPlane::GetPadRowNumber(const Double_t z) const
+void AliTRDpadPlane::SetTiltingAngle(Double_t t)
 {
   //
-  // Finds the pad row number for a given global z-position
+  // Set the tilting angle of the pads
+  //
+  fTiltingAngle = t; 
+  fTiltingTan   = TMath::Tan(TMath::Pi()/180.0 * fTiltingAngle); 
+
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
+{
+  //
+  // Finds the pad row number for a given z-position in local supermodule system
   //
 
   Int_t row    = 0;
@@ -392,20 +247,27 @@ Int_t AliTRDpadPlane::GetPadRowNumber(const Double_t z) const
   Int_t nbelow = 0;
   Int_t middle = 0;
 
-  if ((z > GetRow0()) || (z < GetRowEnd())) {
+  if ((z > GetRow0()  ) || 
+      (z < GetRowEnd())) {
 
     row = -1;
 
   }
   else {
 
-    nabove = fNrows+1;
+    nabove = fNrows + 1;
     nbelow = 0;
     while (nabove - nbelow > 1) {
       middle = (nabove + nbelow) / 2;
-      if (z == fPadRow[middle-1]) row    = middle;
-      if (z  > fPadRow[middle-1]) nabove = middle;
-      else                        nbelow = middle;
+      if (z == (fPadRow[middle-1] + fPadRowSMOffset)) {
+        row    = middle;
+      }
+      if (z  > (fPadRow[middle-1] + fPadRowSMOffset)) {
+        nabove = middle;
+      }
+      else {
+        nbelow = middle;
+      }
     }
     row = nbelow - 1;
 
@@ -416,45 +278,82 @@ Int_t AliTRDpadPlane::GetPadRowNumber(const Double_t z) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDpadPlane::GetPadColNumber(const Double_t rphi
-                                    , const Double_t rowOffset) const
+Int_t AliTRDpadPlane::GetPadRowNumberROC(Double_t z) const
 {
   //
-  // Finds the pad column number for a given global rphi-position
+  // Finds the pad row number for a given z-position in local ROC system
   //
 
-  Int_t    col       = 0;
-  Int_t    nabove    = 0;
-  Int_t    nbelow    = 0;
-  Int_t    middle    = 0;
-  Double_t rphiShift = 0;
+  Int_t row    = 0;
+  Int_t nabove = 0;
+  Int_t nbelow = 0;
+  Int_t middle = 0;
 
-  if ((rphi > GetCol0()) || (rphi < GetColEnd())) {
+  if ((z > GetRow0ROC()  ) || 
+      (z < GetRowEndROC())) {
 
-    col = -1;
+    row = -1;
 
   }
   else {
 
-    //
-    // Take the tilting angle into account by shifting the hit position
-    // into the opposite direction
-    //
+    nabove = fNrows + 1;
+    nbelow = 0;
+    while (nabove - nbelow > 1) {
+      middle = (nabove + nbelow) / 2;
+      if (z == fPadRow[middle-1]) {
+        row    = middle;
+      }
+      if (z  > fPadRow[middle-1]) {
+        nabove = middle;
+      }
+      else {
+        nbelow = middle;
+      }
+    }
+    row = nbelow - 1;
+
+  }
+
+  return row;
+
+}
+
+//_____________________________________________________________________________
+Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
+{
+  //
+  // Finds the pad column number for a given rphi-position
+  //
+
+  Int_t col    = 0;
+  Int_t nabove = 0;
+  Int_t nbelow = 0;
+  Int_t middle = 0;
 
-    rphiShift = rphi + fTiltingTan * rowOffset;
+  if ((rphi < GetCol0()  ) || 
+      (rphi > GetColEnd())) {
 
-    nabove = fNcols+1;
+    col = -1;
+
+  }
+  else {
+
+    nabove = fNcols;
     nbelow = 0;
     while (nabove - nbelow > 1) {
       middle = (nabove + nbelow) / 2;
-      if (rphi == fPadCol[middle-1]) col    = middle;
-      if (rphi  > fPadCol[middle-1]) nabove = middle;
-      else                           nbelow = middle;
+      if (rphi == fPadCol[middle]) {
+        col    = middle;
+      }
+      if (rphi  > fPadCol[middle]) {
+        nbelow = middle;
+      }
+      else {
+        nabove = middle;
+      }
     }
-    col = nbelow - 1;
-
-    //printf("rphi=%f, rphiShift=%f, col=%d, colH=%f\n"
-    //   ,rphi,rphiShift,col,fPadCol[col]);
+    col = nbelow;
 
   }