two virtual functions added
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackV1.h
CommitLineData
d9950a5a 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
0906e73e 8///////////////////////////////////////////////////////////////////////////////
9// //
10// Represents a reconstructed TRD track //
11// //
12///////////////////////////////////////////////////////////////////////////////
d9950a5a 13
d8069611 14#ifndef ALIKALMANTRACK_H
3b57a3f7 15#include "AliKalmanTrack.h"
d8069611 16#endif
3b57a3f7 17
d8069611 18#ifndef ALITRDSEEDV1_H
3b57a3f7 19#include "AliTRDseedV1.h"
d8069611 20#endif
d9950a5a 21
e2a1c98b 22template <typename Value> class TVectorT;
23typedef class TVectorT<Double_t> TVectorD;
3b57a3f7 24class AliESDtrack;
d8069611 25class AliTRDcluster;
181c7f7e 26class AliTRDReconstructor;
3b57a3f7 27class AliTRDtrackV1 : public AliKalmanTrack
d9950a5a 28{
d8069611 29 friend class AliHLTTRDTrack; // allow HLT special access
3b57a3f7 30public:
eb2b4f91 31 enum ETRDtrackSize {
e3cf3d02 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 };
3b57a3f7 41
2e2915e7 42 // bits from 0-13 are reserved by ROOT (see TObject.h)
eb2b4f91 43 enum ETRDtrackStatus {
44 kOwner = BIT(14)
45 ,kStopped = BIT(15)
46 ,kKink = BIT(16)
2eb10c34 47 ,kPrimary = BIT(17)
eb2b4f91 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
af4e990c 58 ,kUnknown = 0xff
eb2b4f91 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
e44586fb 70 };
0906e73e 71
3b57a3f7 72 AliTRDtrackV1();
e17f4785 73 AliTRDtrackV1(AliTRDseedV1 * const trklts, const Double_t p[5], const Double_t cov[15], Double_t x, Double_t alpha);
3b57a3f7 74 AliTRDtrackV1(const AliESDtrack &ref);
75 AliTRDtrackV1(const AliTRDtrackV1 &ref);
76 virtual ~AliTRDtrackV1();
e08a5492 77 AliTRDtrackV1 &operator=(const AliTRDtrackV1 &ref);
78 virtual void Copy(TObject &ref) const;
79
3b57a3f7 80 Bool_t CookPID();
e2a1c98b 81 Double_t CookTruncatedMean(const Bool_t kinvq, const Double_t mag, const Int_t charge, const Int_t kcalib, TVectorD *Qs=NULL, TVectorD *Xs=NULL, Int_t timeBin0=-1, Int_t timeBin1=1000, Int_t tstep=1) const;
82
e73baf29 83 Int_t CookLabel(Float_t wrong, Int_t *labs=NULL, Float_t *freq=NULL);
3b57a3f7 84 AliTRDtrackV1* GetBackupTrack() const {return fBackupTrack;}
85 Double_t GetBudget(Int_t i) const { return fBudget[i];}
0349cc67 86 AliTRDcluster* GetCluster(Int_t id);
3b57a3f7 87 Int_t GetClusterIndex(Int_t id) const;
88 Float_t GetEdep() const {return fDE;}
352cef8f 89 Int_t GetESDid() const {return fESDid;}
c4a4e64f 90 inline Float_t GetMomentum(Int_t plane=-1) const;
3b57a3f7 91 inline Int_t GetNCross();
82180ec1 92 inline Int_t GetNumberOfTracklets() const;
1128e139 93 Double_t GetPIDsignal() const { return 0.;}
3b57a3f7 94 Double_t GetPID(Int_t is) const { return (is >=0 && is < AliPID::kSPECIES) ? fPID[is] : -1.;}
eb2b4f91 95 UChar_t GetNumberOfTrackletsPID() const;
b72f4eaf 96 Double_t GetPredictedChi2(const AliTRDseedV1 *tracklet, Double_t *cov) const;
3b57a3f7 97 Double_t GetPredictedChi2(const AliCluster* /*c*/) const { return 0.0; }
f8a9723f 98 Int_t GetProlongation(Double_t xk, Double_t &y, Double_t &z) const;
eb2b4f91 99 inline UChar_t GetStatusTRD(Int_t ly=-1) const;
100 Int_t GetSector() const;
4d6aee34 101 AliTRDseedV1* GetTracklet(Int_t plane) const {return plane >=0 && plane <kNplane ? fTracklet[plane] : NULL;}
e3cf3d02 102 Int_t GetTrackletIndex(Int_t plane) const { return (plane>=0 && plane<kNplane) ? fTrackletIndex[plane] : -1;}
103 AliExternalTrackParam*
a310e49b 104 GetTrackIn() const { return fTrackLow;}
e3cf3d02 105 AliExternalTrackParam*
a310e49b 106 GetTrackOut() const { return fTrackHigh;}
17896e82 107 const Int_t* GetTrackletIndexes() const { return &fTrackletIndex[0];}
3b57a3f7 108
203967fc 109 Bool_t IsEqual(const TObject *inTrack) const;
f29f13a6 110 Bool_t IsKink() const { return TestBit(kKink);}
111 Bool_t IsOwner() const { return TestBit(kOwner);};
2eb10c34 112 Bool_t IsPrimary() const { return TestBit(kPrimary);};
f29f13a6 113 Bool_t IsStopped() const { return TestBit(kStopped);};
22a4ab0c 114 Bool_t IsElectron() const;
eb2b4f91 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
b453ef55 118 Int_t MakeBackupTrack();
203967fc 119 void Print(Option_t *o="") const;
120
3b57a3f7 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;}
bee2b41e 125 void SetEdep(Double32_t inDE){fDE = inDE;};
352cef8f 126 void SetESDid(Int_t id) {fESDid = id;}
f29f13a6 127 void SetKink(Bool_t k) { SetBit(kKink, k);}
2eb10c34 128 void SetPrimary(Bool_t k) { SetBit(kPrimary, k);}
3b57a3f7 129 void SetNumberOfClusters();
130 void SetOwner();
bee2b41e 131 void SetPID(Short_t is, Double_t inPID){if (is >=0 && is < AliPID::kSPECIES) fPID[is]=inPID;};
4d6aee34 132 void SetPIDquality(UChar_t /*inPIDquality*/) const {/*fPIDquality = inPIDquality*/;};
34b5e42d 133 inline void SetErrStat(UChar_t stat, Int_t ly=-1);
e44586fb 134 void SetStopped(Bool_t stop) {SetBit(kStopped, stop);}
4d6aee34 135 void SetTracklet(AliTRDseedV1 *const trklt, Int_t index);
a310e49b 136 void SetTrackIn();
137 void SetTrackOut(const AliExternalTrackParam *op=NULL);
181c7f7e 138 inline void SetReconstructor(const AliTRDReconstructor *rec);
3b57a3f7 139 inline Float_t StatusForTOF();
181d2c97 140 void UnsetTracklet(Int_t plane);
4d6aee34 141 Bool_t Update(const AliCluster *, Double_t, Int_t) { return kFALSE; };
ef867f55 142 void UpdateChi2(Float_t chi2);
3b57a3f7 143 void UpdateESDtrack(AliESDtrack *t);
3b57a3f7 144
145private:
eb2b4f91 146 UInt_t fStatus; // Bit map for the status of propagation
17896e82 147 Int_t fTrackletIndex[kNplane];// Tracklets index in the tracker list
352cef8f 148 Int_t fESDid; // ESD track id
eb2b4f91 149 Double32_t fPID[AliPID::kSPECIES]; // PID probabilities
150 Double32_t fBudget[3]; // Integrated material budget
151 Double32_t fDE; // Integrated delta energy
e2a1c98b 152 Double32_t fTruncatedMean; // Truncated mean
153
4d6aee34 154 const AliTRDReconstructor *fkReconstructor;//! reconstructor link
eb2b4f91 155 AliTRDtrackV1 *fBackupTrack; //! Backup track
17896e82 156 AliTRDseedV1 *fTracklet[kNplane]; // Tracklets array defining the track
eb2b4f91 157 AliExternalTrackParam *fTrackLow; // parameters of the track which enter TRD from below (TPC)
17896e82 158 AliExternalTrackParam *fTrackHigh; // parameters of the track which enter TRD from above (HMPID, PHOS)
d9950a5a 159
352cef8f 160 ClassDef(AliTRDtrackV1, 7) // TRD track - tracklet based
d9950a5a 161};
162
3b57a3f7 163//____________________________________________________
164inline Float_t AliTRDtrackV1::GetMomentum(Int_t plane) const
165{
c4a4e64f 166// Return ESD momentum stored in the tracklet reconstructed in layer = "plane".
167// By default returns the ESD momentum in first tracklet attached to track
168 if(plane==-1){
169 for(Int_t i(0); i<kNplane; i++){
170 if(fTracklet[i]) return fTracklet[i]->GetMomentum();
171 }
172 } else if( plane >=0 && plane < kNplane){
173 if(fTracklet[plane]) return fTracklet[plane]->GetMomentum();
174 }
175 return -1.;
3b57a3f7 176}
177
178//____________________________________________________
179inline Int_t AliTRDtrackV1::GetNCross()
180{
181 Int_t ncross = 0;
182 for(Int_t ip=0; ip<kNplane; ip++){
183 if(!fTracklet[ip]) continue;
184 ncross += fTracklet[ip]->IsRowCross();
185 }
186 return ncross;
187}
188
82180ec1 189//____________________________________________________
190inline Int_t AliTRDtrackV1::GetNumberOfTracklets() const
191{
192 Int_t n = 0;
193 for(Int_t ip=0; ip<kNplane; ip++){
194 if(!fTracklet[ip]) continue;
195 n++;
196 }
197 return n;
198}
199
eb2b4f91 200//____________________________________________________
201inline UChar_t AliTRDtrackV1::GetStatusTRD(Int_t ly) const
202{
af4e990c 203 if(ly>=-1 && ly<kNplane) return (fStatus>>((ly+1)*4))&0xf;
204 return kUnknown;
eb2b4f91 205}
206
207//____________________________________________________
208inline Bool_t AliTRDtrackV1::IsTrackError(ETRDtrackError error, UInt_t status)
209{
210 return (status&0xf)==UChar_t(error);
211}
212
213//____________________________________________________
214inline Bool_t AliTRDtrackV1::IsLayerError(ETRDlayerError error, Int_t ly, UInt_t status)
215{
216 if(ly>=kNplane || ly<0) return kFALSE;
217 return ((status>>((ly+1)*4))&0xf) == UChar_t(error);
218}
181c7f7e 219
220//____________________________________________________
221inline void AliTRDtrackV1::SetReconstructor(const AliTRDReconstructor *rec)
222{
223 for(Int_t ip=0; ip<kNplane; ip++){
224 if(!fTracklet[ip]) continue;
225 fTracklet[ip]->SetReconstructor(rec);
226 }
4d6aee34 227 fkReconstructor = rec;
181c7f7e 228}
229
eb2b4f91 230//____________________________________________________
34b5e42d 231inline void AliTRDtrackV1::SetErrStat(UChar_t status, Int_t ly)
eb2b4f91 232{
233 if(ly<kNplane) fStatus|=((status&0xf)<<((ly+1)*4));
234 return;
235}
236
181c7f7e 237
3b57a3f7 238//____________________________________________________________________________
239inline Float_t AliTRDtrackV1::StatusForTOF()
240{
eb2b4f91 241 // OBSOLETE
3b57a3f7 242 // Defines the status of the TOF extrapolation
243 //
244
245 if(!fTracklet[5]) return 0.;
246
247 // Definition of res ????
248 Float_t res = /*(0.2 + 0.8 * (fN / (fNExpected + 5.0))) **/ (0.4 + 0.6 * fTracklet[5]->GetN() / 20.0);
249 res *= (0.25 + 0.8 * 40.0 / (40.0 + fBudget[2]));
250 return res;
251}
d9950a5a 252
253#endif
254
255
6e49cfdb 256