Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[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
e3cf3d02 37 ,kMAXCLUSTERSPERTRACK = 210
38 };
3b57a3f7 39
2e2915e7 40 // bits from 0-13 are reserved by ROOT (see TObject.h)
eb2b4f91 41 enum ETRDtrackStatus {
42 kOwner = BIT(14)
43 ,kStopped = BIT(15)
44 ,kKink = BIT(16)
92032839 45 ,kPrimary = BIT(17)
46 ,kSeeder = BIT(18) // if set other than TPC (ITS, TRD)
eb2b4f91 47 };
48
49 // propagation/update error codes (up to 4 bits)
50 enum ETRDtrackError {
51 kProlongation = 1
52 ,kPropagation
53 ,kAdjustSector
54 ,kSnp
55 ,kTrackletInit
56 ,kUpdate
af4e990c 57 ,kUnknown = 0xff
eb2b4f91 58 };
59
60 // data/clusters/tracklet error codes (up to 4 bits/layer)
61 enum ETRDlayerError {
62 kGeometry = 1
63 ,kBoundary
64 ,kNoClusters
65 ,kNoAttach
66 ,kNoClustersTracklet
67 ,kNoFit
68 ,kChi2
e44586fb 69 };
0906e73e 70
3b57a3f7 71 AliTRDtrackV1();
e17f4785 72 AliTRDtrackV1(AliTRDseedV1 * const trklts, const Double_t p[5], const Double_t cov[15], Double_t x, Double_t alpha);
3b57a3f7 73 AliTRDtrackV1(const AliESDtrack &ref);
74 AliTRDtrackV1(const AliTRDtrackV1 &ref);
75 virtual ~AliTRDtrackV1();
e08a5492 76 AliTRDtrackV1 &operator=(const AliTRDtrackV1 &ref);
77 virtual void Copy(TObject &ref) const;
24aea01c 78 virtual TObject* Clone(const char* newname = "") const;
3b57a3f7 79 Bool_t CookPID();
d0037ea4 80 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;
e2a1c98b 81
e73baf29 82 Int_t CookLabel(Float_t wrong, Int_t *labs=NULL, Float_t *freq=NULL);
3b57a3f7 83 AliTRDtrackV1* GetBackupTrack() const {return fBackupTrack;}
84 Double_t GetBudget(Int_t i) const { return fBudget[i];}
0349cc67 85 AliTRDcluster* GetCluster(Int_t id);
3b57a3f7 86 Int_t GetClusterIndex(Int_t id) const;
87 Float_t GetEdep() const {return fDE;}
352cef8f 88 Int_t GetESDid() const {return fESDid;}
c4a4e64f 89 inline Float_t GetMomentum(Int_t plane=-1) const;
3b57a3f7 90 inline Int_t GetNCross();
82180ec1 91 inline Int_t GetNumberOfTracklets() const;
1128e139 92 Double_t GetPIDsignal() const { return 0.;}
3b57a3f7 93 Double_t GetPID(Int_t is) const { return (is >=0 && is < AliPID::kSPECIES) ? fPID[is] : -1.;}
eb2b4f91 94 UChar_t GetNumberOfTrackletsPID() const;
1f97f376 95 Int_t GetNumberOfPhysicsSlices() const { return fNdEdxSlices; };
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];}
203967fc 108 Bool_t IsEqual(const TObject *inTrack) const;
1f97f376 109 Bool_t IsKink() const { return TestBit(kKink);}
110 Bool_t IsOwner() const { return TestBit(kOwner);};
111 Bool_t IsPrimary() const { return TestBit(kPrimary);};
112 Bool_t IsStopped() const { return TestBit(kStopped);};
22a4ab0c 113 Bool_t IsElectron() const;
1f97f376 114 Bool_t IsTPCseeded() const { return !TestBit(kSeeder);};
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);}
92032839 129 void SetNonTPCseeded(Bool_t k){ SetBit(kSeeder, k);}
3b57a3f7 130 void SetNumberOfClusters();
131 void SetOwner();
bee2b41e 132 void SetPID(Short_t is, Double_t inPID){if (is >=0 && is < AliPID::kSPECIES) fPID[is]=inPID;};
4d6aee34 133 void SetPIDquality(UChar_t /*inPIDquality*/) const {/*fPIDquality = inPIDquality*/;};
34b5e42d 134 inline void SetErrStat(UChar_t stat, Int_t ly=-1);
e44586fb 135 void SetStopped(Bool_t stop) {SetBit(kStopped, stop);}
4d6aee34 136 void SetTracklet(AliTRDseedV1 *const trklt, Int_t index);
a310e49b 137 void SetTrackIn();
138 void SetTrackOut(const AliExternalTrackParam *op=NULL);
181c7f7e 139 inline void SetReconstructor(const AliTRDReconstructor *rec);
3b57a3f7 140 inline Float_t StatusForTOF();
181d2c97 141 void UnsetTracklet(Int_t plane);
4d6aee34 142 Bool_t Update(const AliCluster *, Double_t, Int_t) { return kFALSE; };
ef867f55 143 void UpdateChi2(Float_t chi2);
3b57a3f7 144 void UpdateESDtrack(AliESDtrack *t);
3b57a3f7 145
146private:
eb2b4f91 147 UInt_t fStatus; // Bit map for the status of propagation
17896e82 148 Int_t fTrackletIndex[kNplane];// Tracklets index in the tracker list
352cef8f 149 Int_t fESDid; // ESD track id
eb2b4f91 150 Double32_t fPID[AliPID::kSPECIES]; // PID probabilities
151 Double32_t fBudget[3]; // Integrated material budget
152 Double32_t fDE; // Integrated delta energy
e2a1c98b 153 Double32_t fTruncatedMean; // Truncated mean
d0037ea4 154 Int_t fNchamberdEdx; // number of chambers used in calculating truncated mean
155 Int_t fNclusterdEdx; // number of clusters used in calculating truncated mean
1f97f376 156 Int_t fNdEdxSlices; // number of "physics slices" fill via AliTRDPIDResponse
e2a1c98b 157
4d6aee34 158 const AliTRDReconstructor *fkReconstructor;//! reconstructor link
eb2b4f91 159 AliTRDtrackV1 *fBackupTrack; //! Backup track
17896e82 160 AliTRDseedV1 *fTracklet[kNplane]; // Tracklets array defining the track
eb2b4f91 161 AliExternalTrackParam *fTrackLow; // parameters of the track which enter TRD from below (TPC)
17896e82 162 AliExternalTrackParam *fTrackHigh; // parameters of the track which enter TRD from above (HMPID, PHOS)
d9950a5a 163
1f97f376 164 ClassDef(AliTRDtrackV1, 8) // TRD track - tracklet based
d9950a5a 165};
166
3b57a3f7 167//____________________________________________________
168inline Float_t AliTRDtrackV1::GetMomentum(Int_t plane) const
169{
c4a4e64f 170// Return ESD momentum stored in the tracklet reconstructed in layer = "plane".
171// By default returns the ESD momentum in first tracklet attached to track
172 if(plane==-1){
173 for(Int_t i(0); i<kNplane; i++){
174 if(fTracklet[i]) return fTracklet[i]->GetMomentum();
175 }
176 } else if( plane >=0 && plane < kNplane){
177 if(fTracklet[plane]) return fTracklet[plane]->GetMomentum();
178 }
179 return -1.;
3b57a3f7 180}
181
182//____________________________________________________
183inline Int_t AliTRDtrackV1::GetNCross()
184{
185 Int_t ncross = 0;
186 for(Int_t ip=0; ip<kNplane; ip++){
187 if(!fTracklet[ip]) continue;
188 ncross += fTracklet[ip]->IsRowCross();
189 }
190 return ncross;
191}
192
82180ec1 193//____________________________________________________
194inline Int_t AliTRDtrackV1::GetNumberOfTracklets() const
195{
196 Int_t n = 0;
197 for(Int_t ip=0; ip<kNplane; ip++){
198 if(!fTracklet[ip]) continue;
199 n++;
200 }
201 return n;
202}
203
eb2b4f91 204//____________________________________________________
205inline UChar_t AliTRDtrackV1::GetStatusTRD(Int_t ly) const
206{
af4e990c 207 if(ly>=-1 && ly<kNplane) return (fStatus>>((ly+1)*4))&0xf;
208 return kUnknown;
eb2b4f91 209}
210
211//____________________________________________________
212inline Bool_t AliTRDtrackV1::IsTrackError(ETRDtrackError error, UInt_t status)
213{
214 return (status&0xf)==UChar_t(error);
215}
216
217//____________________________________________________
218inline Bool_t AliTRDtrackV1::IsLayerError(ETRDlayerError error, Int_t ly, UInt_t status)
219{
220 if(ly>=kNplane || ly<0) return kFALSE;
221 return ((status>>((ly+1)*4))&0xf) == UChar_t(error);
222}
181c7f7e 223
224//____________________________________________________
225inline void AliTRDtrackV1::SetReconstructor(const AliTRDReconstructor *rec)
226{
227 for(Int_t ip=0; ip<kNplane; ip++){
228 if(!fTracklet[ip]) continue;
229 fTracklet[ip]->SetReconstructor(rec);
230 }
4d6aee34 231 fkReconstructor = rec;
181c7f7e 232}
233
eb2b4f91 234//____________________________________________________
34b5e42d 235inline void AliTRDtrackV1::SetErrStat(UChar_t status, Int_t ly)
eb2b4f91 236{
237 if(ly<kNplane) fStatus|=((status&0xf)<<((ly+1)*4));
238 return;
239}
240
181c7f7e 241
3b57a3f7 242//____________________________________________________________________________
243inline Float_t AliTRDtrackV1::StatusForTOF()
244{
eb2b4f91 245 // OBSOLETE
3b57a3f7 246 // Defines the status of the TOF extrapolation
247 //
248
249 if(!fTracklet[5]) return 0.;
250
251 // Definition of res ????
252 Float_t res = /*(0.2 + 0.8 * (fN / (fNExpected + 5.0))) **/ (0.4 + 0.6 * fTracklet[5]->GetN() / 20.0);
253 res *= (0.25 + 0.8 * 40.0 / (40.0 + fBudget[2]));
254 return res;
255}
d9950a5a 256
257#endif
258
259
6e49cfdb 260