]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDpadPlane.cxx
Making online tracklets usable in offline reconstruction
[u/mrichter/AliRoot.git] / TRD / AliTRDpadPlane.cxx
index 8d9c7e78900beca9c25124f9d9f74bb3dfa27afa..85f7469f5bf6bd5ecfc84ff9b11fb79b8c3f890d 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 "AliTRDgeometry.h"
 
@@ -34,9 +38,8 @@ ClassImp(AliTRDpadPlane)
 //_____________________________________________________________________________
 AliTRDpadPlane::AliTRDpadPlane()
   :TObject()
-  ,fGeo(0)
-  ,fPla(0)
-  ,fCha(0)
+  ,fLayer(0)
+  ,fStack(0)
   ,fLength(0)
   ,fWidth(0)
   ,fLengthRim(0)
@@ -53,6 +56,8 @@ AliTRDpadPlane::AliTRDpadPlane()
   ,fTiltingTan(0)
   ,fPadRow(0)
   ,fPadCol(0)
+  ,fPadRowSMOffset(0)
+  ,fAnodeWireOffset(0)
 {
   //
   // Default constructor
@@ -61,11 +66,10 @@ AliTRDpadPlane::AliTRDpadPlane()
 }
 
 //_____________________________________________________________________________
-AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c)
+AliTRDpadPlane::AliTRDpadPlane(Int_t layer, Int_t stack)
   :TObject()
-  ,fGeo(0)
-  ,fPla(0)
-  ,fCha(0)
+  ,fLayer(layer)
+  ,fStack(stack)
   ,fLength(0)
   ,fWidth(0)
   ,fLengthRim(0)
@@ -82,229 +86,20 @@ AliTRDpadPlane::AliTRDpadPlane(Int_t p, Int_t c)
   ,fTiltingTan(0)
   ,fPadRow(0)
   ,fPadCol(0)
+  ,fPadRowSMOffset(0)
+  ,fAnodeWireOffset(0)
 {
   //
-  // Constructor that initializes a given pad plane type
+  // Constructor
   //
 
-  fGeo = new AliTRDgeometry();
-
-  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
-  //
-  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)
-  ,fGeo(0)
-  ,fPla(p.fPla)
-  ,fCha(p.fCha)
+  ,fLayer(p.fLayer)
+  ,fStack(p.fStack)
   ,fLength(p.fLength)
   ,fWidth(p.fWidth)
   ,fLengthRim(p.fLengthRim)
@@ -321,6 +116,8 @@ AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
   ,fTiltingTan(p.fTiltingTan)
   ,fPadRow(0)
   ,fPadCol(0)
+  ,fPadRowSMOffset(p.fPadRowSMOffset)
+  ,fAnodeWireOffset(p.fAnodeWireOffset)
 {
   //
   // AliTRDpadPlane copy constructor
@@ -328,13 +125,17 @@ AliTRDpadPlane::AliTRDpadPlane(const AliTRDpadPlane &p)
 
   Int_t iBin = 0;
 
-  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];
@@ -349,11 +150,6 @@ AliTRDpadPlane::~AliTRDpadPlane()
   // AliTRDpadPlane destructor
   //
 
-  if (fGeo) {
-    delete fGeo;
-    fGeo    = 0;
-  }
-
   if (fPadRow) {
     delete [] fPadRow;
     fPadRow = 0;
@@ -373,7 +169,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;
 
 }
@@ -387,36 +186,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];
@@ -426,11 +230,23 @@ void AliTRDpadPlane::Copy(TObject &p) const
 
 }
 
+//_____________________________________________________________________________
+void AliTRDpadPlane::SetTiltingAngle(Double_t t)
+{
+  //
+  // 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 global z-position
+  // Finds the pad row number for a given z-position in local supermodule system
   //
 
   Int_t row    = 0;
@@ -438,20 +254,27 @@ Int_t AliTRDpadPlane::GetPadRowNumber(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;
 
@@ -462,42 +285,82 @@ Int_t AliTRDpadPlane::GetPadRowNumber(Double_t z) const
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi
-                                    , 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 ((z > GetRow0ROC()  ) || 
+      (z < GetRowEndROC())) {
+
+    row = -1;
+
+  }
+  else {
+
+    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;
+
+}
 
-  // MI change don't apply tilting angle here - better to do it directly on hit level
-  // Take the tilting angle into account by shifting the hit position
-  // into the opposite direction
-  // 
+//_____________________________________________________________________________
+Int_t AliTRDpadPlane::GetPadColNumber(Double_t rphi) const
+{
+  //
+  // Finds the pad column number for a given rphi-position
+  //
 
-  rphiShift = rphi ;
+  Int_t col    = 0;
+  Int_t nabove = 0;
+  Int_t nbelow = 0;
+  Int_t middle = 0;
 
-  if ((rphiShift > GetCol0()) || (rphiShift < GetColEnd())) {
+  if ((rphi < GetCol0()  ) || 
+      (rphi > GetColEnd())) {
 
     col = -1;
 
   }
   else {
 
-    nabove = fNcols+1;
+    nabove = fNcols;
     nbelow = 0;
     while (nabove - nbelow > 1) {
       middle = (nabove + nbelow) / 2;
-      if (rphiShift == fPadCol[middle-1]) col    = middle;
-      if (rphiShift  > 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;
+    col = nbelow;
 
   }