19 #include "KFParticle.h"
20 #include "TDatabasePDG.h"
21 #include "TParticlePDG.h"
26 Double_t KFParticle::fgBz = -5.;
28 void KFParticle::Create(
const Double_t Param[],
const Double_t Cov[], Int_t Charge, Int_t PID )
42 for(
int i=0; i<21; i++ ) C[i] = Cov[i];
44 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(PID);
45 Double_t mass = (particlePDG) ? particlePDG->Mass() :0.13957;
47 KFParticleBase::Initialize( Param, C, Charge, mass, PID );
50 KFParticle::KFParticle(
const MTrack &
track, Int_t PID )
57 track.GetCovarianceXYZPxPyPz( fC );
66 vertex.GetCovarianceMatrix( fC );
67 fChi2 = vertex.GetChi2();
68 fNDF = 2*vertex.GetNContributors() - 3;
70 fAtProductionVertex = 0;
75 void KFParticle::GetExternalTrackParam(
const KFParticleBase &p, Double_t &X, Double_t &Alpha, Double_t P[5] )
79 Double_t cosA = p.GetPx(), sinA = p.GetPy();
80 Double_t pt = TMath::Sqrt(cosA*cosA + sinA*sinA);
90 Alpha = TMath::ATan2(sinA,cosA);
91 X = p.GetX()*cosA + p.GetY()*sinA;
92 P[0]= p.GetY()*cosA - p.GetX()*sinA;
99 Bool_t KFParticle::GetDistanceFromVertexXY(
const Double_t vtx[],
const Double_t Cv[], Double_t &val, Double_t &err )
const
109 Transport( GetDStoPoint(vtx), mP, mC );
111 Double_t dx = mP[0] - vtx[0];
112 Double_t dy = mP[1] - vtx[1];
115 Double_t pt = TMath::Sqrt(px*px + py*py);
129 Double_t h3 = (dy*ey + dx*ex)*ey/pt;
130 Double_t h4 = -(dy*ey + dx*ex)*ex/pt;
133 h0*(h0*GetCovariance(0,0) + h1*GetCovariance(0,1) + h3*GetCovariance(0,3) + h4*GetCovariance(0,4) ) +
134 h1*(h0*GetCovariance(1,0) + h1*GetCovariance(1,1) + h3*GetCovariance(1,3) + h4*GetCovariance(1,4) ) +
135 h3*(h0*GetCovariance(3,0) + h1*GetCovariance(3,1) + h3*GetCovariance(3,3) + h4*GetCovariance(3,4) ) +
136 h4*(h0*GetCovariance(4,0) + h1*GetCovariance(4,1) + h3*GetCovariance(4,3) + h4*GetCovariance(4,4) );
139 err+= h0*(h0*Cv[0] + h1*Cv[1] ) + h1*(h0*Cv[1] + h1*Cv[2] );
142 err = TMath::Sqrt(TMath::Abs(err));
147 Bool_t KFParticle::GetDistanceFromVertexXY(
const Double_t vtx[], Double_t &val, Double_t &err )
const
149 return GetDistanceFromVertexXY( vtx, 0, val, err );
153 Bool_t KFParticle::GetDistanceFromVertexXY(
const KFParticle &Vtx, Double_t &val, Double_t &err )
const
157 return GetDistanceFromVertexXY( Vtx.fP, Vtx.fC, val, err );
160 Bool_t KFParticle::GetDistanceFromVertexXY(
const MVertex &Vtx, Double_t &val, Double_t &err )
const
164 return GetDistanceFromVertexXY(
KFParticle(Vtx), val, err );
167 Double_t KFParticle::GetDistanceFromVertexXY(
const Double_t vtx[] )
const
171 GetDistanceFromVertexXY( vtx, 0, val, err );
175 Double_t KFParticle::GetDistanceFromVertexXY(
const KFParticle &Vtx )
const
179 return GetDistanceFromVertexXY( Vtx.fP );
182 Double_t KFParticle::GetDistanceFromVertexXY(
const MVertex &Vtx )
const
186 return GetDistanceFromVertexXY(
KFParticle(Vtx).fP );
189 Double_t KFParticle::GetDistanceFromParticleXY(
const KFParticle &p )
const
194 GetDStoParticleXY( p, dS, dS1 );
195 Double_t mP[8], mC[36], mP1[8], mC1[36];
196 Transport( dS, mP, mC );
197 p.Transport( dS1, mP1, mC1 );
198 Double_t dx = mP[0]-mP1[0];
199 Double_t dy = mP[1]-mP1[1];
200 return TMath::Sqrt(dx*dx+dy*dy);
203 Double_t KFParticle::GetDeviationFromParticleXY(
const KFParticle &p )
const
208 GetDStoParticleXY( p, dS, dS1 );
209 Double_t mP1[8], mC1[36];
210 p.Transport( dS1, mP1, mC1 );
212 Double_t d[2]={ fP[0]-mP1[0], fP[1]-mP1[1] };
214 Double_t sigmaS = .1+10.*TMath::Sqrt( (d[0]*d[0]+d[1]*d[1] )/
215 (mP1[3]*mP1[3]+mP1[4]*mP1[4] ) );
217 Double_t h[2] = { mP1[3]*sigmaS, mP1[4]*sigmaS };
223 return GetDeviationFromVertexXY( mP1, mC1 )*TMath::Sqrt(2./1.);
227 Double_t KFParticle::GetDeviationFromVertexXY(
const Double_t vtx[],
const Double_t Cv[] )
const
233 Bool_t problem = GetDistanceFromVertexXY( vtx, Cv, val, err );
234 if( problem || err<1.e-20 )
return 1.e4;
239 Double_t KFParticle::GetDeviationFromVertexXY(
const KFParticle &Vtx )
const
244 return GetDeviationFromVertexXY( Vtx.fP, Vtx.fC );
247 Double_t KFParticle::GetDeviationFromVertexXY(
const MVertex &Vtx )
const
253 return GetDeviationFromVertexXY( v.fP, v.fC );
256 Double_t KFParticle::GetAngle (
const KFParticle &p )
const
261 GetDStoParticle( p, dS, dS1 );
262 Double_t mP[8], mC[36], mP1[8], mC1[36];
263 Transport( dS, mP, mC );
264 p.Transport( dS1, mP1, mC1 );
265 Double_t n = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] + mP[5]*mP[5] );
266 Double_t n1= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] + mP1[5]*mP1[5] );
269 if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] + mP[5]*mP1[5] )/n;
270 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
271 else a = (a>=0) ?0 :TMath::Pi();
275 Double_t KFParticle::GetAngleXY(
const KFParticle &p )
const
280 GetDStoParticleXY( p, dS, dS1 );
281 Double_t mP[8], mC[36], mP1[8], mC1[36];
282 Transport( dS, mP, mC );
283 p.Transport( dS1, mP1, mC1 );
284 Double_t n = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] );
285 Double_t n1= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] );
288 if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] )/n;
289 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
290 else a = (a>=0) ?0 :TMath::Pi();
294 Double_t KFParticle::GetAngleRZ(
const KFParticle &p )
const
299 GetDStoParticle( p, dS, dS1 );
300 Double_t mP[8], mC[36], mP1[8], mC1[36];
301 Transport( dS, mP, mC );
302 p.Transport( dS1, mP1, mC1 );
303 Double_t nr = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] );
304 Double_t n1r= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] );
305 Double_t n = TMath::Sqrt( nr*nr + mP[5]*mP[5] );
306 Double_t n1= TMath::Sqrt( n1r*n1r + mP1[5]*mP1[5] );
309 if( n>1.e-8 ) a = ( nr*n1r +mP[5]*mP1[5])/n;
310 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
311 else a = (a>=0) ?0 :TMath::Pi();
Bool_t fIsLinearized
Guess for the position of the decay vertex ( used for linearisation of equations ) ...