]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODTrack.h
ab9cef24a7f62e05cd632de98975ff564f8b437d
[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     using AliVVtrack::GetP;
207
208 //  template <typename T> void GetPxPyPz(T *p) const {
209 //    p[0] = Px(); p[1] = Py(); p[2] = Pz();}
210   Bool_t GetPxPyPz(Double_t *p) const;
211
212   template <typename T> Bool_t GetPosition(T *x) const {
213     x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
214     return TestBit(kIsDCA);}
215
216   template <typename T> void SetCovMatrix(const T *covMatrix) {
217     if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
218     fCovMatrix->SetCovMatrix(covMatrix);}
219
220   template <typename T> Bool_t GetCovMatrix(T *covMatrix) const {
221     if(!fCovMatrix) return kFALSE;
222     fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
223
224   Bool_t GetXYZ(Double_t *p) const {
225     return GetPosition(p); }
226   using AliVVtrack::GetXYZ;
227   
228   Bool_t GetXYZAt(Double_t x, Double_t b, Double_t *r) const;
229   Bool_t GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz=0, Double_t* alpSect=0) const;  
230
231   Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const {
232     return GetCovMatrix(cv);}
233
234   void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
235
236   Double_t XAtDCA() const { return fPositionAtDCA[0]; }
237   Double_t YAtDCA() const { return fPositionAtDCA[1]; }
238   Double_t ZAtDCA() const {
239     if (IsMuonTrack()) return fPosition[2];
240     else if (TestBit(kIsDCA)) return fPosition[1];
241     else return -999.; }
242   Bool_t   XYZAtDCA(Double_t x[3]) const { x[0] = XAtDCA(); x[1] = YAtDCA(); x[2] = ZAtDCA(); return kTRUE; }
243   
244   Double_t DCA() const {
245     if (IsMuonTrack()) return TMath::Sqrt(XAtDCA()*XAtDCA() + YAtDCA()*YAtDCA());
246     else if (TestBit(kIsDCA)) return fPosition[0];
247     else return -999.; }
248   
249   Double_t PxAtDCA() const { return fMomentumAtDCA[0]; }
250   Double_t PyAtDCA() const { return fMomentumAtDCA[1]; }
251   Double_t PzAtDCA() const { return fMomentumAtDCA[2]; }
252   Double_t PAtDCA() const { return TMath::Sqrt(PxAtDCA()*PxAtDCA() + PyAtDCA()*PyAtDCA() + PzAtDCA()*PzAtDCA()); }
253   Bool_t   PxPyPzAtDCA(Double_t p[3]) const { p[0] = PxAtDCA(); p[1] = PyAtDCA(); p[2] = PzAtDCA(); return kTRUE; }
254   
255   Double_t GetRAtAbsorberEnd() const { return fRAtAbsorberEnd; }
256   
257   UChar_t  GetITSClusterMap() const       { return (UChar_t)(fITSMuonClusterMap&0xff); }
258   Int_t    GetITSNcls() const; 
259   Bool_t   HasPointOnITSLayer(Int_t i) const { return TESTBIT(GetITSClusterMap(),i); }
260   UShort_t GetHitsPatternInTrigCh() const { return (UShort_t)((fITSMuonClusterMap&0xff00)>>8); }
261   UInt_t   GetMUONClusterMap() const      { return (fITSMuonClusterMap&0x3ff0000)>>16; }
262   UInt_t   GetITSMUONClusterMap() const   { return fITSMuonClusterMap; }
263   
264   Bool_t  TestFilterBit(UInt_t filterBit) const {return (Bool_t) ((filterBit & fFilterMap) != 0);}
265   Bool_t  TestFilterMask(UInt_t filterMask) const {return (Bool_t) ((filterMask & fFilterMap) == filterMask);}
266   void    SetFilterMap(UInt_t i){fFilterMap = i;}
267   UInt_t  GetFilterMap() const {return fFilterMap;}
268
269   const TBits& GetTPCClusterMap() const {return fTPCClusterMap;}
270   const TBits* GetTPCClusterMapPtr() const {return &fTPCClusterMap;}
271   const TBits& GetTPCFitMap() const {return fTPCFitMap;}
272   const TBits* GetTPCFitMapPtr() const {return &fTPCFitMap;}
273   Float_t GetTPCClusterInfo(Int_t nNeighbours=3, Int_t type=0, Int_t row0=0, Int_t row1=159, Int_t /*type*/=0) const;
274   
275   const TBits& GetTPCSharedMap() const {return fTPCSharedMap;}
276   const TBits* GetTPCSharedMapPtr() const {return &fTPCSharedMap;}
277   void    SetTPCClusterMap(const TBits amap) {fTPCClusterMap = amap;}
278   void    SetTPCSharedMap(const TBits amap) {fTPCSharedMap = amap;}
279   void    SetTPCFitMap(const TBits amap) {fTPCFitMap = amap;}
280   void    SetTPCPointsF(UShort_t  findable){fTPCnclsF = findable;}
281   void    SetTPCNCrossedRows(UInt_t n)     {fTPCNCrossedRows = n;}
282   
283   virtual const    AliExternalTrackParam * GetInnerParam() const { return NULL; }
284   virtual const    AliExternalTrackParam * GetOuterParam() const { return NULL; }
285
286   UShort_t GetTPCNclsF() const { return fTPCnclsF;}
287   UShort_t GetTPCNCrossedRows()  const { return fTPCNCrossedRows;}
288   Float_t  GetTPCFoundFraction() const { return fTPCNCrossedRows>0 ? float(GetTPCNcls())/fTPCNCrossedRows : 0;}
289
290   // Calorimeter Cluster
291   Int_t GetEMCALcluster() const {return fCaloIndex;}
292   void SetEMCALcluster(Int_t index) {fCaloIndex=index;}
293   Bool_t IsEMCAL() const {return fFlags&kEMCALmatch;}
294
295   Double_t GetTrackPhiOnEMCal() const {return fTrackPhiOnEMCal;}
296   Double_t GetTrackEtaOnEMCal() const {return fTrackEtaOnEMCal;}
297   Double_t GetTrackPtOnEMCal() const {return fTrackPtOnEMCal;}
298   Double_t GetTrackPOnEMCal() const {return TMath::Abs(fTrackEtaOnEMCal) < 1 ? fTrackPtOnEMCal*TMath::CosH(fTrackEtaOnEMCal) : -999;}
299   void SetTrackPhiEtaPtOnEMCal(Double_t phi,Double_t eta,Double_t pt) {fTrackPhiOnEMCal=phi;fTrackEtaOnEMCal=eta;fTrackPtOnEMCal=pt;}
300
301   Int_t GetPHOScluster() const {return fCaloIndex;}
302   void SetPHOScluster(Int_t index) {fCaloIndex=index;}
303   Bool_t IsPHOS() const {return fFlags&kPHOSmatch;}
304
305   //pid signal interface
306   Double_t  GetITSsignal()       const { return fDetPid?fDetPid->GetITSsignal():0.;    }
307   void      GetITSdEdxSamples(Double_t s[4]) const;
308   Double_t  GetTPCsignal()       const { return fDetPid?fDetPid->GetTPCsignal():0.;    }
309   Double_t  GetTPCsignalTunedOnData() const { return fTPCsignalTuned;}
310   void      SetTPCsignalTunedOnData(Double_t signal) {fTPCsignalTuned = signal;}
311   UShort_t  GetTPCsignalN()      const { return fDetPid?fDetPid->GetTPCsignalN():0;    }
312   virtual AliTPCdEdxInfo* GetTPCdEdxInfo() const {return fDetPid?fDetPid->GetTPCdEdxInfo():0;}
313   Double_t  GetTPCmomentum()     const { return fDetPid?fDetPid->GetTPCmomentum():0.;  }
314   Double_t  GetTPCTgl()          const { return fDetPid?fDetPid->GetTPCTgl():0.;  }
315   Double_t  GetTOFsignal()       const { return fDetPid?fDetPid->GetTOFsignal():0.;    }
316   Double_t  GetIntegratedLength() const { return fTrackLength;}
317   void      SetIntegratedLength(Double_t l) {fTrackLength = l;}
318   Double_t  GetTOFsignalTunedOnData() const { return fTOFsignalTuned;}
319   void      SetTOFsignalTunedOnData(Double_t signal) {fTOFsignalTuned = signal;}
320   Double_t  GetHMPIDsignal()     const; 
321   Double_t  GetHMPIDoccupancy()  const;
322
323   Int_t     GetHMPIDcluIdx()     const;
324     
325   void GetHMPIDtrk(Float_t &x, Float_t &y, Float_t &th, Float_t &ph) const;  
326   void GetHMPIDmip(Float_t &x,Float_t &y,Int_t &q,Int_t &nph) const;
327   
328   Bool_t GetOuterHmpPxPyPz(Double_t *p) const;
329   
330   void      GetIntegratedTimes(Double_t *times, Int_t nspec=AliPID::kSPECIESC) const {if (fDetPid) fDetPid->GetIntegratedTimes(times, nspec);}
331   Double_t  GetTRDslice(Int_t plane, Int_t slice) const;
332   Double_t  GetTRDsignal()                        const {return fDetPid ? fDetPid->GetTRDsignal() : 0;}
333   Double_t  GetTRDmomentum(Int_t plane, Double_t */*sp*/=0x0) const;
334   Double_t  GetTRDchi2()                 const {return fDetPid ? fDetPid->GetTRDChi2() : -1;}
335   UChar_t   GetTRDncls(Int_t layer)      const;
336   UChar_t   GetTRDncls()                 const {return GetTRDncls(-1);}
337   UChar_t   GetTRDntrackletsPID() const;
338   Int_t     GetNumberOfTRDslices() const { return fDetPid?fDetPid->GetTRDnSlices():0; }
339   void      GetHMPIDpid(Double_t */*p*/) const { return; } // TODO: To be implemented properly with the new HMPID object
340
341   void SetMFTClusterPattern(ULong_t mftClusterPattern) { fMFTClusterPattern = mftClusterPattern; }   // AU
342   ULong_t GetMFTClusterPattern() { return fMFTClusterPattern; }                                      // AU
343
344   const AliAODEvent* GetAODEvent() const {return fAODEvent;}
345   virtual const AliVEvent* GetEvent() const {return (AliVEvent*)fAODEvent;}
346   void SetAODEvent(const AliAODEvent* ptr){fAODEvent = ptr;}
347   const AliTOFHeader* GetTOFHeader() const;
348
349   AliAODPid    *GetDetPid() const { return fDetPid; }
350   AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
351   
352   // print
353   void  Print(const Option_t *opt = "") const;
354
355   // setters
356   void SetFlags(ULong_t flags) { fFlags = flags; }
357   void SetStatus(ULong_t flags) { fFlags|=flags; }
358   void ResetStatus(ULong_t flags) { fFlags&=~flags; }
359
360   void SetID(Short_t id) { fID = id; }
361   void SetLabel(Int_t label) { fLabel = label; }
362   void SetTOFLabel(const Int_t* p);
363   template <typename T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
364   void SetDCA(Double_t d, Double_t z);
365   void SetUsedForVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForVtxFit) : ResetBit(kUsedForVtxFit); }
366   void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
367
368   void SetIsTPCOnly(Bool_t b = kTRUE) { SetIsTPCConstrained(b); }// obsolete bad naming
369
370   void SetIsTPCConstrained(Bool_t b = kTRUE) { b ? SetBit(kIsTPCConstrained) : ResetBit(kIsTPCConstrained); }
371   void SetIsHybridTPCConstrainedGlobal(Bool_t hybrid = kTRUE) { hybrid ? SetBit(kIsHybridTPCCG) : ResetBit(kIsHybridTPCCG); }
372
373   void SetIsGlobalConstrained(Bool_t b = kTRUE) { b ? SetBit(kIsGlobalConstrained) : ResetBit(kIsGlobalConstrained); }
374   void SetIsHybridGlobalConstrainedGlobal(Bool_t hybrid = kTRUE) { hybrid ? SetBit(kIsHybridGCG) : ResetBit(kIsHybridGCG); }
375
376
377
378   void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = 1. / oneOverPt; }
379   void SetPt(Double_t pt) { fMomentum[0] = pt; };
380   void SetPhi(Double_t phi) { fMomentum[1] = phi; }
381   void SetTheta(Double_t theta) { fMomentum[2] = theta; }
382   template <typename T> void SetP(const T *p, Bool_t cartesian = kTRUE);
383   void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
384
385   void SetXYAtDCA(Double_t x, Double_t y) {fPositionAtDCA[0] = x; fPositionAtDCA[1] = y;}
386   void SetPxPyPzAtDCA(Double_t pX, Double_t pY, Double_t pZ) {fMomentumAtDCA[0] = pX; fMomentumAtDCA[1] = pY; fMomentumAtDCA[2] = pZ;}
387   
388   void SetRAtAbsorberEnd(Double_t r) { fRAtAbsorberEnd = r; }
389   
390   void SetCharge(Short_t q) { fCharge = q; }
391   void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
392
393   void SetITSClusterMap(UChar_t itsClusMap)                 { fITSMuonClusterMap = (fITSMuonClusterMap&0xffffff00)|(((UInt_t)itsClusMap)&0xff); }
394   void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffff00ff)|((((UInt_t)hitsPatternInTrigCh)&0xff)<<8); }
395   void SetMuonClusterMap(UInt_t muonClusMap)                { fITSMuonClusterMap = (fITSMuonClusterMap&0xfc00ffff)|((muonClusMap&0x3ff)<<16); }
396   void SetITSMuonClusterMap(UInt_t itsMuonClusMap)          { fITSMuonClusterMap = itsMuonClusMap; }
397   void SetMUONtrigHitsMapTrg(UInt_t muonTrigHitsMap) { fMUONtrigHitsMapTrg = muonTrigHitsMap; }
398   UInt_t GetMUONTrigHitsMapTrg() { return fMUONtrigHitsMapTrg; }
399   void SetMUONtrigHitsMapTrk(UInt_t muonTrigHitsMap) { fMUONtrigHitsMapTrk = muonTrigHitsMap; }
400   UInt_t GetMUONTrigHitsMapTrk() { return fMUONtrigHitsMapTrk; }
401
402   Int_t GetMatchTrigger() const {return fITSMuonClusterMap>>30;}
403                                         //  0 Muon track does not match trigger
404                                         //  1 Muon track match but does not pass pt cut
405                                         //  2 Muon track match Low pt cut
406                                         //  3 Muon track match High pt cut
407   void     SetMatchTrigger(Int_t MatchTrigger);
408   Bool_t   MatchTrigger() const { return (GetMatchTrigger()>0); }         //  Muon track matches trigger track
409   Bool_t   MatchTriggerLowPt()   const  { return (GetMatchTrigger()>1); } //  Muon track matches trigger track and passes Low pt cut
410   Bool_t   MatchTriggerHighPt()  const  { return (GetMatchTrigger()>2); } //  Muon track matches trigger track and passes High pt cut
411   Bool_t   MatchTriggerDigits()  const;                                   //  Muon track matches trigger digits
412   Double_t GetChi2MatchTrigger() const  { return fChi2MatchTrigger;}
413   void     SetChi2MatchTrigger(Double_t Chi2MatchTrigger) {fChi2MatchTrigger = Chi2MatchTrigger; }
414   Bool_t   HitsMuonChamber(Int_t MuonChamber, Int_t cathode = -1) const;  // Check if track hits Muon chambers
415   Bool_t   IsMuonTrack() const { return ( (GetMUONClusterMap()>0) && !fIsMuonGlobalTrack ) ? kTRUE : kFALSE; }
416   
417   Bool_t   IsMuonGlobalTrack() const { return fIsMuonGlobalTrack; }                                     // AU
418   void     SetIsMuonGlobalTrack(Bool_t isMuonGlobalTrack) { fIsMuonGlobalTrack = isMuonGlobalTrack; }   // AU
419
420   void     Connected(Bool_t flag) {flag ? SETBIT(fITSMuonClusterMap,26) : CLRBIT(fITSMuonClusterMap,26);}
421   Bool_t   IsConnected() const {return TESTBIT(fITSMuonClusterMap,26);}
422
423   void     SetProdVertex(TObject *vertex) { fProdVertex = vertex; }
424   void     SetType(AODTrk_t ttype) { fType=ttype; }
425
426   // Trasient PID object, is owned by the track
427   virtual void  SetDetectorPID(const AliDetectorPID *pid);
428   virtual const AliDetectorPID* GetDetectorPID() const { return fDetectorPID; }
429
430   // Dummy
431   Int_t    PdgCode() const {return 0;}
432   
433  private :
434
435   // Momentum & position
436   Double32_t    fMomentum[3];       // momemtum stored in pt, phi, theta
437   Double32_t    fPosition[3];       // position of first point on track or dca
438   
439   Double32_t    fMomentumAtDCA[3];  // momentum (px,py,pz) at DCA
440   Double32_t    fPositionAtDCA[2];  // trasverse position (x,y) at DCA
441   
442   Double32_t    fRAtAbsorberEnd;    // transverse position r at the end of the muon absorber
443   
444   Double32_t    fChi2perNDF;        // chi2/NDF of momentum fit
445   Double32_t    fChi2MatchTrigger;  // chi2 of trigger/track matching
446   Double32_t*   fPID;               //! [0.,1.,8] pointer to PID object
447
448   ULong_t       fFlags;             // reconstruction status flags 
449   Int_t         fLabel;             // track label, points back to MC track
450   Int_t         fTOFLabel[3];       // TOF label
451   Double32_t    fTrackLength;       // Track length
452   UInt_t        fITSMuonClusterMap; // map of ITS and muon clusters, one bit per layer
453                                     // (ITS: bit 1-8, muon trigger: bit 9-16, muon tracker: bit 17-26, muon match trigger: bit 31-32) 
454   UInt_t        fMUONtrigHitsMapTrg; // Muon trigger hits map from trigger
455   UInt_t        fMUONtrigHitsMapTrk; // Muon trigger hits map from tracker track extrapolation
456   UInt_t        fFilterMap;         // filter information, one bit per set of cuts
457
458   TBits         fTPCFitMap;      // Map of clusters, one bit per padrow; if has a cluster on given padrow which is used in the fit   
459   TBits         fTPCClusterMap;     // Map of clusters, one bit per padrow; 1 if has a cluster on given padrow
460   TBits         fTPCSharedMap;      // Map of clusters, one bit per padrow; 1 if has a shared cluster on given padrow
461
462   UShort_t      fTPCnclsF;          // findable clusters
463   UShort_t      fTPCNCrossedRows;   // n crossed rows
464
465   Short_t       fID;                // unique track ID, points back to the ESD track
466
467   Char_t        fCharge;            // particle charge
468   Char_t        fType;              // Track Type
469
470   Char_t        fPIDForTracking;    // pid using for tracking of ESD track
471
472   Int_t         fCaloIndex;         // index of associated EMCAL/PHOS cluster (AliAODCaloCluster)
473
474   
475   AliAODRedCov<6> *fCovMatrix;      // covariance matrix (x, y, z, px, py, pz)
476   AliAODPid    *fDetPid;            // more detailed or detector specific raw pid information
477   mutable const AliDetectorPID* fDetectorPID; //! transient object to cache calibrated PID information
478   TRef          fProdVertex;        // vertex of origin
479
480   Double_t      fTrackPhiOnEMCal;   // phi of track after being propagated to the EMCal surface (default r = 440 cm)
481   Double_t      fTrackEtaOnEMCal;   // eta of track after being propagated to the EMCal surface (default r = 440 cm)
482   Double_t      fTrackPtOnEMCal;    // pt of track after being propagated to the EMCal surface (default r = 440 cm)
483
484   Bool_t fIsMuonGlobalTrack;        // True if the track is built from the combination of MUON and MFT clusters     // AU
485
486   Double_t      fTPCsignalTuned;    //! TPC signal tuned on data when using MC
487   Double_t      fTOFsignalTuned;    //! TOF signal tuned on data when using MC
488
489   ULong_t fMFTClusterPattern;       // Tells us which MFT clusters are contained in the track, and which one is a good one (if MC)  // AU
490
491   const AliAODEvent* fAODEvent;     //! pointer back to the event the track belongs to
492
493   ClassDef(AliAODTrack, 24);
494 };
495
496 inline Bool_t  AliAODTrack::IsPrimaryCandidate() const
497 {
498     // True of track passes primary particle selection (independent of type) 
499     // 
500     if (fFilterMap) {
501         return kTRUE;
502     } else {
503         return kFALSE;
504     }
505 }
506
507 inline Int_t AliAODTrack::GetITSNcls() const 
508 {
509   // Number of points in ITS
510   Int_t n=0;
511   for(Int_t i=0;i<6;i++) if(HasPointOnITSLayer(i)) n++;
512   return n;
513 }
514
515 //______________________________________________________________________________
516 template <typename T> 
517 void AliAODTrack::SetPosition(const T *x, const Bool_t dca) 
518 {
519   // set the position
520
521   if (x) {
522     if (!dca) {
523       ResetBit(kIsDCA);
524
525       fPosition[0] = x[0];
526       fPosition[1] = x[1];
527       fPosition[2] = x[2];
528     } else {
529       SetBit(kIsDCA);
530       // don't know any better yet
531       fPosition[0] = -999.;
532       fPosition[1] = -999.;
533       fPosition[2] = -999.;
534     }
535   } else {
536     ResetBit(kIsDCA);
537
538     fPosition[0] = -999.;
539     fPosition[1] = -999.;
540     fPosition[2] = -999.;
541   }
542 }
543
544 //template<> void AliAODTrack::SetPosition(const double *, Bool_t);
545
546 #endif