]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AOD/AliAODTrack.h
AliAODEvent::GetHeader now return AliVHeader
[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  
21
22 class AliVVertex;
23 class AliDetectorPID;
24 class AliTPCdEdxInfo;
25 class AliAODEvent;
26 class AliTOFHeader;
27
28 class AliAODTrack : public AliVTrack {
29
30  public:
31   
32   enum AODTrk_t {kUndef = -1, 
33                  kPrimary, 
34                  kFromDecayVtx, 
35                  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): 
36                            //kPrimary: TPC only tracks, global constrained tracks, primary tracks, kink mothers; 
37                            //kFromDecayVtx: bachelor tracks from cascades, tracks from V0, kink daughters; 
38                            //kUndef:TRD matched tracks
39
40   enum AODTrkBits_t {
41     kIsDCA=BIT(14),   // set if fPosition is the DCA and not the position of the first point
42     kUsedForVtxFit=BIT(15), // set if this track was used to fit the vertex it is attached to
43     kUsedForPrimVtxFit=BIT(16), // set if this track was used to fit the primary vertex
44     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
45     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
46     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
47     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
48   };
49
50
51   enum AODTrkFilterBits_t {
52     kTrkTPCOnly            = BIT(0), // Standard TPC only tracks
53     kTrkITSsa              = BIT(1), // ITS standalone
54     kTrkITSConstrained     = BIT(2), // Pixel OR necessary for the electrons
55     kTrkElectronsPID       = BIT(3),    // PID for the electrons
56     kTrkGlobalNoDCA        = BIT(4), // standard cuts with very loose DCA
57     kTrkGlobal             = BIT(5),  // standard cuts with tight DCA cut
58     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
59     kTrkTPCOnlyConstrained = BIT(7) // TPC only tracks: TPConly information constrained to SPD vertex in the filter below
60   };
61   
62
63   enum AODTrkPID_t {
64     kElectron     =  0,
65     kMuon         =  1,
66     kPion         =  2,
67     kKaon         =  3,
68     kProton       =  4,
69     kDeuteron     =  5,
70     kTriton       =  6,
71     kHelium3      =  7,
72     kAlpha        =  8,
73     kUnknown      =  9,
74     kMostProbable = -1
75   };
76
77   AliAODTrack();
78   AliAODTrack(Short_t id,
79               Int_t label,
80               Double_t p[3],
81               Bool_t cartesian,
82               Double_t x[3],
83               Bool_t dca,
84               Double_t covMatrix[21],
85               Short_t q,
86               UChar_t itsClusMap,
87               AliAODVertex *prodVertex,
88               Bool_t usedForVtxFit,
89               Bool_t usedForPrimVtxFit,
90               AODTrk_t ttype=kUndef,
91               UInt_t selectInfo=0,
92               Float_t chi2perNDF = -999.);
93
94
95   AliAODTrack(Short_t id,
96               Int_t label,
97               Float_t p[3],
98               Bool_t cartesian,
99               Float_t x[3],
100               Bool_t dca,
101               Float_t covMatrix[21],
102               Short_t q,
103               UChar_t itsClusMap,
104               AliAODVertex *prodVertex,
105               Bool_t usedForVtxFit,
106               Bool_t usedForPrimVtxFit,
107               AODTrk_t ttype=kUndef,
108               UInt_t selectInfo=0,
109               Float_t chi2perNDF = -999.);
110
111   virtual ~AliAODTrack();
112   AliAODTrack(const AliAODTrack& trk); 
113   AliAODTrack& operator=(const AliAODTrack& trk);
114
115   // kinematics
116   virtual Double_t OneOverPt() const { return (fMomentum[0] != 0.) ? 1./fMomentum[0] : -999.; }
117   virtual Double_t Phi()       const { return fMomentum[1]; }
118   virtual Double_t Theta()     const { return fMomentum[2]; }
119   
120   virtual Double_t Px() const { return fMomentum[0] * TMath::Cos(fMomentum[1]); }
121   virtual Double_t Py() const { return fMomentum[0] * TMath::Sin(fMomentum[1]); }
122   virtual Double_t Pz() const { return fMomentum[0] / TMath::Tan(fMomentum[2]); }
123   virtual Double_t Pt() const { return fMomentum[0]; }
124   virtual Double_t P()  const { return TMath::Sqrt(Pt()*Pt()+Pz()*Pz()); }
125   virtual Bool_t   PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
126
127   virtual Double_t Xv() const { return GetProdVertex() ? GetProdVertex()->GetX() : -999.; }
128   virtual Double_t Yv() const { return GetProdVertex() ? GetProdVertex()->GetY() : -999.; }
129   virtual Double_t Zv() const { return GetProdVertex() ? GetProdVertex()->GetZ() : -999.; }
130   virtual Bool_t   XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
131
132   Double_t Chi2perNDF()  const { return fChi2perNDF; }
133
134   UShort_t GetTPCnclsS(Int_t i0=0,Int_t i1=159)  const { 
135     UShort_t cl = fTPCSharedMap.CountBits(i0)-fTPCSharedMap.CountBits(i1);
136     return cl;
137   }
138   
139   UShort_t GetTPCncls(Int_t i0=0,Int_t i1=159)  const { 
140     UShort_t cl = fTPCFitMap.CountBits(i0)-fTPCFitMap.CountBits(i1);
141     if(cl==0)cl = fTPCClusterMap.CountBits(i0)-fTPCClusterMap.CountBits(i1);// backward compatibility
142     return cl;
143   }
144   
145   UShort_t GetTPCNcls()  const { return GetTPCncls(); }
146
147   Int_t GetNcls(Int_t idet) const;
148
149   virtual Double_t M() const { return M(GetMostProbablePID()); }
150   Double_t M(AODTrkPID_t pid) const;
151   virtual Double_t E() const { return E(GetMostProbablePID()); }
152   Double_t E(AODTrkPID_t pid) const;
153   Double_t E(Double_t m) const { return TMath::Sqrt(P()*P() + m*m); }
154   virtual Double_t Y() const { return Y(GetMostProbablePID()); }
155   Double_t Y(AODTrkPID_t pid) const;
156   Double_t Y(Double_t m) const;
157   
158   virtual Double_t Eta() const { return -TMath::Log(TMath::Tan(0.5 * fMomentum[2])); }
159
160   virtual Short_t  Charge() const {return fCharge; }
161
162   virtual Bool_t   PropagateToDCA(const AliVVertex *vtx, 
163           Double_t b, Double_t maxd, Double_t dz[2], Double_t covar[3]);
164
165   // PID
166   virtual const Double_t *PID() const { return fPID; }
167   AODTrkPID_t GetMostProbablePID() const;
168   void ConvertAliPIDtoAODPID();
169   void SetDetPID(AliAODPid *aodpid) {fDetPid = aodpid;}
170
171   void     SetPIDForTracking(Int_t pid) {fPIDForTracking = pid;}
172   Int_t    GetPIDForTracking()  const   {return fPIDForTracking;}
173   Double_t GetMassForTracking() const;
174
175   template <typename T> void GetPID(T *pid) const {
176     for(Int_t i=0; i<10; ++i) pid[i] = fPID ? fPID[i]:0;}
177  
178   template <typename T> void SetPID(const T *pid) {
179     if (pid) {
180       if (!fPID) fPID = new Double32_t[10];
181       for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
182     }
183     else {delete[] fPID; fPID = 0;}
184   }
185   
186   Bool_t IsOn(Int_t mask) const {return (fFlags&mask)>0;}
187   ULong_t GetStatus() const { return GetFlags(); }
188   ULong_t GetFlags() const { return fFlags; }
189
190   Int_t   GetID() const { return (Int_t)fID; }
191   Int_t   GetLabel() const { return fLabel; } 
192   void    GetTOFLabel(Int_t *p) const;
193
194
195   Char_t  GetType() const { return fType;}
196   Bool_t  IsPrimaryCandidate() const;
197   Bool_t  GetUsedForVtxFit() const { return TestBit(kUsedForVtxFit); }
198   Bool_t  GetUsedForPrimVtxFit() const { return TestBit(kUsedForPrimVtxFit); }
199
200   Bool_t  IsHybridGlobalConstrainedGlobal() const { return TestBit(kIsHybridGCG); }
201   Bool_t  IsHybridTPCConstrainedGlobal() const { return TestBit(kIsHybridTPCCG); }
202   Bool_t  IsTPCOnly() const { return IsTPCConstrained(); } // obsolete bad naming
203   Bool_t  IsTPCConstrained() const { return TestBit(kIsTPCConstrained); }
204   Bool_t  IsGlobalConstrained() const { return TestBit(kIsGlobalConstrained); }
205   //
206   Int_t   GetTOFBunchCrossing(Double_t b=0, Bool_t tpcPIDonly=kFALSE) const;
207   //
208   template <typename T> void GetP(T *p) const {
209     p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
210
211 //  template <typename T> void GetPxPyPz(T *p) const {
212 //    p[0] = Px(); p[1] = Py(); p[2] = Pz();}
213   Bool_t GetPxPyPz(Double_t *p) const;
214
215   template <typename T> Bool_t GetPosition(T *x) const {
216     x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
217     return TestBit(kIsDCA);}
218
219   template <typename T> void SetCovMatrix(const T *covMatrix) {
220     if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
221     fCovMatrix->SetCovMatrix(covMatrix);}
222
223   template <typename T> Bool_t GetCovMatrix(T *covMatrix) const {
224     if(!fCovMatrix) return kFALSE;
225     fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
226
227   Bool_t GetXYZ(Double_t *p) const {
228     return GetPosition(p); }
229   
230   Bool_t GetXYZAt(Double_t x, Double_t b, Double_t *r) const;
231   Bool_t GetXYZatR(Double_t xr,Double_t bz, Double_t *xyz=0, Double_t* alpSect=0) const;  
232
233   Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const {
234     return GetCovMatrix(cv);}
235
236   void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
237
238   Double_t XAtDCA() const { return fPositionAtDCA[0]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
239   Double_t YAtDCA() const { return fPositionAtDCA[1]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
240   Double_t ZAtDCA() const {
241     if (IsMuonTrack()) return fPosition[2];
242     else if (TestBit(kIsDCA)) return fPosition[1];
243     else return -999.; }                                //makes sense only for constrained tracks, returns dummy values for all other tracks
244   Bool_t   XYZAtDCA(Double_t x[3]) const { x[0] = XAtDCA(); x[1] = YAtDCA(); x[2] = ZAtDCA(); return kTRUE; }
245   
246   Double_t DCA() const {
247     if (IsMuonTrack()) return TMath::Sqrt(XAtDCA()*XAtDCA() + YAtDCA()*YAtDCA());
248     else if (TestBit(kIsDCA)) return fPosition[0];
249     else return -999.; }
250   
251   Double_t PxAtDCA() const { return fMomentumAtDCA[0]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
252   Double_t PyAtDCA() const { return fMomentumAtDCA[1]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
253   Double_t PzAtDCA() const { return fMomentumAtDCA[2]; } //makes sense only for constrained tracks, returns dummy values for all other tracks
254   Double_t PAtDCA() const { return TMath::Sqrt(PxAtDCA()*PxAtDCA() + PyAtDCA()*PyAtDCA() + PzAtDCA()*PzAtDCA()); }
255   Bool_t   PxPyPzAtDCA(Double_t p[3]) const { p[0] = PxAtDCA(); p[1] = PyAtDCA(); p[2] = PzAtDCA(); return kTRUE; }
256   
257   Double_t GetRAtAbsorberEnd() const { return fRAtAbsorberEnd; }
258   
259   UChar_t  GetITSClusterMap() const       { return (UChar_t)(fITSMuonClusterMap&0xff); }
260   Int_t    GetITSNcls() const; 
261   Bool_t   HasPointOnITSLayer(Int_t i) const { return TESTBIT(GetITSClusterMap(),i); }
262   UShort_t GetHitsPatternInTrigCh() const { return (UShort_t)((fITSMuonClusterMap&0xff00)>>8); }
263   UInt_t   GetMUONClusterMap() const      { return (fITSMuonClusterMap&0x3ff0000)>>16; }
264   UInt_t   GetITSMUONClusterMap() const   { return fITSMuonClusterMap; }
265   
266   Bool_t  TestFilterBit(UInt_t filterBit) const {return (Bool_t) ((filterBit & fFilterMap) != 0);}
267   Bool_t  TestFilterMask(UInt_t filterMask) const {return (Bool_t) ((filterMask & fFilterMap) == filterMask);}
268   void    SetFilterMap(UInt_t i){fFilterMap = i;}
269   UInt_t  GetFilterMap() const {return fFilterMap;}
270
271   const TBits& GetTPCClusterMap() const {return fTPCClusterMap;}
272   const TBits* GetTPCClusterMapPtr() const {return &fTPCClusterMap;}
273   const TBits& GetTPCFitMap() const {return fTPCFitMap;}
274   const TBits* GetTPCFitMapPtr() const {return &fTPCFitMap;}
275   Float_t GetTPCClusterInfo(Int_t nNeighbours=3, Int_t type=0, Int_t row0=0, Int_t row1=159, Int_t /*type*/=0) const;
276   
277   const TBits& GetTPCSharedMap() const {return fTPCSharedMap;}
278   const TBits* GetTPCSharedMapPtr() const {return &fTPCSharedMap;}
279   void    SetTPCClusterMap(const TBits amap) {fTPCClusterMap = amap;}
280   void    SetTPCSharedMap(const TBits amap) {fTPCSharedMap = amap;}
281   void    SetTPCFitMap(const TBits amap) {fTPCFitMap = amap;}
282   void    SetTPCPointsF(UShort_t  findable){fTPCnclsF = findable;}
283   void    SetTPCNCrossedRows(UInt_t n)     {fTPCNCrossedRows = n;}
284
285   UShort_t GetTPCNclsF() const { return fTPCnclsF;}
286   UShort_t GetTPCNCrossedRows()  const { return fTPCNCrossedRows;}
287   Float_t  GetTPCFoundFraction() const { return fTPCNCrossedRows>0 ? float(GetTPCNcls())/fTPCNCrossedRows : 0;}
288
289   // Calorimeter Cluster
290   Int_t GetEMCALcluster() const {return fCaloIndex;}
291   void SetEMCALcluster(Int_t index) {fCaloIndex=index;}
292   Bool_t IsEMCAL() const {return fFlags&kEMCALmatch;}
293
294   Double_t GetTrackPhiOnEMCal() const {return fTrackPhiOnEMCal;}
295   Double_t GetTrackEtaOnEMCal() const {return fTrackEtaOnEMCal;}
296   Double_t GetTrackPtOnEMCal() const {return fTrackPtOnEMCal;}
297   Double_t GetTrackPOnEMCal() const {return TMath::Abs(fTrackEtaOnEMCal) < 1 ? fTrackPtOnEMCal*TMath::CosH(fTrackEtaOnEMCal) : -999;}
298   void SetTrackPhiEtaPtOnEMCal(Double_t phi,Double_t eta,Double_t pt) {fTrackPhiOnEMCal=phi;fTrackEtaOnEMCal=eta;fTrackPtOnEMCal=pt;}
299
300   Int_t GetPHOScluster() const {return fCaloIndex;}
301   void SetPHOScluster(Int_t index) {fCaloIndex=index;}
302   Bool_t IsPHOS() const {return fFlags&kPHOSmatch;}
303
304   //pid signal interface
305   Double_t  GetITSsignal()       const { return fDetPid?fDetPid->GetITSsignal():0.;    }
306   void      GetITSdEdxSamples(Double_t s[4]) const;
307   Double_t  GetTPCsignal()       const { return fDetPid?fDetPid->GetTPCsignal():0.;    }
308   Double_t  GetTPCsignalTunedOnData() const { return fTPCsignalTuned;}
309   void      SetTPCsignalTunedOnData(Double_t signal) {fTPCsignalTuned = signal;}
310   UShort_t  GetTPCsignalN()      const { return fDetPid?fDetPid->GetTPCsignalN():0;    }
311   virtual AliTPCdEdxInfo* GetTPCdEdxInfo() const {return fDetPid?fDetPid->GetTPCdEdxInfo():0;}
312   Double_t  GetTPCmomentum()     const { return fDetPid?fDetPid->GetTPCmomentum():0.;  }
313   Double_t  GetTPCTgl()          const { return fDetPid?fDetPid->GetTPCTgl():0.;  }
314   Double_t  GetTOFsignal()       const { return fDetPid?fDetPid->GetTOFsignal():0.;    }
315   Double_t  GetIntegratedLength() const { return fTrackLength;}
316   void      SetIntegratedLength(Double_t l) {fTrackLength = l;}
317   Double_t  GetTOFsignalTunedOnData() const { return fTOFsignalTuned;}
318   void      SetTOFsignalTunedOnData(Double_t signal) {fTOFsignalTuned = signal;}
319   Double_t  GetHMPIDsignal()     const; 
320   Double_t  GetHMPIDoccupancy()  const;
321
322   Int_t     GetHMPIDcluIdx()     const;
323     
324   void GetHMPIDtrk(Float_t &x, Float_t &y, Float_t &th, Float_t &ph) const;  
325   void GetHMPIDmip(Float_t &x,Float_t &y,Int_t &q,Int_t &nph) const;
326   
327   Bool_t GetOuterHmpPxPyPz(Double_t *p) const;
328   
329   void      GetIntegratedTimes(Double_t *times, Int_t nspec=AliPID::kSPECIES) const {if (fDetPid) fDetPid->GetIntegratedTimes(times, nspec);}
330   Double_t  GetTRDslice(Int_t plane, Int_t slice) const;
331   Double_t  GetTRDsignal()                        const {return fDetPid ? fDetPid->GetTRDsignal() : 0;}
332   Double_t  GetTRDmomentum(Int_t plane, Double_t */*sp*/=0x0) const;
333   Double_t  GetTRDchi2()                 const {return fDetPid ? fDetPid->GetTRDChi2() : -1;}
334   UChar_t   GetTRDncls(Int_t layer)      const;
335   UChar_t   GetTRDncls()                 const {return GetTRDncls(-1);}
336   UChar_t   GetTRDntrackletsPID() const;
337   Int_t     GetNumberOfTRDslices() const { return fDetPid?fDetPid->GetTRDnSlices():0; }
338   void      GetHMPIDpid(Double_t */*p*/) const { return; } // TODO: To be implemented properly with the new HMPID object
339
340   void SetMFTClusterPattern(ULong_t mftClusterPattern) { fMFTClusterPattern = mftClusterPattern; }   // AU
341   ULong_t GetMFTClusterPattern() { return fMFTClusterPattern; }                                      // AU
342
343   const AliAODEvent* GetAODEvent() const {return fAODEvent;}
344   virtual const AliVEvent* GetEvent() const {return (AliVEvent*)fAODEvent;}
345   void SetAODEvent(const AliAODEvent* ptr){fAODEvent = ptr;}
346   const AliTOFHeader* GetTOFHeader() const;
347
348   AliAODPid    *GetDetPid() const { return fDetPid; }
349   AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
350   
351   // print
352   void  Print(const Option_t *opt = "") const;
353
354   // setters
355   void SetFlags(ULong_t flags) { fFlags = flags; }
356   void SetStatus(ULong_t flags) { fFlags|=flags; }
357   void ResetStatus(ULong_t flags) { fFlags&=~flags; }
358
359   void SetID(Short_t id) { fID = id; }
360   void SetLabel(Int_t label) { fLabel = label; }
361   void SetTOFLabel(const Int_t* p);
362   template <typename T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
363   void SetDCA(Double_t d, Double_t z);
364   void SetUsedForVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForVtxFit) : ResetBit(kUsedForVtxFit); }
365   void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
366
367   void SetIsTPCOnly(Bool_t b = kTRUE) { SetIsTPCConstrained(b); }// obsolete bad naming
368
369   void SetIsTPCConstrained(Bool_t b = kTRUE) { b ? SetBit(kIsTPCConstrained) : ResetBit(kIsTPCConstrained); }
370   void SetIsHybridTPCConstrainedGlobal(Bool_t hybrid = kTRUE) { hybrid ? SetBit(kIsHybridTPCCG) : ResetBit(kIsHybridTPCCG); }
371
372   void SetIsGlobalConstrained(Bool_t b = kTRUE) { b ? SetBit(kIsGlobalConstrained) : ResetBit(kIsGlobalConstrained); }
373   void SetIsHybridGlobalConstrainedGlobal(Bool_t hybrid = kTRUE) { hybrid ? SetBit(kIsHybridGCG) : ResetBit(kIsHybridGCG); }
374
375
376
377   void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = 1. / oneOverPt; }
378   void SetPt(Double_t pt) { fMomentum[0] = pt; };
379   void SetPhi(Double_t phi) { fMomentum[1] = phi; }
380   void SetTheta(Double_t theta) { fMomentum[2] = theta; }
381   template <typename T> void SetP(const T *p, Bool_t cartesian = kTRUE);
382   void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
383
384   void SetXYAtDCA(Double_t x, Double_t y) {fPositionAtDCA[0] = x; fPositionAtDCA[1] = y;}
385   void SetPxPyPzAtDCA(Double_t pX, Double_t pY, Double_t pZ) {fMomentumAtDCA[0] = pX; fMomentumAtDCA[1] = pY; fMomentumAtDCA[2] = pZ;}
386   
387   void SetRAtAbsorberEnd(Double_t r) { fRAtAbsorberEnd = r; }
388   
389   void SetCharge(Short_t q) { fCharge = q; }
390   void SetChi2perNDF(Double_t chi2perNDF) { fChi2perNDF = chi2perNDF; }
391
392   void SetITSClusterMap(UChar_t itsClusMap)                 { fITSMuonClusterMap = (fITSMuonClusterMap&0xffffff00)|(((UInt_t)itsClusMap)&0xff); }
393   void SetHitsPatternInTrigCh(UShort_t hitsPatternInTrigCh) { fITSMuonClusterMap = (fITSMuonClusterMap&0xffff00ff)|((((UInt_t)hitsPatternInTrigCh)&0xff)<<8); }
394   void SetMuonClusterMap(UInt_t muonClusMap)                { fITSMuonClusterMap = (fITSMuonClusterMap&0xfc00ffff)|((muonClusMap&0x3ff)<<16); }
395   void SetITSMuonClusterMap(UInt_t itsMuonClusMap)          { fITSMuonClusterMap = itsMuonClusMap; }
396   void SetMUONtrigHitsMapTrg(UInt_t muonTrigHitsMap) { fMUONtrigHitsMapTrg = muonTrigHitsMap; }
397   UInt_t GetMUONTrigHitsMapTrg() const { return fMUONtrigHitsMapTrg; }
398   void SetMUONtrigHitsMapTrk(UInt_t muonTrigHitsMap) { fMUONtrigHitsMapTrk = muonTrigHitsMap; }
399   UInt_t GetMUONTrigHitsMapTrk() const { return fMUONtrigHitsMapTrk; }
400   Int_t GetMuonTrigDevSign() const;
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, explanation close to the enum AODTrk_t
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