]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODTrack.h
Merge remote-tracking branch 'origin/master' into mergingFlat
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODTrack.h
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 //-------------------------------------------------------------------------
9 //     AOD track implementation of AliVTrack
10 //     Author: Markus Oldenburg, CERN
11 //-------------------------------------------------------------------------
12
13 #include <TRef.h>
14 #include <TBits.h>
15
16 #include "AliVTrack.h"
17 #include "AliAODVertex.h"
18 #include "AliAODRedCov.h"
19 #include "AliAODPid.h"
20 #include "AliExternalTrackParam.h"
21  
22
23 class AliVVertex;
24 class AliDetectorPID;
25 class AliTPCdEdxInfo;
26 class AliAODEvent;
27 class AliTOFHeader;
28
29 class AliAODTrack : public AliVTrack {
30
31  public:
32   
33   enum AODTrk_t {kUndef = -1, 
34                  kPrimary, 
35                  kFromDecayVtx, 
36                  kOrphan}; // Please note that this flag does not guarantee that the particle is a Physical Primary, it simply identifies the algorithm which was used to filter the track. In general, the following associations are used (check the filter macro to be sure, as this comment may be outdated): 
37                            //kPrimary: TPC only tracks, global constrained tracks, primary tracks, kink mothers; 
38                            //kFromDecayVtx: bachelor tracks from cascades, tracks from V0, kink daughters; 
39                            //kUndef:TRD matched tracks
40
41   enum AODTrkBits_t {
42     kIsDCA=BIT(14),   // set if fPosition is the DCA and not the position of the first point
43     kUsedForVtxFit=BIT(15), // set if this track was used to fit the vertex it is attached to
44     kUsedForPrimVtxFit=BIT(16), // set if this track was used to fit the primary vertex
45     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
46     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
47     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
48     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
49   };
50
51
52   enum AODTrkFilterBits_t {
53     kTrkTPCOnly            = BIT(0), // Standard TPC only tracks
54     kTrkITSsa              = BIT(1), // ITS standalone
55     kTrkITSConstrained     = BIT(2), // Pixel OR necessary for the electrons
56     kTrkElectronsPID       = BIT(3),    // PID for the electrons
57     kTrkGlobalNoDCA        = BIT(4), // standard cuts with very loose DCA
58     kTrkGlobal             = BIT(5),  // standard cuts with tight DCA cut
59     kTrkGlobalSDD          = BIT(6), // 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
60     kTrkTPCOnlyConstrained = BIT(7) // TPC only tracks: TPConly information constrained to SPD vertex in the filter below
61   };
62   
63
64   enum AODTrkPID_t {
65     kElectron     =  0,
66     kMuon         =  1,
67     kPion         =  2,
68     kKaon         =  3,
69     kProton       =  4,
70     kDeuteron     =  5,
71     kTriton       =  6,
72     kHelium3      =  7,
73     kAlpha        =  8,
74     kUnknown      =  9,
75     kMostProbable = -1
76   };
77
78   AliAODTrack();
79   AliAODTrack(Short_t id,
80               Int_t label,
81               Double_t p[3],
82               Bool_t cartesian,
83               Double_t x[3],
84               Bool_t dca,
85               Double_t covMatrix[21],
86               Short_t q,
87               UChar_t itsClusMap,
88               AliAODVertex *prodVertex,
89               Bool_t usedForVtxFit,
90               Bool_t usedForPrimVtxFit,
91               AODTrk_t ttype=kUndef,
92               UInt_t selectInfo=0,
93               Float_t chi2perNDF = -999.);
94
95
96   AliAODTrack(Short_t id,
97               Int_t label,
98               Float_t p[3],
99               Bool_t cartesian,
100               Float_t x[3],
101               Bool_t dca,
102               Float_t covMatrix[21],
103               Short_t q,
104               UChar_t itsClusMap,
105               AliAODVertex *prodVertex,
106               Bool_t usedForVtxFit,
107               Bool_t usedForPrimVtxFit,
108               AODTrk_t ttype=kUndef,
109               UInt_t selectInfo=0,
110               Float_t chi2perNDF = -999.);
111
112   virtual ~AliAODTrack();
113   AliAODTrack(const AliAODTrack& trk); 
114   AliAODTrack& operator=(const AliAODTrack& trk);
115
116   // kinematics
117   virtual Double_t OneOverPt() const { return (fMomentum[0] != 0.) ? 1./fMomentum[0] : -999.; }
118   virtual Double_t Phi()       const { return fMomentum[1]; }
119   virtual Double_t Theta()     const { return fMomentum[2]; }
120   
121   virtual Double_t Px() const { return fMomentum[0] * TMath::Cos(fMomentum[1]); }
122   virtual Double_t Py() const { return fMomentum[0] * TMath::Sin(fMomentum[1]); }
123   virtual Double_t Pz() const { return fMomentum[0] / TMath::Tan(fMomentum[2]); }
124   virtual Double_t Pt() const { return fMomentum[0]; }
125   virtual Double_t P()  const { return TMath::Sqrt(Pt()*Pt()+Pz()*Pz()); }
126   virtual Bool_t   PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
127
128   virtual Double_t Xv() const { return GetProdVertex() ? GetProdVertex()->GetX() : -999.; }
129   virtual Double_t Yv() const { return GetProdVertex() ? GetProdVertex()->GetY() : -999.; }
130   virtual Double_t Zv() const { return GetProdVertex() ? GetProdVertex()->GetZ() : -999.; }
131   virtual Bool_t   XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
132
133   Double_t Chi2perNDF()  const { return fChi2perNDF; }
134
135   UShort_t GetTPCnclsS(Int_t i0=0,Int_t i1=159)  const { 
136     UShort_t cl = fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
137     return cl;
138   }
139   
140   UShort_t GetTPCncls(Int_t i0=0,Int_t i1=159)  const { 
141     UShort_t cl = fTPCFitMap.CountBits(i0)-fTPCFitMap.CountBits(i1);
142     if(cl==0)cl = fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);// backward compatibility
143     return cl;
144   }
145   
146   UShort_t GetTPCNcls()  const { return GetTPCncls(); }
147
148   Int_t GetNcls(Int_t idet) const;
149
150   virtual Double_t M() const { return M(GetMostProbablePID()); }
151   Double_t M(AODTrkPID_t pid) const;
152   virtual Double_t E() const { return E(GetMostProbablePID()); }
153   Double_t E(AODTrkPID_t pid) const;
154   Double_t E(Double_t m) const { return TMath::Sqrt(P()*P() + m*m); }
155   virtual Double_t Y() const { return Y(GetMostProbablePID()); }
156   Double_t Y(AODTrkPID_t pid) const;
157   Double_t Y(Double_t m) const;
158   
159   virtual Double_t Eta() const { return -TMath::Log(TMath::Tan(0.5 * fMomentum[2])); }
160
161   virtual Short_t  Charge() const {return fCharge; }
162
163   virtual Bool_t   PropagateToDCA(const AliVVertex *vtx, 
164           Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3]);
165
166   // PID
167   virtual const Double_t *PID() const { return fPID; }
168   AODTrkPID_t GetMostProbablePID() const;
169   void ConvertAliPIDtoAODPID();
170   void SetDetPID(AliAODPid *aodpid) {fDetPid = aodpid;}
171
172   void     SetPIDForTracking(Int_t pid) {fPIDForTracking = pid;}
173   Int_t    GetPIDForTracking()  const   {return fPIDForTracking;}
174   Double_t GetMassForTracking() const;
175
176   template <typename T> void GetPID(T *pid) const {
177     for(Int_t i=0; i<10; ++i) pid[i] = fPID ? fPID[i]:0;}
178  
179   template <typename T> void SetPID(const T *pid) {
180     if (pid) {
181       if (!fPID) fPID = new Double32_t[10];
182       for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
183     }
184     else {delete[] fPID; fPID = 0;}
185   }
186   
187   Bool_t IsOn(Int_t mask) const {return (fFlags&mask)>0;}
188   ULong_t GetStatus() const { return GetFlags(); }
189   ULong_t GetFlags() const { return fFlags; }
190
191   Int_t   GetID() const { return (Int_t)fID; }
192   Int_t   GetLabel() const { return fLabel; } 
193   void    GetTOFLabel(Int_t *p) const;
194
195
196   Char_t  GetType() const { return fType;}
197   Bool_t  IsPrimaryCandidate() const;
198   Bool_t  GetUsedForVtxFit() const { return TestBit(kUsedForVtxFit); }
199   Bool_t  GetUsedForPrimVtxFit() const { return TestBit(kUsedForPrimVtxFit); }
200
201   Bool_t  IsHybridGlobalConstrainedGlobal() const { return TestBit(kIsHybridGCG); }
202   Bool_t  IsHybridTPCConstrainedGlobal() const { return TestBit(kIsHybridTPCCG); }
203   Bool_t  IsTPCOnly() const { return IsTPCConstrained(); } // obsolete bad naming
204   Bool_t  IsTPCConstrained() const { return TestBit(kIsTPCConstrained); }
205   Bool_t  IsGlobalConstrained() const { return TestBit(kIsGlobalConstrained); }
206   //
207   Int_t   GetTOFBunchCrossing(Double_t b=0, Bool_t tpcPIDonly=kFALSE) const;
208   //
209   using AliVTrack::GetP;
210   template <typename T> void GetP(T *p) const {
211     p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
212
213 //  template <typename T> void GetPxPyPz(T *p) const {
214 //    p[0] = Px(); p[1] = Py(); p[2] = Pz();}
215   Bool_t GetPxPyPz(Double_t *p) const;
216
217   template <typename T> Bool_t GetPosition(T *x) const {
218     x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
219     return TestBit(kIsDCA);}
220
221   template <typename T> void SetCovMatrix(const T *covMatrix) {
222     if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
223     fCovMatrix->SetCovMatrix(covMatrix);}
224
225   template <typename T> Bool_t GetCovMatrix(T *covMatrix) const {
226     if(!fCovMatrix) return kFALSE;
227     fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
228
229   Bool_t GetXYZ(Double_t *p) const {
230     return GetPosition(p); }  
231   
232   Bool_t GetXYZAt(Double_t x, Double_t b, Double_t *r) const;
233   Bool_t GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz=0, Double_t* alpSect=0) const;  
234
235   Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const {
236     return GetCovMatrix(cv);}
237
238   void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
239
240   Double_t XAtDCA() const { return fPositionAtDCA[0]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
241   Double_t YAtDCA() const { return fPositionAtDCA[1]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
242   Double_t ZAtDCA() const {
243     if (IsMuonTrack()) return fPosition[2];
244     else if (TestBit(kIsDCA)) return fPosition[1];
245     else return -999.; }                                //makes sense only for constrained tracks, returns dummy values for all other tracks
246   Bool_t   XYZAtDCA(Double_t x[3]) const { x[0] = XAtDCA(); x[1] = YAtDCA(); x[2] = ZAtDCA(); return kTRUE; }
247   
248   Double_t DCA() const {
249     if (IsMuonTrack()) return TMath::Sqrt(XAtDCA()*XAtDCA() + YAtDCA()*YAtDCA());
250     else if (TestBit(kIsDCA)) return fPosition[0];
251     else return -999.; }
252   
253   Double_t PxAtDCA() const { return fMomentumAtDCA[0]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
254   Double_t PyAtDCA() const { return fMomentumAtDCA[1]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
255   Double_t PzAtDCA() const { return fMomentumAtDCA[2]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
256   Double_t PAtDCA() const { return TMath::Sqrt(PxAtDCA()*PxAtDCA() + PyAtDCA()*PyAtDCA() + PzAtDCA()*PzAtDCA()); }
257   Bool_t   PxPyPzAtDCA(Double_t p[3]) const { p[0] = PxAtDCA(); p[1] = PyAtDCA(); p[2] = PzAtDCA(); return kTRUE; }
258   
259   Double_t GetRAtAbsorberEnd() const { return fRAtAbsorberEnd; }
260   
261   UChar_t  GetITSClusterMap() const       { return (UChar_t)(fITSMuonClusterMap&0xff); }
262   Int_t    GetITSNcls() const; 
263   Bool_t   HasPointOnITSLayer(Int_t i) const { return TESTBIT(GetITSClusterMap(),i); }
264   UShort_t GetHitsPatternInTrigCh() const { return (UShort_t)((fITSMuonClusterMap&0xff00)>>8); }
265   UInt_t   GetMUONClusterMap() const      { return (fITSMuonClusterMap&0x3ff0000)>>16; }
266   UInt_t   GetITSMUONClusterMap() const   { return fITSMuonClusterMap; }
267   
268   Bool_t  TestFilterBit(UInt_t filterBit) const {return (Bool_t) ((filterBit & fFilterMap) != 0);}
269   Bool_t  TestFilterMask(UInt_t filterMask) const {return (Bool_t) ((filterMask & fFilterMap) == filterMask);}
270   void    SetFilterMap(UInt_t i){fFilterMap = i;}
271   UInt_t  GetFilterMap() const {return fFilterMap;}
272
273   const TBits& GetTPCClusterMap() const {return fTPCClusterMap;}
274   const TBits* GetTPCClusterMapPtr() const {return &fTPCClusterMap;}
275   const TBits& GetTPCFitMap() const {return fTPCFitMap;}
276   const TBits* GetTPCFitMapPtr() const {return &fTPCFitMap;}
277   Float_t GetTPCClusterInfo(Int_t nNeighbours=3, Int_t type=0, Int_t row0=0, Int_t row1=159, Int_t /*type*/=0) const;
278   
279   const TBits& GetTPCSharedMap() const {return fTPCSharedMap;}
280   const TBits* GetTPCSharedMapPtr() const {return &fTPCSharedMap;}
281   void    SetTPCClusterMap(const TBits amap) {fTPCClusterMap = amap;}
282   void    SetTPCSharedMap(const TBits amap) {fTPCSharedMap = amap;}
283   void    SetTPCFitMap(const TBits amap) {fTPCFitMap = amap;}
284   void    SetTPCPointsF(UShort_t  findable){fTPCnclsF = findable;}
285   void    SetTPCNCrossedRows(UInt_t n)     {fTPCNCrossedRows = n;}
286   
287   virtual const    AliExternalTrackParam * GetInnerParam() const { return NULL; }
288   virtual const    AliExternalTrackParam * GetOuterParam() const { return NULL; }
289
290   UShort_t GetTPCNclsF() const { return fTPCnclsF;}
291   UShort_t GetTPCNCrossedRows()  const { return fTPCNCrossedRows;}
292   Float_t  GetTPCFoundFraction() const { return fTPCNCrossedRows>0 ? float(GetTPCNcls())/fTPCNCrossedRows : 0;}
293
294   // Calorimeter Cluster
295   Int_t GetEMCALcluster() const {return fCaloIndex;}
296   void SetEMCALcluster(Int_t index) {fCaloIndex=index;}
297   Bool_t IsEMCAL() const {return fFlags&kEMCALmatch;}
298
299   Double_t GetTrackPhiOnEMCal() const {return fTrackPhiOnEMCal;}
300   Double_t GetTrackEtaOnEMCal() const {return fTrackEtaOnEMCal;}
301   Double_t GetTrackPtOnEMCal() const {return fTrackPtOnEMCal;}
302   Double_t GetTrackPOnEMCal() const {return TMath::Abs(fTrackEtaOnEMCal) < 1 ? fTrackPtOnEMCal*TMath::CosH(fTrackEtaOnEMCal) : -999;}
303   void SetTrackPhiEtaPtOnEMCal(Double_t phi,Double_t eta,Double_t pt) {fTrackPhiOnEMCal=phi;fTrackEtaOnEMCal=eta;fTrackPtOnEMCal=pt;}
304
305   Int_t GetPHOScluster() const {return fCaloIndex;}
306   void SetPHOScluster(Int_t index) {fCaloIndex=index;}
307   Bool_t IsPHOS() const {return fFlags&kPHOSmatch;}
308
309   //pid signal interface
310   Double_t  GetITSsignal()       const { return fDetPid?fDetPid->GetITSsignal():0.;    }
311   void      GetITSdEdxSamples(Double_t s[4]) const;
312   Double_t  GetTPCsignal()       const { return fDetPid?fDetPid->GetTPCsignal():0.;    }
313   Double_t  GetTPCsignalTunedOnData() const { return fTPCsignalTuned;}
314   void      SetTPCsignalTunedOnData(Double_t signal) {fTPCsignalTuned = signal;}
315   UShort_t  GetTPCsignalN()      const { return fDetPid?fDetPid->GetTPCsignalN():0;    }
316   virtual AliTPCdEdxInfo* GetTPCdEdxInfo() const {return fDetPid?fDetPid->GetTPCdEdxInfo():0;}
317   Double_t  GetTPCmomentum()     const { return fDetPid?fDetPid->GetTPCmomentum():0.;  }
318   Double_t  GetTPCTgl()          const { return fDetPid?fDetPid->GetTPCTgl():0.;  }
319   Double_t  GetTOFsignal()       const { return fDetPid?fDetPid->GetTOFsignal():0.;    }
320   Double_t  GetIntegratedLength() const { return fTrackLength;}
321   void      SetIntegratedLength(Double_t l) {fTrackLength = l;}
322   Double_t  GetTOFsignalTunedOnData() const { return fTOFsignalTuned;}
323   void      SetTOFsignalTunedOnData(Double_t signal) {fTOFsignalTuned = signal;}
324   Double_t  GetHMPIDsignal()     const; 
325   Double_t  GetHMPIDoccupancy()  const;
326
327   Int_t     GetHMPIDcluIdx()     const;
328     
329   void GetHMPIDtrk(Float_t &x, Float_t &y, Float_t &th, Float_t &ph) const;  
330   void GetHMPIDmip(Float_t &x,Float_t &y,Int_t &q,Int_t &nph) const;
331   
332   Bool_t GetOuterHmpPxPyPz(Double_t *p) const;
333   
334   void      GetIntegratedTimes(Double_t *times, Int_t nspec=AliPID::kSPECIES) const {if (fDetPid) fDetPid->GetIntegratedTimes(times, nspec);}
335   Double_t  GetTRDslice(Int_t plane, Int_t slice) const;
336   Double_t  GetTRDsignal()                        const {return fDetPid ? fDetPid->GetTRDsignal() : 0;}
337   Double_t  GetTRDmomentum(Int_t plane, Double_t */*sp*/=0x0) const;
338   Double_t  GetTRDchi2()                 const {return fDetPid ? fDetPid->GetTRDChi2() : -1;}
339   UChar_t   GetTRDncls(Int_t layer)      const;
340   UChar_t   GetTRDncls()                 const {return GetTRDncls(-1);}
341   UChar_t   GetTRDntrackletsPID() const;
342   Int_t     GetNumberOfTRDslices() const { return fDetPid?fDetPid->GetTRDnSlices():0; }
343   void      GetHMPIDpid(Double_t */*p*/) const { return; } // TODO: To be implemented properly with the new HMPID object
344
345   void SetMFTClusterPattern(ULong_t mftClusterPattern) { fMFTClusterPattern = mftClusterPattern; }   // AU
346   ULong_t GetMFTClusterPattern() { return fMFTClusterPattern; }                                      // AU
347
348   const AliAODEvent* GetAODEvent() const {return fAODEvent;}
349   virtual const AliVEvent* GetEvent() const {return (AliVEvent*)fAODEvent;}
350   void SetAODEvent(const AliAODEvent* ptr){fAODEvent = ptr;}
351   const AliTOFHeader* GetTOFHeader() const;
352
353   AliAODPid    *GetDetPid() const { return fDetPid; }
354   AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
355   
356   // print
357   void  Print(const Option_t *opt = "") const;
358
359   // setters
360   void SetFlags(ULong_t flags) { fFlags = flags; }
361   void SetStatus(ULong_t flags) { fFlags|=flags; }
362   void ResetStatus(ULong_t flags) { fFlags&=~flags; }
363
364   void SetID(Short_t id) { fID = id; }
365   void SetLabel(Int_t label) { fLabel = label; }
366   void SetTOFLabel(const Int_t* p);
367   template <typename T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
368   void SetDCA(Double_t d, Double_t z);
369   void SetUsedForVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForVtxFit) : ResetBit(kUsedForVtxFit); }
370   void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
371
372   void SetIsTPCOnly(Bool_t b = kTRUE) { SetIsTPCConstrained(b); }// obsolete bad naming
373
374   void SetIsTPCConstrained(Bool_t b = kTRUE) { b ? SetBit(kIsTPCConstrained) : ResetBit(kIsTPCConstrained); }
375   void SetIsHybridTPCConstrainedGlobal(Bool_t hybrid = kTRUE) { hybrid ? SetBit(kIsHybridTPCCG) : ResetBit(kIsHybridTPCCG); }
376
377   void SetIsGlobalConstrained(Bool_t b = kTRUE) { b ? SetBit(kIsGlobalConstrained) : ResetBit(kIsGlobalConstrained); }
378   void SetIsHybridGlobalConstrainedGlobal(Bool_t hybrid = kTRUE) { hybrid ? SetBit(kIsHybridGCG) : ResetBit(kIsHybridGCG); }
379
380
381
382   void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = 1. / oneOverPt; }
383   void SetPt(Double_t pt) { fMomentum[0] = pt; };
384   void SetPhi(Double_t phi) { fMomentum[1] = phi; }
385   void SetTheta(Double_t theta) { fMomentum[2] = theta; }
386   template <typename T> void SetP(const T *p, Bool_t cartesian = kTRUE);
387   void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
388
389   void SetXYAtDCA(Double_t x, Double_t y) {fPositionAtDCA[0] = x; fPositionAtDCA[1] = y;}
390   void SetPxPyPzAtDCA(Double_t pX, Double_t pY, Double_t pZ) {fMomentumAtDCA[0] = pX; fMomentumAtDCA[1] = pY; fMomentumAtDCA[2] = pZ;}
391   
392   void SetRAtAbsorberEnd(Double_t r) { fRAtAbsorberEnd = r; }
393   
394   void SetCharge(Short_t q) { fCharge = q; }
395   void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
396
397   void SetITSClusterMap(UChar_t itsClusMap)                 { fITSMuonClusterMap = (fITSMuonClusterMap&0xffffff00)|(((UInt_t)itsClusMap)&0xff); }
398   void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffff00ff)|((((UInt_t)hitsPatternInTrigCh)&0xff)<<8); }
399   void SetMuonClusterMap(UInt_t muonClusMap)                { fITSMuonClusterMap = (fITSMuonClusterMap&0xfc00ffff)|((muonClusMap&0x3ff)<<16); }
400   void SetITSMuonClusterMap(UInt_t itsMuonClusMap)          { fITSMuonClusterMap = itsMuonClusMap; }
401   void SetMUONtrigHitsMapTrg(UInt_t muonTrigHitsMap) { fMUONtrigHitsMapTrg = muonTrigHitsMap; }
402   UInt_t GetMUONTrigHitsMapTrg() const { return fMUONtrigHitsMapTrg; }
403   void SetMUONtrigHitsMapTrk(UInt_t muonTrigHitsMap) { fMUONtrigHitsMapTrk = muonTrigHitsMap; }
404   UInt_t GetMUONTrigHitsMapTrk() const { return fMUONtrigHitsMapTrk; }
405   Int_t GetMuonTrigDevSign() const;
406
407   Int_t GetMatchTrigger() const {return fITSMuonClusterMap>>30;}
408                                         //  0 Muon track does not match trigger
409                                         //  1 Muon track match but does not pass pt cut
410                                         //  2 Muon track match Low pt cut
411                                         //  3 Muon track match High pt cut
412   void     SetMatchTrigger(Int_t MatchTrigger);
413   Bool_t   MatchTrigger() const { return (GetMatchTrigger()>0); }         //  Muon track matches trigger track
414   Bool_t   MatchTriggerLowPt()   const  { return (GetMatchTrigger()>1); } //  Muon track matches trigger track and passes Low pt cut
415   Bool_t   MatchTriggerHighPt()  const  { return (GetMatchTrigger()>2); } //  Muon track matches trigger track and passes High pt cut
416   Bool_t   MatchTriggerDigits()  const;                                   //  Muon track matches trigger digits
417   Double_t GetChi2MatchTrigger() const  { return fChi2MatchTrigger;}
418   void     SetChi2MatchTrigger(Double_t Chi2MatchTrigger) {fChi2MatchTrigger = Chi2MatchTrigger; }
419   Bool_t   HitsMuonChamber(Int_t MuonChamber, Int_t cathode = -1) const;  // Check if track hits Muon chambers
420   Bool_t   IsMuonTrack() const { return ( (GetMUONClusterMap()>0) && !fIsMuonGlobalTrack ) ? kTRUE : kFALSE; }
421   
422   Bool_t   IsMuonGlobalTrack() const { return fIsMuonGlobalTrack; }                                     // AU
423   void     SetIsMuonGlobalTrack(Bool_t isMuonGlobalTrack) { fIsMuonGlobalTrack = isMuonGlobalTrack; }   // AU
424
425   void     Connected(Bool_t flag) {flag ? SETBIT(fITSMuonClusterMap,26) : CLRBIT(fITSMuonClusterMap,26);}
426   Bool_t   IsConnected() const {return TESTBIT(fITSMuonClusterMap,26);}
427
428   void     SetProdVertex(TObject *vertex) { fProdVertex = vertex; }
429   void     SetType(AODTrk_t ttype) { fType=ttype; }
430
431   // Trasient PID object, is owned by the track
432   virtual void  SetDetectorPID(const AliDetectorPID *pid);
433   virtual const AliDetectorPID* GetDetectorPID() const { return fDetectorPID; }
434
435   // Dummy
436   Int_t    PdgCode() const {return 0;}
437   
438  private :
439
440   // Momentum & position
441   Double32_t    fMomentum[3];       // momemtum stored in pt, phi, theta
442   Double32_t    fPosition[3];       // position of first point on track or dca
443   
444   Double32_t    fMomentumAtDCA[3];  // momentum (px,py,pz) at DCA
445   Double32_t    fPositionAtDCA[2];  // trasverse position (x,y) at DCA
446   
447   Double32_t    fRAtAbsorberEnd;    // transverse position r at the end of the muon absorber
448   
449   Double32_t    fChi2perNDF;        // chi2/NDF of momentum fit
450   Double32_t    fChi2MatchTrigger;  // chi2 of trigger/track matching
451   Double32_t*   fPID;               //! [0.,1.,8] pointer to PID object
452
453   ULong_t       fFlags;             // reconstruction status flags 
454   Int_t         fLabel;             // track label, points back to MC track
455   Int_t         fTOFLabel[3];       // TOF label
456   Double32_t    fTrackLength;       // Track length
457   UInt_t        fITSMuonClusterMap; // map of ITS and muon clusters, one bit per layer
458                                     // (ITS: bit 1-8, muon trigger: bit 9-16, muon tracker: bit 17-26, muon match trigger: bit 31-32) 
459   UInt_t        fMUONtrigHitsMapTrg; // Muon trigger hits map from trigger
460   UInt_t        fMUONtrigHitsMapTrk; // Muon trigger hits map from tracker track extrapolation
461   UInt_t        fFilterMap;         // filter information, one bit per set of cuts
462
463   TBits         fTPCFitMap;      // Map of clusters, one bit per padrow; if has a cluster on given padrow which is used in the fit   
464   TBits         fTPCClusterMap;     // Map of clusters, one bit per padrow; 1 if has a cluster on given padrow
465   TBits         fTPCSharedMap;      // Map of clusters, one bit per padrow; 1 if has a shared cluster on given padrow
466
467   UShort_t      fTPCnclsF;          // findable clusters
468   UShort_t      fTPCNCrossedRows;   // n crossed rows
469
470   Short_t       fID;                // unique track ID, points back to the ESD track
471
472   Char_t        fCharge;            // particle charge
473   Char_t        fType;              // Track Type, explanation close to the enum AODTrk_t
474
475   Char_t        fPIDForTracking;    // pid using for tracking of ESD track
476
477   Int_t         fCaloIndex;         // index of associated EMCAL/PHOS cluster (AliAODCaloCluster)
478
479   
480   AliAODRedCov<6> *fCovMatrix;      // covariance matrix (x, y, z, px, py, pz)
481   AliAODPid    *fDetPid;            // more detailed or detector specific raw pid information
482   mutable const AliDetectorPID* fDetectorPID; //! transient object to cache calibrated PID information
483   TRef          fProdVertex;        // vertex of origin
484
485   Double_t      fTrackPhiOnEMCal;   // phi of track after being propagated to the EMCal surface (default r = 440 cm)
486   Double_t      fTrackEtaOnEMCal;   // eta of track after being propagated to the EMCal surface (default r = 440 cm)
487   Double_t      fTrackPtOnEMCal;    // pt of track after being propagated to the EMCal surface (default r = 440 cm)
488
489   Bool_t fIsMuonGlobalTrack;        // True if the track is built from the combination of MUON and MFT clusters     // AU
490
491   Double_t      fTPCsignalTuned;    //! TPC signal tuned on data when using MC
492   Double_t      fTOFsignalTuned;    //! TOF signal tuned on data when using MC
493
494   ULong_t fMFTClusterPattern;       // Tells us which MFT clusters are contained in the track, and which one is a good one (if MC)  // AU
495
496   const AliAODEvent* fAODEvent;     //! pointer back to the event the track belongs to
497
498   //---------------------------------------------------------------------------
499   //--the calibration interface--
500   //--to be used in online calibration/QA
501   //--should also be implemented in ESD so it works offline as well
502   //-----------
503   virtual Int_t GetTrackParam         ( AliExternalTrackParam &p ) const;
504   virtual Int_t GetTrackParamRefitted ( AliExternalTrackParam &p ) const;
505   virtual Int_t GetTrackParamIp       ( AliExternalTrackParam &p ) const;
506   virtual Int_t GetTrackParamTPCInner ( AliExternalTrackParam &p ) const;
507   virtual Int_t GetTrackParamOp       ( AliExternalTrackParam &p ) const;
508   virtual Int_t GetTrackParamCp       ( AliExternalTrackParam &p ) const;
509   virtual Int_t GetTrackParamITSOut   ( AliExternalTrackParam &p ) const;
510
511   ClassDef(AliAODTrack, 24);
512 };
513
514 inline Bool_t  AliAODTrack::IsPrimaryCandidate() const
515 {
516     // True of track passes primary particle selection (independent of type) 
517     // 
518     if (fFilterMap) {
519         return kTRUE;
520     } else {
521         return kFALSE;
522     }
523 }
524
525 inline Int_t AliAODTrack::GetITSNcls() const 
526 {
527   // Number of points in ITS
528   Int_t n=0;
529   for(Int_t i=0;i<6;i++) if(HasPointOnITSLayer(i)) n++;
530   return n;
531 }
532
533 //______________________________________________________________________________
534 template <typename T> 
535 void AliAODTrack::SetPosition(const T *x, const Bool_t dca) 
536 {
537   // set the position
538
539   if (x) {
540     if (!dca) {
541       ResetBit(kIsDCA);
542
543       fPosition[0] = x[0];
544       fPosition[1] = x[1];
545       fPosition[2] = x[2];
546     } else {
547       SetBit(kIsDCA);
548       // don't know any better yet
549       fPosition[0] = -999.;
550       fPosition[1] = -999.;
551       fPosition[2] = -999.;
552     }
553   } else {
554     ResetBit(kIsDCA);
555
556     fPosition[0] = -999.;
557     fPosition[1] = -999.;
558     fPosition[2] = -999.;
559   }
560 }
561
562 //template<> void AliAODTrack::SetPosition(const double *, Bool_t);
563
564 #endif