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 void AliKFParticle::Create( const Double_t Param[], const Double_t Cov[], Int_t Charge, Int_t PID )
31 // Constructor from "cartesian" track, PID hypothesis should be provided
33 // Param[6] = { X, Y, Z, Px, Py, Pz } - position and momentum
34 // Cov [21] = lower-triangular part of the covariance matrix:
38 // Cov. matrix = ( 3 4 5 . . . ) - numbering of covariance elements in Cov[]
40 // ( 10 11 12 13 14 . )
41 // ( 15 16 17 18 19 20 )
43 for( int i=0; i<21; i++ ) C[i] = Cov[i];
45 TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(PID);
46 Double_t mass = (particlePDG) ? particlePDG->Mass() :0.13957;
48 AliKFParticleBase::Initialize( Param, C, Charge, mass );
52 AliKFParticle::AliKFParticle( const AliVTrack &track, Int_t PID )
54 // Constructor from ALICE track, PID hypothesis should be provided
59 track.GetCovarianceXYZPxPyPz( fC );
63 AliKFParticle::AliKFParticle( const AliVVertex &vertex )
65 // Constructor from ALICE vertex
68 vertex.GetCovarianceMatrix( fC );
69 fChi2 = vertex.GetChi2();
70 fNDF = 2*vertex.GetNContributors() - 3;
72 fAtProductionVertex = 0;
78 void AliKFParticle::GetExternalTrackParam( const AliKFParticleBase &p, Double_t &X, Double_t &Alpha, Double_t P[5] )
80 // Conversion to AliExternalTrackParam parameterization
82 Double_t cosA = p.GetPx(), sinA = p.GetPy();
83 Double_t pt = TMath::Sqrt(cosA*cosA + sinA*sinA);
93 Alpha = TMath::ATan2(sinA,cosA);
94 X = p.GetX()*cosA + p.GetY()*sinA;
95 P[0]= p.GetY()*cosA - p.GetX()*sinA;
104 Double_t AliKFParticle::GetDistanceFromVertexXY( const Double_t vtx[] ) const
106 //* Calculate distance from vertex [cm] in XY-plane
108 Double_t mP[8], mC[36];
109 Transport( GetDStoPoint(vtx), mP, mC );
110 Double_t d[2]={ vtx[0]-mP[0], vtx[1]-mP[1] };
111 Double_t dist = TMath::Sqrt( d[0]*d[0]+d[1]*d[1] );
112 Double_t sign = d[0]*mP[3] - d[1]*mP[4];
113 return (sign>=0) ?dist :-dist;
116 Double_t AliKFParticle::GetDistanceFromVertexXY( const AliKFParticle &Vtx ) const
118 //* Calculate distance from vertex [cm] in XY-plane
120 return GetDistanceFromVertexXY( Vtx.fP );
123 Double_t AliKFParticle::GetDistanceFromVertexXY( const AliVVertex &Vtx ) const
125 //* Calculate distance from vertex [cm] in XY-plane
127 return GetDistanceFromVertexXY( AliKFParticle(Vtx).fP );
130 Double_t AliKFParticle::GetDistanceFromParticleXY( const AliKFParticle &p ) const
132 //* Calculate distance to other particle [cm]
135 GetDStoParticleXY( p, dS, dS1 );
136 Double_t mP[8], mC[36], mP1[8], mC1[36];
137 Transport( dS, mP, mC );
138 p.Transport( dS1, mP1, mC1 );
139 Double_t dx = mP[0]-mP1[0];
140 Double_t dy = mP[1]-mP1[1];
141 return TMath::Sqrt(dx*dx+dy*dy);
144 Double_t AliKFParticle::GetDeviationFromParticleXY( const AliKFParticle &p ) const
146 //* Calculate sqrt(Chi2/ndf) deviation from other particle
149 GetDStoParticleXY( p, dS, dS1 );
150 Double_t mP1[8], mC1[36];
151 p.Transport( dS1, mP1, mC1 );
153 Double_t d[2]={ fP[0]-mP1[0], fP[1]-mP1[1] };
155 Double_t sigmaS = .1+10.*TMath::Sqrt( (d[0]*d[0]+d[1]*d[1] )/
156 (mP1[3]*mP1[3]+mP1[4]*mP1[4] ) );
158 Double_t h[2] = { mP1[3]*sigmaS, mP1[4]*sigmaS };
164 return GetDeviationFromVertexXY( mP1, mC1 )*TMath::Sqrt(2./1.);
168 Double_t AliKFParticle::GetDeviationFromVertexXY( const Double_t v[], const Double_t Cv[] ) const
170 //* Calculate sqrt(Chi2/ndf) deviation from vertex
171 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
176 Transport( GetDStoPoint(v), mP, mC );
178 Double_t d[2]={ v[0]-mP[0], v[1]-mP[1] };
180 Double_t sigmaS = .1+10.*TMath::Sqrt( (d[0]*d[0]+d[1]*d[1] )/
181 (mP[3]*mP[3]+mP[4]*mP[4] ) );
183 Double_t h[2] = { mP[3]*sigmaS, mP[4]*sigmaS };
185 Double_t mSi[3] = { mC[0] +h[0]*h[0],
186 mC[1] +h[1]*h[0], mC[2] +h[1]*h[1] };
193 Double_t s = ( mSi[0]*mSi[2] - mSi[1]*mSi[1] );
194 s = ( s > 1.E-20 ) ?1./s :0;
196 Double_t mS[3] = { mSi[2],
199 return TMath::Sqrt( TMath::Abs(s*( ( mS[0]*d[0] + mS[1]*d[1] )*d[0]
200 +(mS[1]*d[0] + mS[2]*d[1] )*d[1] ))/1);
204 Double_t AliKFParticle::GetDeviationFromVertexXY( const AliKFParticle &Vtx ) const
206 //* Calculate sqrt(Chi2/ndf) deviation from vertex
207 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
209 return GetDeviationFromVertexXY( Vtx.fP, Vtx.fC );
212 Double_t AliKFParticle::GetDeviationFromVertexXY( const AliVVertex &Vtx ) const
214 //* Calculate sqrt(Chi2/ndf) deviation from vertex
215 //* v = [xyz], Cv=[Cxx,Cxy,Cyy,Cxz,Cyz,Czz]-covariance matrix
217 AliKFParticle v(Vtx);
218 return GetDeviationFromVertexXY( v.fP, v.fC );
222 Double_t AliKFParticle::GetAngle ( const AliKFParticle &p ) const
224 //* Calculate the opening angle between two particles
227 GetDStoParticle( p, dS, dS1 );
228 Double_t mP[8], mC[36], mP1[8], mC1[36];
229 Transport( dS, mP, mC );
230 p.Transport( dS1, mP1, mC1 );
231 Double_t n = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] + mP[5]*mP[5] );
232 Double_t n1= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] + mP1[5]*mP1[5] );
235 if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] + mP[5]*mP1[5] )/n;
236 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
237 else a = (a>=0) ?0 :TMath::Pi();
241 Double_t AliKFParticle::GetAngleXY( const AliKFParticle &p ) const
243 //* Calculate the opening angle between two particles in XY plane
246 GetDStoParticleXY( p, dS, dS1 );
247 Double_t mP[8], mC[36], mP1[8], mC1[36];
248 Transport( dS, mP, mC );
249 p.Transport( dS1, mP1, mC1 );
250 Double_t n = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] );
251 Double_t n1= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] );
254 if( n>1.e-8 ) a = ( mP[3]*mP1[3] + mP[4]*mP1[4] )/n;
255 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
256 else a = (a>=0) ?0 :TMath::Pi();
260 Double_t AliKFParticle::GetAngleRZ( const AliKFParticle &p ) const
262 //* Calculate the opening angle between two particles in RZ plane
265 GetDStoParticle( p, dS, dS1 );
266 Double_t mP[8], mC[36], mP1[8], mC1[36];
267 Transport( dS, mP, mC );
268 p.Transport( dS1, mP1, mC1 );
269 Double_t nr = TMath::Sqrt( mP[3]*mP[3] + mP[4]*mP[4] );
270 Double_t n1r= TMath::Sqrt( mP1[3]*mP1[3] + mP1[4]*mP1[4] );
271 Double_t n = TMath::Sqrt( nr*nr + mP[5]*mP[5] );
272 Double_t n1= TMath::Sqrt( n1r*n1r + mP1[5]*mP1[5] );
275 if( n>1.e-8 ) a = ( nr*n1r +mP[5]*mP1[5])/n;
276 if (TMath::Abs(a)<1.) a = TMath::ACos(a);
277 else a = (a>=0) ?0 :TMath::Pi();
284 #include "AliExternalTrackParam.h"
286 void AliKFParticle::GetDStoParticleALICE( const AliKFParticleBase &p,
287 Double_t &DS, Double_t &DS1 )
291 Double_t x1, a1, x2, a2;
292 Double_t par1[5], par2[5], cov[15];
293 for(int i=0; i<15; i++) cov[i] = 0;
294 cov[0] = cov[2] = cov[5] = cov[9] = cov[14] = .001;
296 GetExternalTrackParam( *this, x1, a1, par1 );
297 GetExternalTrackParam( p, x2, a2, par2 );
299 AliExternalTrackParam t1(x1,a1, par1, cov);
300 AliExternalTrackParam t2(x2,a2, par2, cov);
302 Double_t xe1=0, xe2=0;
303 t1.GetDCA( &t2, -GetFieldAlice(), xe1, xe2 );
304 t1.PropagateTo( xe1, -GetFieldAlice() );
305 t2.PropagateTo( xe2, -GetFieldAlice() );
307 Double_t xyz1[3], xyz2[3];
311 DS = GetDStoPoint( xyz1 );
312 DS1 = p.GetDStoPoint( xyz2 );