]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODTrack.cxx
Additional protections, corrected creation of kinks, neutral clusters included
[u/mrichter/AliRoot.git] / STEER / AliAODTrack.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //     AOD track base class
20 //     Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
22
23 #include "AliAODTrack.h"
24
25 ClassImp(AliAODTrack)
26
27 //______________________________________________________________________________
28 AliAODTrack::AliAODTrack() : 
29   AliVirtualParticle(),
30   fChi2(-999.),
31   fID(-999),
32   fLabel(-999),
33   fCovMatrix(NULL),
34   fProdVertex(0x0),
35   fCharge(-999),
36   fITSClusterMap(0),
37   fType(kUndef)
38 {
39   // default constructor
40
41   SetP();
42   SetPosition((Float_t*)NULL);
43   SetPID((Float_t*)NULL);
44 }
45
46 //______________________________________________________________________________
47 AliAODTrack::AliAODTrack(Int_t id,
48                          Int_t label, 
49                          Double_t p[3],
50                          Bool_t cartesian,
51                          Double_t x[3],
52                          Bool_t isDCA,
53                          Double_t covMatrix[21],
54                          Short_t charge,
55                          UChar_t itsClusMap,
56                          Double_t pid[10],
57                          AliAODVertex *prodVertex,
58                          AODTrk_t ttype) :
59   AliVirtualParticle(),
60   fChi2(-999.),
61   fID(id),
62   fLabel(label),
63   fCovMatrix(NULL),
64   fProdVertex(prodVertex),
65   fCharge(charge),
66   fITSClusterMap(itsClusMap),
67   fType(ttype)
68 {
69   // constructor
70  
71   SetP(p, cartesian);
72   SetPosition(x, isDCA);
73   if(covMatrix) SetCovMatrix(covMatrix);
74   SetPID(pid);
75
76 }
77
78 //______________________________________________________________________________
79 AliAODTrack::AliAODTrack(Int_t id,
80                          Int_t label, 
81                          Float_t p[3],
82                          Bool_t cartesian,
83                          Float_t x[3],
84                          Bool_t isDCA,
85                          Float_t covMatrix[21],
86                          Short_t charge,
87                          UChar_t itsClusMap,
88                          Float_t pid[10],
89                          AliAODVertex *prodVertex,
90                          AODTrk_t ttype) :
91   AliVirtualParticle(),
92   fChi2(-999.),
93   fID(id),
94   fLabel(label),
95   fCovMatrix(NULL),
96   fProdVertex(prodVertex),
97   fCharge(charge),
98   fITSClusterMap(itsClusMap),
99   fType(ttype)
100 {
101   // constructor
102  
103   SetP(p, cartesian);
104   SetPosition(x, isDCA);
105   if(covMatrix) SetCovMatrix(covMatrix);
106   SetPID(pid);
107
108 }
109
110 //______________________________________________________________________________
111 AliAODTrack::~AliAODTrack() 
112 {
113   // destructor
114   delete fCovMatrix;
115 }
116
117
118 //______________________________________________________________________________
119 AliAODTrack::AliAODTrack(const AliAODTrack& trk) :
120   AliVirtualParticle(trk),
121   fChi2(trk.fChi2),
122   fID(trk.fID),
123   fLabel(trk.fLabel),
124   fCovMatrix(NULL),
125   fProdVertex(trk.fProdVertex),
126   fCharge(trk.fCharge),
127   fITSClusterMap(trk.fITSClusterMap),
128   fType(trk.fType)
129 {
130   // Copy constructor
131
132   trk.GetP(fMomentum);
133   trk.GetPosition(fPosition);
134   if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
135   SetPID(trk.fPID);
136
137 }
138
139 //______________________________________________________________________________
140 AliAODTrack& AliAODTrack::operator=(const AliAODTrack& trk)
141 {
142   // Assignment operator
143   if(this!=&trk) {
144
145     AliVirtualParticle::operator=(trk);
146
147     trk.GetP(fMomentum);
148     trk.GetPosition(fPosition);
149     trk.GetPID(fPID);
150
151     fChi2 = trk.fChi2;
152
153     fID = trk.fID;
154     fLabel = trk.fLabel;    
155     
156     delete fCovMatrix;
157     if(trk.fCovMatrix) fCovMatrix=new AliAODRedCov<6>(*trk.fCovMatrix);
158     else fCovMatrix=NULL;
159     fProdVertex = trk.fProdVertex;
160
161     fCharge = trk.fCharge;
162     fITSClusterMap = trk.fITSClusterMap;
163     fType = trk.fType;
164   }
165
166   return *this;
167 }
168
169 //______________________________________________________________________________
170 template <class T> void AliAODTrack::SetP(const T *p, const Bool_t cartesian) 
171 {
172   // set the momentum
173
174   if (p) {
175     if (cartesian) {
176       Double_t pt = TMath::Sqrt(p[0]*p[0] + p[1]*p[1]);
177       Double_t P = TMath::Sqrt(pt*pt + p[2]*p[2]);
178       
179       fMomentum[0] = 1./pt;
180       fMomentum[1] = TMath::ACos(p[2]/P);
181       fMomentum[2] = TMath::ATan2(p[1], p[0]);
182     } else {
183       fMomentum[0] = p[0];  // 1/pt
184       fMomentum[1] = p[1];  // phi
185       fMomentum[2] = p[2];  // theta
186     }
187   } else {
188     fMomentum[0] = -999.;
189     fMomentum[1] = -999.;
190     fMomentum[2] = -999.;
191   }
192 }
193
194 //______________________________________________________________________________
195 template <class T> void AliAODTrack::SetPosition(const T *x, const Bool_t dca) 
196 {
197   // set the position
198
199   if (x) {
200     if (!dca) {
201       ResetBit(kIsDCA);
202
203       fPosition[0] = x[0];
204       fPosition[1] = x[1];
205       fPosition[2] = x[2];
206     } else {
207       SetBit(kIsDCA);
208       // don't know any better yet
209       fPosition[0] = -999.;
210       fPosition[1] = -999.;
211       fPosition[2] = -999.;
212     }
213   } else {
214     ResetBit(kIsDCA);
215
216     fPosition[0] = -999.;
217     fPosition[1] = -999.;
218     fPosition[2] = -999.;
219   }
220 }
221
222 //______________________________________________________________________________
223 void AliAODTrack::SetDCA(Double_t d, Double_t z) 
224 {
225   // set the dca
226   fPosition[0] = d;
227   fPosition[1] = z;
228   fPosition[2] = 0.;
229   SetBit(kIsDCA);
230 }
231
232 //______________________________________________________________________________
233 void AliAODTrack::Print(Option_t* /* option */) const
234 {
235   // prints information about AliAODTrack
236
237   printf("Object name: %s   Track type: %s\n", GetName(), GetTitle()); 
238   printf("        px = %f\n", Px());
239   printf("        py = %f\n", Py());
240   printf("        pz = %f\n", Pz());
241   printf("        pt = %f\n", Pt());
242   printf("      1/pt = %f\n", OneOverPt());
243   printf("     theta = %f\n", Theta());
244   printf("       phi = %f\n", Phi());
245   printf("      chi2 = %f\n", Chi2());
246   printf("    charge = %d\n", Charge());
247   printf(" PID object: %p\n", PID());
248 }
249