Coding convention: RC11 rule violation -> suppression
[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//-------------------------------------------------------------------------
0c5f89fb 9// AOD track implementation of AliVParticle
df9db588 10// Author: Markus Oldenburg, CERN
11//-------------------------------------------------------------------------
12
13#include <TRef.h>
14
9861edc0 15#include "AliVParticle.h"
df9db588 16#include "AliAODVertex.h"
5d62ce04 17#include "AliAODRedCov.h"
df9db588 18
9861edc0 19class AliAODTrack : public AliVParticle {
df9db588 20
21 public:
22
1912763f 23 enum AODTrk_t {kUndef = -1,
24 kPrimary,
25 kSecondary,
26 kOrphan};
df9db588 27
28 enum AODTrkBits_t {
dc825b15 29 kIsDCA=BIT(14), // set if fPosition is the DCA and not the position of the first point
1912763f 30 kUsedForVtxFit=BIT(15), // set if this track was used to fit the vertex it is attached to
31 kUsedForPrimVtxFit=BIT(16) // set if this track was used to fit the primary vertex
df9db588 32 };
33
4697e4fb 34 enum AODTrkPID_t {
1912763f 35 kElectron = 0,
36 kMuon = 1,
37 kPion = 2,
38 kKaon = 3,
39 kProton = 4,
4697e4fb 40 kDeuteron = 5,
41 kTriton = 6,
42 kHelium3 = 7,
43 kAlpha = 8,
44 kUnknown = 9,
45 kMostProbable = -1
46 };
df9db588 47
48 AliAODTrack();
02153d58 49 AliAODTrack(Short_t id,
df9db588 50 Int_t label,
51 Double_t p[3],
52 Bool_t cartesian,
53 Double_t x[3],
54 Bool_t dca,
55 Double_t covMatrix[21],
56 Short_t q,
57 UChar_t itsClusMap,
58 Double_t pid[10],
59 AliAODVertex *prodVertex,
1912763f 60 Bool_t usedForVtxFit,
dc825b15 61 Bool_t usedForPrimVtxFit,
ec40c484 62 AODTrk_t ttype=kUndef,
63 UInt_t selectInfo=0);
df9db588 64
02153d58 65 AliAODTrack(Short_t id,
df9db588 66 Int_t label,
67 Float_t p[3],
68 Bool_t cartesian,
69 Float_t x[3],
70 Bool_t dca,
71 Float_t covMatrix[21],
72 Short_t q,
73 UChar_t itsClusMap,
74 Float_t pid[10],
75 AliAODVertex *prodVertex,
1912763f 76 Bool_t usedForVtxFit,
dc825b15 77 Bool_t usedForPrimVtxFit,
ec40c484 78 AODTrk_t ttype=kUndef,
79 UInt_t selectInfo=0);
df9db588 80
81 virtual ~AliAODTrack();
82 AliAODTrack(const AliAODTrack& trk);
83 AliAODTrack& operator=(const AliAODTrack& trk);
84
85 // kinematics
16b65f2a 86 virtual Double_t OneOverPt() const { return (fMomentum[0] != 0.) ? 1./fMomentum[0] : -999.; }
df9db588 87 virtual Double_t Phi() const { return fMomentum[1]; }
88 virtual Double_t Theta() const { return fMomentum[2]; }
89
16b65f2a 90 virtual Double_t Px() const { return fMomentum[0] * TMath::Cos(fMomentum[1]); }
91 virtual Double_t Py() const { return fMomentum[0] * TMath::Sin(fMomentum[1]); }
92 virtual Double_t Pz() const { return fMomentum[0] / TMath::Tan(fMomentum[2]); }
93 virtual Double_t Pt() const { return fMomentum[0]; }
df9db588 94 virtual Double_t P() const { return TMath::Sqrt(Pt()*Pt()+Pz()*Pz()); }
c683ddc2 95 virtual Bool_t PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
96
97 virtual Double_t Xv() const { return GetProdVertex() ? GetProdVertex()->GetX() : -999.; }
98 virtual Double_t Yv() const { return GetProdVertex() ? GetProdVertex()->GetY() : -999.; }
99 virtual Double_t Zv() const { return GetProdVertex() ? GetProdVertex()->GetZ() : -999.; }
100 virtual Bool_t XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
101
1912763f 102 Double_t Chi2perNDF() const { return fChi2perNDF; }
4697e4fb 103
104 virtual Double_t M() const { return M(GetMostProbablePID()); }
105 Double_t M(AODTrkPID_t pid) const;
106 virtual Double_t E() const { return E(GetMostProbablePID()); }
107 Double_t E(AODTrkPID_t pid) const;
108 Double_t E(Double_t m) const { return TMath::Sqrt(P()*P() + m*m); }
109 virtual Double_t Y() const { return Y(GetMostProbablePID()); }
110 Double_t Y(AODTrkPID_t pid) const;
111 Double_t Y(Double_t m) const;
df9db588 112
113 virtual Double_t Eta() const { return -TMath::Log(TMath::Tan(0.5 * fMomentum[2])); }
df9db588 114
115 virtual Short_t Charge() const {return fCharge; }
116
117 // PID
118 virtual const Double_t *PID() const { return fPID; }
4697e4fb 119 AODTrkPID_t GetMostProbablePID() const;
120 void ConvertAliPIDtoAODPID();
df9db588 121
122 template <class T> void GetPID(T *pid) const {
123 for(Int_t i=0; i<10; ++i) pid[i]=fPID[i];}
124
125 template <class T> void SetPID(const T *pid) {
126 if(pid) for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
186bf2c9 127 else {for(Int_t i=0; i<10; fPID[i++]=0.); fPID[AliAODTrack::kUnknown]=1.;}}
df9db588 128
02153d58 129 Short_t GetID() const { return fID; }
130 Int_t GetLabel() const { return fLabel; }
131 Char_t GetType() const { return fType;}
132 Bool_t GetUsedForVtxFit() const { return TestBit(kUsedForVtxFit); }
133 Bool_t GetUsedForPrimVtxFit() const { return TestBit(kUsedForPrimVtxFit); }
df9db588 134
135 template <class T> void GetP(T *p) const {
136 p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
137
138 template <class T> void GetPxPyPz(T *p) const {
139 p[0] = Px(); p[1] = Py(); p[2] = Pz();}
140
141 template <class T> Bool_t GetPosition(T *x) const {
142 x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
143 return TestBit(kIsDCA);}
144
145 template <class T> void SetCovMatrix(const T *covMatrix) {
5d62ce04 146 if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
df9db588 147 fCovMatrix->SetCovMatrix(covMatrix);}
148
149 template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
150 if(!fCovMatrix) return kFALSE;
151 fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
152
153 void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
154
1912763f 155 UChar_t GetITSClusterMap() const { return (UChar_t)fITSMuonClusterMap; }
156 UInt_t GetMUONClusterMap() const { return fITSMuonClusterMap/65536; }
157 UInt_t GetITSMUONClusterMap() const { return fITSMuonClusterMap; }
8a1418dc 158 Bool_t TestFilterBit(UInt_t filterBit) const {return (Bool_t) ((filterBit & fFilterMap) != 0);}
df9db588 159
160 AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
161
162 // print
163 void Print(const Option_t *opt = "") const;
164
165 // setters
02153d58 166 void SetID(Short_t id) { fID = id; }
14b34be5 167 void SetLabel(Int_t label) {fLabel = label; }
df9db588 168
14b34be5 169 template <class T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
df9db588 170 void SetDCA(Double_t d, Double_t z);
1912763f 171 void SetUsedForVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForVtxFit) : ResetBit(kUsedForVtxFit); }
dc825b15 172 void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
df9db588 173
14b34be5 174 void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = oneOverPt; }
16b65f2a 175 void SetPt(Double_t pt) { fMomentum[0] = pt; };
14b34be5 176 void SetPhi(Double_t phi) { fMomentum[1] = phi; }
177 void SetTheta(Double_t theta) { fMomentum[2] = theta; }
178 template <class T> void SetP(const T *p, Bool_t cartesian = kTRUE);
df9db588 179 void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
180
14b34be5 181 void SetCharge(Short_t q) { fCharge = q; }
1912763f 182 void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
df9db588 183
1912763f 184 void SetITSClusterMap(UChar_t itsClusMap) { fITSMuonClusterMap = (UInt_t)itsClusMap; }
185 void SetMuonClusterMap(UInt_t muonClusMap) { fITSMuonClusterMap = muonClusMap*65536; }
186 void SetITSMuonClusterMap(UInt_t itsMuonClusMap) { fITSMuonClusterMap = itsMuonClusMap; }
df9db588 187
8a1418dc 188 Int_t GetMatchTrigger() const {return fITSMuonClusterMap>>30;}
e1c744ca 189 // 0 Muon track does not match trigger
190 // 1 Muon track match but does not pass pt cut
191 // 2 Muon track match Low pt cut
192 // 3 Muon track match High pt cut
193 void SetMatchTrigger(Int_t MatchTrigger);
8a1418dc 194 Int_t MatchTrigger() const { return (GetMatchTrigger()>0)?1:0; } // Muon track matches trigger track
195 Int_t MatchTriggerAnyPt() const { return (GetMatchTrigger()>0)?1:0; } // Muon track matches trigger track
196 Int_t MatchTriggerLowPt() const { return (GetMatchTrigger()>1)?1:0; } // Muon track matches trigger track and passes Low pt cut
197 Int_t MatchTriggerHighPt() const { return (GetMatchTrigger()>2)?1:0; } // Muon track matches trigger track and passes High pt cut
198 Double_t GetChi2MatchTrigger() const { return fChi2MatchTrigger;}
e1c744ca 199 void SetChi2MatchTrigger(Double_t Chi2MatchTrigger) {fChi2MatchTrigger = Chi2MatchTrigger;}
200 UShort_t GetHitsPatternInTrigCh() const { return (fITSMuonClusterMap&0xff00)>>8; }
201 void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh);
9861edc0 202 Int_t HitsMT(Int_t istation, Int_t iplane, Char_t *cathode=0); // Check if track hits Muon chambers
203 Int_t HitsMuonChamber(Int_t MuonChamber); // Check if track hits Muon chambers
204 Bool_t IsMuonTrack() const { return fITSMuonClusterMap>>16;} // This scheme has to be checked, still!
e1c744ca 205
c683ddc2 206 void SetProdVertex(TObject *vertex) { fProdVertex = vertex; }
207 void SetType(AODTrk_t ttype) { fType=ttype; }
208
209 // track operations
210 Bool_t PropagateTo(Double_t xk, Double_t b);
df9db588 211
df9db588 212
df9db588 213 private :
214
215 // Momentum & position
1912763f 216 Double32_t fMomentum[3]; // momemtum stored in pt, phi, theta
217 Double32_t fPosition[3]; // position of first point on track or dca
df9db588 218
1912763f 219 Double32_t fChi2perNDF; // chi2/NDF of mometum fit
9333290e 220 Double32_t fChi2MatchTrigger; // chi2 of trigger/track matching
221 Double32_t fPID[10]; // [0.,1.,8] pointer to PID object
df9db588 222
1912763f 223 Int_t fLabel; // track label, points back to MC track
df9db588 224
9333290e 225 UInt_t fITSMuonClusterMap; // map of ITS and muon clusters, one bit per layer (ITS: bit 1-8, muon: bit 17-32)
226 UInt_t fFilterMap; // filter information, one bit per set of cuts
df9db588 227
02153d58 228 Short_t fID; // unique track ID, points back to the ESD track
229
1912763f 230 Char_t fCharge; // particle charge
1912763f 231 Char_t fType; // Track Type
df9db588 232
9333290e 233 AliAODRedCov<6> *fCovMatrix; // covariance matrix (x, y, z, px, py, pz)
234 TRef fProdVertex; // vertex of origin
df9db588 235
9333290e 236 ClassDef(AliAODTrack,5);
df9db588 237};
238
239#endif