FairRoot/PandaRoot
AliKFVertex.cxx
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 // Implementation of the AliKFVertex class
3 // .
4 // @author S.Gorbunov, I.Kisel
5 // @version 1.0
6 // @since 13.05.07
7 //
8 // Class to reconstruct and store primary and secondary vertices
9 // The method is described in CBM-SOFT note 2007-003,
10 // ``Reconstruction of decayed particles based on the Kalman filter'',
11 // http://www.gsi.de/documents/DOC-2007-May-14-1.pdf
12 //
13 // This class is ALICE interface to general mathematics in AliKFParticleCore
14 //
15 // -= Copyright &copy ALICE HLT Group =-
16 //____________________________________________________________________________
17 
18 
19 #include "AliKFVertex.h"
20 
21 
22 AliKFVertex::AliKFVertex( const KFPVertex &vertex ): fIsConstrained(0)
23 {
24  // Constructor from ALICE VVertex
25 
26  vertex.GetXYZ( fP );
27  vertex.GetCovarianceMatrix( fC );
28  fChi2 = vertex.GetChi2();
29  fNDF = 2*vertex.GetNContributors() - 3;
30  fQ = 0;
31  fAtProductionVertex = 0;
32  fIsLinearized = 0;
33  fSFromDecay = 0;
34 }
35 
36 /*
37 void AliKFVertex::Print(Option_t* ) const
38 {
39  cout<<"AliKFVertex position: "<<GetX()<<" "<<GetY()<<" "<<GetZ()<<endl;
40  cout<<"AliKFVertex cov. matrix: "<<GetCovariance(0)<<endl;
41  cout<<" "<<GetCovariance(1)<<" "<<GetCovariance(2)<<endl;
42  cout<<" "<<GetCovariance(3)<<" "<<GetCovariance(4)<<" "<<GetCovariance(5)<<endl;
43 }
44  */
45 
46 void AliKFVertex::SetBeamConstraint( float x, float y, float z,
47  float errX, float errY, float errZ )
48 {
49  // Set beam constraint to the vertex
50  fP[0] = x;
51  fP[1] = y;
52  fP[2] = z;
53  fC[0] = errX*errX;
54  fC[1] = 0;
55  fC[2] = errY*errY;
56  fC[3] = 0;
57  fC[4] = 0;
58  fC[5] = errZ*errZ;
59  fIsConstrained = 1;
60 }
61 
63 {
64  fIsConstrained = 0;
65 }
66 
67 void AliKFVertex::ConstructPrimaryVertex( const AliKFParticle *vDaughters[],
68  int NDaughters, Bool_t vtxFlag[],
69  float ChiCut )
70 {
71  //* Primary vertex finder with simple rejection of outliers
72 
73  if( NDaughters<2 ) return;
74  float constrP[3]={fP[0], fP[1], fP[2]};
75  float constrC[6]={fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]};
76 
77  Construct( vDaughters, NDaughters, 0, -1, fIsConstrained );
78 
79  SetVtxGuess( fVtxGuess[0], fVtxGuess[1], fVtxGuess[2] );
80 
81  for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 1;
82 
83  Int_t nRest = NDaughters;
84  while( nRest>2 )
85  {
86  float worstChi = 0.;
87  Int_t worstDaughter = 0;
88  for( Int_t it=0; it<NDaughters; it++ ){
89  if( !vtxFlag[it] ) continue;
90  const AliKFParticle &p = *(vDaughters[it]);
91  AliKFVertex tmp = *this - p;
92  float chi = p.GetDeviationFromVertex( tmp );
93  if( worstChi < chi ){
94  worstChi = chi;
95  worstDaughter = it;
96  }
97  }
98  if( worstChi < ChiCut ) break;
99 
100  vtxFlag[worstDaughter] = 0;
101  *this -= *(vDaughters[worstDaughter]);
102  nRest--;
103  }
104 
105  if( nRest>=2 ) {// final refit
106  SetVtxGuess( fP[0], fP[1], fP[2] );
107  if( fIsConstrained ){
108  fP[0] = constrP[0];
109  fP[1] = constrP[1];
110  fP[2] = constrP[2];
111  for( int i=0; i<6; i++ ) fC[i] = constrC[i];
112  }
113  int nDaughtersNew=0;
114  const AliKFParticle **vDaughtersNew=new const AliKFParticle *[NDaughters];
115  for( int i=0; i<NDaughters; i++ ){
116  if( vtxFlag[i] ) vDaughtersNew[nDaughtersNew++] = vDaughters[i];
117  }
118  Construct( vDaughtersNew, nDaughtersNew, 0, -1, fIsConstrained );
119  delete[] vDaughtersNew;
120  }
121 
122  if( nRest<=2 && GetChi2() > ChiCut*ChiCut*GetNDF() ) {
123  for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 0;
124  fNDF = -3;
125  fChi2 = 0;
126  }
127 }
Double_t p
Definition: anasim.C:58
void ConstructPrimaryVertex(const AliKFParticle *vDaughters[], int NDaughters, Bool_t vtxFlag[], float ChiCut=3.5)
Definition: AliKFVertex.cxx:67
Int_t i
Definition: run_full.C:25
void SetBeamConstraint(float X, float Y, float Z, float ErrX, float ErrY, float ErrZ)
Definition: AliKFVertex.cxx:46
int GetNContributors() const
Definition: KFPVertex.h:33
float GetChi2() const
Definition: KFPVertex.h:31
void GetXYZ(float *position) const
Definition: KFPVertex.h:17
void SetBeamConstraintOff()
Definition: AliKFVertex.cxx:62
Double_t z
Bool_t fIsConstrained
Definition: AliKFVertex.h:86
Double_t x
void GetCovarianceMatrix(float *covmatrix) const
Definition: KFPVertex.h:19
Double_t y