ROOT logo
//----------------------------------------------------------------------------
// Implementation of the AliKFVertex class
// .
// @author  S.Gorbunov, I.Kisel
// @version 1.0
// @since   13.05.07
// 
// Class to reconstruct and store primary and secondary vertices
// The method is described in CBM-SOFT note 2007-003, 
// ``Reconstruction of decayed particles based on the Kalman filter'', 
// http://www.gsi.de/documents/DOC-2007-May-14-1.pdf
//
// This class is ALICE interface to general mathematics in AliKFParticleCore
// 
//  -= Copyright &copy ALICE HLT Group =-
//____________________________________________________________________________


#include "AliKFVertex.h"

ClassImp(AliKFVertex)


AliKFVertex::AliKFVertex( const AliVVertex &vertex ): fIsConstrained(0)
{
  // Constructor from ALICE VVertex

  vertex.GetXYZ( fP );
  vertex.GetCovarianceMatrix( fC );  
  fChi2 = vertex.GetChi2();  
  fNDF = 2*vertex.GetNContributors() - 3;
  fQ = 0;
  fAtProductionVertex = 0;
  fIsLinearized = 0;
  fSFromDecay = 0;
}

/*
void     AliKFVertex::Print(Option_t* ) const
{  
  cout<<"AliKFVertex position:    "<<GetX()<<" "<<GetY()<<" "<<GetZ()<<endl;
  cout<<"AliKFVertex cov. matrix: "<<GetCovariance(0)<<endl;
  cout<<"                         "<<GetCovariance(1)<<" "<<GetCovariance(2)<<endl;
  cout<<"                         "<<GetCovariance(3)<<" "<<GetCovariance(4)<<" "<<GetCovariance(5)<<endl;
}
  */

void AliKFVertex::SetBeamConstraint( Double_t x, Double_t y, Double_t z, 
				     Double_t errX, Double_t errY, Double_t errZ )
{
  // Set beam constraint to the vertex
  fP[0] = x;
  fP[1] = y;
  fP[2] = z;
  fC[0] = errX*errX;
  fC[1] = 0;
  fC[2] = errY*errY;
  fC[3] = 0;
  fC[4] = 0;
  fC[5] = errZ*errZ;
  fIsConstrained = 1;
}

void AliKFVertex::SetBeamConstraintOff()
{
  fIsConstrained = 0;
}

