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