]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtrackingSector.cxx
Merge remote-tracking branch 'remotes/origin/master' into TPCdev
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackingSector.cxx
index a443a7ed008d709073fad767b10d0ceb52d8d905..2145cb2b37ed845cf7d28543d5c482c77cee3ce2 100644 (file)
 /**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-
-/*
-$Log$
-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) 
-
-//_______________________________________________________
-
-AliTRDtrackingSector::~AliTRDtrackingSector()
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+*                                                                        *
+* Author: The ALICE Off-line Project.                                    *
+* Contributors are mentioned in the code where appropriate.              *
+*                                                                        *
+* Permission to use, copy, modify and distribute this software and its   *
+* documentation strictly for non-commercial purposes is hereby granted   *
+* without fee, provided that the above copyright notice appears in all   *
+* copies and that both the copyright notice and this permission notice   *
+* appear in the supporting documentation. The authors make no claims     *
+* about the suitability of this software for any purpose. It is          *
+* provided "as is" without express or implied warranty.                  *
+**************************************************************************/
+
+/* $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 "AliTRDReconstructor.h"
+#include "AliTRDtrackingSector.h"
+#include "AliTRDtrackingChamber.h"
+
+
+ClassImp(AliTRDtrackingSector)
+
+//_____________________________________________________________________________
+AliTRDtrackingSector::AliTRDtrackingSector()
+  :fSector(-1)
+  ,fN(0)
+  ,fGeom(NULL)
 {
-  //
-  // Destructor
-  //
-
-  delete[] fTimeBin;
-
+  // Default constructor
+  
+  memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));
+  memset(fStack,   0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));
+  memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
+  memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));
 }
 
-//_______________________________________________________
-AliTRDtimeBin &AliTRDtrackingSector::operator[](Int_t i)
+//_____________________________________________________________________________
+AliTRDtrackingSector::AliTRDtrackingSector(AliTRDgeometry *geo, Int_t gs)
+  :fSector(gs)
+  ,fN(0)
+  ,fGeom(geo)
 {
   //
-  // Index operator 
+  // AliTRDtrackingSector Constructor
   //
 
-  return *(fTimeBin+i);
-
+  memset(fChamber, 0, AliTRDgeometry::kNdets*sizeof(AliTRDtrackingChamber*));
+  memset(fStack,   0, AliTRDgeometry::kNlayer*sizeof(AliTRDtrackingChamber*));
+  memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
+  memset(fX0, 0, AliTRDgeometry::kNlayer*sizeof(Float_t));
 }
 
-//_______________________________________________________
-
-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]; 
-
-}
-
-//______________________________________________________
-
-Double_t AliTRDtrackingSector::GetX(Int_t l) const
-{
-  if( (l<0) || (l>fN-1)) {
-    fprintf(stderr,"AliTRDtrackingSector::GetX: TimeBin index is out of range !\n");
-    return -99999.;
+    
+//_____________________________________________________________________________
+void AliTRDtrackingSector::Init(const AliTRDReconstructor *rec)
+{              
+//     Steer building of tracking chambers and build tracking sector.
+//     Propagate radial position information (calibration/alignment aware) from chambers to sector level
+//
+  
+  AliTRDchamberTimeBin *tb = NULL;
+  AliTRDtrackingChamber **tc = &fChamber[0];
+  for(Int_t ic = 0; (ic<AliTRDgeometry::kNdets) && (*tc); ic++, tc++){
+    for(Int_t itb=0; itb<AliTRDseedV1::kNtb; itb++){
+      if(!(tb = (*tc)->GetTB(itb))) continue;
+      tb->SetReconstructor(rec);
+    }
+    (*tc)->Build(fGeom, rec->IsHLT());
   }
-  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;
-
-    //    cerr<<"plane, tb, x = "<<plane<<","<<time_slice<<","<<x<<endl;
-
-    return x;
+  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;
+      fX0[il] += GetChamber(fIndex[idx])->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);
   }
 }
 
-//______________________________________________________
 
-Double_t AliTRDtrackingSector::GetMaxY(Int_t l) const 
-{ 
 
-  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);
-  }
+//_____________________________________________________________________________
+void AliTRDtrackingSector::Clear(const Option_t *opt)
+{
+// Reset counters and steer chamber clear
+
+  AliTRDtrackingChamber **tc = &fChamber[0];
+  for(Int_t ich=0; ich<fN; ich++, tc++){ 
+    (*tc)->Clear(opt);
+    delete (*tc); (*tc) = NULL;   // I would avoid
+  }    
+  memset(fIndex, -1, AliTRDgeometry::kNdets*sizeof(Char_t));
+  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) 
-  //              + AliTRDgeometry::DrThick(); 
-  // Changed to new time0 (CBL)
-  Float_t r_out = fGeom->GetTime0(AliTRDgeometry::Nplan()-1); 
-  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;
-
-  Float_t gap = fGeom->GetTime0(1) - fGeom->GetTime0(0);
-  //  cerr<<"GetTimeBinNumber: gap = "<<gap<<endl;
-
-  Int_t plane = Int_t((x - r_in + fTimeBinSize/2)/gap);
-  //  cerr<<"GetTimeBinNumber: plane="<<plane<<endl;
-
-  Int_t local_tb = Int_t((x-fGeom->GetTime0(plane))/fTimeBinSize + 0.5);
-  //  cerr<<"GetTimeBinNumber: local_tb="<<local_tb<<endl;
-
-  Int_t time_bin = plane * (Int_t(AliTRDgeometry::DrThick()
-                                 /fTimeBinSize) + 1) + local_tb;
-  //  cerr<<"GetTimeBinNumber: time_bin = "<<time_bin<<endl;
+// Return chamber at position (stack, plane) in current 
+// sector or build a new one if it is not already created
   
-
-  return time_bin;
+  Int_t ch = stack*AliTRDgeometry::kNlayer + layer;
+  if(fIndex[ch] >= 0) return fChamber[Int_t(fIndex[ch])];
+  else if(!build) return NULL;
+  
+  // 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])], (AliTRDgeometry::kNdets-fIndex[ch]-1)*sizeof(void*));
+  for(Int_t ic = ch+1; ic<AliTRDgeometry::kNdets; ic++) fIndex[ic] += fIndex[ic] >= 0 ? 1 : 0;
+  
+  AliTRDtrackingChamber *chmb = fChamber[Int_t(fIndex[ch])] = new AliTRDtrackingChamber();
+  chmb->SetDetector(AliTRDgeometry::GetDetector(layer, stack, fSector));
+  return chmb;
 }
 
-//______________________________________________________
+//_____________________________________________________________________________
+AliTRDtrackingChamber** AliTRDtrackingSector::GetStack(Int_t stack)
+{
+// 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 NULL;
+  
+  Int_t ich, n = 0;
+  for(int il=0; il<AliTRDgeometry::kNlayer; il++){
+    ich = stack*AliTRDgeometry::kNlayer + il;
+    if(fIndex[ich] < 0) fStack[il] = NULL; 
+    else{
+      fStack[il] = fChamber[Int_t(fIndex[ich])];
+      n++;
+    }
+  }
+  
+  return n ? &fStack[0] : NULL;
+}
 
-Int_t AliTRDtrackingSector::GetTimeBin(Int_t det, Int_t local_tb) const 
+//_____________________________________________________________________________
+void AliTRDtrackingSector::Print(Option_t *opt) const
 {
-  Int_t plane = fGeom->GetPlane(det);
+// Dump info about this tracking sector and the tracking chamber within
+// 
+
+  printf("\n\tSector[%2d]\n", fSector);
+  for(int il=0; il<AliTRDgeometry::kNlayer; il++){
+    for(int is =0; is<AliTRDgeometry::kNstack; is++){
+      Int_t ch = is*AliTRDgeometry::kNlayer + il;
+      if(opt) fChamber[Int_t(fIndex[ch])]->Print(opt);
+      else printf("%2d[%2d] ", fIndex[ch], fIndex[ch]>=0 ? fChamber[Int_t(fIndex[ch])]->GetNClusters() : 0);
+    }
+    if(!opt) printf("\n");
+  }
 
-  Int_t time_bin = plane * (Int_t(AliTRDgeometry::DrThick()
-                                 /fTimeBinSize) + 1) + local_tb;  
-  return time_bin;
 }
-