]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrackingSector.cxx
Removing warnings
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
index 5ed07b6d0abcdcae1e0314e3857dbe0c417f57e8..5852d6ff5ca3beaa22d8188cc11d969de4838e89 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.2  2000/10/06 16:49:46  cblume
-Made Getters const
+/* $Id$ */
 
-Revision 1.1.2.2  2000/10/04 16:34:58  cblume
-Replace include files by forward declarations
-
-Revision 1.1.2.1  2000/09/22 14:47:52  cblume
-Add the tracking code
-
-*/                        
+/////////////////////////////////////////////////////////////////////////
+//                                                                     //
+//  Tracking sector                                                    //
+//                                                                     //
+/////////////////////////////////////////////////////////////////////////                       
                                 
 #include <TObject.h>
 
@@ -35,18 +30,18 @@ Add the tracking code
 #include "AliTRDcluster.h" 
 #include "AliTRDtimeBin.h" 
 #include "AliTRDtrackingSector.h" 
+#include "AliTRDparameter.h"
 
 ClassImp(AliTRDtrackingSector) 
 
 //_______________________________________________________
-
 AliTRDtrackingSector::~AliTRDtrackingSector()
 {
   //
   // Destructor
   //
 
-  delete[] fTimeBin;
+  delete fTimeBin;
 
 }
 
@@ -62,12 +57,14 @@ AliTRDtimeBin &AliTRDtrackingSector::operator[](Int_t i)
 }
 
 //_______________________________________________________
-
 void AliTRDtrackingSector::SetUp()
 { 
+  //
+  // Initialization
+  //
 
-  AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD");
-  fGeom = TRD->GetGeometry();
+  AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
+  fGeom = trd->GetGeometry();
 
   fTimeBinSize = fGeom->GetTimeBinSize();
 
@@ -76,87 +73,130 @@ void AliTRDtrackingSector::SetUp()
 
   fTimeBin = new AliTRDtimeBin[fN]; 
 
+  if (!fPar) {
+    fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
+  }
+
+  fTimeBinSize = fPar->GetTimeBinSize();
+
 }
 
 //______________________________________________________
