]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerSA.cxx
Removing GetDebug and SetDebug from AliRun and AliModule. Using AliLog for the messages
[u/mrichter/AliRoot.git] / ITS / AliITStrackerSA.cxx
index 26c0dc6927b5be0090359cb9154c4c1194805be2..855c1edb8fc69a5c859c366b8a4dee2ad7fcf991 100644 (file)
@@ -1,4 +1,3 @@
-
 /**************************************************************************
  * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. *
  *                                                                        *
@@ -14,6 +13,8 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 ////////////////////////////////////////////////////
 //  Stand alone tracker class                     //
 //  Origin:  Elisabetta Crescio                   //
 ////////////////////////////////////////////////////
 
 #include <stdlib.h>
-#include "TArrayI.h"
+
+#include <TArrayI.h>
 #include <TBranch.h>
 #include <TMath.h>
 #include <TObjArray.h>
 #include <TTree.h>
-#include "AliRun.h"
+
+#include "AliESD.h"
+#include "AliESDVertex.h"
+#include "AliESDtrack.h"
+#include "AliITSRiemannFit.h"
+#include "AliITSVertexer.h"
 #include "AliITSclusterTable.h"
 #include "AliITSclusterV2.h"
 #include "AliITSgeom.h"
-#include "AliITSRiemannFit.h"
-#include "AliITStrackerSA.h"
 #include "AliITStrackSA.h"
-#include "AliITSVertexer.h"
-#include "AliESDVertex.h"
-#include "AliESD.h"
-#include "AliESDtrack.h"
+#include "AliITStrackerSA.h"
+#include "AliRun.h"
 
 ClassImp(AliITStrackerSA)
 
 //____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA():AliITStrackerV2(){
+AliITStrackerSA::AliITStrackerSA():AliITStrackerMI(){
   // Default constructor
   Init();
  
 }
 //____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom):AliITStrackerV2(geom) 
+AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom):AliITStrackerMI(geom) 
 {
   // Standard constructor (Vertex is known and passed to this obj.)
   Init();
@@ -58,7 +61,7 @@ AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom):AliITStrackerV2(geom)
 }
 
 //____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliESDVertex *vert):AliITStrackerV2(geom) 
+AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliESDVertex *vert):AliITStrackerMI(geom) 
 {
   // Standard constructor (Vertex is known and passed to this obj.)
   Init();
@@ -67,25 +70,8 @@ AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliESDVertex *vert):AliITStra
  
 }
 
-//______________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(const AliITStrackerSA &trkr) : 
-                    AliITStrackerV2(trkr) {
-  // Copy constructor
-  // Copies are not allowed. The method is protected to avoid misuse.
-  Error("AliITStrackerSA","Copy constructor not allowed\n");
-}
-
-//______________________________________________________________________
-AliITStrackerSA& AliITStrackerSA::operator=(const 
-                    AliITStrackerSA& /* trkr */){
-  // Assignment operator
-  // Assignment is not allowed. The method is protected to avoid misuse.
-  Error("= operator","Assignment operator not allowed\n");
-  return *this;
-}
-
 //____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliITSVertexer *vertexer):AliITStrackerV2(geom) 
+AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliITSVertexer *vertexer):AliITStrackerMI(geom) 
 {
   // Standard constructor (Vertex is unknown - vertexer is passed to this obj)
   Init();
@@ -95,7 +81,7 @@ AliITStrackerSA::AliITStrackerSA(AliITSgeom *geom, AliITSVertexer *vertexer):Ali
 }
 
 //____________________________________________________________________________