void AliKFVertex::ConstructPrimaryVertex( const AliKFParticle *vDaughters[], 
					  int NDaughters, Bool_t vtxFlag[],
					  Double_t ChiCut  )
{
  //* Primary vertex finder with simple rejection of outliers

  if( NDaughters<2 ) return;
  double constrP[3]={fP[0], fP[1], fP[2]};
  double constrC[6]={fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]};

  Construct( vDaughters, NDaughters, 0, -1, fIsConstrained );

  SetVtxGuess( fVtxGuess[0], fVtxGuess[1], fVtxGuess[2] );

  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 ){// final refit     
    SetVtxGuess( fP[0], fP[1], fP[2] );
    if( fIsConstrained ){
      fP[0] = constrP[0];
      fP[1] = constrP[1];
      fP[2] = constrP[2];
      for( int i=0; i<6; i++ ) fC[i] = constrC[i];
    }
    int nDaughtersNew=0;
    const AliKFParticle **vDaughtersNew=new const AliKFParticle *[NDaughters];
    for( int i=0; i<NDaughters; i++ ){
      if( vtxFlag[i] )  vDaughtersNew[nDaughtersNew++] = vDaughters[i];
    }
    Construct( vDaughtersNew, nDaughtersNew, 0, -1, fIsConstrained );
    delete[] vDaughtersNew;
  }

  if( nRest<=2 && GetChi2()>ChiCut*ChiCut*GetNDF() ){
    for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 0;
    fNDF = -3;
    fChi2 = 0;
  }
}
 AliKFVertex.cxx:1
 AliKFVertex.cxx:2
 AliKFVertex.cxx:3
 AliKFVertex.cxx:4
 AliKFVertex.cxx:5
 AliKFVertex.cxx:6
 AliKFVertex.cxx:7
 AliKFVertex.cxx:8
 AliKFVertex.cxx:9
 AliKFVertex.cxx:10
 AliKFVertex.cxx:11
 AliKFVertex.cxx:12
 AliKFVertex.cxx:13
 AliKFVertex.cxx:14
 AliKFVertex.cxx:15
 AliKFVertex.cxx:16
 AliKFVertex.cxx:17
 AliKFVertex.cxx:18
 AliKFVertex.cxx:19
 AliKFVertex.cxx:20
 AliKFVertex.cxx:21
 AliKFVertex.cxx:22
 AliKFVertex.cxx:23
 AliKFVertex.cxx:24
 AliKFVertex.cxx:25
 AliKFVertex.cxx:26
 AliKFVertex.cxx:27
 AliKFVertex.cxx:28
 AliKFVertex.cxx:29
 AliKFVertex.cxx:30
 AliKFVertex.cxx:31
 AliKFVertex.cxx:32
 AliKFVertex.cxx:33
 AliKFVertex.cxx:34
 AliKFVertex.cxx:35
 AliKFVertex.cxx:36
 AliKFVertex.cxx:37
 AliKFVertex.cxx:38
 AliKFVertex.cxx:39
 AliKFVertex.cxx:40
 AliKFVertex.cxx:41
 AliKFVertex.cxx:42
 AliKFVertex.cxx:43
 AliKFVertex.cxx:44
 AliKFVertex.cxx:45
 AliKFVertex.cxx:46
 AliKFVertex.cxx:47
 AliKFVertex.cxx:48
 AliKFVertex.cxx:49
 AliKFVertex.cxx:50
 AliKFVertex.cxx:51
 AliKFVertex.cxx:52
 AliKFVertex.cxx:53
 AliKFVertex.cxx:54
 AliKFVertex.cxx:55
 AliKFVertex.cxx:56
 AliKFVertex.cxx:57
 AliKFVertex.cxx:58
 AliKFVertex.cxx:59
 AliKFVertex.cxx:60
 AliKFVertex.cxx:61
 AliKFVertex.cxx:62
 AliKFVertex.cxx:63
 AliKFVertex.cxx:64
 AliKFVertex.cxx:65
 AliKFVertex.cxx:66
 AliKFVertex.cxx:67
 AliKFVertex.cxx:68
 AliKFVertex.cxx:69
 AliKFVertex.cxx:70
 AliKFVertex.cxx:71
 AliKFVertex.cxx:72
 AliKFVertex.cxx:73
 AliKFVertex.cxx:74
 AliKFVertex.cxx:75
 AliKFVertex.cxx:76
 AliKFVertex.cxx:77
 AliKFVertex.cxx:78
 AliKFVertex.cxx:79
 AliKFVertex.cxx:80
 AliKFVertex.cxx:81
 AliKFVertex.cxx:82
 AliKFVertex.cxx:83
 AliKFVertex.cxx:84
 AliKFVertex.cxx:85
 AliKFVertex.cxx:86
 AliKFVertex.cxx:87
 AliKFVertex.cxx:88
 AliKFVertex.cxx:89
 AliKFVertex.cxx:90
 AliKFVertex.cxx:91
 AliKFVertex.cxx:92
 AliKFVertex.cxx:93
 AliKFVertex.cxx:94
 AliKFVertex.cxx:95
 AliKFVertex.cxx:96
 AliKFVertex.cxx:97
 AliKFVertex.cxx:98
 AliKFVertex.cxx:99
 AliKFVertex.cxx:100
 AliKFVertex.cxx:101
 AliKFVertex.cxx:102
 AliKFVertex.cxx:103
 AliKFVertex.cxx:104
 AliKFVertex.cxx:105
 AliKFVertex.cxx:106
 AliKFVertex.cxx:107
 AliKFVertex.cxx:108
 AliKFVertex.cxx:109
 AliKFVertex.cxx:110
 AliKFVertex.cxx:111
 AliKFVertex.cxx:112
 AliKFVertex.cxx:113
 AliKFVertex.cxx:114
 AliKFVertex.cxx:115
 AliKFVertex.cxx:116
 AliKFVertex.cxx:117
 AliKFVertex.cxx:118
 AliKFVertex.cxx:119
 AliKFVertex.cxx:120
 AliKFVertex.cxx:121
 AliKFVertex.cxx:122
 AliKFVertex.cxx:123
 AliKFVertex.cxx:124
 AliKFVertex.cxx:125
 AliKFVertex.cxx:126
 AliKFVertex.cxx:127
 AliKFVertex.cxx:128
 AliKFVertex.cxx:129