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