fixed build error
[u/mrichter/AliRoot.git] / STEER / AliAODTrack.h
CommitLineData
df9db588 1#ifndef AliAODTrack_H
2#define AliAODTrack_H
3/* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/* $Id$ */
7
8//-------------------------------------------------------------------------
4f6e22bd 9// AOD track implementation of AliVTrack
df9db588 10// Author: Markus Oldenburg, CERN
11//-------------------------------------------------------------------------
12
13#include <TRef.h>
507ed024 14#include <TBits.h>
df9db588 15
4f6e22bd 16#include "AliVTrack.h"
df9db588 17#include "AliAODVertex.h"
5d62ce04 18#include "AliAODRedCov.h"
7be1db84 19#include "AliAODPid.h"
df9db588 20
4f6e22bd 21class AliAODTrack : public AliVTrack {
df9db588 22
23 public:
24
1912763f 25 enum AODTrk_t {kUndef = -1,
26 kPrimary,
27 kSecondary,
28 kOrphan};
df9db588 29
30 enum AODTrkBits_t {
dc825b15 31 kIsDCA=BIT(14), // set if fPosition is the DCA and not the position of the first point
1912763f 32 kUsedForVtxFit=BIT(15), // set if this track was used to fit the vertex it is attached to
33 kUsedForPrimVtxFit=BIT(16) // set if this track was used to fit the primary vertex
df9db588 34 };
35
4697e4fb 36 enum AODTrkPID_t {
1912763f 37 kElectron = 0,
38 kMuon = 1,
39 kPion = 2,
40 kKaon = 3,
41 kProton = 4,
4697e4fb 42 kDeuteron = 5,
43 kTriton = 6,
44 kHelium3 = 7,
45 kAlpha = 8,
46 kUnknown = 9,
47 kMostProbable = -1
48 };
df9db588 49
50 AliAODTrack();
02153d58 51 AliAODTrack(Short_t id,
df9db588 52 Int_t label,
53 Double_t p[3],
54 Bool_t cartesian,
55 Double_t x[3],
56 Bool_t dca,
57 Double_t covMatrix[21],
58 Short_t q,
59 UChar_t itsClusMap,
60 Double_t pid[10],
61 AliAODVertex *prodVertex,
1912763f 62 Bool_t usedForVtxFit,
dc825b15 63 Bool_t usedForPrimVtxFit,
ec40c484 64 AODTrk_t ttype=kUndef,
862ce351 65 UInt_t selectInfo=0,
66 Float_t chi2perNDF = -999.);
df9db588 67
02153d58 68 AliAODTrack(Short_t id,
df9db588 69 Int_t label,
70 Float_t p[3],
71 Bool_t cartesian,
72 Float_t x[3],
73 Bool_t dca,
74 Float_t covMatrix[21],
75 Short_t q,
76 UChar_t itsClusMap,
77 Float_t pid[10],
78 AliAODVertex *prodVertex,
1912763f 79 Bool_t usedForVtxFit,
dc825b15 80 Bool_t usedForPrimVtxFit,
ec40c484 81 AODTrk_t ttype=kUndef,
862ce351 82 UInt_t selectInfo=0,
83 Float_t chi2perNDF = -999.);
df9db588 84
85 virtual ~AliAODTrack();
86 AliAODTrack(const AliAODTrack& trk);
87 AliAODTrack& operator=(const AliAODTrack& trk);
88
89 // kinematics
16b65f2a 90 virtual Double_t OneOverPt() const { return (fMomentum[0] != 0.) ? 1./fMomentum[0] : -999.; }
df9db588 91 virtual Double_t Phi() const { return fMomentum[1]; }
92 virtual Double_t Theta() const { return fMomentum[2]; }
93
16b65f2a 94 virtual Double_t Px() const { return fMomentum[0] * TMath::Cos(fMomentum[1]); }
95 virtual Double_t Py() const { return fMomentum[0] * TMath::Sin(fMomentum[1]); }
96 virtual Double_t Pz() const { return fMomentum[0] / TMath::Tan(fMomentum[2]); }
97 virtual Double_t Pt() const { return fMomentum[0]; }
df9db588 98 virtual Double_t P() const { return TMath::Sqrt(Pt()*Pt()+Pz()*Pz()); }
c683ddc2 99 virtual Bool_t PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
100
101 virtual Double_t Xv() const { return GetProdVertex() ? GetProdVertex()->GetX() : -999.; }
102 virtual Double_t Yv() const { return GetProdVertex() ? GetProdVertex()->GetY() : -999.; }
103 virtual Double_t Zv() const { return GetProdVertex() ? GetProdVertex()->GetZ() : -999.; }
104 virtual Bool_t XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
105
c4460410 106 Double_t Chi2perNDF() const { return fChi2perNDF; }
107 UShort_t GetTPCNcls() const { return fTPCClusterMap.CountBits();}
4697e4fb 108
109 virtual Double_t M() const { return M(GetMostProbablePID()); }
110 Double_t M(AODTrkPID_t pid) const;
111 virtual Double_t E() const { return E(GetMostProbablePID()); }
112 Double_t E(AODTrkPID_t pid) const;
113 Double_t E(Double_t m) const { return TMath::Sqrt(P()*P() + m*m); }
114 virtual Double_t Y() const { return Y(GetMostProbablePID()); }
115 Double_t Y(AODTrkPID_t pid) const;
116 Double_t Y(Double_t m) const;
df9db588 117
118 virtual Double_t Eta() const { return -TMath::Log(TMath::Tan(0.5 * fMomentum[2])); }
df9db588 119
120 virtual Short_t Charge() const {return fCharge; }
121
122 // PID
123 virtual const Double_t *PID() const { return fPID; }
4697e4fb 124 AODTrkPID_t GetMostProbablePID() const;
125 void ConvertAliPIDtoAODPID();
e68fa179 126 void SetDetPID(AliAODPid *aodpid) {fDetPid = aodpid;}
df9db588 127
128 template <class T> void GetPID(T *pid) const {
129 for(Int_t i=0; i<10; ++i) pid[i]=fPID[i];}
130
131 template <class T> void SetPID(const T *pid) {
132 if(pid) for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
f12d42ce 133 else {for(Int_t i=0; i<10; fPID[i++]=0.) ; fPID[AliAODTrack::kUnknown]=1.;}}
df9db588 134
6efb741f 135 Bool_t IsOn(Int_t mask) const {return (fFlags&mask)>0;}
136 ULong_t GetStatus() const { return GetFlags(); }
137 ULong_t GetFlags() const { return fFlags; }
138
4f6e22bd 139 Int_t GetID() const { return (Int_t)fID; }
02153d58 140 Int_t GetLabel() const { return fLabel; }
141 Char_t GetType() const { return fType;}
862ce351 142 Bool_t IsPrimaryCandidate() const;
02153d58 143 Bool_t GetUsedForVtxFit() const { return TestBit(kUsedForVtxFit); }
144 Bool_t GetUsedForPrimVtxFit() const { return TestBit(kUsedForPrimVtxFit); }
df9db588 145
146 template <class T> void GetP(T *p) const {
147 p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
148
149 template <class T> void GetPxPyPz(T *p) const {
150 p[0] = Px(); p[1] = Py(); p[2] = Pz();}
151
152 template <class T> Bool_t GetPosition(T *x) const {
153 x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
154 return TestBit(kIsDCA);}
155
156 template <class T> void SetCovMatrix(const T *covMatrix) {
5d62ce04 157 if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
df9db588 158 fCovMatrix->SetCovMatrix(covMatrix);}
159
160 template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
161 if(!fCovMatrix) return kFALSE;
162 fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
163
892be05f 164 Bool_t GetXYZ(Double_t *p) const {
165 return GetPosition(p); }
166
4f6e22bd 167 Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const {
168 return GetCovMatrix(cv);}
169
df9db588 170 void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
171
6c954176 172 Double_t XAtDCA() const { return fPositionAtDCA[0]; }
173 Double_t YAtDCA() const { return fPositionAtDCA[1]; }
174 Double_t ZAtDCA() const {
175 if (IsMuonTrack()) return fPosition[2];
176 else if (TestBit(kIsDCA)) return fPosition[1];
177 else return -999.; }
178 Bool_t XYZAtDCA(Double_t x[3]) const { x[0] = XAtDCA(); x[1] = YAtDCA(); x[2] = ZAtDCA(); return kTRUE; }
179
180 Double_t DCA() const {
181 if (IsMuonTrack()) return TMath::Sqrt(XAtDCA()*XAtDCA() + YAtDCA()*YAtDCA());
182 else if (TestBit(kIsDCA)) return fPosition[0];
183 else return -999.; }
184
185 Double_t PxAtDCA() const { return fMomentumAtDCA[0]; }
186 Double_t PyAtDCA() const { return fMomentumAtDCA[1]; }
187 Double_t PzAtDCA() const { return fMomentumAtDCA[2]; }
188 Double_t PAtDCA() const { return TMath::Sqrt(PxAtDCA()*PxAtDCA() + PyAtDCA()*PyAtDCA() + PzAtDCA()*PzAtDCA()); }
189 Bool_t PxPyPzAtDCA(Double_t p[3]) const { p[0] = PxAtDCA(); p[1] = PyAtDCA(); p[2] = PzAtDCA(); return kTRUE; }
190
f43586f0 191 Double_t GetRAtAbsorberEnd() const { return fRAtAbsorberEnd; }
192
6c954176 193 UChar_t GetITSClusterMap() const { return (UChar_t)(fITSMuonClusterMap&0xff); }
194 UShort_t GetHitsPatternInTrigCh() const { return (UShort_t)((fITSMuonClusterMap&0xff00)>>8); }
195 UInt_t GetMUONClusterMap() const { return (fITSMuonClusterMap&0x3ff0000)>>16; }
196 UInt_t GetITSMUONClusterMap() const { return fITSMuonClusterMap; }
197
8a1418dc 198 Bool_t TestFilterBit(UInt_t filterBit) const {return (Bool_t) ((filterBit & fFilterMap) != 0);}
6db112a4 199 Bool_t TestFilterMask(UInt_t filterMask) const {return (Bool_t) ((filterMask & fFilterMap) == filterMask);}
df9db588 200
507ed024 201 const TBits& GetTPCClusterMap() const {return fTPCClusterMap;}
202 const TBits& GetTPCSharedMap() const {return fTPCSharedMap;}
203 void SetTPCClusterMap(const TBits amap) {fTPCClusterMap = amap;}
204 void SetTPCSharedMap(const TBits amap) {fTPCSharedMap = amap;}
205
7be1db84 206 AliAODPid *GetDetPid() const { return fDetPid; }
df9db588 207 AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
208
209 // print
210 void Print(const Option_t *opt = "") const;
211
212 // setters
6efb741f 213 void SetFlags(ULong_t flags) { fFlags = flags; }
214 void SetStatus(ULong_t flags) { fFlags|=flags; }
215 void ResetStatus(ULong_t flags) { fFlags&=~flags; }
216
02153d58 217 void SetID(Short_t id) { fID = id; }
6efb741f 218 void SetLabel(Int_t label) { fLabel = label; }
df9db588 219
14b34be5 220 template <class T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
df9db588 221 void SetDCA(Double_t d, Double_t z);
1912763f 222 void SetUsedForVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForVtxFit) : ResetBit(kUsedForVtxFit); }
dc825b15 223 void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
df9db588 224
f4ad422f 225 void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = 1. / oneOverPt; }
16b65f2a 226 void SetPt(Double_t pt) { fMomentum[0] = pt; };
14b34be5 227 void SetPhi(Double_t phi) { fMomentum[1] = phi; }
228 void SetTheta(Double_t theta) { fMomentum[2] = theta; }
229 template <class T> void SetP(const T *p, Bool_t cartesian = kTRUE);
df9db588 230 void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
231
6c954176 232 void SetXYAtDCA(Double_t x, Double_t y) {fPositionAtDCA[0] = x; fPositionAtDCA[1] = y;}
233 void SetPxPyPzAtDCA(Double_t pX, Double_t pY, Double_t pZ) {fMomentumAtDCA[0] = pX; fMomentumAtDCA[1] = pY; fMomentumAtDCA[2] = pZ;}
234
f43586f0 235 void SetRAtAbsorberEnd(Double_t r) { fRAtAbsorberEnd = r; }
236
14b34be5 237 void SetCharge(Short_t q) { fCharge = q; }
1912763f 238 void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
df9db588 239
6c954176 240 void SetITSClusterMap(UChar_t itsClusMap) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffffff00)|(((UInt_t)itsClusMap)&0xff); }
241 void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffff00ff)|((((UInt_t)hitsPatternInTrigCh)&0xff)<<8); }
242 void SetMuonClusterMap(UInt_t muonClusMap) { fITSMuonClusterMap = (fITSMuonClusterMap&0xfc00ffff)|((muonClusMap&0x3ff)<<16); }
243 void SetITSMuonClusterMap(UInt_t itsMuonClusMap) { fITSMuonClusterMap = itsMuonClusMap; }
df9db588 244
8a1418dc 245 Int_t GetMatchTrigger() const {return fITSMuonClusterMap>>30;}
e1c744ca 246 // 0 Muon track does not match trigger
247 // 1 Muon track match but does not pass pt cut
248 // 2 Muon track match Low pt cut
249 // 3 Muon track match High pt cut
250 void SetMatchTrigger(Int_t MatchTrigger);
2200238e 251 Bool_t MatchTrigger() const { return (GetMatchTrigger()>0); } // Muon track matches trigger track
252 Bool_t MatchTriggerLowPt() const { return (GetMatchTrigger()>1); } // Muon track matches trigger track and passes Low pt cut
253 Bool_t MatchTriggerHighPt() const { return (GetMatchTrigger()>2); } // Muon track matches trigger track and passes High pt cut
254 Bool_t MatchTriggerDigits() const; // Muon track matches trigger digits
8a1418dc 255 Double_t GetChi2MatchTrigger() const { return fChi2MatchTrigger;}
6c954176 256 void SetChi2MatchTrigger(Double_t Chi2MatchTrigger) {fChi2MatchTrigger = Chi2MatchTrigger; }
2200238e 257 Bool_t HitsMuonChamber(Int_t MuonChamber, Int_t cathode = -1) const; // Check if track hits Muon chambers
6c954176 258 Bool_t IsMuonTrack() const { return (GetMUONClusterMap()>0) ? kTRUE : kFALSE; }
5c15a68b 259
260 void Connected(Bool_t flag) {flag ? SETBIT(fITSMuonClusterMap,26) : CLRBIT(fITSMuonClusterMap,26);}
261 Bool_t IsConnected() const {return TESTBIT(fITSMuonClusterMap,26);}
e1c744ca 262
c683ddc2 263 void SetProdVertex(TObject *vertex) { fProdVertex = vertex; }
264 void SetType(AODTrk_t ttype) { fType=ttype; }
265
6a8e543a 266 // Dummy
267 Int_t PdgCode() const {return 0;}
268
df9db588 269 private :
270
271 // Momentum & position
1912763f 272 Double32_t fMomentum[3]; // momemtum stored in pt, phi, theta
273 Double32_t fPosition[3]; // position of first point on track or dca
6c954176 274
275 Double32_t fMomentumAtDCA[3]; // momentum (px,py,pz) at DCA
276 Double32_t fPositionAtDCA[2]; // trasverse position (x,y) at DCA
277
f43586f0 278 Double32_t fRAtAbsorberEnd; // transverse position r at the end of the muon absorber
279
862ce351 280 Double32_t fChi2perNDF; // chi2/NDF of momentum fit
9333290e 281 Double32_t fChi2MatchTrigger; // chi2 of trigger/track matching
282 Double32_t fPID[10]; // [0.,1.,8] pointer to PID object
df9db588 283
6efb741f 284 ULong_t fFlags; // reconstruction status flags
1912763f 285 Int_t fLabel; // track label, points back to MC track
df9db588 286
6c954176 287 UInt_t fITSMuonClusterMap; // map of ITS and muon clusters, one bit per layer
288 // (ITS: bit 1-8, muon trigger: bit 9-16, muon tracker: bit 17-26, muon match trigger: bit 31-32)
9333290e 289 UInt_t fFilterMap; // filter information, one bit per set of cuts
df9db588 290
507ed024 291 TBits fTPCClusterMap; // Map of clusters, one bit per padrow; 1 if has a cluster on given padrow
292 TBits fTPCSharedMap; // Map of clusters, one bit per padrow; 1 if has a shared cluster on given padrow
293
02153d58 294 Short_t fID; // unique track ID, points back to the ESD track
295
1912763f 296 Char_t fCharge; // particle charge
1912763f 297 Char_t fType; // Track Type
507ed024 298
9333290e 299 AliAODRedCov<6> *fCovMatrix; // covariance matrix (x, y, z, px, py, pz)
7be1db84 300 AliAODPid *fDetPid; // more detailed or detector specific pid information
9333290e 301 TRef fProdVertex; // vertex of origin
df9db588 302
f43586f0 303 ClassDef(AliAODTrack, 10);
df9db588 304};
305
862ce351 306inline Bool_t AliAODTrack::IsPrimaryCandidate() const
307{
308 // True of track passes primary particle selection (independent of type)
309 //
310 if (fFilterMap) {
311 return kTRUE;
312 } else {
313 return kFALSE;
314 }
315}
316
df9db588 317#endif