technial fix to suppress the warning
[u/mrichter/AliRoot.git] / ITS / AliITStrackerSA.cxx
index 545c718..ea8abeb 100644 (file)
@@ -161,7 +161,7 @@ void AliITStrackerSA::Init(){
     fPointc[0]=0;
     fPointc[1]=0;
     Int_t nLoops=AliITSReconstructor::GetRecoParam()->GetNLoopsSA();
-    if(nLoops==33){
+    if(nLoops==32){
       SetFixedWindowSizes();
     }else{
       Double_t phimin=AliITSReconstructor::GetRecoParam()->GetMinPhiSA();
@@ -287,6 +287,7 @@ Int_t AliITStrackerSA::FindTracks(AliESDEvent* event, Bool_t useAllClusters){
        dmar[ilay]++;
       }
     }
+    fCluCoord[ilay]->Sort();
   }
    
   // track counter
@@ -690,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();
@@ -708,12 +710,14 @@ Int_t AliITStrackerSA::SearchClusters(Int_t layer,Double_t phiwindow,Double_t la
   Double_t lamExpect=fLambdac;
 
   Int_t ncl = fCluCoord[layer]->GetEntriesFast();
-  for (Int_t index=0; index<ncl; index++) {
-    
+  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;
@@ -721,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();
@@ -769,11 +776,18 @@ Int_t AliITStrackerSA::FindEquation(Double_t x1, Double_t y1, Double_t x2, Doubl
 
    //given (x,y) of three recpoints (in global coordinates) 
    //returns the parameters a,b,c of circonference x*x + y*y +a*x + b*y +c
-
-   Double_t den = (x3-x1)*(y2-y1)-(x2-x1)*(y3-y1);
+   double dx31=x3-x1,dy31=y3-y1,dx21=x2-x1,dy21=y2-y1;
+   Double_t den = dx31*dy21-dx21*dy31;
    if(den==0) return 0;
-   a = ((y3-y1)*(x2*x2+y2*y2-x1*x1-y1*y1)-(y2-y1)*(x3*x3+y3*y3-x1*x1-y1*y1))/den;
-   b = -(x2*x2-x1*x1+y2*y2-y1*y1+a*(x2-x1))/(y2-y1);
+   else den = 1./den;
+   //
+   double r31 = -dx31*(x1+x3) - dy31*(y1+y3);
+   double r21 = -dx21*(x1+x2) - dy21*(y1+y2);
+   //
+   double da = r31*dy21 - r21*dy31;
+   double db = r21*dx31 - r31*dx21;
+   a = da*den;
+   b = db*den;
    c = -x1*x1-y1*y1-a*x1-b*y1;
    return 1;
  }
@@ -945,19 +959,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;
     }
     
     
@@ -1030,3 +1048,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;
+}
+