]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackV1.h
use truncated mean infrastructure from ESD track(Xianguo)
[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 template <typename Value> class TVectorT;
23 typedef class TVectorT<Double_t> TVectorD;
24 class AliESDtrack;
25 class AliTRDcluster;
26 class AliTRDReconstructor;
27 class AliTRDtrackV1 : public AliKalmanTrack
28 {
29   friend class AliHLTTRDTrack; // allow HLT special access
30 public:
31   enum ETRDtrackSize { 
32     kNdet      = AliTRDgeometry::kNdet
33    ,kNstacks   = AliTRDgeometry::kNstack*AliTRDgeometry::kNsector
34    ,kNplane    = AliTRDgeometry::kNlayer
35    ,kNcham     = AliTRDgeometry::kNstack
36    ,kNsect     = AliTRDgeometry::kNsector
37    ,kNslice    =   3
38    ,kNMLPslice =   8 
39    ,kMAXCLUSTERSPERTRACK = 210
40   };
41   
42   // bits from 0-13 are reserved by ROOT (see TObject.h)
43   enum ETRDtrackStatus {
44     kOwner     = BIT(14)
45    ,kStopped   = BIT(15) 
46    ,kKink      = BIT(16) 
47    ,kPrimary   = BIT(17) 
48   };
49
50   // propagation/update error codes (up to 4 bits)
51   enum ETRDtrackError {
52     kProlongation = 1
53    ,kPropagation
54    ,kAdjustSector
55    ,kSnp
56    ,kTrackletInit
57    ,kUpdate
58    ,kUnknown      = 0xff
59   };
60
61   // data/clusters/tracklet error codes (up to 4 bits/layer)
62   enum ETRDlayerError {
63     kGeometry = 1
64    ,kBoundary
65    ,kNoClusters
66    ,kNoAttach
67    ,kNoClustersTracklet
68    ,kNoFit
69    ,kChi2
70   };
71
72   AliTRDtrackV1();
73   AliTRDtrackV1(AliTRDseedV1 * const trklts, const Double_t p[5], const Double_t cov[15], Double_t x, Double_t alpha);
74   AliTRDtrackV1(const AliESDtrack &ref);
75   AliTRDtrackV1(const AliTRDtrackV1 &ref);
76   virtual ~AliTRDtrackV1();
77   AliTRDtrackV1 &operator=(const AliTRDtrackV1 &ref);
78   virtual void   Copy(TObject &ref) const;
79  
80   Bool_t         CookPID();
81   Double_t       CookTruncatedMean(const Bool_t kinvq, const Double_t mag, const Int_t charge, const Int_t kcalib, Int_t &nch, Int_t &ncls, TVectorD *Qs=NULL, TVectorD *Xs=NULL, Int_t timeBin0=-1, Int_t timeBin1=1000, Int_t tstep=1) const;
82  
83   Int_t          CookLabel(Float_t wrong, Int_t *labs=NULL, Float_t *freq=NULL);
84   AliTRDtrackV1* GetBackupTrack() const {return fBackupTrack;}
85   Double_t       GetBudget(Int_t i) const { return fBudget[i];}
86   AliTRDcluster* GetCluster(Int_t id);
87   Int_t          GetClusterIndex(Int_t id) const;
88   Float_t        GetEdep() const {return fDE;}
89   Int_t          GetESDid() const {return fESDid;}
90   inline Float_t GetMomentum(Int_t plane=-1) const;
91   inline Int_t   GetNCross();
92   inline Int_t   GetNumberOfTracklets() const;
93   Double_t       GetPIDsignal() const   { return 0.;}
94   Double_t       GetPID(Int_t is) const { return (is >=0 && is < AliPID::kSPECIES) ? fPID[is] : -1.;}
95   UChar_t        GetNumberOfTrackletsPID() const;
96   Double_t       GetPredictedChi2(const AliTRDseedV1 *tracklet, Double_t *cov) const;
97   Double_t       GetPredictedChi2(const AliCluster* /*c*/) const                   { return 0.0; }
98   Int_t          GetProlongation(Double_t xk, Double_t &y, Double_t &z) const;
99   inline UChar_t GetStatusTRD(Int_t ly=-1) const;
100   Int_t          GetSector() const;
101   AliTRDseedV1*  GetTracklet(Int_t plane) const {return plane >=0 && plane <kNplane ? fTracklet[plane] : NULL;}
102   Int_t          GetTrackletIndex(Int_t plane) const          { return (plane>=0 && plane<kNplane) ? fTrackletIndex[plane] : -1;}
103   AliExternalTrackParam*
104                  GetTrackIn() const  { return fTrackLow;} 
105   AliExternalTrackParam*
106                  GetTrackOut() const  { return fTrackHigh;} 
107   const Int_t* GetTrackletIndexes() const { return &fTrackletIndex[0];}
108   
109   Bool_t         IsEqual(const TObject *inTrack) const;
110   Bool_t         IsKink() const    { return TestBit(kKink);}
111   Bool_t         IsOwner() const   { return TestBit(kOwner);};
112   Bool_t         IsPrimary() const   { return TestBit(kPrimary);};
113   Bool_t         IsStopped() const { return TestBit(kStopped);};
114   Bool_t         IsElectron() const;
115   inline static Bool_t IsTrackError(ETRDtrackError error, UInt_t status);
116   inline static Bool_t IsLayerError(ETRDlayerError error, Int_t layer, UInt_t status);
117
118   Int_t          MakeBackupTrack();
119   void           Print(Option_t *o="") const;
120
121   Bool_t         PropagateTo(Double_t xr, Double_t x0 = 8.72, Double_t rho = 5.86e-3);
122   Int_t          PropagateToR(Double_t xr, Double_t step);
123   Bool_t         Rotate(Double_t angle, Bool_t absolute = kFALSE);
124   void           SetBudget(Int_t i, Double_t b) {if(i>=0 && i<3) fBudget[i] = b;}
125   void           SetEdep(Double32_t inDE){fDE = inDE;};
126   void           SetESDid(Int_t id) {fESDid = id;}
127   void           SetKink(Bool_t k)        { SetBit(kKink, k);}
128   void           SetPrimary(Bool_t k)     { SetBit(kPrimary, k);}
129   void           SetNumberOfClusters();
130   void           SetOwner();
131   void           SetPID(Short_t is, Double_t inPID){if (is >=0 && is < AliPID::kSPECIES) fPID[is]=inPID;};
132   void           SetPIDquality(UChar_t /*inPIDquality*/) const {/*fPIDquality = inPIDquality*/;};
133   inline void    SetErrStat(UChar_t stat, Int_t ly=-1);
134   void           SetStopped(Bool_t stop) {SetBit(kStopped, stop);}
135   void           SetTracklet(AliTRDseedV1 *const trklt,  Int_t index);
136   void           SetTrackIn();
137   void           SetTrackOut(const AliExternalTrackParam *op=NULL);
138   inline void    SetReconstructor(const AliTRDReconstructor *rec);
139   inline Float_t StatusForTOF();
140   void           UnsetTracklet(Int_t plane);
141   Bool_t         Update(const AliCluster *, Double_t, Int_t) { return kFALSE; };
142   void           UpdateChi2(Float_t chi2);
143   void           UpdateESDtrack(AliESDtrack *t);
144
145 private:
146   UInt_t       fStatus;                //  Bit map for the status of propagation
147   Int_t        fTrackletIndex[kNplane];//  Tracklets index in the tracker list
148   Int_t        fESDid;                 //  ESD track id 
149   Double32_t   fPID[AliPID::kSPECIES]; //  PID probabilities
150   Double32_t   fBudget[3];             //  Integrated material budget
151   Double32_t   fDE;                    //  Integrated delta energy
152   Double32_t   fTruncatedMean;         //  Truncated mean
153   Int_t        fNchamberdEdx;          //  number of chambers used in calculating truncated mean
154   Int_t        fNclusterdEdx;          //  number of clusters used in calculating truncated mean
155
156   const AliTRDReconstructor *fkReconstructor;//! reconstructor link 
157   AliTRDtrackV1 *fBackupTrack;         //! Backup track
158   AliTRDseedV1  *fTracklet[kNplane];   //  Tracklets array defining the track
159   AliExternalTrackParam *fTrackLow;    // parameters of the track which enter TRD from below (TPC) 
160   AliExternalTrackParam *fTrackHigh;   // parameters of the track which enter TRD from above (HMPID, PHOS) 
161
162   ClassDef(AliTRDtrackV1, 7)          // TRD track - tracklet based
163 };
164
165 //____________________________________________________
166 inline Float_t AliTRDtrackV1::GetMomentum(Int_t plane) const
167 {
168 // Return ESD momentum stored in the tracklet reconstructed in layer = "plane". 
169 // By default returns the ESD momentum in first tracklet attached to track
170   if(plane==-1){
171     for(Int_t i(0); i<kNplane; i++){
172       if(fTracklet[i]) return fTracklet[i]->GetMomentum();
173     }
174   } else if( plane >=0 && plane < kNplane){
175     if(fTracklet[plane]) return fTracklet[plane]->GetMomentum();
176   }
177   return -1.;
178 }
179
180 //____________________________________________________
181 inline Int_t AliTRDtrackV1::GetNCross()
182 {
183   Int_t ncross = 0;
184   for(Int_t ip=0; ip<kNplane; ip++){
185     if(!fTracklet[ip]) continue;
186     ncross += fTracklet[ip]->IsRowCross();
187   }
188   return ncross;
189 }
190
191 //____________________________________________________
192 inline Int_t AliTRDtrackV1::GetNumberOfTracklets() const
193 {
194   Int_t n = 0;
195   for(Int_t ip=0; ip<kNplane; ip++){
196     if(!fTracklet[ip]) continue;
197     n++;
198   }
199   return n;
200 }
201
202 //____________________________________________________
203 inline UChar_t AliTRDtrackV1::GetStatusTRD(Int_t ly) const
204 {
205   if(ly>=-1 && ly<kNplane) return (fStatus>>((ly+1)*4))&0xf;
206   return kUnknown;
207 }
208
209 //____________________________________________________
210 inline Bool_t AliTRDtrackV1::IsTrackError(ETRDtrackError error, UInt_t status)
211 {
212   return (status&0xf)==UChar_t(error);
213 }
214
215 //____________________________________________________
216 inline Bool_t AliTRDtrackV1::IsLayerError(ETRDlayerError error, Int_t ly, UInt_t status)
217 {
218   if(ly>=kNplane || ly<0) return kFALSE;
219   return ((status>>((ly+1)*4))&0xf) == UChar_t(error);
220 }
221
222 //____________________________________________________
223 inline void AliTRDtrackV1::SetReconstructor(const AliTRDReconstructor *rec)
224 {
225   for(Int_t ip=0; ip<kNplane; ip++){
226     if(!fTracklet[ip]) continue;
227     fTracklet[ip]->SetReconstructor(rec);
228   }
229   fkReconstructor = rec;
230 }
231
232 //____________________________________________________
233 inline void AliTRDtrackV1::SetErrStat(UChar_t status, Int_t ly)
234 {
235   if(ly<kNplane) fStatus|=((status&0xf)<<((ly+1)*4));
236   return;
237 }
238
239
240 //____________________________________________________________________________
241 inline Float_t AliTRDtrackV1::StatusForTOF()
242 {
243   // OBSOLETE
244   // Defines the status of the TOF extrapolation
245   //
246
247   if(!fTracklet[5]) return 0.;
248
249   // Definition of res ????
250   Float_t res = /*(0.2 + 0.8 * (fN / (fNExpected + 5.0))) **/ (0.4 + 0.6 * fTracklet[5]->GetN() / 20.0);
251   res *= (0.25 + 0.8 * 40.0 / (40.0 + fBudget[2]));
252   return res;
253 }
254
255 #endif
256
257
258