1 //----------------------------------------------------------------------------
2 // Implementation of the AliKFParticle class
4 // @author S.Gorbunov, I.Kisel
8 // Class to reconstruct and store the decayed particle parameters.
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
13 // This class is ALICE interface to general mathematics in AliKFParticleCore
15 // -= Copyright © ALICE HLT Group =-
16 //____________________________________________________________________________
19 #include "AliKFParticle.h"
20 #include "TDatabasePDG.h"
21 #include "TParticlePDG.h"
22 #include "AliVTrack.h"
23 #include "AliVVertex.h"
25 ClassImp(AliKFParticle)
27 Double_t AliKFParticle::fgBz = -5.; //* Bz compoment of the magnetic field
29 AliKFParticle::AliKFParticle( const AliKFParticle &d1, const AliKFParticle &d2, Bool_t gamma )
37 ConstructGamma(d1, d2);
40 void AliKFParticle::Create( const Double_t Param[], const Double_t Cov[], Int_t Charge, Int_t PID )
42 // Constructor from "cartesian" track, PID hypothesis should be provided
44 // Param[6] = { X, Y, Z, Px, Py, Pz } - position and momentum
45 // Cov [21] = lower-triangular part of the covariance matrix:
49 // Cov. matrix = ( 3 4 5 . . . ) - numbering of covariance elements in Cov[]
51 // ( 10 11 12 13 14 . )
52 // ( 15 16 17 18 19 20 )
54 for( int i=0; i<21; i++ ) C[i] = Cov[i];
56 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(PID);
57 Double_t mass = (particlePDG) ? particlePDG->Mass() :0.13957;
59 AliKFParticleBase::Initialize( Param, C, Charge, mass );
62 AliKFParticle::AliKFParticle( const AliVTrack &track, Int_t PID )
64 // Constructor from ALICE track, PID hypothesis should be provided
69 track.GetCovarianceXYZPxPyPz( fC );
73 AliKFParticle::AliKFParticle( const AliVVertex &vertex )
75 // Constructor from ALICE vertex
78 vertex.GetCovarianceMatrix( fC );
79 fChi2 = vertex.GetChi2();
80 fNDF = 2*vertex.GetNContributors() - 3;
82 fAtProductionVertex = 0;
87 void AliKFParticle::GetExternalTrackParam( const AliKFParticleBase &p, Double_t &X, Double_t &Alpha, Double_t P[5] )
89 // Conversion to AliExternalTrackParam parameterization
91 Double_t cosA = p.GetPx(), sinA = p.GetPy();
92 Double_t pt = TMath::Sqrt(cosA*cosA + sinA*sinA);
102 Alpha = TMath::ATan2(sinA,cosA);
103 X = p.GetX()*cosA + p.GetY()*sinA;
104 P[0]= p.GetY()*cosA - p.GetX()*sinA;
111 Bool_t AliKFParticle::GetDistanceFromVertexXY( const Double_t vtx[], const Double_t Cv[], Double_t &val, Double_t &err ) const
113 //* Calculate DCA distance from vertex (transverse impact parameter) in XY
114 //* v = [xy], Cv=[Cxx,Cxy,Cyy ]-covariance matrix
121 Transport( GetDStoPoint(vtx), mP, mC );
123 Double_t dx = mP[0] - vtx[0];
124 Double_t dy = mP[1] - vtx[1];
127 Double_t pt = TMath::Sqrt(px*px + py*py);
141 Double_t h3 = (dy*ey + dx*ex)*ey/pt;
142 Double_t h4 = -(dy*ey + dx*ex)*ex/pt;
145 h0*(h0*GetCovariance(0,0) + h1*GetCovariance(0,1) + h3*GetCovariance(0,3) + h4*GetCovariance(0,4) ) +
146 h1*(h0*GetCovariance(1,0) + h1*GetCovariance(1,1) + h3*GetCovariance(1,3) + h4*GetCovariance(1,4) ) +
147 h3*(h0*GetCovariance(3,0) + h1*GetCovariance(3,1) + h3*GetCovariance(3,3) + h4*GetCovariance(3,4) ) +
148 h4*(h0*GetCovariance(4,0) + h1*GetCovariance(4,1) + h3*GetCovariance(4,3) + h4*GetCovariance(4,4) );
151 err+= h0*(h0*Cv[0] + h1*Cv[1] ) + h1*(h0*Cv[1] + h1*Cv[2] );
154 err = TMath::Sqrt(TMath::Abs(err));
159 Bool_t AliKFParticle::GetDistanceFromVertexXY( const Double_t vtx[], Double_t &val, Double_t &err ) const
161 return GetDistanceFromVertexXY( vtx, 0, val, err );
165 Bool_t AliKFParticle::GetDistanceFromVertexXY( const AliKFParticle &Vtx, Double_t &val, Double_t &err ) const
167 //* Calculate distance from vertex [cm] in XY-plane
169 return GetDistanceFromVertexXY( Vtx.fP, Vtx.fC, val, err );
172 Bool_t AliKFParticle::GetDistanceFromVertexXY( const AliVVertex &Vtx, Double_t &val, Double_t &err ) const
174 //* Calculate distance from vertex [cm] in XY-plane
176 return GetDistanceFromVertexXY( AliKFParticle(Vtx), val, err );
179 Double_t AliKFParticle::GetDistanceFromVertexXY( const Double_t vtx[] ) const
181 //* Calculate distance from vertex [cm] in XY-plane
183 GetDistanceFromVertexXY( vtx, 0, val, err );
187 Double_t AliKFParticle::GetDistanceFromVertexXY( const AliKFParticle &Vtx ) const
189 //* Calculate distance from vertex [cm] in XY-plane
191 return GetDistanceFromVertexXY( Vtx.fP );
194 Double_t AliKFParticle::GetDistanceFromVertexXY( const AliVVertex &Vtx ) const
196 //* Calculate distance from vertex [cm] in XY-plane
198 return GetDistanceFromVertexXY( AliKFParticle(Vtx).fP );
201 Double_t AliKFParticle::GetDistanceFromParticleXY( const AliKFParticle &p ) const
203 //* Calculate distance to other particle [cm]
206 GetDStoParticleXY( p, dS, dS1 );
207 Double_t mP[8], mC[36], mP1[8], mC1[36];
208 Transport( dS, mP, mC );
209 p.Transport( dS1, mP1, mC1 );
210 Double_t dx = mP[0]-mP1[0];
211 Double_t dy = mP[1]-mP1[1];
212 return TMath::Sqrt(dx*dx+dy*dy);
215 Double_t AliKFParticle::GetDeviationFromParticleXY( const AliKFParticle &p ) const
217 //* Calculate sqrt(Chi2/ndf) deviation from other particle
220 GetDStoParticleXY( p, dS, dS1 );
221 Double_t mP1[8], mC1[36];
222 p.Transport( dS1, mP1, mC1 );
224 Double_t d[2]={ fP[0]-mP1[0], fP[1]-mP1[1] };
226 Double_t sigmaS = .1+10.*TMath::Sqrt( (d[0]*d[0]+d[1]*d[1] )/
227 (mP1[3]*mP1[3]+mP1[4]*mP1[4] ) );
229 Double_t h[2] = { mP1[3]*sigmaS, mP1[4]*sigmaS };
235 return GetDeviationFromVertexXY( mP1, mC1 )*TMath::Sqrt(2./1.);
239 Double_t AliKFParticle::GetDeviationFromVertexXY( const Double_t vtx[], const Double_t Cv[] ) const
241 //* Calculate sqrt(Chi2/ndf) deviation from vertex
242 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
245 Bool_t problem = GetDistanceFromVertexXY( vtx, Cv, val, err );
246 if( problem || err<1.e-20 ) return 1.e4;
251 Double_t AliKFParticle::GetDeviationFromVertexXY( const AliKFParticle &Vtx ) const
253 //* Calculate sqrt(Chi2/ndf) deviation from vertex
254 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
256 return GetDeviationFromVertexXY( Vtx.fP, Vtx.fC );
259 Double_t AliKFParticle::GetDeviationFromVertexXY( const AliVVertex &Vtx ) const
261 //* Calculate sqrt(Chi2/ndf) deviation from vertex
262 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
264 AliKFParticle v(Vtx);
265 return GetDeviationFromVertexXY( v.fP, v.fC );
268 Double_t AliKFParticle::GetAngle ( const AliKFParticle &p ) const
270 //* Calculate the opening angle between two particles
273 GetDStoParticle( p, dS, dS1 );
274 Double_t mP[8], mC[36], mP1[8], mC1[36];
275 Transport( dS, mP, mC );
276 p.Transport( dS1, mP1, mC1 );
277 Double_t n = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] + mP[5]*mP[5] );
278 Double_t n1= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] + mP1[5]*mP1[5] );
281 if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] + mP[5]*mP1[5] )/n;
282 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
283 else a = (a>=0) ?0 :TMath::Pi();
287 Double_t AliKFParticle::GetAngleXY( const AliKFParticle &p ) const
289 //* Calculate the opening angle between two particles in XY plane
292 GetDStoParticleXY( p, dS, dS1 );
293 Double_t mP[8], mC[36], mP1[8], mC1[36];
294 Transport( dS, mP, mC );
295 p.Transport( dS1, mP1, mC1 );
296 Double_t n = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] );
297 Double_t n1= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] );
300 if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] )/n;
301 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
302 else a = (a>=0) ?0 :TMath::Pi();
306 Double_t AliKFParticle::GetAngleRZ( const AliKFParticle &p ) const
308 //* Calculate the opening angle between two particles in RZ plane
311 GetDStoParticle( p, dS, dS1 );
312 Double_t mP[8], mC[36], mP1[8], mC1[36];
313 Transport( dS, mP, mC );
314 p.Transport( dS1, mP1, mC1 );
315 Double_t nr = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] );
316 Double_t n1r= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] );
317 Double_t n = TMath::Sqrt( nr*nr + mP[5]*mP[5] );
318 Double_t n1= TMath::Sqrt( n1r*n1r + mP1[5]*mP1[5] );
321 if( n>1.e-8 ) a = ( nr*n1r +mP[5]*mP1[5])/n;
322 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
323 else a = (a>=0) ?0 :TMath::Pi();
330 #include "AliExternalTrackParam.h"
332 void AliKFParticle::GetDStoParticleALICE( const AliKFParticleBase &p,
333 Double_t &DS, Double_t &DS1 )
337 Double_t x1, a1, x2, a2;
338 Double_t par1[5], par2[5], cov[15];
339 for(int i=0; i<15; i++) cov[i] = 0;
340 cov[0] = cov[2] = cov[5] = cov[9] = cov[14] = .001;
342 GetExternalTrackParam( *this, x1, a1, par1 );
343 GetExternalTrackParam( p, x2, a2, par2 );
345 AliExternalTrackParam t1(x1,a1, par1, cov);
346 AliExternalTrackParam t2(x2,a2, par2, cov);
348 Double_t xe1=0, xe2=0;
349 t1.GetDCA( &t2, -GetFieldAlice(), xe1, xe2 );
350 t1.PropagateTo( xe1, -GetFieldAlice() );
351 t2.PropagateTo( xe2, -GetFieldAlice() );
353 Double_t xyz1[3], xyz2[3];
357 DS = GetDStoPoint( xyz1 );
358 DS1 = p.GetDStoPoint( xyz2 );