]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerSA.cxx
Skipping layers corresponding to ITS subdetectors that are not in the TriggerCluster...
[u/mrichter/AliRoot.git] / ITS / AliITStrackerSA.cxx
index 12d5dc2a4fb3d5b96a4a40a0b9f1cc21ada7471d..fa7fd1d1b58ff3e7e19e6ffe0b65735394fd2d3a 100644 (file)
@@ -39,6 +39,7 @@
 #include "AliITStrackSA.h"
 #include "AliITStrackerSA.h"
 #include "AliITSReconstructor.h"
+#include "AliLog.h"
 #include "AliRun.h"
 
 ClassImp(AliITStrackerSA)
@@ -60,8 +61,11 @@ fVertexer(0),
 fListOfTracks(0),
 fListOfSATracks(0),
 fITSclusters(0),
-fSixPoints(0),
+fInwardFlag(0),
 fOuterStartLayer(0),
+fInnerStartLayer(5),
+fMinNPoints(0),
+fMinQ(0.),
 fCluLayer(0),
 fCluCoord(0){
   // Default constructor
@@ -85,8 +89,11 @@ fVertexer(0),
 fListOfTracks(0),
 fListOfSATracks(0),
 fITSclusters(0),
-fSixPoints(0),
+fInwardFlag(0),
 fOuterStartLayer(0),
+fInnerStartLayer(5),
+fMinNPoints(0),
+fMinQ(0.),
 fCluLayer(0),
 fCluCoord(0) 
 {
@@ -117,8 +124,11 @@ fVertexer(0),
 fListOfTracks(0),
 fListOfSATracks(0),
 fITSclusters(0),
-fSixPoints(0),
+fInwardFlag(0),
 fOuterStartLayer(0),
+fInnerStartLayer(5),
+fMinNPoints(0),
+fMinQ(0.),
 fCluLayer(0),
 fCluCoord(0)
 {
@@ -147,8 +157,11 @@ fVertexer(vertexer),
 fListOfTracks(0),
 fListOfSATracks(0),
 fITSclusters(0),
-fSixPoints(0),
+fInwardFlag(0),
 fOuterStartLayer(0),
+fInnerStartLayer(5),
+fMinNPoints(0),
+fMinQ(0.),
 fCluLayer(0),
 fCluCoord(0)
 {
@@ -178,8 +191,11 @@ fVertexer(tracker.fVertexer),
 fListOfTracks(tracker.fListOfTracks),
 fListOfSATracks(tracker.fListOfSATracks),
 fITSclusters(tracker.fITSclusters),
-fSixPoints(tracker.fSixPoints),
+fInwardFlag(tracker.fInwardFlag),
 fOuterStartLayer(tracker.fOuterStartLayer),
+fInnerStartLayer(tracker.fInnerStartLayer),
+fMinNPoints(tracker.fMinNPoints),
+fMinQ(tracker.fMinQ),
 fCluLayer(tracker.fCluLayer),
 fCluCoord(tracker.fCluCoord) {
   // Copy constructor
@@ -289,14 +305,15 @@ void AliITStrackerSA::Init(){
       Double_t lambmax=AliITSReconstructor::GetRecoParam()->GetMaxLambdaSA();
       SetCalculatedWindowSizes(nLoops,phimin,phimax,lambmin,lambmax);
     }
+    fMinQ=AliITSReconstructor::GetRecoParam()->GetSAMinClusterCharge();
     fITSclusters = 0;
-    SetSixPoints();
-    SetOuterStartLayer(0);
+    SetOuterStartLayer(1);
     SetSAFlag(kFALSE);
     fListOfTracks=new TObjArray(0,0);
     fListOfSATracks=new TObjArray(0,0);
     fCluLayer = 0;
     fCluCoord = 0;
+    fMinNPoints = 3;
  }
 //_______________________________________________________________________
 void AliITStrackerSA::ResetForFinding(){
@@ -320,7 +337,10 @@ void AliITStrackerSA::ResetForFinding(){
 Int_t AliITStrackerSA::FindTracks(AliESDEvent* event){
 
 // Track finder using the ESD object
-  
+
+  AliDebug(2,Form(" field is %f",event->GetMagneticField()));
+  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");
     return -1;
@@ -330,7 +350,7 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event){
   if(AliITSReconstructor::GetRecoParam()->GetSAUseAllClusters()==kFALSE) {
     while (nentr--) {
       AliESDtrack *track=event->GetTrack(nentr);
-      if (track->GetStatus()&AliESDtrack::kITSin==AliESDtrack::kITSin){
+      if ((track->GetStatus()&AliESDtrack::kITSin) == AliESDtrack::kITSin){
        Int_t idx[12];
        Int_t ncl = track->GetITSclusters(idx);
        for(Int_t k=0;k<ncl;k++){
@@ -357,11 +377,12 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event){
   }
   for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++){
     AliITSlayer &layer=fgLayers[i];
-    if (!AliITSReconstructor::GetRecoParam()->GetLayersToSkip(i)) {
+    if (!ForceSkippingOfLayer(i)) {
       for(Int_t cli=0;cli<layer.GetNumberOfClusters();cli++){
        AliITSRecPoint* cls = (AliITSRecPoint*)layer.GetCluster(cli);
        if(cls->TestBit(kSAflag)==kTRUE) continue; //clusters used by TPC prol.
        if(cls->GetQ()==0) continue; //fake clusters dead zones
+       if(i>1 && cls->GetQ()<=fMinQ) continue; // cut on SDD and SSD cluster charge
        nclusters[i]++;
       }
     }
@@ -376,11 +397,12 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event){
     TClonesArray &clulay = *fCluLayer[ilay];
     TClonesArray &clucoo = *fCluCoord[ilay];
     AliITSlayer &layer=fgLayers[ilay];
-    if (!AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilay)) {
+    if (!ForceSkippingOfLayer(ilay)) {
       for(Int_t cli=0;cli<layer.GetNumberOfClusters();cli++){
        AliITSRecPoint* cls = (AliITSRecPoint*)layer.GetCluster(cli);
        if(cls->TestBit(kSAflag)==kTRUE) continue;
        if(cls->GetQ()==0) continue;
+       if(ilay>1 && cls->GetQ()<=fMinQ) continue; 
        Double_t phi=0;Double_t lambda=0;
        Float_t x=0;Float_t y=0;Float_t z=0;
        Float_t sx=0;Float_t sy=0;Float_t sz=0;
@@ -393,272 +415,167 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event){
     }
   }
    
-  Int_t minNPoints = (fSixPoints ? AliITSgeomTGeo::GetNLayers() : AliITSgeomTGeo::GetNLayers()-1);  
-  for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++) {
-    if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(i)) {
-      minNPoints--;
-    }
-  }
-
-
+  // track counter
   Int_t ntrack=0;
-  //loop on the different windows
-  static Int_t nClusLay[AliITSgeomTGeo::kNLayers];//counter for clusters on each layer
-  for(Int_t nloop=0;nloop<fNloop;nloop++){
-    for(Int_t ncl=0;ncl<fCluLayer[0]->GetEntries();ncl++){ //loop starting from layer 0
-      
-      ResetForFinding();
-      Int_t pflag=0;
-      
-      AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[0]->At(ncl);
-      
-      if(!cl) continue;
-      if (cl->GetQ()<=0) continue;
-      
-      AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(0,ncl); 
-      fPhic = arr->GetPhi();
-      fLambdac = arr->GetLambda();
-      if (TMath::Abs(fLambdac)>0.26*TMath::Pi()) continue;
-      fPhiEstimate = fPhic;
-      AliITStrackSA* trs = new AliITStrackSA(); 
-      fPoint1[0]=primaryVertex[0];
-      fPoint1[1]=primaryVertex[1];
-      
-      
-      fPoint2[0]=arr->GetX();
-      fPoint2[1]=arr->GetY();
-      for(Int_t i=0;i<AliITSgeomTGeo::GetNLayers();i++) nClusLay[i]=0;
-      nClusLay[0] = SearchClusters(0,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
-      nClusLay[1] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
-      if(nClusLay[1]>0){
-        pflag=1;
-        fPoint3[0] = fPointc[0];
-        fPoint3[1] = fPointc[1];
-      }
-      nClusLay[2] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
-      if(nClusLay[1]==0 && nClusLay[2]==0) pflag=0;
-      if(nClusLay[2]!=0 && nClusLay[1]!=0){ pflag=1; UpdatePoints();}
-      if(nClusLay[2]!=0 && nClusLay[1]==0){
-        pflag=1;
-        fPoint3[0]=fPointc[0];
-        fPoint3[1]=fPointc[1];
-      }
-
-      nClusLay[3] = SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag);
-      pflag=1;
-      if(nClusLay[3]!=0) UpdatePoints();
-      nClusLay[4] = SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag); 
-      pflag=1;
-      if(nClusLay[4]!=0) UpdatePoints();
-      nClusLay[5] = SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],trs,primaryVertex[2],pflag); 
-          
-
-      Int_t layOK=0;
-      //check of the candidate track
-      for(Int_t nnp=0;nnp<AliITSgeomTGeo::GetNLayers();nnp++) {
-        if(nClusLay[nnp]!=0) layOK+=1;
-      }
-
-      if(layOK>=minNPoints) {
-       AliITStrackV2* tr2 = 0;
-       tr2 = FitTrack(trs,primaryVertex);
-       if(!tr2) continue;
-
-       AliESDtrack outtrack;
-       outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
-       event->AddTrack(&outtrack);
-       ntrack++;
-      }
-      delete trs;
-     }//end loop on clusters of layer1
-     //end loop2
-  }
-
 
+  static Int_t nClusLay[AliITSgeomTGeo::kNLayers];//counter for clusters on each layer
 
-  minNPoints--;
+  if(AliITSReconstructor::GetRecoParam()->GetAllowProlongationWithEmptyRoad()) fMinNPoints=2;
 
-  //if 5/6 points are required, second loop starting 
-  //from second layer (SPD2), to find tracks with point of 
-  //layer 1 missing   
-  if(!fSixPoints) {
-    //printf("looking from SPD2\n");
-    //   counter for clusters on each layer  
-    for(Int_t nloop=0;nloop<fNloop;nloop++){
-      Int_t ncl2=fCluLayer[1]->GetEntries();
-      while(ncl2--){ //loop starting from layer 2
-       ResetForFinding();
-       Int_t pflag=0;
-       AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[1]->At(ncl2);
-       
-       if(!cl) continue;
-       AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(1,ncl2);
-       fPhic = arr->GetPhi();
-       fLambdac = arr->GetLambda();
-       fPhiEstimate = fPhic;
-       
-       AliITStrackSA* trs = new AliITStrackSA(); 
-       fPoint1[0]=primaryVertex[0];
-       fPoint1[1]=primaryVertex[1];
-       
-       fPoint2[0]=arr->GetX();
-       fPoint2[1]=arr->GetY();
-       for(Int_t kk=0;kk<AliITSgeomTGeo::GetNLayers();kk++) nClusLay[kk] = 0;
-       nClusLay[0] = SearchClusters(1,fPhiWin[nloop],fLambdaWin[nloop],
-                              trs,primaryVertex[2],pflag);
-       nClusLay[1] = SearchClusters(2,fPhiWin[nloop],fLambdaWin[nloop],
-                              trs,primaryVertex[2],pflag);
-       if(nClusLay[1]!=0){
-         pflag=1;
-         fPoint3[0]=fPointc[0];
-         fPoint3[1]=fPointc[1];
-       }
-       nClusLay[2]= SearchClusters(3,fPhiWin[nloop],fLambdaWin[nloop],
-                             trs,primaryVertex[2],pflag);
-       if(nClusLay[2]!=0){
-         pflag=1;
-         UpdatePoints();
-       }
-       nClusLay[3]= SearchClusters(4,fPhiWin[nloop],fLambdaWin[nloop],
-                             trs,primaryVertex[2],pflag);
-       if(nClusLay[3]!=0){
-         pflag=1;
-         UpdatePoints();
-       }
-       nClusLay[4]=SearchClusters(5,fPhiWin[nloop],fLambdaWin[nloop],
-                            trs,primaryVertex[2],pflag);
-       
-       Int_t layOK=0;
-       for(Int_t nnp=0;nnp<AliITSgeomTGeo::GetNLayers()-1;nnp++){
-         if(nClusLay[nnp]!=0) layOK+=1;
-       }
-       if(layOK>=minNPoints){  // 5/6       
-         AliITStrackV2* tr2 = 0;
-         tr2 = FitTrack(trs,primaryVertex);
-         if(!tr2) continue;
-         
-         AliESDtrack outtrack;
-         outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
-         event->AddTrack(&outtrack);
-         ntrack++;
-         
-       }   
-       
-        delete trs;
-      }//end loop on clusters of layer2
-    }
-    
-  } //end opt="5/6"  
-
-  // search for tracks starting from SPD2, SDD1, SDD2, SSD2
-  // for cosmics (A. Dainese 31.07.07)
-  if(fOuterStartLayer>0) {
-    for(Int_t innLay=1; innLay<=fOuterStartLayer; innLay++) {
-      //printf("Searching from layer %d outward\n",innLay);
-      minNPoints=AliITSgeomTGeo::GetNLayers()-innLay;
-      for(Int_t i=innLay;i<AliITSgeomTGeo::GetNLayers();i++) 
-       if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(i)) 
-         minNPoints--;
-      //   counter for clusters on each layer  
-
-      for(Int_t nloop=0;nloop<fNloop;nloop++){
-       Int_t nclInnLay=fCluLayer[innLay]->GetEntries();
-       while(nclInnLay--){ //loop starting from layer innLay
-         ResetForFinding();
-         Int_t pflag=0;
-         AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[innLay]->At(nclInnLay);
-         
-         if(!cl) continue;
-         AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(innLay,nclInnLay);
-         fPhic = arr->GetPhi();
-         fLambdac = arr->GetLambda();
-         fPhiEstimate = fPhic;
-         
-         AliITStrackSA* trs = new AliITStrackSA(); 
-         fPoint1[0]=primaryVertex[0];
-         fPoint1[1]=primaryVertex[1];
-         fPoint2[0]=arr->GetX();
-         fPoint2[1]=arr->GetY();
-         
-         Int_t kk;
-         for(kk=0;kk<AliITSgeomTGeo::GetNLayers();kk++) nClusLay[kk] = 0;
-         
-         kk=0;
-         nClusLay[kk] = SearchClusters(innLay,fPhiWin[nloop],fLambdaWin[nloop],
-                                 trs,primaryVertex[2],pflag);
-         for(Int_t nextLay=innLay+1; nextLay<AliITSgeomTGeo::GetNLayers(); nextLay++) {
-           kk++;
-           nClusLay[kk] = SearchClusters(nextLay,fPhiWin[nloop],fLambdaWin[nloop],
-                                   trs,primaryVertex[2],pflag);
-           if(nClusLay[kk]!=0){
-             pflag=1;
-             if(kk==1) {
-               fPoint3[0]=fPointc[0];
-               fPoint3[1]=fPointc[1];
-             } else {
-               UpdatePoints();
+  // loop on minimum number of points
+  for(Int_t iMinNPoints=AliITSgeomTGeo::GetNLayers(); iMinNPoints>=fMinNPoints; iMinNPoints--) {
+
+    if(!fInwardFlag){ // Tracking outwards from the inner layers
+      // loop on starting layer for track finding 
+      for(Int_t innLay=0; innLay<=fOuterStartLayer; innLay++) {
+       if(ForceSkippingOfLayer(innLay)) continue; 
+       Int_t minNPoints=iMinNPoints-innLay;
+       for(Int_t i=innLay+1;i<AliITSgeomTGeo::GetNLayers();i++)
+         if(ForceSkippingOfLayer(i)) 
+           minNPoints--;
+       if(minNPoints<fMinNPoints) continue;
+
+       // loop on phi and lambda window size
+       for(Int_t nloop=0;nloop<fNloop;nloop++){
+         Int_t nclInnLay=fCluLayer[innLay]->GetEntries();
+         while(nclInnLay--){ 
+           ResetForFinding();
+           Bool_t useRP=SetFirstPoint(innLay,nclInnLay,primaryVertex);
+           if(!useRP) continue;            
+           AliITStrackSA* trs = new AliITStrackSA(); 
+           
+           Int_t pflag=0;          
+           Int_t kk;
+           for(kk=0;kk<AliITSgeomTGeo::GetNLayers();kk++) nClusLay[kk] = 0;
+           
+           kk=0;
+           nClusLay[kk] = SearchClusters(innLay,fPhiWin[nloop],fLambdaWin[nloop],
+                                         trs,primaryVertex[2],pflag);
+           for(Int_t nextLay=innLay+1; nextLay<AliITSgeomTGeo::GetNLayers(); nextLay++) {
+             kk++;
+             nClusLay[kk] = SearchClusters(nextLay,fPhiWin[nloop],fLambdaWin[nloop],
+                                           trs,primaryVertex[2],pflag);
+             if(nClusLay[kk]!=0){
+               pflag=1;
+               if(kk==1) {
+                 fPoint3[0]=fPointc[0];
+                 fPoint3[1]=fPointc[1];
+               } else {
+                 UpdatePoints();
+               }
              }
            }
-         }
-         
-         Int_t layOK=0;
-         for(Int_t nnp=0;nnp<AliITSgeomTGeo::GetNLayers()-innLay;nnp++){
-           if(nClusLay[nnp]!=0) layOK+=1;
-         }
-         if(layOK>=minNPoints){ 
-           AliITStrackV2* tr2 = 0;
-           tr2 = FitTrack(trs,primaryVertex);
-           if(!tr2) continue;
            
+           Int_t layOK=0;
+           for(Int_t nnp=0;nnp<AliITSgeomTGeo::GetNLayers()-innLay;nnp++){
+             if(nClusLay[nnp]!=0) layOK+=1;
+           }
+           if(layOK>=minNPoints){ 
+             AliDebug(2,Form("---NPOINTS: %d; MAP: %d %d %d %d %d %d\n",layOK,nClusLay[0],nClusLay[1],nClusLay[2],nClusLay[3],nClusLay[4],nClusLay[5]));
+             AliITStrackV2* tr2 = 0;
+             tr2 = FitTrack(trs,primaryVertex);
+             if(!tr2) continue;
+             AliDebug(2,Form("---NPOINTS fit: %d\n",tr2->GetNumberOfClusters()));
+             
+             StoreTrack(tr2,event);
+             ntrack++;
+             
+           }   
+           
+           delete trs;
+         }//end loop on clusters of innLay
+       } //end loop on window sizes
+      } //end loop on innLay
+    }else{// Tracking inwards from the outer layers
+    // loop on starting layer for track finding 
+      for(Int_t outLay=AliITSgeomTGeo::GetNLayers()-1; outLay>=fInnerStartLayer; outLay--) {
+
+       if(ForceSkippingOfLayer(outLay)) continue;
+       Int_t minNPoints=iMinNPoints-(AliITSgeomTGeo::GetNLayers()-1-outLay);
+       for(Int_t i=0;i<outLay-1;i++)
+         if(ForceSkippingOfLayer(i)) 
+           minNPoints--;
+       if(minNPoints<fMinNPoints) continue;
+       
+       // loop on phi and lambda window size
+       for(Int_t nloop=0;nloop<fNloop;nloop++){
+         Int_t nclOutLay=fCluLayer[outLay]->GetEntries();
+         while(nclOutLay--){ 
+           ResetForFinding();
+           Bool_t useRP=SetFirstPoint(outLay,nclOutLay,primaryVertex);
+           if(!useRP) continue;            
+           AliITStrackSA* trs = new AliITStrackSA(); 
            
-           AliESDtrack outtrack;
-           outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
-           event->AddTrack(&outtrack);
-           ntrack++;
+           Int_t pflag=0;          
+           Int_t kk;
+           for(kk=0;kk<AliITSgeomTGeo::GetNLayers();kk++) nClusLay[kk] = 0;
            
-         }   
+           kk=0;
+           nClusLay[kk] = SearchClusters(outLay,fPhiWin[nloop],fLambdaWin[nloop],
+                                 trs,primaryVertex[2],pflag);
+           for(Int_t nextLay=outLay-1; nextLay>=0; nextLay--) {
+             kk++;
+             nClusLay[kk] = SearchClusters(nextLay,fPhiWin[nloop],fLambdaWin[nloop],
+                                           trs,primaryVertex[2],pflag);
+             if(nClusLay[kk]!=0){
+               pflag=1;
+               if(kk==1) {
+                 fPoint3[0]=fPointc[0];
+                 fPoint3[1]=fPointc[1];
+               } else {
+                 UpdatePoints();
+               }
+             }
+           }
          
-         delete trs;
+           Int_t layOK=0;
+           for(Int_t nnp=outLay; nnp>=0; nnp--){
+             if(nClusLay[nnp]!=0) layOK+=1;
+           }
+           if(layOK>=minNPoints){ 
+             AliDebug(2,Form("---NPOINTS: %d; MAP: %d %d %d %d %d %d\n",layOK,nClusLay[0],nClusLay[1],nClusLay[2],nClusLay[3],nClusLay[4],nClusLay[5]));
+             AliITStrackV2* tr2 = 0;
+             tr2 = FitTrack(trs,primaryVertex);
+             if(!tr2) continue;
+             AliDebug(2,Form("---NPOINTS fit: %d\n",tr2->GetNumberOfClusters()));
+             
+             StoreTrack(tr2,event);
+             ntrack++;
+             
+           }   
+           
+           delete trs;
        }//end loop on clusters of innLay
-      } //end loop on window sizes
-      
-    } //end loop on innLay
-  } //end if(fOuterStartLayer>0)
-  
+       } //end loop on window sizes
+      } //end loop on innLay
+    } // end if (fInwardFlag)
+  }//end loop on min points
 
-  // search for 1-point tracks, only for cosmics
+  // search for 1-point tracks in SPD, only for cosmics
   // (A.Dainese 21.03.08)
   if(AliITSReconstructor::GetRecoParam()->GetSAOnePointTracks() && 
      TMath::Abs(event->GetMagneticField())<0.01) {
-    for(Int_t innLay=0; innLay<=fOuterStartLayer; innLay++) {
+    Int_t outerLayer=1; // only SPD
+    for(Int_t innLay=0; innLay<=TMath::Min(1,fOuterStartLayer); innLay++) {
       //   counter for clusters on each layer  
 
       for(Int_t nloop=0;nloop<fNloop;nloop++){
        Int_t nclInnLay=fCluLayer[innLay]->GetEntries();
        while(nclInnLay--){ //loop starting from layer innLay
          ResetForFinding();
-         Int_t pflag=0;
-         AliITSRecPoint* cl = (AliITSRecPoint*)fCluLayer[innLay]->At(nclInnLay);
-         
-         if(!cl) continue;
-         AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(innLay,nclInnLay);
-         fPhic = arr->GetPhi();
-         fLambdac = arr->GetLambda();
-         fPhiEstimate = fPhic;
-         
+         Bool_t useRP=SetFirstPoint(innLay,nclInnLay,primaryVertex);
+         if(!useRP) continue;
          AliITStrackSA* trs = new AliITStrackSA(); 
-         fPoint1[0]=primaryVertex[0];
-         fPoint1[1]=primaryVertex[1];
-         fPoint2[0]=arr->GetX();
-         fPoint2[1]=arr->GetY();
-         
+           
+         Int_t pflag=0;            
          Int_t kk;
          for(kk=0;kk<AliITSgeomTGeo::GetNLayers();kk++) nClusLay[kk] = 0;
          
          kk=0;
          nClusLay[kk] = SearchClusters(innLay,fPhiWin[nloop],fLambdaWin[nloop],
                                  trs,primaryVertex[2],pflag);
-         for(Int_t nextLay=innLay+1; nextLay<AliITSgeomTGeo::GetNLayers(); nextLay++) {
+         for(Int_t nextLay=innLay+1; nextLay<=outerLayer; nextLay++) {
            kk++;
            nClusLay[kk] = SearchClusters(nextLay,fPhiWin[nloop],fLambdaWin[nloop],
                                    trs,primaryVertex[2],pflag);
@@ -678,14 +595,14 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event){
            if(nClusLay[nnp]!=0) layOK+=1;
          }
          if(layOK==1) {
+           AliDebug(2,Form("----NPOINTS: %d; MAP: %d %d %d %d %d %d\n",layOK,nClusLay[0],nClusLay[1],nClusLay[2],nClusLay[3],nClusLay[4],nClusLay[5]));
            AliITStrackV2* tr2 = 0;
            Bool_t onePoint = kTRUE;
            tr2 = FitTrack(trs,primaryVertex,onePoint);
            if(!tr2) continue;
+           AliDebug(2,Form("----NPOINTS fit: %d\n",tr2->GetNumberOfClusters()));
            
-           AliESDtrack outtrack;
-           outtrack.UpdateTrackParams(tr2,AliESDtrack::kITSin);
-           event->AddTrack(&outtrack);
+           StoreTrack(tr2,event);
            ntrack++;
            
          }   
@@ -913,21 +830,24 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
               ot->ResetCovariance(10.);
               ot->ResetClusters();
               
-              if(RefitAt(AliITSRecoParam::GetrInsideITSscreen(),ot,trac)){ //fit from layer 1 to layer 6
-                AliITStrackMI *otrack2 = new AliITStrackMI(*ot);
-                otrack2->ResetCovariance(10.); 
-                otrack2->ResetClusters();
-                //fit from layer 6 to layer 1
-                if(RefitAt(AliITSRecoParam::GetrInsideSPD1(),otrack2,ot)) {
-                 fListOfTracks->AddLast(otrack2);
-                 fListOfSATracks->AddLast(trac);
-               } else {
-                 delete otrack2;
-                 delete trac;
-               }
+             // Propagate inside the innermost layer with a cluster 
+             if(ot->Propagate(ot->GetX()-0.1*ot->GetX())) {
+
+               if(RefitAt(AliITSRecoParam::GetrInsideITSscreen(),ot,trac)){ //fit from layer 1 to layer 6
+                 AliITStrackMI *otrack2 = new AliITStrackMI(*ot);
+                 otrack2->ResetCovariance(10.); 
+                 otrack2->ResetClusters();
+                 //fit from layer 6 to layer 1
+                 if(RefitAt(AliITSRecoParam::GetrInsideSPD1(),otrack2,ot)) {
+                   fListOfTracks->AddLast(otrack2);
+                   fListOfSATracks->AddLast(trac);
+                 } else {
+                   delete otrack2;
+                   delete trac;
+                 }
                               
-              }       
-          
+               }       
+             }
               delete ot;
             }//end loop layer 6
           }//end loop layer 5
@@ -990,13 +910,31 @@ AliITStrackV2* AliITStrackerSA::FitTrack(AliITStrackSA* tr,Double_t *primaryVert
 
 }
 
+//_______________________________________________________
+void AliITStrackerSA::StoreTrack(AliITStrackV2 *t,AliESDEvent *event) const 
+{
+  //
+  // Add new track to the ESD
+  //
+  AliESDtrack outtrack;
+  outtrack.UpdateTrackParams(t,AliESDtrack::kITSin);
+  for(Int_t i=0;i<12;i++) {
+    outtrack.SetITSModuleIndex(i,t->GetModuleIndex(i));
+  }
+  Double_t sdedx[4]={0.,0.,0.,0.};
+  for(Int_t i=0; i<4; i++) sdedx[i]=t->GetSampledEdx(i);
+  outtrack.SetITSdEdxSamples(sdedx);
+  event->AddTrack(&outtrack);
+
+  return;
+}
 
 
 //_______________________________________________________
 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
 
-  if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(layer)) return 0;
+  if(ForceSkippingOfLayer(layer)) return 0;
 
   Int_t nc=0;
   AliITSlayer &lay = fgLayers[layer];
@@ -1017,6 +955,7 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
     AliITSRecPoint *c = (AliITSRecPoint*)fCluLayer[layer]->At(index);
     if (!c) continue;
     if (c->GetQ()<=0) continue;
+    if(layer>1 && c->GetQ()<=fMinQ) continue;
     
      AliITSclusterTable* arr = (AliITSclusterTable*)GetClusterCoord(layer,index);
      Double_t phi = arr->GetPhi();
@@ -1042,6 +981,26 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
   return nc;
 }
 
+//________________________________________________________________
+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]->At(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();
+  fPhiEstimate = fPhic;
+  fPoint1[0]=primaryVertex[0];
+  fPoint1[1]=primaryVertex[1];
+  fPoint2[0]=arr->GetX();
+  fPoint2[1]=arr->GetY();
+  return kTRUE; 
+}
+
 //________________________________________________________________
 void AliITStrackerSA::UpdatePoints(){
   //update of points for the estimation of the curvature  
@@ -1138,7 +1097,7 @@ Int_t AliITStrackerSA::FindTrackLowChiSquare() const {
   Double_t minChi2=trk->GetChi2();
   Int_t index=0;
   for(Int_t i=1;i<dim;i++){
-    AliITStrackV2* trk = (AliITStrackV2*)fListOfTracks->At(i);
+    trk = (AliITStrackV2*)fListOfTracks->At(i);
     Double_t chi2=trk->GetChi2();
     if(chi2<minChi2){
       minChi2=chi2;
@@ -1330,3 +1289,4 @@ void AliITStrackerSA::GetCoorErrors(AliITSRecPoint* cl,Float_t &sx,Float_t &sy,
   sz = TMath::Sqrt(cl->GetSigmaZ2());
 */
 }
+