]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackV1.h
Correct the baseline subtraction in clusterizer
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackV1.h
1 #ifndef ALITRDTRACKV1_H
2 #define ALITRDTRACKV1_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * See cxx source for full Copyright notice                               */
5
6 /* $Id$ */
7
8 ///////////////////////////////////////////////////////////////////////////////
9 //                                                                           //
10 //  Represents a reconstructed TRD track                                     //
11 //                                                                           //
12 ///////////////////////////////////////////////////////////////////////////////
13
14 //#ifndef ALIKALMANTRACK_H
15 #include "AliKalmanTrack.h"
16 //#endif
17
18 //#ifndef ALITRDSEEDV1_H
19 #include "AliTRDseedV1.h"
20 //#endif
21
22 class AliTRDcluster;
23 class AliESDtrack;
24 class AliTRDReconstructor;
25 class AliTRDtrackV1 : public AliKalmanTrack
26 {
27   friend class AliHLTTRDTrack;
28 public:
29   enum ETRDtrackSize { 
30     kNdet      = AliTRDgeometry::kNdet
31    ,kNstacks   = AliTRDgeometry::kNstack*AliTRDgeometry::kNsector
32    ,kNplane    = AliTRDgeometry::kNlayer
33    ,kNcham     = AliTRDgeometry::kNstack
34    ,kNsect     = AliTRDgeometry::kNsector
35    ,kNslice    =   3
36    ,kNMLPslice =   8 
37    ,kMAXCLUSTERSPERTRACK = 210
38   };
39   
40   // bits from 0-13 are reserved by ROOT (see TObject.h)
41   enum ETRDtrackStatus {
42     kOwner     = BIT(14)
43    ,kStopped   = BIT(15) 
44    ,kKink      = BIT(16) 
45   };
46
47   // propagation/update error codes (up to 4 bits)
48   enum ETRDtrackError {
49     kProlongation = 1
50    ,kPropagation
51    ,kAdjustSector
52    ,kSnp
53    ,kTrackletInit
54    ,kUpdate
55    ,kUnknown      = 0xff
56   };
57
58   // data/clusters/tracklet error codes (up to 4 bits/layer)
59   enum ETRDlayerError {
60     kGeometry = 1
61    ,kBoundary
62    ,kNoClusters
63    ,kNoAttach
64    ,kNoClustersTracklet
65    ,kNoFit
66    ,kChi2
67   };
68
69   AliTRDtrackV1();
70   AliTRDtrackV1(AliTRDseedV1 * const trklts, const Double_t p[5], const Double_t cov[15], Double_t x, Double_t alpha);
71   AliTRDtrackV1(const AliESDtrack &ref);
72   AliTRDtrackV1(const AliTRDtrackV1 &ref);
73   virtual ~AliTRDtrackV1();
74   AliTRDtrackV1 &operator=(const AliTRDtrackV1 &ref) { *(new(this) AliTRDtrackV1(ref)); return *this; }
75   
76   Bool_t         CookPID();
77   Bool_t         CookLabel(Float_t wrong);
78   AliTRDtrackV1* GetBackupTrack() const {return fBackupTrack;}
79   Double_t       GetBudget(Int_t i) const { return fBudget[i];}
80   AliTRDcluster* GetCluster(Int_t id);
81   Int_t          GetClusterIndex(Int_t id) const;
82   Float_t        GetEdep() const {return fDE;}
83   inline Float_t GetMomentum(Int_t plane) const;
84   inline Int_t   GetNCross();
85   inline Int_t   GetNumberOfTracklets() const;
86   Double_t       GetPIDsignal() const   { return 0.;}
87   Double_t       GetPID(Int_t is) const { return (is >=0 && is < AliPID::kSPECIES) ? fPID[is] : -1.;}
88   UChar_t        GetNumberOfTrackletsPID() const;
89   Double_t       GetPredictedChi2(const AliTRDseedV1 *tracklet, Double_t *cov) const;
90   Double_t       GetPredictedChi2(const AliCluster* /*c*/) const                   { return 0.0; }
91   Int_t          GetProlongation(Double_t xk, Double_t &y, Double_t &z);
92   inline UChar_t GetStatusTRD(Int_t ly=-1) const;
93   Int_t          GetSector() const;
94   AliTRDseedV1*  GetTracklet(Int_t plane) const {return plane >=0 && plane <kNplane ? fTracklet[plane] : NULL;}
95   Int_t          GetTrackletIndex(Int_t plane) const          { return (plane>=0 && plane<kNplane) ? fTrackletIndex[plane] : -1;}
96   AliExternalTrackParam*
97                  GetTrackLow() const  { return fTrackLow;} 
98   AliExternalTrackParam*
99                  GetTrackHigh() const  { return fTrackHigh;} 
100   const UShort_t* GetTrackletIndexes() const { return &fTrackletIndex[0];}
101   
102   Bool_t         IsEqual(const TObject *inTrack) const;
103   Bool_t         IsKink() const    { return TestBit(kKink);}
104   Bool_t         IsOwner() const   { return TestBit(kOwner);};
105   Bool_t         IsStopped() const { return TestBit(kStopped);};
106   Bool_t         IsElectron() const;
107   inline static Bool_t IsTrackError(ETRDtrackError error, UInt_t status);
108   inline static Bool_t IsLayerError(ETRDlayerError error, Int_t layer, UInt_t status);
109
110   void           MakeBackupTrack();
111   void           Print(Option_t *o="") const;
112
113   Bool_t         PropagateTo(Double_t xr, Double_t x0 = 8.72, Double_t rho = 5.86e-3);
114   Int_t          PropagateToR(Double_t xr, Double_t step);
115   Bool_t         Rotate(Double_t angle, Bool_t absolute = kFALSE);
116   void           SetBudget(Int_t i, Double_t b) {if(i>=0 && i<3) fBudget[i] = b;}
117   void           SetEdep(Double32_t inDE){fDE = inDE;};
118   void           SetKink(Bool_t k)        { SetBit(kKink, k);}
119   void           SetNumberOfClusters();
120   UChar_t        SetNumberOfTrackletsPID(Bool_t recalc);
121   void           SetOwner();
122   void           SetPID(Short_t is, Double_t inPID){if (is >=0 && is < AliPID::kSPECIES) fPID[is]=inPID;};
123   void           SetPIDquality(UChar_t /*inPIDquality*/) const {/*fPIDquality = inPIDquality*/;};
124   inline void    SetStatus(UChar_t stat, Int_t ly=-1);
125   void           SetStopped(Bool_t stop) {SetBit(kStopped, stop);}
126   void           SetTracklet(AliTRDseedV1 *const trklt,  Int_t index);
127   void           SetTrackLow();
128   void           SetTrackHigh(const AliExternalTrackParam *op=NULL);
129   inline void    SetReconstructor(const AliTRDReconstructor *rec);
130   inline Float_t StatusForTOF();
131   void           UnsetTracklet(Int_t plane);
132   Bool_t         Update(Double_t *p, Double_t *cov, Double_t chi2);
133   Bool_t         Update(const AliCluster *, Double_t, Int_t) { return kFALSE; };
134   void           UpdateESDtrack(AliESDtrack *t);
135
136 private:
137   UInt_t       fStatus;                //  Bit map for the status of propagation
138   UShort_t     fTrackletIndex[kNplane];//  Tracklets index in the tracker list
139   Double32_t   fPID[AliPID::kSPECIES]; //  PID probabilities
140   Double32_t   fBudget[3];             //  Integrated material budget
141   Double32_t   fDE;                    //  Integrated delta energy
142   const AliTRDReconstructor *fkReconstructor;//! reconstructor link 
143   AliTRDtrackV1 *fBackupTrack;         //! Backup track
144   AliTRDseedV1 *fTracklet[kNplane];    //  Tracklets array defining the track
145   AliExternalTrackParam *fTrackLow;    // parameters of the track which enter TRD from below (TPC) 
146   AliExternalTrackParam *fTrackHigh;  // parameters of the track which enter TRD from above (HMPID, PHOS) 
147
148   ClassDef(AliTRDtrackV1, 5)          // TRD track - tracklet based
149 };
150
151 //____________________________________________________
152 inline Float_t AliTRDtrackV1::GetMomentum(Int_t plane) const
153 {
154   return plane >=0 && plane < kNplane && fTrackletIndex[plane] != 0xff ? fTracklet[plane]->GetMomentum() : -1.;
155 }
156
157 //____________________________________________________
158 inline Int_t AliTRDtrackV1::GetNCross()
159 {
160   Int_t ncross = 0;
161   for(Int_t ip=0; ip<kNplane; ip++){
162     if(!fTracklet[ip]) continue;
163     ncross += fTracklet[ip]->IsRowCross();
164   }
165   return ncross;
166 }
167
168 //____________________________________________________
169 inline Int_t AliTRDtrackV1::GetNumberOfTracklets() const
170 {
171   Int_t n = 0;
172   for(Int_t ip=0; ip<kNplane; ip++){
173     if(!fTracklet[ip]) continue;
174     n++;
175   }
176   return n;
177 }
178
179 //____________________________________________________
180 inline UChar_t AliTRDtrackV1::GetStatusTRD(Int_t ly) const
181 {
182   if(ly>=-1 && ly<kNplane) return (fStatus>>((ly+1)*4))&0xf;
183   return kUnknown;
184 }
185
186 //____________________________________________________
187 inline Bool_t AliTRDtrackV1::IsTrackError(ETRDtrackError error, UInt_t status)
188 {
189   return (status&0xf)==UChar_t(error);
190 }
191
192 //____________________________________________________
193 inline Bool_t AliTRDtrackV1::IsLayerError(ETRDlayerError error, Int_t ly, UInt_t status)
194 {
195   if(ly>=kNplane || ly<0) return kFALSE;
196   return ((status>>((ly+1)*4))&0xf) == UChar_t(error);
197 }
198
199 //____________________________________________________
200 inline void AliTRDtrackV1::SetReconstructor(const AliTRDReconstructor *rec)
201 {
202   for(Int_t ip=0; ip<kNplane; ip++){
203     if(!fTracklet[ip]) continue;
204     fTracklet[ip]->SetReconstructor(rec);
205   }
206   fkReconstructor = rec;
207 }
208
209 //____________________________________________________
210 inline void AliTRDtrackV1::SetStatus(UChar_t status, Int_t ly)
211 {
212   if(ly<kNplane) fStatus|=((status&0xf)<<((ly+1)*4));
213   return;
214 }
215
216
217 //____________________________________________________________________________
218 inline Float_t AliTRDtrackV1::StatusForTOF()
219 {
220   // OBSOLETE
221   // Defines the status of the TOF extrapolation
222   //
223
224   if(!fTracklet[5]) return 0.;
225
226   // Definition of res ????
227   Float_t res = /*(0.2 + 0.8 * (fN / (fNExpected + 5.0))) **/ (0.4 + 0.6 * fTracklet[5]->GetN() / 20.0);
228   res *= (0.25 + 0.8 * 40.0 / (40.0 + fBudget[2]));
229   return res;
230 }
231
232 #endif
233
234
235