]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliKFVertex.cxx
Access method
[u/mrichter/AliRoot.git] / STEER / AliKFVertex.cxx
index 402ff5407063a9907f41e3467325304d5bf2e2dc..ac65035406e51bc77ef38f0e88d88ac4d35f2b51 100644 (file)
@@ -36,23 +36,41 @@ AliKFVertex::AliKFVertex( const AliESDVertex &vertex )
   fSFromDecay = 0;
 }
 
+
 void AliKFVertex::ConstructPrimaryVertex( const AliKFParticle *vDaughters[], 
-                                         int NDaughters, Double_t ChiCut  )
+                                         int NDaughters, Bool_t vtxFlag[],
+                                         Double_t ChiCut  )
 {
   //* Primary vertex finder with simple rejection of outliers
-
   if( NDaughters<2 ) return;
-  Construct( &(vDaughters[0]), NDaughters );
-    
-  Int_t nt=NDaughters;
-  for( Int_t it=0; it<NDaughters; it++){
-    if( nt<3) return;
-    const AliKFParticle &p = *(vDaughters[it]);
-    AliKFVertex tmp = *this - p;
-    Double_t d = p.GetDeviationFromVertex( tmp );
-    if( d>ChiCut ){  
-      *this = tmp;
-      nt--;
-    }
-  }   
+  Construct( vDaughters, NDaughters );
+  for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 1;
+
+  Int_t nRest = NDaughters;
+  while( nRest>2 )
+    {    
+      Double_t worstChi = 0.;
+      Int_t worstDaughter = 0;
+      for( Int_t it=0; it<NDaughters; it++ ){
+       if( !vtxFlag[it] ) continue;
+       const AliKFParticle &p = *(vDaughters[it]);
+       AliKFVertex tmp = *this - p;
+       Double_t chi = p.GetDeviationFromVertex( tmp );      
+       if( worstChi < chi ){
+         worstChi = chi;
+         worstDaughter = it;
+       }
+      }
+      if( worstChi < ChiCut ) break;
+      
+      vtxFlag[worstDaughter] = 0;    
+      *this -= *(vDaughters[worstDaughter]);
+      nRest--;
+    } 
+
+  if( nRest<=2 && GetChi2()>ChiCut*ChiCut*GetNDF() ){
+    for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 0;
+    fNDF = -3;
+    fChi2 = 0;
+  }
 }