]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrackingSector.cxx
fix for the corrupt data
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
index 68a517135cb5f1d0f0a4cb672193f1d74956b93b..50c125c39e493e0eff1dba72e38abc9627d923ae 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.5  2000/12/08 16:07:02  cblume
-Update of the tracking by Sergei
-
-Revision 1.4  2000/10/16 01:16:53  cblume
-Changed timebin 0 to be the one closest to the readout
-
-Revision 1.3  2000/10/15 23:40:01  cblume
-Remove AliTRDconst
-
-Revision 1.2  2000/10/06 16:49:46  cblume
-Made Getters const
-
-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
-
-*/                        
-                                
-#include <TObject.h>
-
-#include "AliRun.h"
-
-#include "AliTRD.h" 
-#include "AliTRDgeometry.h" 
-#include "AliTRDcluster.h" 
-#include "AliTRDtimeBin.h" 
-#include "AliTRDtrackingSector.h" 
-
-ClassImp(AliTRDtrackingSector) 
-
-//_______________________________________________________
+/* $Id: AliTRDtrackingSector.cxx 23810 2008-02-08 09:00:27Z hristov $ */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Tracking data container for one sector                                   //
+//                                                                           //
+//  Authors:                                                                 //
+//    Alex Bercuci <A.Bercuci@gsi.de>                                        //
+//    Markus Fasel <M.Fasel@gsi.de>                                          //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include "AliTRDtrackingSector.h"
+#include "AliTRDcalibDB.h"
+#include "AliTRDCommonParam.h"
+#include "AliTRDgeometry.h"
+#include "AliTRDpadPlane.h"
+#include "AliTRDtrackingChamber.h"
+
+ClassImp(AliTRDtrackingSector)
+
+//_____________________________________________________________________________
+AliTRDtrackingSector::AliTRDtrackingSector()
+  :fSector(-1)
+  ,fN(0)
+  ,fGeom(0x0)
+{
+       // Default constructor
+       
+       for(int ic=0; ic<kNChambersSector; ic++){
+               fChamber[ic] = 0x0;
+               fIndex[ic]   = -1;
+       }
+       for(int il=0; il<AliTRDgeometry::kNlayer; il++) fX0[il] = 0.;
+}
 
-AliTRDtrackingSector::~AliTRDtrackingSector()
+//_____________________________________________________________________________
+AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)
+  :fSector(gs)
+  ,fN(0)
+  ,fGeom(geo)
 {
   //
-  // Destructor
+  // AliTRDtrackingSector Constructor
   //
 
-  delete[] fTimeBin;
-
+       for(int ic=0; ic<kNChambersSector; ic++){
+               fChamber[ic] = 0x0;
+               fIndex[ic]   = -1;
+       }
+       for(int il=0; il<AliTRDgeometry::kNlayer; il++) fX0[il] = 0.;
 }
 
-//_______________________________________________________
-AliTRDtimeBin &AliTRDtrackingSector::operator[](Int_t i)
+//_____________________________________________________________________________
+AliTRDtrackingSector::AliTRDtrackingSector(const AliTRDtrackingSector &/*t*/)
+  :fSector(-1)
+  ,fN(0)
+  ,fGeom(0x0)
 {
   //
-  // Index operator 
+  // Copy constructor
   //
 
-  return *(fTimeBin+i);
-
 }
 
-//_______________________________________________________
-
-void AliTRDtrackingSector::SetUp()
-{ 
-  AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD");
-  fGeom = TRD->GetGeometry();
-
-  fTimeBinSize = fGeom->GetTimeBinSize();
-
-  fN = AliTRDgeometry::Nplan() * (Int_t(AliTRDgeometry::DrThick()
-                                       /fTimeBinSize) + 1);
-
-  fTimeBin = new AliTRDtimeBin[fN]; 
+//_____________________________________________________________________________
+AliTRDtrackingSector::~AliTRDtrackingSector()
+{
+  //
+  // Destructor
+  //
 
 }
-
-//______________________________________________________
-
-Double_t AliTRDtrackingSector::GetX(Int_t tb) const
+               
+//_____________________________________________________________________________
+void AliTRDtrackingSector::Init()
+{              
+//     Steer building of tracking chambers and build tracking sector.
+//     Propagate radial position information (calibration/alignment aware) from chambers to sector level
+//
+       
+       AliTRDtrackingChamber *tc = 0x0; int ic = 0; 
+       while((ic<kNChambersSector) && (tc = fChamber[ic++])) tc->Build(fGeom);
+               
+       Int_t nl;
+       for(int il=0; il<AliTRDgeometry::kNlayer; il++){
+               fX0[il] = 0.; nl = 0;
+               for(int is=0; is<AliTRDgeometry::kNstack; is++){
+                       Int_t idx = is*AliTRDgeometry::kNlayer + il;
+                       if(fIndex[idx]<0) continue;
+                       tc = GetChamber(fIndex[idx]);
+                       fX0[il] += tc->GetX(); nl++; 
+               }
+               if(!nl){
+                       //printf("Could not estimate radial position  of plane %d in sector %d.\n", ip, fSector);
+                       continue;
+               }
+               fX0[il] /= Float_t(nl);
+       }
+}
+//_____________________________________________________________________________
+void AliTRDtrackingSector::Clear(const Option_t *opt)
 {
-  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 local_tb = tb_per_plane - tb%tb_per_plane - 1;
-
-    Int_t plane = tb/tb_per_plane;
-    Float_t t0 = fGeom->GetTime0(plane);
-    Double_t x = t0 - (local_tb + 0.5) * fTimeBinSize;
-
-    return x;
-  }
+// Reset counters and steer chamber clear
+
+       for(Int_t ich=0; ich<fN; ich++){ 
+               fChamber[ich]->Clear(opt);
+               delete fChamber[ich]; fChamber[ich] = 0x0;   // I would avoid
+       }       
+       for(Int_t ich=0; ich<kNChambersSector; ich++) fIndex[ich] = -1;
+       fN = 0;
 }
 
