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