3 /* Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
8 //-------------------------------------------------------------------------
9 // AOD track implementation of AliVTrack
10 // Author: Markus Oldenburg, CERN
11 //-------------------------------------------------------------------------
16 #include "AliVTrack.h"
17 #include "AliAODVertex.h"
18 #include "AliAODRedCov.h"
19 #include "AliAODPid.h"
23 class AliAODTrack : public AliVTrack {
27 enum AODTrk_t {kUndef = -1,
33 kIsDCA=BIT(14), // set if fPosition is the DCA and not the position of the first point
34 kUsedForVtxFit=BIT(15), // set if this track was used to fit the vertex it is attached to
35 kUsedForPrimVtxFit=BIT(16) // set if this track was used to fit the primary vertex
53 AliAODTrack(Short_t id,
59 Double_t covMatrix[21],
63 AliAODVertex *prodVertex,
65 Bool_t usedForPrimVtxFit,
66 AODTrk_t ttype=kUndef,
68 Float_t chi2perNDF = -999.);
70 AliAODTrack(Short_t id,
76 Float_t covMatrix[21],
80 AliAODVertex *prodVertex,
82 Bool_t usedForPrimVtxFit,
83 AODTrk_t ttype=kUndef,
85 Float_t chi2perNDF = -999.);
87 virtual ~AliAODTrack();
88 AliAODTrack(const AliAODTrack& trk);
89 AliAODTrack& operator=(const AliAODTrack& trk);
92 virtual Double_t OneOverPt() const { return (fMomentum[0] != 0.) ? 1./fMomentum[0] : -999.; }
93 virtual Double_t Phi() const { return fMomentum[1]; }
94 virtual Double_t Theta() const { return fMomentum[2]; }
96 virtual Double_t Px() const { return fMomentum[0] * TMath::Cos(fMomentum[1]); }
97 virtual Double_t Py() const { return fMomentum[0] * TMath::Sin(fMomentum[1]); }
98 virtual Double_t Pz() const { return fMomentum[0] / TMath::Tan(fMomentum[2]); }
99 virtual Double_t Pt() const { return fMomentum[0]; }
100 virtual Double_t P() const { return TMath::Sqrt(Pt()*Pt()+Pz()*Pz()); }
101 virtual Bool_t PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
103 virtual Double_t Xv() const { return GetProdVertex() ? GetProdVertex()->GetX() : -999.; }
104 virtual Double_t Yv() const { return GetProdVertex() ? GetProdVertex()->GetY() : -999.; }
105 virtual Double_t Zv() const { return GetProdVertex() ? GetProdVertex()->GetZ() : -999.; }
106 virtual Bool_t XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
108 Double_t Chi2perNDF() const { return fChi2perNDF; }
109 UShort_t GetTPCNcls() const { return fTPCClusterMap.CountBits();}
111 virtual Double_t M() const { return M(GetMostProbablePID()); }
112 Double_t M(AODTrkPID_t pid) const;
113 virtual Double_t E() const { return E(GetMostProbablePID()); }
114 Double_t E(AODTrkPID_t pid) const;
115 Double_t E(Double_t m) const { return TMath::Sqrt(P()*P() + m*m); }
116 virtual Double_t Y() const { return Y(GetMostProbablePID()); }
117 Double_t Y(AODTrkPID_t pid) const;
118 Double_t Y(Double_t m) const;
120 virtual Double_t Eta() const { return -TMath::Log(TMath::Tan(0.5 * fMomentum[2])); }
122 virtual Short_t Charge() const {return fCharge; }
124 virtual Bool_t PropagateToDCA(const AliVVertex *vtx,
125 Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3]);
128 virtual const Double_t *PID() const { return fPID; }
129 AODTrkPID_t GetMostProbablePID() const;
130 void ConvertAliPIDtoAODPID();
131 void SetDetPID(AliAODPid *aodpid) {fDetPid = aodpid;}
133 template <class T> void GetPID(T *pid) const {
134 for(Int_t i=0; i<10; ++i) pid[i]=fPID[i];}
136 template <class T> void SetPID(const T *pid) {
137 if(pid) for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
138 else {for(Int_t i=0; i<10; fPID[i++]=0.) ; fPID[AliAODTrack::kUnknown]=1.;}}
140 Bool_t IsOn(Int_t mask) const {return (fFlags&mask)>0;}
141 ULong_t GetStatus() const { return GetFlags(); }
142 ULong_t GetFlags() const { return fFlags; }
144 Int_t GetID() const { return (Int_t)fID; }
145 Int_t GetLabel() const { return fLabel; }
146 Char_t GetType() const { return fType;}
147 Bool_t IsPrimaryCandidate() const;
148 Bool_t GetUsedForVtxFit() const { return TestBit(kUsedForVtxFit); }
149 Bool_t GetUsedForPrimVtxFit() const { return TestBit(kUsedForPrimVtxFit); }
151 template <class T> void GetP(T *p) const {
152 p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
154 template <class T> void GetPxPyPz(T *p) const {
155 p[0] = Px(); p[1] = Py(); p[2] = Pz();}
157 template <class T> Bool_t GetPosition(T *x) const {
158 x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
159 return TestBit(kIsDCA);}
161 template <class T> void SetCovMatrix(const T *covMatrix) {
162 if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
163 fCovMatrix->SetCovMatrix(covMatrix);}
165 template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
166 if(!fCovMatrix) return kFALSE;
167 fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
169 Bool_t GetXYZ(Double_t *p) const {
170 return GetPosition(p); }
172 Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const {
173 return GetCovMatrix(cv);}
175 void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
177 Double_t XAtDCA() const { return fPositionAtDCA[0]; }
178 Double_t YAtDCA() const { return fPositionAtDCA[1]; }
179 Double_t ZAtDCA() const {
180 if (IsMuonTrack()) return fPosition[2];
181 else if (TestBit(kIsDCA)) return fPosition[1];
183 Bool_t XYZAtDCA(Double_t x[3]) const { x[0] = XAtDCA(); x[1] = YAtDCA(); x[2] = ZAtDCA(); return kTRUE; }
185 Double_t DCA() const {
186 if (IsMuonTrack()) return TMath::Sqrt(XAtDCA()*XAtDCA() + YAtDCA()*YAtDCA());
187 else if (TestBit(kIsDCA)) return fPosition[0];
190 Double_t PxAtDCA() const { return fMomentumAtDCA[0]; }
191 Double_t PyAtDCA() const { return fMomentumAtDCA[1]; }
192 Double_t PzAtDCA() const { return fMomentumAtDCA[2]; }
193 Double_t PAtDCA() const { return TMath::Sqrt(PxAtDCA()*PxAtDCA() + PyAtDCA()*PyAtDCA() + PzAtDCA()*PzAtDCA()); }
194 Bool_t PxPyPzAtDCA(Double_t p[3]) const { p[0] = PxAtDCA(); p[1] = PyAtDCA(); p[2] = PzAtDCA(); return kTRUE; }
196 Double_t GetRAtAbsorberEnd() const { return fRAtAbsorberEnd; }
198 UChar_t GetITSClusterMap() const { return (UChar_t)(fITSMuonClusterMap&0xff); }
199 Int_t GetITSNcls() const;
200 Bool_t HasPointOnITSLayer(Int_t i) const { return TESTBIT(GetITSClusterMap(),i); }
201 UShort_t GetHitsPatternInTrigCh() const { return (UShort_t)((fITSMuonClusterMap&0xff00)>>8); }
202 UInt_t GetMUONClusterMap() const { return (fITSMuonClusterMap&0x3ff0000)>>16; }
203 UInt_t GetITSMUONClusterMap() const { return fITSMuonClusterMap; }
205 Bool_t TestFilterBit(UInt_t filterBit) const {return (Bool_t) ((filterBit & fFilterMap) != 0);}
206 Bool_t TestFilterMask(UInt_t filterMask) const {return (Bool_t) ((filterMask & fFilterMap) == filterMask);}
208 const TBits& GetTPCClusterMap() const {return fTPCClusterMap;}
209 const TBits& GetTPCSharedMap() const {return fTPCSharedMap;}
210 void SetTPCClusterMap(const TBits amap) {fTPCClusterMap = amap;}
211 void SetTPCSharedMap(const TBits amap) {fTPCSharedMap = amap;}
213 AliAODPid *GetDetPid() const { return fDetPid; }
214 AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
217 void Print(const Option_t *opt = "") const;
220 void SetFlags(ULong_t flags) { fFlags = flags; }
221 void SetStatus(ULong_t flags) { fFlags|=flags; }
222 void ResetStatus(ULong_t flags) { fFlags&=~flags; }
224 void SetID(Short_t id) { fID = id; }
225 void SetLabel(Int_t label) { fLabel = label; }
227 template <class T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
228 void SetDCA(Double_t d, Double_t z);
229 void SetUsedForVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForVtxFit) : ResetBit(kUsedForVtxFit); }
230 void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
232 void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = 1. / oneOverPt; }
233 void SetPt(Double_t pt) { fMomentum[0] = pt; };
234 void SetPhi(Double_t phi) { fMomentum[1] = phi; }
235 void SetTheta(Double_t theta) { fMomentum[2] = theta; }
236 template <class T> void SetP(const T *p, Bool_t cartesian = kTRUE);
237 void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
239 void SetXYAtDCA(Double_t x, Double_t y) {fPositionAtDCA[0] = x; fPositionAtDCA[1] = y;}
240 void SetPxPyPzAtDCA(Double_t pX, Double_t pY, Double_t pZ) {fMomentumAtDCA[0] = pX; fMomentumAtDCA[1] = pY; fMomentumAtDCA[2] = pZ;}
242 void SetRAtAbsorberEnd(Double_t r) { fRAtAbsorberEnd = r; }
244 void SetCharge(Short_t q) { fCharge = q; }
245 void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
247 void SetITSClusterMap(UChar_t itsClusMap) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffffff00)|(((UInt_t)itsClusMap)&0xff); }
248 void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffff00ff)|((((UInt_t)hitsPatternInTrigCh)&0xff)<<8); }
249 void SetMuonClusterMap(UInt_t muonClusMap) { fITSMuonClusterMap = (fITSMuonClusterMap&0xfc00ffff)|((muonClusMap&0x3ff)<<16); }
250 void SetITSMuonClusterMap(UInt_t itsMuonClusMap) { fITSMuonClusterMap = itsMuonClusMap; }
252 Int_t GetMatchTrigger() const {return fITSMuonClusterMap>>30;}
253 // 0 Muon track does not match trigger
254 // 1 Muon track match but does not pass pt cut
255 // 2 Muon track match Low pt cut
256 // 3 Muon track match High pt cut
257 void SetMatchTrigger(Int_t MatchTrigger);
258 Bool_t MatchTrigger() const { return (GetMatchTrigger()>0); } // Muon track matches trigger track
259 Bool_t MatchTriggerLowPt() const { return (GetMatchTrigger()>1); } // Muon track matches trigger track and passes Low pt cut
260 Bool_t MatchTriggerHighPt() const { return (GetMatchTrigger()>2); } // Muon track matches trigger track and passes High pt cut
261 Bool_t MatchTriggerDigits() const; // Muon track matches trigger digits
262 Double_t GetChi2MatchTrigger() const { return fChi2MatchTrigger;}
263 void SetChi2MatchTrigger(Double_t Chi2MatchTrigger) {fChi2MatchTrigger = Chi2MatchTrigger; }
264 Bool_t HitsMuonChamber(Int_t MuonChamber, Int_t cathode = -1) const; // Check if track hits Muon chambers
265 Bool_t IsMuonTrack() const { return (GetMUONClusterMap()>0) ? kTRUE : kFALSE; }
267 void Connected(Bool_t flag) {flag ? SETBIT(fITSMuonClusterMap,26) : CLRBIT(fITSMuonClusterMap,26);}
268 Bool_t IsConnected() const {return TESTBIT(fITSMuonClusterMap,26);}
270 void SetProdVertex(TObject *vertex) { fProdVertex = vertex; }
271 void SetType(AODTrk_t ttype) { fType=ttype; }
276 Int_t PdgCode() const {return 0;}
280 // Momentum & position
281 Double32_t fMomentum[3]; // momemtum stored in pt, phi, theta
282 Double32_t fPosition[3]; // position of first point on track or dca
284 Double32_t fMomentumAtDCA[3]; // momentum (px,py,pz) at DCA
285 Double32_t fPositionAtDCA[2]; // trasverse position (x,y) at DCA
287 Double32_t fRAtAbsorberEnd; // transverse position r at the end of the muon absorber
289 Double32_t fChi2perNDF; // chi2/NDF of momentum fit
290 Double32_t fChi2MatchTrigger; // chi2 of trigger/track matching
291 Double32_t fPID[10]; // [0.,1.,8] pointer to PID object
293 ULong_t fFlags; // reconstruction status flags
294 Int_t fLabel; // track label, points back to MC track
296 UInt_t fITSMuonClusterMap; // map of ITS and muon clusters, one bit per layer
297 // (ITS: bit 1-8, muon trigger: bit 9-16, muon tracker: bit 17-26, muon match trigger: bit 31-32)
298 UInt_t fFilterMap; // filter information, one bit per set of cuts
300 TBits fTPCClusterMap; // Map of clusters, one bit per padrow; 1 if has a cluster on given padrow
301 TBits fTPCSharedMap; // Map of clusters, one bit per padrow; 1 if has a shared cluster on given padrow
303 Short_t fID; // unique track ID, points back to the ESD track
305 Char_t fCharge; // particle charge
306 Char_t fType; // Track Type
308 AliAODRedCov<6> *fCovMatrix; // covariance matrix (x, y, z, px, py, pz)
309 AliAODPid *fDetPid; // more detailed or detector specific pid information
310 TRef fProdVertex; // vertex of origin
312 ClassDef(AliAODTrack, 10);
315 inline Bool_t AliAODTrack::IsPrimaryCandidate() const
317 // True of track passes primary particle selection (independent of type)
326 inline Int_t AliAODTrack::GetITSNcls() const
328 // Number of points in ITS
330 for(Int_t i=0;i<6;i++) if(HasPointOnITSLayer(i)) n++;