]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODTrack.h
Fix momentum implementation.
[u/mrichter/AliRoot.git] / STEER / 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 base class
10 //     Author: Markus Oldenburg, CERN
11 //-------------------------------------------------------------------------
12
13 #include <TRef.h>
14
15 #include "AliVirtualParticle.h"
16 #include "AliAODVertex.h"
17 #include "AliAODRedCov.h"
18
19 class AliAODTrack : public AliVirtualParticle {
20
21  public:
22   
23   enum AODTrk_t {kUndef=-1, kPrimary, kSecondary, kOrphan};
24
25   enum AODTrkBits_t {
26     kIsDCA=BIT(14),   // set if fPosition is the DCA and not the position of the first point
27     kUsedForPrimVtxFit=BIT(15) // set if this track was used to fit the primary vertex
28   };
29
30   enum AODTrkPID_t { // not clear why this was introduced
31     kUnknown=0, kElectron, kMuon, kPion, kProton, kDeuteron, kTriton, kAlpha, kOther}; // Where is the Kaon, why the Triton? 
32
33   AliAODTrack();
34   AliAODTrack(Int_t id,
35               Int_t label,
36               Double_t p[3],
37               Bool_t cartesian,
38               Double_t x[3],
39               Bool_t dca,
40               Double_t covMatrix[21],
41               Short_t q,
42               UChar_t itsClusMap,
43               Double_t pid[10],
44               AliAODVertex *prodVertex,
45               Bool_t usedForPrimVtxFit,
46               AODTrk_t ttype=kUndef);
47
48   AliAODTrack(Int_t id,
49               Int_t label,
50               Float_t p[3],
51               Bool_t cartesian,
52               Float_t x[3],
53               Bool_t dca,
54               Float_t covMatrix[21],
55               Short_t q,
56               UChar_t itsClusMap,
57               Float_t pid[10],
58               AliAODVertex *prodVertex,
59               Bool_t usedForPrimVtxFit,
60               AODTrk_t ttype=kUndef);
61
62   virtual ~AliAODTrack();
63   AliAODTrack(const AliAODTrack& trk); 
64   AliAODTrack& operator=(const AliAODTrack& trk);
65
66   // kinematics
67   virtual Double_t OneOverPt() const { return (fMomentum[0] != 0.) ? 1./fMomentum[0] : -999.; }
68   virtual Double_t Phi()       const { return fMomentum[1]; }
69   virtual Double_t Theta()     const { return fMomentum[2]; }
70   
71   virtual Double_t Px() const { return fMomentum[0] * TMath::Cos(fMomentum[1]); }
72   virtual Double_t Py() const { return fMomentum[0] * TMath::Sin(fMomentum[1]); }
73   virtual Double_t Pz() const { return fMomentum[0] / TMath::Tan(fMomentum[2]); }
74   virtual Double_t Pt() const { return fMomentum[0]; }
75   virtual Double_t P()  const { return TMath::Sqrt(Pt()*Pt()+Pz()*Pz()); }
76
77           Double_t Chi2() const { return fChi2; }
78
79   virtual Double_t E() const { return -999.; }
80   // make a connection to the PID object, here!!!
81   virtual Double_t M() const { return -999.; }
82   
83   virtual Double_t Eta() const { return -TMath::Log(TMath::Tan(0.5 * fMomentum[2])); }
84   // make a connection to the PID object, here!!!
85   virtual Double_t Y() const { return -999.; }
86
87   virtual Short_t  Charge() const {return fCharge; }
88
89   // PID
90   virtual const Double_t *PID() const { return fPID; }
91
92   template <class T> void GetPID(T *pid) const {
93     for(Int_t i=0; i<10; ++i) pid[i]=fPID[i];}
94  
95   template <class T> void SetPID(const T *pid) {
96     if(pid) for(Int_t i=0; i<10; ++i) fPID[i]=pid[i];
97     else {for(Int_t i=1; i<10; fPID[i++]=0); fPID[0]=1.;}}
98
99   Int_t GetID() const { return fID; }
100   Int_t GetLabel() const { return fLabel; } 
101   Char_t GetType() const { return fType;}
102   Bool_t GetUsedForPrimVtxFit() const { return TestBit(kUsedForPrimVtxFit); }
103
104   template <class T> void GetP(T *p) const {
105     p[0]=fMomentum[0]; p[1]=fMomentum[1]; p[2]=fMomentum[2];}
106
107   template <class T> void GetPxPyPz(T *p) const {
108     p[0] = Px(); p[1] = Py(); p[2] = Pz();}
109
110   template <class T> Bool_t GetPosition(T *x) const {
111     x[0]=fPosition[0]; x[1]=fPosition[1]; x[2]=fPosition[2];
112     return TestBit(kIsDCA);}
113
114   template <class T> void SetCovMatrix(const T *covMatrix) {
115     if(!fCovMatrix) fCovMatrix=new AliAODRedCov<6>();
116     fCovMatrix->SetCovMatrix(covMatrix);}
117
118   template <class T> Bool_t GetCovMatrix(T *covMatrix) const {
119     if(!fCovMatrix) return kFALSE;
120     fCovMatrix->GetCovMatrix(covMatrix); return kTRUE;}
121
122   void RemoveCovMatrix() {delete fCovMatrix; fCovMatrix=NULL;}
123
124   UChar_t GetITSClusterMap() const { return fITSClusterMap; }
125
126   AliAODVertex *GetProdVertex() const { return (AliAODVertex*)fProdVertex.GetObject(); }
127   
128   // print
129   void  Print(const Option_t *opt = "") const;
130
131   // setters
132   void SetID(Int_t id) { fID = id; }
133   void SetLabel(Int_t label) {fLabel = label; }
134
135   template <class T> void SetPosition(const T *x, Bool_t isDCA = kFALSE);
136   void SetDCA(Double_t d, Double_t z);
137   void SetUsedForPrimVtxFit(Bool_t used = kTRUE) { used ? SetBit(kUsedForPrimVtxFit) : ResetBit(kUsedForPrimVtxFit); }
138
139   void SetOneOverPt(Double_t oneOverPt) { fMomentum[0] = oneOverPt; }
140   void SetPt(Double_t pt) { fMomentum[0] = pt; };
141   void SetPhi(Double_t phi) { fMomentum[1] = phi; }
142   void SetTheta(Double_t theta) { fMomentum[2] = theta; }
143   template <class T> void SetP(const T *p, Bool_t cartesian = kTRUE);
144   void SetP() {fMomentum[0]=fMomentum[1]=fMomentum[2]=-999.;}
145
146   void SetCharge(Short_t q) { fCharge = q; }
147   void SetChi2(Double_t chi2) { fChi2 = chi2; }
148
149   void SetITSClusterMap(UChar_t itsClusMap) { fITSClusterMap = itsClusMap; }
150
151   void SetProdVertex(TObject *vertex) { fProdVertex = vertex; }
152
153   // name and title
154   void SetType(AODTrk_t ttype) { fType=ttype; }
155
156  private :
157
158   // Momentum & position
159   Double32_t    fMomentum[3];    // momemtum stored in pt, phi, theta
160   Double32_t    fPosition[3];    // position of first point on track or dca
161
162   Double32_t    fPID[10];        // [0.,1.,8] pointer to PID object
163   Double32_t    fChi2;           // chi2 of mometum fit
164
165   Int_t         fID;             // unique track ID, points back to the ESD track
166   Int_t         fLabel;          // track label, points back to MC track
167   
168   AliAODRedCov<6> *fCovMatrix;      // covariance matrix (x, y, z, px, py, pz)
169   TRef          fProdVertex;     // vertex of origin
170
171   Char_t        fCharge;         // particle charge
172   UChar_t       fITSClusterMap;  // map of ITS cluster, one bit per layer
173   Char_t        fType;           // Track Type
174
175
176   ClassDef(AliAODTrack,1);
177 };
178
179 #endif