FairRoot/PandaRoot
KFVertex.cxx
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 // Implementation of the KFVertex 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 KFParticleCore
14 //
15 // -= Copyright &copy ALICE HLT Group =-
16 //____________________________________________________________________________
17 
18 
19 #include "KFVertex.h"
20 
21 
22 KFVertex::KFVertex( 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;
32  fIsLinearized = 0;
33  fSFromDecay = 0;
34 }
35 
36 /*
37 void KFVertex::Print(Option_t* ) const
38 {
39  cout<<"KFVertex position: "<<GetX()<<" "<<GetY()<<" "<<GetZ()<<endl;
40  cout<<"KFVertex 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 KFVertex::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 KFVertex::ConstructPrimaryVertex( const KFParticle *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]={static_cast<float>(fP[0]), static_cast<float>(fP[1]), static_cast<float>(fP[2])};
75  float constrC[6]={static_cast<float>(fC[0]), static_cast<float>(fC[1]), static_cast<float>(fC[2]),
76  static_cast<float>(fC[3]), static_cast<float>(fC[4]), static_cast<float>(fC[5])};
77 
78  Construct( vDaughters, nDaughters, 0, -1, fIsConstrained );
79 
81 
82  for( int i=0; i<nDaughters; i++ ) vtxFlag[i] = 1;
83 
84  Int_t nRest = nDaughters;
85  while( nRest>2 )
86  {
87  float worstChi = 0.;
88  Int_t worstDaughter = 0;
89  for( Int_t it=0; it<nDaughters; it++ ){
90  if( !vtxFlag[it] ) continue;
91  const KFParticle &p = *(vDaughters[it]);
92  KFVertex tmp = *this - p;
93  float chi = p.GetDeviationFromVertex( tmp );
94  if( worstChi < chi ){
95  worstChi = chi;
96  worstDaughter = it;
97  }
98  }
99  if( worstChi < ChiCut ) break;
100 
101  vtxFlag[worstDaughter] = 0;
102  *this -= *(vDaughters[worstDaughter]);
103  nRest--;
104  }
105 
106  if( nRest>=2 ) {// final refit
107  SetVtxGuess( fP[0], fP[1], fP[2] );
108  if( fIsConstrained ){
109  fP[0] = constrP[0];
110  fP[1] = constrP[1];
111  fP[2] = constrP[2];
112  for( int i=0; i<6; i++ ) fC[i] = constrC[i];
113  }
114  int nDaughtersNew=0;
115  const KFParticle **vDaughtersNew=new const KFParticle *[nDaughters];
116  for( int i=0; i<nDaughters; i++ ){
117  if( vtxFlag[i] ) vDaughtersNew[nDaughtersNew++] = vDaughters[i];
118  }
119  Construct( vDaughtersNew, nDaughtersNew, 0, -1, fIsConstrained );
120  delete[] vDaughtersNew;
121  }
122 
123  if( nRest<=2 && GetChi2() > ChiCut*ChiCut*GetNDF() ) {
124  for( int i=0; i<nDaughters; i++ ) vtxFlag[i] = 0;
125  fNDF = -3;
126  fChi2 = 0;
127  }
128 }
Double_t p
Definition: anasim.C:58
Int_t GetNDF() const
Definition: KFParticle.h:497
Int_t i
Definition: run_full.C:25
Double_t fVtxGuess[3]
Double_t fP[8]
int GetNContributors() const
Definition: KFPVertex.h:33
void SetVtxGuess(Double_t x, Double_t y, Double_t z)
Definition: KFParticle.h:442
Double_t GetDeviationFromVertex(const Double_t v[], const Double_t Cv[]=0) const
Definition: KFParticle.h:918
float GetChi2() const
Definition: KFPVertex.h:31
void SetBeamConstraint(float X, float Y, float Z, float ErrX, float ErrY, float ErrZ)
Definition: KFVertex.cxx:46
void GetXYZ(float *position) const
Definition: KFPVertex.h:17
Double_t fSFromDecay
void ConstructPrimaryVertex(const KFParticle *vDaughters[], int NDaughters, Bool_t vtxFlag[], float ChiCut=3.5)
Definition: KFVertex.cxx:67
Double_t z
Double_t fC[36]
Bool_t fIsConstrained
Definition: KFVertex.h:86
void Construct(const KFParticle *vDaughters[], int nDaughters, const KFParticle *ProdVtx=0, Double_t Mass=-1, Bool_t IsConstrained=0)
Definition: KFParticle.h:856
Double_t x
Double_t GetChi2() const
Definition: KFParticle.h:492
void SetBeamConstraintOff()
Definition: KFVertex.cxx:62
Bool_t fAtProductionVertex
KFVertex()
Definition: KFVertex.h:35
void GetCovarianceMatrix(float *covmatrix) const
Definition: KFPVertex.h:19
Double_t y