-
-Double_t AliTRDtrackingSector::GetX(Int_t l) const
+Double_t AliTRDtrackingSector::GetX(Int_t tb) const
 {
-  if( (l<0) || (l>fN-1)) {
+  //
+  // Get global x coordinate
+  //
+
+  if( (tb<0) || (tb>fN-1)) {
     fprintf(stderr,"AliTRDtrackingSector::GetX: TimeBin index is out of range !\n");
     return -99999.;
   }
   else { 
     
-    Int_t tb_per_plane = fN/AliTRDgeometry::Nplan();
-    Int_t plane = l/tb_per_plane;
-    Int_t time_slice = l%(Int_t(AliTRDgeometry::DrThick()
-                               /fTimeBinSize) + 1);
-
-    Float_t t0 = fGeom->GetTime0(plane);
-    Double_t x = t0 + time_slice * fTimeBinSize;
+    Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
+    Int_t localTb = tbPerPlane - tb%tbPerPlane - 1;
 
-    //    cerr<<"plane, tb, x = "<<plane<<","<<time_slice<<","<<x<<endl;
+    Int_t plane = tb/tbPerPlane;
+    Float_t t0 = fPar->GetTime0(plane);
+    Double_t x = t0 - (localTb + 0.5) * fTimeBinSize;
 
     return x;
+
   }
+
 }
 
 //______________________________________________________
+Int_t AliTRDtrackingSector::GetTimeBinNumber(Double_t x) const
+{
+  //
+  // Returns the time bin number
+  //
 
-Double_t AliTRDtrackingSector::GetMaxY(Int_t l) const 
-{ 
+  Float_t rOut = fPar->GetTime0(AliTRDgeometry::Nplan()-1); 
+  Float_t rIn  = fPar->GetTime0(0) - AliTRDgeometry::DrThick();
 
-  if((l<(fN-1)) && (l>-1)) { 
-    Int_t tb_per_plane = fN/AliTRDgeometry::Nplan();
-    Int_t plane = l/tb_per_plane;
-    return fGeom->GetChamberWidth(plane); 
-  }
-  else {
-    fprintf(stderr,
-    "AliTRDtrackingSector::GetMaxY: TimeBin index is out of range !\n");
-    if(l<0) return fGeom->GetChamberWidth(0);
-    else return fGeom->GetChamberWidth(AliTRDgeometry::Nplan()-1);
+
+  if(x >= rOut) return fN-1;
+  if(x <= rIn)  return 0;
+
+  Int_t plane;
+  for (plane = AliTRDgeometry::Nplan()-1; plane >= 0; plane--) {
+    if(x > (fPar->GetTime0(plane) - AliTRDgeometry::DrThick())) break;
+  }  
+  Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
+  Int_t localTb = Int_t((fPar->GetTime0(plane)-x)/fTimeBinSize);
+
+  if((localTb < 0) || (localTb >= tbPerPlane)) {
+    printf("AliTRDtrackingSector::GetTimeBinNumber: \n");
+    printf("local time bin %d is out of bounds [0..%d]: x = %f \n",
+          localTb,tbPerPlane-1,x);
+    return -1;
   }
+      
+  Int_t timeBin = (plane + 1) * tbPerPlane - 1 - localTb;
+
+  return timeBin;
 }
 
 //______________________________________________________
-
-Int_t AliTRDtrackingSector::GetTimeBinNumber(Double_t x) const
+Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t localTb) const 
 {
-  Float_t r_out = fGeom->GetTime0(AliTRDgeometry::Nplan()-1) 
-                + AliTRDgeometry::DrThick(); 
-  Float_t r_in = fGeom->GetTime0(0);
-  //  cerr<<"GetTimeBinNumber: r_in,r_out = "<<r_in<<","<<r_out<<endl;
-
-  if(x >= r_out) return fN-1;
-  if(x <= r_in) return 0;
+  //
+  // Time bin
+  //
 
-  Float_t gap = fGeom->GetTime0(1) - fGeom->GetTime0(0);
-  //  cerr<<"GetTimeBinNumber: gap = "<<gap<<endl;
+  Int_t plane = fGeom->GetPlane(det);
 
-  Int_t plane = Int_t((x - r_in + fTimeBinSize/2)/gap);
-  //  cerr<<"GetTimeBinNumber: plane="<<plane<<endl;
+  Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
 
-  Int_t local_tb = Int_t((x-fGeom->GetTime0(plane))/fTimeBinSize + 0.5);
-  //  cerr<<"GetTimeBinNumber: local_tb="<<local_tb<<endl;
+  Int_t timeBin = (plane + 1) * tbPerPlane - 1 - localTb;
 
-  Int_t time_bin = plane * (Int_t(AliTRDgeometry::DrThick()
-                                 /fTimeBinSize) + 1) + local_tb;
-  //  cerr<<"GetTimeBinNumber: time_bin = "<<time_bin<<endl;
-  
+  return timeBin;
 
-  return time_bin;
 }
 
+
 //______________________________________________________
 
-Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t local_tb) const 
+Bool_t AliTRDtrackingSector::TECframe(Int_t tb, Double_t y, Double_t z) const
 {
-  Int_t plane = fGeom->GetPlane(det);
+  //  
+  // Returns <true> if point defined by <x(tb),y,z> is within 
+  // the TEC G10 frame, otherwise returns <false>  
+  //  
 
-  Int_t time_bin = plane * (Int_t(AliTRDgeometry::DrThick()
-                                 /fTimeBinSize) + 1) + local_tb;  
-  return time_bin;
-}
+  if((tb > (fN-1)) || (tb < 0)) return kFALSE; 
 
+  Int_t tbPerPlane = fN/AliTRDgeometry::Nplan();
+  Int_t plane = tb/tbPerPlane;
+  
+  Double_t x = GetX(tb);
+  y = TMath::Abs(y);
+
+  if((y > fGeom->GetChamberWidth(plane)/2.) &&
+     (y < x*TMath::Tan(0.5*AliTRDgeometry::GetAlpha()))) return kTRUE; 
+
+  Double_t zmin, zmax;
+  Float_t  fRowPadSize, fRow0;
+  Int_t    nPadRows;
+
+  for(Int_t iCha = 1; iCha < AliTRDgeometry::Ncham(); iCha++) {
+
+    fRow0 = fPar->GetRow0(plane,iCha-1,0);
+    fRowPadSize = fPar->GetRowPadSize(plane,iCha-1,0);
+    nPadRows = fPar->GetRowMax(plane,iCha-1,0);
+    zmin = fRow0 - fRowPadSize/2 + fRowPadSize * nPadRows;
+
+    fRow0 = fPar->GetRow0(plane,iCha,0);
+    fRowPadSize = fPar->GetRowPadSize(plane,iCha,0);
+    zmax = fRow0 - fRowPadSize/2;
+
+    if((z > zmin) && (z < zmax)) return kTRUE;     
+  }
+
+  return kFALSE;
+
+}