-//______________________________________________________
-
-Int_t AliTRDtrackingSector::GetTimeBinNumber(Double_t x) const
+//_____________________________________________________________________________
+AliTRDtrackingChamber* AliTRDtrackingSector::GetChamber(Int_t stack, Int_t layer, Bool_t build)
 {
-  Float_t r_out = fGeom->GetTime0(AliTRDgeometry::Nplan()-1); 
-  Float_t r_in = fGeom->GetTime0(0) - AliTRDgeometry::DrThick();
-
-
-  if(x >= r_out) return fN-1;
-  if(x <= r_in) return 0;
-
-  Int_t plane;
-  for (plane = AliTRDgeometry::Nplan()-1; plane >= 0; plane--) {
-    if(x > (fGeom->GetTime0(plane) - AliTRDgeometry::DrThick())) break;
-  }  
-  Int_t tb_per_plane = fN/AliTRDgeometry::Nplan();
-  Int_t local_tb = Int_t((fGeom->GetTime0(plane)-x)/fTimeBinSize);
-
-  if((local_tb < 0) || (local_tb >= tb_per_plane)) {
-    printf("AliTRDtrackingSector::GetTimeBinNumber: \n");
-    printf("local time bin %d is out of bounds [0..%d]: x = %f \n",
-          local_tb,tb_per_plane-1,x);
-    return -1;
-  }
-      
-  Int_t time_bin = (plane + 1) * tb_per_plane - 1 - local_tb;
-
-  return time_bin;
+// Return chamber at position (stack, plane) in current 
+// sector or build a new one if it is not already created
+       
+       Int_t ch = stack*AliTRDgeometry::kNlayer + layer;
+       if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];
+       else if(!build) return 0x0;
+       
+       // CHAMBER HAS TO BE BUILD
+       Int_t rch = ch;do rch--; while(rch>=0 && fIndex[rch]<0);
+       fIndex[ch] = rch >=0 ? fIndex[rch]+1 : 0; 
+       fN++;
+       
+       memmove(&fChamber[Int_t(fIndex[ch])+1], &fChamber[Int_t(fIndex[ch])], (kNChambersSector-fIndex[ch]-1)*sizeof(void*));
+       for(Int_t ic = ch+1; ic<kNChambersSector; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;
+       
+       return fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber(AliTRDgeometry::GetDetector(layer, stack, fSector));
 }
 
-//______________________________________________________
-
-Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t local_tb) const 
+//_____________________________________________________________________________
+AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)
 {
-  Int_t plane = fGeom->GetPlane(det);
-
-  Int_t tb_per_plane = fN/AliTRDgeometry::Nplan();
-
-  Int_t time_bin = (plane + 1) * tb_per_plane - 1 - local_tb;
-
-  return time_bin;
+// Return chamber at position (stack, plane) in current 
+// sector or build a new one if it is not already created
+       
+       if(stack<0 || stack>=AliTRDgeometry::kNstack) return 0x0;
+       
+       Int_t ich, n = 0;
+       for(int il=0; il<AliTRDgeometry::kNlayer; il++){
+               ich = stack*AliTRDgeometry::kNlayer + il;
+               if(fIndex[ich] < 0) fStack[il] = 0x0; 
+               else{
+                       fStack[il] = fChamber[Int_t(fIndex[ich])];
+                       n++;
+               }
+       }
+       
+       return n ? &fStack[0] : 0x0;
 }
 
-
-//______________________________________________________
-
-Bool_t AliTRDtrackingSector::TECframe(Int_t tb, Double_t y, Double_t z) const
+//_____________________________________________________________________________
+void AliTRDtrackingSector::Print(Option_t *)
 {
+// Dump info about this tracking sector and the tracking chamber within
 // 
-// Returns <true> if point defined by <x(tb),y,z> is within 
-// the TEC G10 frame, otherwise returns <false>  
-//  
-
-  if((tb > (fN-1)) || (tb < 0)) return kFALSE; 
-
-  Int_t tb_per_plane = fN/AliTRDgeometry::Nplan();
-  Int_t plane = tb/tb_per_plane;
-  
-  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 = fGeom->GetRow0(plane,iCha-1,0);
-    fRowPadSize = fGeom->GetRowPadSize(plane,iCha-1,0);
-    nPadRows = fGeom->GetRowMax(plane,iCha-1,0);
-    zmin = fRow0 - fRowPadSize/2 + fRowPadSize * nPadRows;
-
-    fRow0 = fGeom->GetRow0(plane,iCha,0);
-    fRowPadSize = fGeom->GetRowPadSize(plane,iCha,0);
-    zmax = fRow0 - fRowPadSize/2;
 
-    if((z > zmin) && (z < zmax)) return kTRUE;     
-  }
+       printf("\tSector %2d\n", fSector);
+       for(int il=0; il<6; il++){
+               for(int is =0; is<5; is++){
+                       Int_t ch = is*AliTRDgeometry::kNlayer + il;
+                       printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);
+               }
+               printf("\n");
+       }
 
-  return kFALSE;
 }