#include "AliKFVertex.h"
-
+#include "Riostream.h"
ClassImp(AliKFVertex)
-AliKFVertex::AliKFVertex( const AliESDVertex &vertex )
+AliKFVertex::AliKFVertex( const AliVVertex &vertex ): fIsConstrained(0)
{
- // Constructor from ALICE ESD vertex
+ // Constructor from ALICE VVertex
vertex.GetXYZ( fP );
- vertex.GetCovMatrix( fC );
- fChi2 = vertex.GetChi2();
+ vertex.GetCovarianceMatrix( fC );
+ fChi2 = vertex.GetChi2();
fNDF = 2*vertex.GetNContributors() - 3;
fQ = 0;
fAtProductionVertex = 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, 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, 0, -1, fIsConstrained );
+ 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;
+ }
}