-AliITStrackerSA::AliITStrackerSA(AliITStrackerSA& tracker):AliITStrackerV2(){
+AliITStrackerSA::AliITStrackerSA(AliITStrackerSA& tracker):AliITStrackerMI(){
   // Copy constructor
   fPhiEstimate = tracker.fPhiEstimate;
   for(Int_t i=0;i<2;i++){
@@ -264,15 +250,15 @@ void AliITStrackerSA::FindTracks(TTree *out,Int_t evnumber){
       
       Int_t * nn = new Int_t[fGeom->GetNlayers()];//counter for clusters on each layer
       for(Int_t i=0;i<fGeom->GetNlayers();i++){ nn[i]=0;}
-      nn[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
-      nn[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
+      nn[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
 
       if(nn[1]>0){
         pflag=1;
         fPoint3[0] = fPointc[0];
         fPoint3[1] = fPointc[1];
       }
-      nn[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
       if(nn[1]==0 && nn[2]==0) pflag=0;
       if(nn[2]!=0 && nn[1]!=0){ pflag=1; UpdatePoints();}
       if(nn[2]!=0 && nn[1]==0){
@@ -281,13 +267,13 @@ void AliITStrackerSA::FindTracks(TTree *out,Int_t evnumber){
         fPoint3[1]=fPointc[1];
       }
 
-      nn[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
       pflag=1;
       if(nn[3]!=0) UpdatePoints();
-      nn[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable); 
+      nn[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag); 
       pflag=1;
       if(nn[4]!=0) UpdatePoints();
-      nn[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable); 
+      nn[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag); 
           
 
       Int_t layOK=0;
@@ -306,6 +292,8 @@ void AliITStrackerSA::FindTracks(TTree *out,Int_t evnumber){
             AliITSclusterV2* kl = (AliITSclusterV2*)GetCluster(index);
            if(kl->TestBit(kSAflag)==kTRUE) kl->ResetBit(kSAflag);
           }
+         delete [] nn;
+         delete trs;
          continue;
         }
         outrack=tr2;  
@@ -328,6 +316,7 @@ void AliITStrackerSA::FindTracks(TTree *out,Int_t evnumber){
                  if(kl->TestBit(kSAflag)==kTRUE) kl->ResetBit(kSAflag);
         }
       }
+      delete [] nn;
       delete trs;
 
     }//end loop on clusters of layer1
@@ -363,7 +352,7 @@ void AliITStrackerSA::FindTracks(TTree *out,Int_t evnumber){
         for(Int_t kk=0;kk<fGeom->GetNlayers()-1;kk++)nn[kk] = 0;
         for(Int_t kk=0;kk<fGeom->GetNlayers()-1;kk++){
           nn[kk] = SearchClusters(kk+1,fPhiWin[nloop],fLambdaWin[nloop],
-                   trs,primaryVertex[2],pflag,fTable);
+                   trs,primaryVertex[2],pflag);
           if(nn[kk]==0)break;
           if(kk>0){
             UpdatePoints();
@@ -383,6 +372,7 @@ void AliITStrackerSA::FindTracks(TTree *out,Int_t evnumber){
               AliITSclusterV2* kl = (AliITSclusterV2*)GetCluster(index);
              if(kl->TestBit(kSAflag)==kTRUE) kl->ResetBit(kSAflag);
             }
+           delete trs;
             continue;
           }
           outrack=tr2;
@@ -465,9 +455,13 @@ Int_t AliITStrackerSA::FindTracks(AliESD* event){
       if(cl==0) continue;
       if(cl->IsUsed()==1) continue;
       if(cl->TestBit(kSAflag)==kTRUE) continue;
+      if (cl->GetQ()<=0) continue;
       
       fPhic = fTable->GetPhiCluster(0,ncl);
       fLambdac = fTable->GetLambdaCluster(0,ncl);
+
+      if (TMath::Abs(fLambdac)>0.26*TMath::Pi()) continue;
+
       fPhiEstimate = fPhic;
       AliITStrackSA* trs = new AliITStrackSA();      
       fPoint1[0]=primaryVertex[0];
@@ -476,15 +470,15 @@ Int_t AliITStrackerSA::FindTracks(AliESD* event){
       fPoint2[1]=fTable->GetYCluster(0,ncl);
       Int_t * nn = new Int_t[fGeom->GetNlayers()];//counter for clusters on each layer
       for(Int_t i=0;i<fGeom->GetNlayers();i++){ nn[i]=0;}
-      nn[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
           
-      nn[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
       if(nn[1]>0){
         pflag=1;
         fPoint3[0] = fPointc[0];
         fPoint3[1] = fPointc[1];
       }
-      nn[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
       if(nn[1]==0 && nn[2]==0) pflag=0;
       if(nn[2]!=0 && nn[1]!=0){ pflag=1; UpdatePoints();}
       if(nn[2]!=0 && nn[1]==0){
@@ -493,13 +487,13 @@ Int_t AliITStrackerSA::FindTracks(AliESD* event){
         fPoint3[1]=fPointc[1];
       }
 
-      nn[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable);
+      nn[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
       pflag=1;
       if(nn[3]!=0) UpdatePoints();
-      nn[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable); 
+      nn[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag); 
       pflag=1;
       if(nn[4]!=0) UpdatePoints();
-      nn[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag,fTable); 
+      nn[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag); 
           
 
       Int_t layOK=0;
@@ -580,7 +574,7 @@ Int_t AliITStrackerSA::FindTracks(AliESD* event){
         for(Int_t kk=0;kk<fGeom->GetNlayers()-1;kk++)nn[kk] = 0;
         for(Int_t kk=0;kk<fGeom->GetNlayers()-1;kk++){
           nn[kk] = SearchClusters(kk+1,fPhiWin[nloop],fLambdaWin[nloop],
-                   trs,primaryVertex[2],pflag,fTable);
+                   trs,primaryVertex[2],pflag);
           if(nn[kk]==0)break;
           if(kk>0){
             UpdatePoints();
@@ -651,7 +645,7 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   for(Int_t i=0;i<fGeom->GetNlayers();i++){
     firstmod[i]=fGeom->GetModuleIndex(i+1,1,1);
   }  
-  AliITStrackV2* otrack2;
+
   Int_t nclusters = tr->GetNumberOfClustersSA();
   TObjArray** listlayer = new TObjArray*[fGeom->GetNlayers()];
   for(Int_t i=0;i<fGeom->GetNlayers();i++){
@@ -748,7 +742,13 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
         Float_t seed1,seed2,seed3;
         AliITSRiemannFit fit;
         Int_t rf = fit.FitHelix(3,recp,errs,seed1,seed2,seed3); //this gives phi,tgl,curvature to start Kalman Filter
-        if(rf==0) continue;  
+        if(rf==0) {
+         for(Int_t i=1;i<3;i++){
+           delete recp[i];
+           delete errs[i];
+         }     
+         continue;
+       }  
         Double_t phi=seed1;
         Double_t tgl=seed2;
         
@@ -802,20 +802,24 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
               if(cl1!=0) trac->AddClusterV2(1,(clind1[l2] & 0x0fffffff)>>0);
               if(cl0!=0) trac->AddClusterV2(0,(clind0[l1] & 0x0fffffff)>>0);
             
-              //fit with Kalman filter using AliITStrackerV2::RefitAt()
+              //fit with Kalman filter using AliITStrackerMI::RefitAt()
           
-              AliITStrackV2* ot = new AliITStrackV2(*trac);
+              AliITStrackMI* ot = new AliITStrackSA(*trac);
               
               ot->ResetCovariance();
               ot->ResetClusters();
               
               if(RefitAt(49.,ot,trac)){ //fit from layer 1 to layer 6
 
-                otrack2 = new AliITStrackV2(*ot);
+                AliITStrackMI *otrack2 = new AliITStrackMI(*ot);
                 otrack2->ResetCovariance(); 
                 otrack2->ResetClusters();
                 //fit from layer 6 to layer 1
-                if(RefitAt(3.7,otrack2,ot)) fListOfTracks->AddLast(otrack2);
+                if(RefitAt(3.7,otrack2,ot)) {
+                 fListOfTracks->AddLast(otrack2);
+               } else {
+                 delete otrack2;
+               }
                               
               }       
           
@@ -844,13 +848,21 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
     for(Int_t i=0;i<fGeom->GetNlayers();i++){
       delete listlayer[i];
     }
-    delete listlayer;
+    delete [] listlayer;
+    delete [] firstmod;
     return 0;
   }
 
   AliITStrackV2* otrack =(AliITStrackV2*)FindTrackLowChiSquare(fListOfTracks,dim);
 
-  if(otrack==0) return 0;
+  if(otrack==0) {
+    for(Int_t i=0;i<fGeom->GetNlayers();i++){
+      delete listlayer[i];
+    }
+    delete [] listlayer; 
+    delete [] firstmod;
+    return 0;
+  }
   Int_t * indexc = new Int_t[fGeom->GetNlayers()];
   for(Int_t i=0;i<fGeom->GetNlayers();i++) indexc[i]=0;
   for(Int_t nind=0;nind<otrack->GetNumberOfClusters();nind++){
@@ -877,6 +889,7 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   Int_t numberofpoints;
   if(fSixPoints) numberofpoints=6;
   else numberofpoints=5;
+  CookLabel(otrack,0.); //MI change - to see fake ratio
   Int_t label =  Label(cl0->GetLabel(0),cl1->GetLabel(0), 
                        cl2->GetLabel(0),cl3->GetLabel(0),
                        cl4->GetLabel(0),labl[0],
@@ -891,7 +904,7 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
   for(Int_t i=0;i<fGeom->GetNlayers();i++){
     delete listlayer[i];
   }
-  delete listlayer; 
+  delete [] listlayer; 
   delete [] firstmod;
   return otrack;
 
@@ -976,8 +989,9 @@ void AliITStrackerSA::UseFoundTracksV2(AliESD *event){
 
 }
 
+/*
 //_______________________________________________________
-Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackSA* trs,Double_t zvertex,Int_t pflag,AliITSclusterTable* table){
+Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackSA* trs,Double_t zvertex,Int_t pflag){
   //function used to to find the clusters associated to the track
   Int_t nc=0;
   AliITSlayer &lay = fgLayers[layer];
@@ -1024,7 +1038,7 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
 
 
   Int_t nn=0;
-  TArrayI* array =(TArrayI*)table->GetListOfClusters(nmod);
+  TArrayI* array =(TArrayI*)fTable->GetListOfClusters(nmod);
   TArrayI* listc = new TArrayI(array->GetSize());
   for(Int_t i=0;i<array->GetSize();i++){
     Int_t in=(Int_t)array->At(i);
@@ -1050,7 +1064,7 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
  
   for(Int_t ii=0;ii<8;ii++){
     if(nm[ii]!=value && nm[ii]!=nmod && nm[ii]>=0){
-      TArrayI* ar =(TArrayI*)table->GetListOfClusters(nm[ii]+firstmod[layer]);
+      TArrayI* ar =(TArrayI*)fTable->GetListOfClusters(nm[ii]+firstmod[layer]);
       listc->Set(listc->GetSize()+ar->GetSize());
       for(Int_t j=0;j<ar->GetSize();j++){
        Int_t in=(Int_t)ar->At(j);
@@ -1093,7 +1107,57 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
   return nc;
 
 }
+*/
+
+
+//_______________________________________________________
+Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t lambdawindow, AliITStrackSA* trs,Double_t zvertex,Int_t pflag){
+  //function used to to find the clusters associated to the track
+  Int_t nc=0;
+  AliITSlayer &lay = fgLayers[layer];
+  Double_t r=lay.GetR(),tgl=TMath::Tan(fLambdac);
 
+  if(pflag==1){      
+    Float_t cx1,cx2,cy1,cy2;
+    FindEquation(fPoint1[0],fPoint1[1],fPoint2[0],fPoint2[1],fPoint3[0],fPoint3[1],fCoef1,fCoef2,fCoef3);
+    if (FindIntersection(fCoef1,fCoef2,fCoef3,-r*r,cx1,cy1,cx2,cy2)==0)
+       return 0;
+    Double_t fi1=TMath::ATan2(cy1,cx1);
+    Double_t fi2=TMath::ATan2(cy2,cx2);
+    fPhiEstimate=ChoosePoint(fi1,fi2,fPhic);
+  }
+
+  Double_t dz=r*lambdawindow*TMath::Sqrt(1+tgl*tgl) + 0.3*TMath::Abs(tgl);
+  Double_t zmax=r*tgl + zvertex + dz;
+  Double_t zmin=r*tgl + zvertex - dz;
+
+  Int_t indmin = lay.FindClusterIndex(zmin);
+  Int_t indmax = lay.FindClusterIndex(zmax);
+  for (Int_t index=indmin; index<indmax; index++) {
+     AliITSclusterV2 *c=lay.GetCluster(index);
+     if (c->IsUsed()) continue;
+     if (c->GetQ()<=0) continue;
+     if (c->TestBit(kSAflag)==kTRUE) continue;
+
+     Double_t phi   =fTable->GetPhiCluster(layer,index);
+     if (TMath::Abs(phi-fPhiEstimate)>phiwindow) continue;
+
+     Double_t lambda=fTable->GetLambdaCluster(layer,index);
+     if (TMath::Abs(lambda-fLambdac)>lambdawindow) continue;
+
+     if(trs->GetNumberOfClustersSA()==15) return 0;
+
+     trs->AddClusterSA(layer,index);
+     nc++;
+     fLambdac=lambda;
+     fPhiEstimate=phi;
+     fPointc[0]=fTable->GetXCluster(layer,index);
+     fPointc[1]=fTable->GetYCluster(layer,index);
+
+     c->SetBit(kSAflag);
+  }
+  return nc;
+}
 
 
 //________________________________________________________________
@@ -1130,14 +1194,15 @@ Int_t AliITStrackerSA::FindEquation(Float_t x1, Float_t y1, Float_t x2, Float_t
  //c2 is -rlayer*rlayer
 
   if(a1==0) return 0;
- Float_t m = c2-c1; 
- Float_t aA = (b1*b1)/(a1*a1)+1;
- Float_t bB = (-2*m*b1/(a1*a1));
- Float_t cC = c2+(m*m)/(a1*a1);
- if((bB*bB-4*aA*cC)<0) return 0;
+ Double_t m = c2-c1; 
+ Double_t aA = (b1*b1)/(a1*a1)+1;
+ Double_t bB = (-2*m*b1/(a1*a1));
+ Double_t cC = c2+(m*m)/(a1*a1);
+ Double_t dD = bB*bB-4*aA*cC;
+ if(dD<0) return 0;
  
- y1 = (-bB+TMath::Sqrt(bB*bB-4*aA*cC))/(2*aA); 
- y2 = (-bB-TMath::Sqrt(bB*bB-4*aA*cC))/(2*aA); 
+ y1 = (-bB+TMath::Sqrt(dD))/(2*aA); 
+ y2 = (-bB-TMath::Sqrt(dD))/(2*aA); 
  x1 = (c2-c1-b1*y1)/a1;
  x2 = (c2-c1-b1*y2)/a1;