]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerSA.cxx
Initialize at analysis time the geometry matrices and calibration parameters stored...
[u/mrichter/AliRoot.git] / ITS / AliITStrackerSA.cxx
index 268f113d59b7ebebf5ff2302ca033c8c0e9c89a5..f575e94c39ddead6fc53b169fb2427b402103feb 100644 (file)
@@ -55,8 +55,6 @@ fCoef3(0),
 fNloop(0),
 fPhiWin(0),
 fLambdaWin(0),
-fVert(0),
-fVertexer(0),
 fListOfTracks(0),
 fListOfSATracks(0),
 fITSclusters(0),
@@ -65,7 +63,6 @@ fOuterStartLayer(0),
 fInnerStartLayer(5),
 fMinNPoints(0),
 fMinQ(0.),
-fCluLayer(0),
 fCluCoord(0){
   // Default constructor
   Init();
@@ -83,8 +80,6 @@ fCoef3(0),
 fNloop(0),
 fPhiWin(0),
 fLambdaWin(0),
-fVert(0),
-fVertexer(0),
 fListOfTracks(0),
 fListOfSATracks(0),
 fITSclusters(0),
@@ -93,7 +88,6 @@ fOuterStartLayer(0),
 fInnerStartLayer(5),
 fMinNPoints(0),
 fMinQ(0.),
-fCluLayer(0),
 fCluCoord(0) 
 {
   // Standard constructor (Vertex is known and passed to this obj.)
@@ -102,138 +96,12 @@ fCluCoord(0)
   }
 
   Init();
-  fVert = 0;
  
 }
 
