]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliKFParticle.cxx
db01fae0301464b60cab4fccb65e3cf49072066f
[u/mrichter/AliRoot.git] / STEER / AliKFParticle.cxx
1 //----------------------------------------------------------------------------
2 // Implementation of the AliKFParticle class
3 // .
4 // @author  S.Gorbunov, I.Kisel
5 // @version 1.0
6 // @since   13.05.07
7 // 
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
12 //
13 // This class is ALICE interface to general mathematics in AliKFParticleCore
14 // 
15 //  -= Copyright &copy ALICE HLT Group =-
16 //____________________________________________________________________________
17
18
19 #include "AliKFParticle.h"
20 #include "TDatabasePDG.h"
21 #include "TParticlePDG.h"
22 #include "AliExternalTrackParam.h"
23 #include "AliHelix.h"
24 //#include "TMath.h"
25
26 ClassImp(AliKFParticle);
27
28 Double_t AliKFParticle::fgBz = -5.;  //* Bz compoment of the magnetic field
29
30 AliKFParticle::AliKFParticle( const AliExternalTrackParam &track, Int_t PID )
31 {
32   // Constructor from ALICE track, PID hypothesis should be provided
33  
34   TParticlePDG* particlePDG = TDatabasePDG::Instance()->GetParticle(PID);
35   Double_t mass = (particlePDG) ? particlePDG->Mass() :0.13957;
36
37   track.GetXYZ(fP);
38   track.GetPxPyPz(fP+3);
39   Double_t energy = TMath::Sqrt( mass*mass + fP[3]*fP[3] + fP[4]*fP[4] + fP[5]*fP[5]);
40   fP[6] = energy;
41   fP[7] = 0;
42   fQ = (track.Get1Pt() >0 ) ?1 :-1;
43   fNDF = 0;
44   fChi2 = 0;
45   fAtProductionVertex = 0;
46   fIsLinearized = 0;
47   fSFromDecay = 0;
48
49   Double_t energyInv = 1./energy;
50   Double_t 
51     h0 = fP[3]*energyInv,
52     h1 = fP[4]*energyInv,
53     h2 = fP[5]*energyInv;
54
55   track.GetCovarianceXYZPxPyPz( fC );
56
57   fC[21] = h0*fC[ 6] + h1*fC[10] + h2*fC[15];
58   fC[22] = h0*fC[ 7] + h1*fC[11] + h2*fC[16];
59   fC[23] = h0*fC[ 8] + h1*fC[12] + h2*fC[17];
60   fC[24] = h0*fC[ 9] + h1*fC[13] + h2*fC[18];
61   fC[25] = h0*fC[13] + h1*fC[14] + h2*fC[19];
62   fC[26] = h0*fC[18] + h1*fC[19] + h2*fC[20];
63   fC[27] = h0*h0*fC[ 9] + h1*h1*fC[14] + h2*h2*fC[20] 
64     + 2*(h0*h1*fC[13] + h0*h2*fC[18] + h1*h2*fC[19] );
65   for( int i=28; i<36; i++ ) fC[i] = 0;
66   fC[35] = 1.;
67 }
68
69 AliKFParticle::AliKFParticle( const AliESDVertex &vertex )
70 {
71   // Constructor from ALICE vertex
72
73   vertex.GetXYZ( fP );
74   vertex.GetCovMatrix( fC );
75   fChi2 = vertex.GetChi2();
76   fNDF = 2*vertex.GetNContributors() - 3;
77   fQ = 0;
78   fAtProductionVertex = 0;
79   fIsLinearized = 0;
80   fSFromDecay = 0;
81 }
82
83
84 void AliKFParticle::GetExternalTrackParam( const AliKFParticleBase &p, Double_t &X, Double_t &Alpha, Double_t P[5] ) 
85 {
86   Double_t cosA = p.GetPx(), sinA = p.GetPy(); 
87   Double_t pt = TMath::Sqrt(cosA*cosA + sinA*sinA);
88   Double_t pti = 0;
89   if( pt<1.e-4 ){
90     cosA = 1;
91     sinA = 0;
92   } else {
93     pti = 1./pt;
94     cosA*=pti;
95     sinA*=pti;
96   }
97   Alpha = TMath::ATan2(sinA,cosA);  
98   X   = p.GetX()*cosA + p.GetY()*sinA;   
99   P[0]= p.GetY()*cosA - p.GetX()*sinA;
100   P[1]= p.GetZ();
101   P[2]= 0;
102   P[3]= p.GetPz()*pti;
103   P[4]= p.GetQ()*pti;
104 }
105
106
107 void AliKFParticle::GetDStoParticleALICE( const AliKFParticleBase &p, 
108                                           Double_t &DS, Double_t &DS1 ) 
109   const
110
111   DS = DS1 = 0;   
112   Double_t x1, a1, x2, a2;
113   Double_t par1[5], par2[5], cov[15];
114   for(int i=0; i<15; i++) cov[i] = 0;
115   cov[0] = cov[2] = cov[5] = cov[9] = cov[14] = .001;
116
117   GetExternalTrackParam( *this, x1, a1, par1 );
118   GetExternalTrackParam( p, x2, a2, par2 );
119
120   AliExternalTrackParam t1(x1,a1, par1, cov);
121   AliExternalTrackParam t2(x2,a2, par2, cov);
122
123   Double_t xe1=0, xe2=0;
124   t1.GetDCA( &t2, -GetFieldAlice(), xe1, xe2 );
125   t1.PropagateTo( xe1, -GetFieldAlice() );
126   t2.PropagateTo( xe2, -GetFieldAlice() );
127
128   Double_t xyz1[3], xyz2[3];
129   t1.GetXYZ( xyz1 );
130   t2.GetXYZ( xyz2 );
131   
132   DS = GetDStoPoint( xyz1 );
133   DS1 = p.GetDStoPoint( xyz2 );
134
135   return;
136 }