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