]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliKalmanTrack.cxx
Corrections to obey coding conventions
[u/mrichter/AliRoot.git] / STEER / AliKalmanTrack.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //                Implementation of the AliKalmanTrack class
20 //   that is the base for AliTPCtrack, AliITStrackV2 and AliTRDtrack
21 //        Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22 //-------------------------------------------------------------------------
23
24 #include "AliKalmanTrack.h"
25 #include "AliPDG.h"
26 #include "TPDGCode.h"
27 #include "TDatabasePDG.h"
28
29 ClassImp(AliKalmanTrack)
30
31 Double_t AliKalmanTrack::fgConvConst;
32
33 //_______________________________________________________________________
34 AliKalmanTrack::AliKalmanTrack():
35   fLab(-3141593),
36   fChi2(0),
37   fMass(0.13957),
38   fN(0)
39 {
40   //
41   // Default constructor
42   //
43     if (fgConvConst==0) 
44       Fatal("AliKalmanTrack()","The magnetic field has not been set !\n"); 
45     
46     fStartTimeIntegral = kFALSE;
47     fIntegratedLength = 0;
48     for(Int_t i=0; i<5; i++) fIntegratedTime[i] = 0;
49 }
50
51 //_______________________________________________________________________
52 AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
53   TObject(t),
54   fLab(t.fLab),
55   fChi2(t.fChi2),
56   fMass(t.fMass),
57   fN(t.fN)
58 {
59   //
60   // Copy constructor
61   //
62   if (fgConvConst==0) 
63     Fatal("AliKalmanTrack(const AliKalmanTrack&)",
64           "The magnetic field has not been set !\n"); 
65
66   fStartTimeIntegral = t.fStartTimeIntegral;
67   fIntegratedLength = t.fIntegratedLength;
68   
69   for (Int_t i=0; i<5; i++) 
70     fIntegratedTime[i] = t.fIntegratedTime[i];
71 }
72 //_______________________________________________________________________
73 void AliKalmanTrack::StartTimeIntegral() 
74 {
75   //
76   // Start time integration
77   // To be called at Vertex by ITS tracker
78   //
79   
80   //if (fStartTimeIntegral) 
81   //  Warning("StartTimeIntegral", "Reseting Recorded Time.");
82
83   fStartTimeIntegral = kTRUE;
84   for(Int_t i=0; i<fTypes; i++) fIntegratedTime[i] = 0;  
85   fIntegratedLength = 0;
86 }
87 //_______________________________________________________________________
88 void AliKalmanTrack:: AddTimeStep(Double_t length) 
89 {
90   // 
91   // Add step to integrated time
92   // this method should be called by a sublasses at the end
93   // of the PropagateTo function or by a tracker
94   // each time step is made.
95   //
96   // If integration not started function does nothing
97   //
98   // Formula
99   // dt = dl * sqrt(p^2 + m^2) / p
100   // p = pT * (1 + tg^2 (lambda) )
101   //
102   // pt = 1/external parameter [4]
103   // tg lambda = external parameter [3]
104   //
105   //
106   // Sylwester Radomski, GSI
107   // S.Radomski@gsi.de
108   // 
109   
110   static const Double_t cc = 2.99792458e-2;
111
112   if (!fStartTimeIntegral) return;
113   
114   fIntegratedLength += length;
115
116   static Int_t pdgCode[fTypes]  = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
117   TDatabasePDG *db = TDatabasePDG::Instance();
118
119   Double_t xr, param[5];
120   Double_t pt, tgl;
121   
122   GetExternalParameters(xr, param);
123   pt =  1/param[4] ;
124   tgl = param[3];
125
126   Double_t p = TMath::Abs(pt * TMath::Sqrt(1+tgl*tgl));
127
128   if (length > 100) return;
129
130   for (Int_t i=0; i<fTypes; i++) {
131     
132     Double_t mass = db->GetParticle(pdgCode[i])->Mass();
133     Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p;
134     Double_t time = length * correction / cc;
135
136     //cout << mass << "\t" << pt << "\t" << p << "\t" 
137     //     << correction << endl;
138
139     fIntegratedTime[i] += time;
140   }
141 }
142
143 //_______________________________________________________________________
144
145 Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const 
146 {
147   //
148   // Return integrated time hypothesis for a given particle
149   // type assumption.
150   //
151   // Input parameter:
152   // pdg - Pdg code of a particle type
153   //
154
155
156   if (!fStartTimeIntegral) {
157     Warning("GetIntegratedTime","Time integration not started");
158     return 0.;
159   }
160
161   static Int_t pdgCode[fTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
162
163   for (Int_t i=0; i<fTypes; i++)
164     if (pdgCode[i] == TMath::Abs(pdg)) return fIntegratedTime[i];
165
166   Warning(":GetIntegratedTime","Particle type [%d] not found", pdg);
167   return 0;
168 }
169 //_______________________________________________________________________
170
171 void AliKalmanTrack::PrintTime() const
172 {
173   // For testing
174   // Prints time for all hypothesis
175   //
176
177   static Int_t pdgCode[fTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
178
179   for (Int_t i=0; i<fTypes; i++)
180     printf("%d: %.2f  ", pdgCode[i], fIntegratedTime[i]);
181   printf("\n");  
182 }
183
184 //_______________________________________________________________________
185