-//____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(const Char_t *geom, AliESDVertex *vert):AliITStrackerMI(0),
-fPhiEstimate(0),
-fITSStandAlone(0),
-fLambdac(0),
-fPhic(0),
-fCoef1(0),
-fCoef2(0),
-fCoef3(0),
-fNloop(0),
-fPhiWin(0),
-fLambdaWin(0),
-fVert(vert),
-fVertexer(0),
-fListOfTracks(0),
-fListOfSATracks(0),
-fITSclusters(0),
-fInwardFlag(0),
-fOuterStartLayer(0),
-fInnerStartLayer(5),
-fMinNPoints(0),
-fMinQ(0.),
-fCluLayer(0),
-fCluCoord(0)
-{
-  // Standard constructor (Vertex is known and passed to this obj.)
-  if (geom) {
-    AliWarning("\"geom\" is actually a dummy argument !");
-  }
-  Init();
-}
-
-//____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(const Char_t *geom, AliITSVertexer *vertexer):AliITStrackerMI(0),
-fPhiEstimate(0),
-fITSStandAlone(0),
-fLambdac(0),
-fPhic(0),
-fCoef1(0),
-fCoef2(0),
-fCoef3(0),
-fNloop(0),
-fPhiWin(0),
-fLambdaWin(0),
-fVert(),
-fVertexer(vertexer),
-fListOfTracks(0),
-fListOfSATracks(0),
-fITSclusters(0),
-fInwardFlag(0),
-fOuterStartLayer(0),
-fInnerStartLayer(5),
-fMinNPoints(0),
-fMinQ(0.),
-fCluLayer(0),
-fCluCoord(0)
-{
-  // Standard constructor (Vertex is unknown - vertexer is passed to this obj)
-  if (geom) {
-    AliWarning("\"geom\" is actually a dummy argument !");
-  }
-  Init();
-  fVertexer = vertexer;
-}
-/*
-//____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(const AliITStrackerSA& tracker):AliITStrackerMI(),
-fPhiEstimate(tracker.fPhiEstimate),
-fITSStandAlone(tracker.fITSStandAlone),
-fLambdac(tracker.fLambdac),
-fPhic(tracker.fPhic),
-fCoef1(tracker.fCoef1),
-fCoef2(tracker.fCoef2),
-fCoef3(tracker.fCoef3),
-fNloop(tracker.fNloop),
-fPhiWin(tracker.fPhiWin),
-fLambdaWin(tracker.fLambdaWin),
-fVert(tracker.fVert),
-fVertexer(tracker.fVertexer),
-fListOfTracks(tracker.fListOfTracks),
-fListOfSATracks(tracker.fListOfSATracks),
-fITSclusters(tracker.fITSclusters),
-fInwardFlag(tracker.fInwardFlag),
-fOuterStartLayer(tracker.fOuterStartLayer),
-fInnerStartLayer(tracker.fInnerStartLayer),
-fMinNPoints(tracker.fMinNPoints),
-fMinQ(tracker.fMinQ),
-fCluLayer(tracker.fCluLayer),
-fCluCoord(tracker.fCluCoord) {
-  // Copy constructor
-  for(Int_t i=0;i<2;i++){
-    fPoint1[i]=tracker.fPoint1[i];
-    fPoint2[i]=tracker.fPoint2[i];
-    fPoint3[i]=tracker.fPoint3[i];
-    fPointc[i]=tracker.fPointc[i];
-  }
-  if(tracker.fVertexer && tracker.fVert){
-    fVert = new AliESDVertex(*tracker.fVert);
-  }
-  else {
-    fVert = tracker.fVert;
-  }
-  for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
-    fCluLayer[i] = tracker.fCluLayer[i];
-    fCluCoord[i] = tracker.fCluCoord[i];
-  } 
-}
-//______________________________________________________________________
-AliITStrackerSA& AliITStrackerSA::operator=(const AliITStrackerSA& source){
-    // Assignment operator. 
-  this->~AliITStrackerSA();
-  new(this) AliITStrackerSA(source);
-  return *this;
-}
-*/
 //____________________________________________________________________________
 AliITStrackerSA::~AliITStrackerSA(){
   // destructor
-  // if fVertexer is not null, the AliESDVertex obj. is owned by this class
-  // and is deleted here
-  if(fVertexer){
-    if(fVert)delete fVert;
-  }
-  fVert = 0;
-  fVertexer = 0;
  
   if(fPhiWin)delete []fPhiWin;
   if(fLambdaWin)delete []fLambdaWin;
@@ -241,15 +109,6 @@ AliITStrackerSA::~AliITStrackerSA(){
   delete fListOfTracks;
   fListOfSATracks->Delete();
   delete fListOfSATracks;
-  if(fCluLayer){
-    for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
-      if(fCluLayer[i]){
-       fCluLayer[i]->Delete();
-       delete fCluLayer[i];
-      }
-    }
-    delete [] fCluLayer;
-  }
   if(fCluCoord){
     for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
       if(fCluCoord[i]){
@@ -259,7 +118,6 @@ AliITStrackerSA::~AliITStrackerSA(){
     }
     delete [] fCluCoord;
   }
-  
 }
 
 //____________________________________________________________________________
@@ -302,10 +160,8 @@ void AliITStrackerSA::Init(){
     fCoef3=0;
     fPointc[0]=0;
     fPointc[1]=0;
-    fVert = 0;
-    fVertexer = 0;
     Int_t nLoops=AliITSReconstructor::GetRecoParam()->GetNLoopsSA();
-    if(nLoops==33){
+    if(nLoops==32){
       SetFixedWindowSizes();
     }else{
       Double_t phimin=AliITSReconstructor::GetRecoParam()->GetMinPhiSA();
@@ -320,7 +176,6 @@ void AliITStrackerSA::Init(){
     SetSAFlag(kFALSE);
     fListOfTracks=new TClonesArray("AliITStrackMI",100);
     fListOfSATracks=new TClonesArray("AliITStrackSA",100);
-    fCluLayer = 0;
     fCluCoord = 0;
     fMinNPoints = 3;
  }
@@ -351,7 +206,7 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
   AliDebug(2,Form("SKIPPING %d %d %d %d %d %d",ForceSkippingOfLayer(0),ForceSkippingOfLayer(1),ForceSkippingOfLayer(2),ForceSkippingOfLayer(3),ForceSkippingOfLayer(4),ForceSkippingOfLayer(5)));
 
   if(!fITSclusters){
-    Fatal("FindTracks","ITS cluster tree is not accessed - Abort!!!\n Please use method SetClusterTree to pass the pointer to the tree\n");
+    Fatal("FindTracks","ITS cluster tree is not accessed!!!\n Please use method SetClusterTree to pass the pointer to the tree\n");
     return -1;
   }
   //Reads event and mark clusters of traks already found, with flag kITSin
@@ -388,11 +243,9 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
   //by AliITStrackerMI are not considered
   Int_t nclusters[AliITSgeomTGeo::kNLayers]={0,0,0,0,0,0};
   Int_t dmar[AliITSgeomTGeo::kNLayers]={0,0,0,0,0,0};
-  if (fCluLayer == 0) {
-    fCluLayer = new TClonesArray*[AliITSgeomTGeo::kNLayers];
+  if (fCluCoord == 0) {
     fCluCoord = new TClonesArray*[AliITSgeomTGeo::kNLayers];
     for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++) {
-      fCluLayer[i]=0;
       fCluCoord[i]=0;
     }
   }
@@ -408,12 +261,6 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
       }
     }
     dmar[i]=0;
-    if(!fCluLayer[i]){
-      fCluLayer[i] = new TClonesArray("AliITSRecPoint",nclusters[i]);
-    }else{
-      fCluLayer[i]->Delete();
-      fCluLayer[i]->Expand(nclusters[i]);
-    }
     if(!fCluCoord[i]){
       fCluCoord[i] = new TClonesArray("AliITSclusterTable",nclusters[i]);
     }else{
@@ -423,7 +270,6 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
   }
 
   for(Int_t ilay=0;ilay<AliITSgeomTGeo::GetNLayers();ilay++){
-    TClonesArray &clulay = *fCluLayer[ilay];
     TClonesArray &clucoo = *fCluCoord[ilay];
     AliITSlayer &layer=fgLayers[ilay];
     if (!ForceSkippingOfLayer(ilay)) {
@@ -437,11 +283,11 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
        Double_t sx=0;Double_t sy=0;Double_t sz=0;
        GetCoorAngles(cls,phi,lambda,x,y,z,primaryVertex);
        GetCoorErrors(cls,sx,sy,sz);
-       new (clulay[dmar[ilay]]) AliITSRecPoint(*cls);
        new (clucoo[dmar[ilay]]) AliITSclusterTable(x,y,z,sx,sy,sz,phi,lambda,cli);
        dmar[ilay]++;
       }
     }
+    fCluCoord[ilay]->Sort();
   }
    
   // track counter
@@ -475,7 +321,7 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
 
       // loop on phi and lambda window size
       for(Int_t nloop=0;nloop<fNloop;nloop++){
-       Int_t nclTheLay=fCluLayer[theLay]->GetEntries();
+       Int_t nclTheLay=fCluCoord[theLay]->GetEntries();
        while(nclTheLay--){ 
          ResetForFinding();
          Bool_t useRP=SetFirstPoint(theLay,nclTheLay,primaryVertex);
@@ -548,7 +394,7 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
       //   counter for clusters on each layer  
 
       for(Int_t nloop=0;nloop<fNloop;nloop++){
-       Int_t nclInnLay=fCluLayer[innLay]->GetEntries();
+       Int_t nclInnLay=fCluCoord[innLay]->GetEntries();
        while(nclInnLay--){ //loop starting from layer innLay
          ResetForFinding();
          Bool_t useRP=SetFirstPoint(innLay,nclInnLay,primaryVertex);
@@ -788,9 +634,7 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   for(Int_t nlay=0;nlay<AliITSgeomTGeo::GetNLayers();nlay++){
     for(Int_t cln=0;cln<trsa->GetNumberOfMarked(nlay);cln++){
       Int_t index = trsa->GetClusterMark(nlay,cln);
-      fCluLayer[nlay]->RemoveAt(index);
       RemoveClusterCoord(nlay,index);
-      fCluLayer[nlay]->Compress();
     }    
   }
 
@@ -847,6 +691,7 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
 
   if(ForceSkippingOfLayer(layer)) return 0;
 
+
   Int_t nc=0;
   AliITSlayer &lay = fgLayers[layer];
   Double_t r=lay.GetR();
@@ -864,13 +709,15 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
   Double_t phiExpect=fPhiEstimate;
   Double_t lamExpect=fLambdac;
 
-  Int_t ncl = fCluLayer[layer]->GetEntriesFast();
-  for (Int_t index=0; index<ncl; index++) {
-    
+  Int_t ncl = fCluCoord[layer]->GetEntriesFast();
+  Int_t startcl=FindIndex(layer,lamExpect-lambdawindow*1.02);
+  Int_t endcl=FindIndex(layer,lamExpect+lambdawindow*1.02)+1;
+  if(endcl>=ncl) endcl=ncl-1;
+
+  for (Int_t index=startcl; index<=endcl; index++) {
+    //for (Int_t index=0; index<ncl; index++) {
     AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index);
 
-    Double_t lambda = arr->GetLambda();
-    if (TMath::Abs(lambda-lamExpect)>lambdawindow) continue;
 
     Double_t phi = arr->GetPhi();
     Double_t deltaPhi = phi-phiExpect;
@@ -878,6 +725,9 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
     else if(deltaPhi<-TMath::Pi()) deltaPhi+=2*TMath::Pi();
     if (TMath::Abs(deltaPhi)>phiwindow) continue;
     
+    Double_t lambda = arr->GetLambda();
+    if (TMath::Abs(lambda-lamExpect)>lambdawindow) continue;
+
     if(trs->GetNumberOfClustersSA()==trs->GetMaxNumberOfClusters()) return 0;
     if(trs->GetNumberOfMarked(layer)==trs->GetMaxNMarkedPerLayer()) return 0;
     Int_t orind = arr->GetOrInd();
@@ -898,11 +748,6 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
 Bool_t AliITStrackerSA::SetFirstPoint(Int_t lay, Int_t clu, Double_t* primaryVertex){
   // Sets the first point (seed) for tracking
 
-  AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[lay]->UncheckedAt(clu);
-  if(!cl) return kFALSE;
-  if (cl->GetQ()<=0) return kFALSE;
-  if(lay>1 && cl->GetQ()<=fMinQ) return kFALSE;
-
   AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(lay,clu);
   fPhic = arr->GetPhi();
   fLambdac = arr->GetLambda();
@@ -1022,7 +867,7 @@ Int_t AliITStrackerSA::FindTrackLowChiSquare() const {
 
 //__________________________________________________________
 Int_t AliITStrackerSA::FindLabel(AliITStrackV2* track){
-  //
+  // compute the track label starting from cluster labels
   
   Int_t labl[AliITSgeomTGeo::kNLayers][3];
   Int_t cnts[AliITSgeomTGeo::kNLayers][3];
@@ -1107,19 +952,23 @@ void AliITStrackerSA::SetFixedWindowSizes(Int_t n, Double_t *phi, Double_t *lam)
   }
   else {  // default values
             
-    Double_t phid[33]   = {0.002,0.003,0.004,0.0045,0.0047,
-                          0.005,0.0053,0.0055,
-                          0.006,0.0063,0.0065,0.007,0.0073,0.0075,0.0077,
-                          0.008,0.0083,0.0085,0.0087,0.009,0.0095,0.0097,
-                          0.01,0.0105,0.011,0.0115,0.012,0.0125,0.013,0.0135,0.0140,0.0145};
-    Double_t lambdad[33] = {0.003,0.004,0.005,0.005,0.005,
-                           0.005,0.005,0.006,
-                           0.006,0.006,0.006,0.007,0.007,0.007,0.007,
-                           0.007,0.007,0.007,0.007,0.007,0.007,0.007,
-                           0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008,0.008};
+    Double_t phid[32]   = {0.002,0.003,0.004,0.0045,0.0047,
+                          0.005,0.0053,0.0055,0.006,0.0063,
+                          0.0065,0.007,0.0073,0.0075,0.0077,
+                          0.008,0.0083,0.0085,0.0087,0.009,
+                          0.0095,0.0097,0.01,0.0105,0.011,
+                          0.0115,0.012,0.0125,0.013,0.0135,
+                          0.0140,0.0145};
+    Double_t lambdad[32] = {0.003,0.004,0.005,0.005,0.005,
+                           0.005,0.005,0.006,0.006,0.006,
+                           0.006,0.007,0.007,0.007,0.007,
+                           0.007,0.007,0.007,0.007,0.007,
+                           0.007,0.007,0.008,0.008,0.008,
+                           0.008,0.008,0.008,0.008,0.008,
+                           0.008,0.008};
     
-    if(fNloop!=33){
-      fNloop = 33;
+    if(fNloop!=32){
+      fNloop = 32;
     }
     
     
@@ -1137,7 +986,7 @@ void AliITStrackerSA::SetFixedWindowSizes(Int_t n, Double_t *phi, Double_t *lam)
 
 }
 //_______________________________________________________________________
-void AliITStrackerSA::GetCoorAngles(AliITSRecPoint* cl,Double_t &phi,Double_t &lambda, Double_t &x, Double_t &y,Double_t &z,Double_t* vertex){
+void AliITStrackerSA::GetCoorAngles(AliITSRecPoint* cl,Double_t &phi,Double_t &lambda, Double_t &x, Double_t &y,Double_t &z, const Double_t* vertex){
   //Returns values of phi (azimuthal) and lambda angles for a given cluster
 /*  
   Double_t rot[9];     fGeom->GetRotMatrix(module,rot);
@@ -1192,3 +1041,26 @@ void AliITStrackerSA::GetCoorErrors(AliITSRecPoint* cl,Double_t &sx,Double_t &sy
 */
 }
 
+//________________________________________________________________________
+Int_t AliITStrackerSA::FindIndex(Int_t lay, Double_t lamVal) const {
+  // Find the cluster at limit of lambda window 
+
+  Int_t base = 0;
+  Int_t last = fCluCoord[lay]->GetEntriesFast()-1;
+  if(last<0) return 0;
+  Int_t position;
+  Double_t lamfirst=((AliITSclusterTable*)fCluCoord[lay]->At(base))->GetLambda();
+  if(lamfirst>lamVal) return base;
+  Double_t lamlast=((AliITSclusterTable*)fCluCoord[lay]->At(last))->GetLambda();
+  if(lamlast<=lamVal) return last;
+  while (last >= base) {
+    position = (base+last) / 2;
+    Double_t a=((AliITSclusterTable*)fCluCoord[lay]->At(position))->GetLambda()-lamVal;
+    Double_t b=((AliITSclusterTable*)fCluCoord[lay]->At(position+1))->GetLambda()-lamVal;
+    if(a*b<=0) return position;
+    if(a>0) last = position;
+    else  base = position;
+  }
+  return 0;
+}
+