New comparison macro (M.Ivanov)
[u/mrichter/AliRoot.git] / TRD / AliTRDtrack.h
CommitLineData
46d29e70 1#ifndef ALITRDTRACK_H
b3a5a838 2#define ALITRDTRACK_H
46d29e70 3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
b3a5a838 5 * See cxx source for full Copyright notice */
46d29e70 6
5443e65e 7#include <AliKalmanTrack.h>
b3a5a838 8#include <TMath.h>
46d29e70 9
9c9d2487 10#include "AliTRDgeometry.h"
304864ab 11#include "AliESDtrack.h"
9c9d2487 12#include "TVector2.h"
13
46d29e70 14class AliTRDcluster;
b3a5a838 15class AliTPCtrack;
79e94bf8 16class AliESDtrack;
3fad3d32 17class AliTrackReference;
5443e65e 18
7ad19338 19const unsigned kMAX_CLUSTERS_PER_TRACK=210;
20
21class AliTRDtracklet :public TObject{
22 friend class AliTRDtrack;
23 public:
24 AliTRDtracklet();
25 void Set(Float_t x, Float_t y, Float_t z, Float_t alpha, Float_t error2){fX=x; fY=y; fZ=z; fAlpha=alpha; fSigma2= error2;}
26 void SetP0(Float_t p0){fP0=p0;}
27 void SetP1(Float_t p1){fP1=p1;}
28 void SetN(Int_t n){fNFound=n;}
29 void SetNCross(Int_t nc){fNCross=nc;}
30 void SetPlane(Int_t plane){fPlane=plane;}
31 void SetSigma2(Float_t sigma2){fExpectedSigma2=sigma2;}
32 void SetChi2(Float_t chi2){fChi2=chi2;}
33 void SetTilt(Float_t tilt){fTilt=tilt;}
34 Float_t GetX() const { return fX;}
35 Float_t GetY() const { return fY;}
36 Float_t GetZ() const {return fZ;}
37 Float_t GetAlpha() const { return fAlpha;}
38 Float_t GetTrackletSigma2() const { return fSigma2;}
39 //
40 Float_t GetP0() const {return fP0;}
41 Float_t GetP1() const {return fP1;}
42 Int_t GetN() const {return fNFound;}
43 Int_t GetNCross() const {return fNCross;}
44 Int_t GetPlane() const {return fPlane;}
45 Float_t GetClusterSigma2() const {return fExpectedSigma2;}
46 Float_t GetChi2() const {return fChi2;}
47 Float_t GetTilt() const {return fTilt;}
48 protected:
49 Float_t fY; // y position
50 Float_t fZ; // z position
51 Float_t fX; // x position
52 Float_t fAlpha; // rotation angle
53 Float_t fSigma2; // expected error of tracklet position
54 Float_t fP0; // offset in y
55 Float_t fP1; // offset in tangent
56 Int_t fNFound; // number of found clusters
57 Int_t fNCross; // number of crosses
58 Int_t fPlane; // plane number
59 Float_t fExpectedSigma2; // expected sigma of residual distribution of clusters
60 Float_t fChi2; // chi2 of the tracklet
61 Float_t fTilt; // tilt factor
62 ClassDef(AliTRDtracklet,2)
63};
46d29e70 64
46d29e70 65
7ad19338 66class AliTRDtrack : public AliKalmanTrack {
67
68// Represents reconstructed TRD track
69 friend class AliTRDtracker;
46d29e70 70public:
71
16d9fbba 72 AliTRDtrack():AliKalmanTrack(){fBackupTrack=0;}
a819a5f7 73 AliTRDtrack(const AliTRDcluster *c, UInt_t index, const Double_t xx[5],
46d29e70 74 const Double_t cc[15], Double_t xr, Double_t alpha);
75 AliTRDtrack(const AliTRDtrack& t);
5443e65e 76 AliTRDtrack(const AliKalmanTrack& t, Double_t alpha);
79e94bf8 77 AliTRDtrack(const AliESDtrack& t);
3fad3d32 78 static AliTRDtrack * MakeTrack(const AliTrackReference *ref, Double_t mass);
16d9fbba 79 ~AliTRDtrack();
a819a5f7 80 Int_t Compare(const TObject *o) const;
4f1c04d3 81 void CookdEdx(Double_t low=0.05, Double_t up=0.55);
7ad19338 82 Float_t StatusForTOF();
46d29e70 83 Double_t GetAlpha() const {return fAlpha;}
9c9d2487 84 Int_t GetSector() const {
85 //if (fabs(fAlpha) < AliTRDgeometry::GetAlpha()/2) return 0;
86 return Int_t(TVector2::Phi_0_2pi(fAlpha)/AliTRDgeometry::GetAlpha())%AliTRDgeometry::kNsect;}
87
46d29e70 88 Double_t GetC() const {return fC;}
89 Int_t GetClusterIndex(Int_t i) const {return fIndex[i];}
a819a5f7 90 Float_t GetClusterdQdl(Int_t i) const {return fdQdl[i];}
5443e65e 91
46d29e70 92 void GetCovariance(Double_t cov[15]) const;
c5507f6d 93 Double_t GetdEdx() const {return fdEdx;}
79e94bf8 94 Double_t GetPIDsignal() const {return GetdEdx();}
7ad19338 95 Float_t GetPIDsignals(Int_t i) const {return fdEdxPlane[i];}
96 Int_t GetPIDTimBin(Int_t i) const {return fTimBinPlane[i];}
46d29e70 97 Double_t GetEta() const {return fE;}
5443e65e 98
99 void GetExternalCovariance(Double_t cov[15]) const ;
100 void GetExternalParameters(Double_t& xr, Double_t x[5]) const ;
101
102 Double_t GetLikelihoodElectron() const { return fLhElectron; };
103
c84a5e9e 104 Double_t Get1Pt() const {
105 return (TMath::Sign(1e-9,fC) + fC)*GetLocalConvConst();
106 }
46d29e70 107 Double_t GetP() const {
108 return TMath::Abs(GetPt())*sqrt(1.+GetTgl()*GetTgl());
109 }
7ad19338 110 Double_t GetPredictedChi2(const AliTRDcluster*, Double_t h01) const ;
5443e65e 111 Double_t GetPt() const {return 1./Get1Pt();}
46d29e70 112 void GetPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const ;
5443e65e 113 void GetGlobalXYZ(Double_t &x, Double_t &y, Double_t &z) const ;
114 Int_t GetSeedLabel() const { return fSeedLab; }
46d29e70 115 Double_t GetSigmaC2() const {return fCcc;}
116 Double_t GetSigmaTgl2() const {return fCtt;}
117 Double_t GetSigmaY2() const {return fCyy;}
118 Double_t GetSigmaZ2() const {return fCzz;}
5443e65e 119 Double_t GetSnp() const {return fX*fC - fE;}
120 Double_t GetTgl() const {return fT;}
121 Double_t GetX() const {return fX;}
122 Double_t GetY() const {return fY;}
123 Double_t GetZ() const {return fZ;}
46e2d86c 124 UInt_t * GetBackupIndexes() {return fIndexBackup;}
125 UInt_t * GetIndexes() {return fIndex;}
3c625a9b 126 Double_t GetYat(Double_t xk) const {
7ad19338 127//-----------------------------------------------------------------
128// This function calculates the Y-coordinate of a track at the plane x=xk.
129// Needed for matching with the TOF (I.Belikov)
130//-----------------------------------------------------------------
1e9bb598 131 Double_t c1=fC*fX - fE, r1=TMath::Sqrt(1.- c1*c1);
132 Double_t c2=fC*xk - fE, r2=TMath::Sqrt(1.- c2*c2);
133 return fY + (xk-fX)*(c1+c2)/(r1+r2);
134 }
7ad19338 135 Int_t GetProlongation(Double_t xk, Double_t &y, Double_t &z);
4f1c04d3 136
7ad19338 137 void SetStop(Bool_t stop) {fStopped=stop;}
138 Bool_t GetStop() const {return fStopped;}
1e9bb598 139
b3a5a838 140 Int_t PropagateTo(Double_t xr, Double_t x0=8.72, Double_t rho=5.86e-3);
3fad3d32 141 Int_t PropagateToX(Double_t xr, Double_t step);
142 Int_t PropagateToR(Double_t xr, Double_t step);
5443e65e 143 void ResetCovariance();
46e2d86c 144 void ResetCovariance(Float_t mult);
7ad19338 145 void ResetClusters() { SetChi2(0.); SetNumberOfClusters(0); }
3fad3d32 146 Int_t Rotate(Double_t angle, Bool_t absolute=kFALSE);
46d29e70 147
46d29e70 148 void SetdEdx(Float_t dedx) {fdEdx=dedx;}
7ad19338 149 void SetPIDsignals(Float_t dedx, Int_t i) {fdEdxPlane[i]=dedx;}
150 void SetPIDTimBin(Int_t timbin, Int_t i) {fTimBinPlane[i]=timbin;}
5443e65e 151 void SetLikelihoodElectron(Float_t l) { fLhElectron = l; };
152
153 void SetSampledEdx(Float_t q, Int_t i) {
4f1c04d3 154 Double_t s=GetSnp(), t=GetTgl();
155 q*= TMath::Sqrt((1-s*s)/(1+t*t));
156 fdQdl[i]=q;
157 }
158 void SetSampledEdx(Float_t q) {
5443e65e 159 Double_t s=GetSnp(), t=GetTgl();
160 q*= TMath::Sqrt((1-s*s)/(1+t*t));
4f1c04d3 161 fdQdl[fNdedx]=q;
162 fNdedx++;
5443e65e 163 }
164
165 void SetSeedLabel(Int_t lab) { fSeedLab=lab; }
166
fd621f36 167 Int_t Update(const AliTRDcluster* c, Double_t chi2, UInt_t i,
b8dc2353 168 Double_t h01);
46e2d86c 169 Int_t UpdateMI(const AliTRDcluster* c, Double_t chi2, UInt_t i,
3c625a9b 170 Double_t h01, Int_t plane);
7ad19338 171 Int_t UpdateMI(const AliTRDtracklet & tracklet);
fd621f36 172
7ad19338 173 //
174 void AddNWrong() {fNWrong++;}
9c9d2487 175
7ad19338 176 Int_t GetNWrong() const {return fNWrong;}
177 Int_t GetNRotate() const {return fNRotate;}
178 Int_t GetNCross() const {return fNCross;}
179 void IncCross() {fNCross++; if (fBackupTrack) fBackupTrack->IncCross();}
16d9fbba 180 AliTRDtrack * GetBackupTrack(){return fBackupTrack;}
7ad19338 181 void MakeBackupTrack();
182 //
183
9c9d2487 184
bbf92647 185protected:
c84a5e9e 186 void GetXYZ(Float_t r[3]) const;
187
188 Double_t GetPredictedChi2(const AliCluster*/*c*/) const {return 0.;}
189 Int_t Update(const AliCluster*/*c*/, Double_t /*chi2*/, UInt_t /*i*/) {
190 return 0;
191 }
bbf92647 192
7ad19338 193 Int_t fSeedLab; // track label taken from seeding
194 Float_t fdEdx; // dE/dx
3fad3d32 195 Float_t fDE; // integrated delta energy
7ad19338 196 Float_t fdEdxPlane[kNPlane]; // dE/dx from all 6 planes
197 Int_t fTimBinPlane[kNPlane]; // time bin of Max cluster from all 6 planes
bbf92647 198
7ad19338 199 Double_t fAlpha; // rotation angle
200 Double_t fX; // running local X-coordinate of the track (time bin)
201 Bool_t fStopped; // track stop indication
b8dc2353 202
203 Double_t fY; // Y-coordinate of the track
204 Double_t fZ; // Z-coordinate of the track
205 Double_t fE; // C*x0
206 Double_t fT; // tangent of the track momentum dip angle
207 Double_t fC; // track curvature
bbf92647 208
209 Double_t fCyy; // covariance
210 Double_t fCzy, fCzz; // matrix
b3a5a838 211 Double_t fCey, fCez, fCee; // of the
212 Double_t fCty, fCtz, fCte, fCtt; // track
213 Double_t fCcy, fCcz, fCce, fCct, fCcc; // parameters
b8dc2353 214
7ad19338 215 UInt_t fIndex[kMAX_CLUSTERS_PER_TRACK]; // global indexes of clusters
216 UInt_t fIndexBackup[kMAX_CLUSTERS_PER_TRACK]; //backup indexes of clusters - used in iterations
217 Float_t fdQdl[kMAX_CLUSTERS_PER_TRACK]; // cluster amplitudes corrected
218 // for track angles
b8dc2353 219
a819a5f7 220 Float_t fLhElectron; // Likelihood to be an electron
7ad19338 221 Int_t fNWrong; // number of wrong clusters
222 Int_t fNRotate; // number of rotation
223 Int_t fNCross; // number of the cross materials
224 Int_t fNExpected; //expected number of cluster
225 Int_t fNLast; //number of clusters in last 2 layers
226 Int_t fNExpectedLast; //number of expected clusters on last 2 layers
227 Int_t fNdedx; //number of clusters for dEdx measurment
228 Float_t fChi2Last; //chi2 in the last 2 layers
229 AliTRDtracklet fTracklets[6]; //tracklets
16d9fbba 230 AliTRDtrack * fBackupTrack; //! backup track
a819a5f7 231 ClassDef(AliTRDtrack,2) // TRD reconstructed tracks
46d29e70 232};
233
c84a5e9e 234inline void AliTRDtrack::GetXYZ(Float_t r[3]) const {
235 //---------------------------------------------------------------------
236 // Returns the position of the track in the global coord. system
237 //---------------------------------------------------------------------
238 Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha);
239 r[0]=fX*cs - fY*sn; r[1]=fX*sn + fY*cs; r[2]=fZ;
240}
46d29e70 241
46d29e70 242#endif