00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "KFVertex.h"
00020
00021 ClassImp(KFVertex)
00022
00023
00024 KFVertex::KFVertex( const VVertex &vertex ): fIsConstrained(0)
00025 {
00026
00027
00028 vertex.GetXYZ( fP );
00029 vertex.GetCovarianceMatrix( fC );
00030 fChi2 = vertex.GetChi2();
00031 fNDF = 2*vertex.GetNContributors() - 3;
00032 fQ = 0;
00033 fAtProductionVertex = 0;
00034 fIsLinearized = 0;
00035 fSFromDecay = 0;
00036 }
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 void KFVertex::SetBeamConstraint( Double_t x, Double_t y, Double_t z,
00049 Double_t errX, Double_t errY, Double_t errZ )
00050 {
00051
00052 fP[0] = x;
00053 fP[1] = y;
00054 fP[2] = z;
00055 fC[0] = errX*errX;
00056 fC[1] = 0;
00057 fC[2] = errY*errY;
00058 fC[3] = 0;
00059 fC[4] = 0;
00060 fC[5] = errZ*errZ;
00061 fIsConstrained = 1;
00062 }
00063
00064 void KFVertex::SetBeamConstraintOff()
00065 {
00066 fIsConstrained = 0;
00067 }
00068
00069 void KFVertex::ConstructPrimaryVertex( const KFParticle *vDaughters[],
00070 int NDaughters, Bool_t vtxFlag[],
00071 Double_t ChiCut )
00072 {
00073
00074
00075 if( NDaughters<2 ) return;
00076 double constrP[3]={fP[0], fP[1], fP[2]};
00077 double constrC[6]={fC[0], fC[1], fC[2], fC[3], fC[4], fC[5]};
00078
00079 Construct( vDaughters, NDaughters, 0, -1, fIsConstrained );
00080
00081 SetVtxGuess( fVtxGuess[0], fVtxGuess[1], fVtxGuess[2] );
00082
00083 for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 1;
00084
00085 Int_t nRest = NDaughters;
00086 while( nRest>2 )
00087 {
00088 Double_t worstChi = 0.;
00089 Int_t worstDaughter = 0;
00090 for( Int_t it=0; it<NDaughters; it++ ){
00091 if( !vtxFlag[it] ) continue;
00092 const KFParticle &p = *(vDaughters[it]);
00093 KFVertex tmp = *this - p;
00094 Double_t chi = p.GetDeviationFromVertex( tmp );
00095 if( worstChi < chi ){
00096 worstChi = chi;
00097 worstDaughter = it;
00098 }
00099 }
00100 if( worstChi < ChiCut ) break;
00101
00102 vtxFlag[worstDaughter] = 0;
00103 *this -= *(vDaughters[worstDaughter]);
00104 nRest--;
00105 }
00106
00107 if( nRest>=2 ){
00108 SetVtxGuess( fP[0], fP[1], fP[2] );
00109 if( fIsConstrained ){
00110 fP[0] = constrP[0];
00111 fP[1] = constrP[1];
00112 fP[2] = constrP[2];
00113 for( int i=0; i<6; i++ ) fC[i] = constrC[i];
00114 }
00115 int nDaughtersNew=0;
00116 const KFParticle **vDaughtersNew=new const KFParticle *[NDaughters];
00117 for( int i=0; i<NDaughters; i++ ){
00118 if( vtxFlag[i] ) vDaughtersNew[nDaughtersNew++] = vDaughters[i];
00119 }
00120 Construct( vDaughtersNew, nDaughtersNew, 0, -1, fIsConstrained );
00121 delete[] vDaughtersNew;
00122 }
00123
00124 if( nRest<=2 && GetChi2()>ChiCut*ChiCut*GetNDF() ){
00125 for( int i=0; i<NDaughters; i++ ) vtxFlag[i] = 0;
00126 fNDF = -3;
00127 fChi2 = 0;
00128 }
00129 }