Decay time in [s].
[u/mrichter/AliRoot.git] / STEER / AliTrackPointArray.cxx
CommitLineData
98937d93 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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//////////////////////////////////////////////////////////////////////////////
17// Class AliTrackPointArray //
18// This class contains the ESD track space-points which are used during //
19// the alignment procedures. Each space-point consist of 3 coordinates //
20// (and their errors) and the index of the sub-detector which contains //
21// the space-point. //
22// cvetan.cheshkov@cern.ch 3/11/2005 //
23//////////////////////////////////////////////////////////////////////////////
24
25#include "AliTrackPointArray.h"
26
27ClassImp(AliTrackPointArray)
28
29//______________________________________________________________________________
30AliTrackPointArray::AliTrackPointArray()
31{
32 fNPoints = fSize = 0;
33 fX = fY = fZ = 0;
34 fVolumeID = 0;
35 fCov = 0;
36}
37
38//______________________________________________________________________________
39AliTrackPointArray::AliTrackPointArray(Int_t npoints):
40 fNPoints(npoints)
41{
42 // Constructor
43 //
44 fSize = 6*npoints;
45 fX = new Float_t[npoints];
46 fY = new Float_t[npoints];
47 fZ = new Float_t[npoints];
48 fVolumeID = new UShort_t[npoints];
49 fCov = new Float_t[fSize];
50}
51
52//______________________________________________________________________________
53AliTrackPointArray::AliTrackPointArray(const AliTrackPointArray &array):
54 TObject(array)
55{
56 // Copy constructor
57 //
58 fNPoints = array.fNPoints;
59 fSize = array.fSize;
60 fX = new Float_t[fNPoints];
61 fY = new Float_t[fNPoints];
62 fZ = new Float_t[fNPoints];
63 fVolumeID = new UShort_t[fNPoints];
64 fCov = new Float_t[fSize];
65 memcpy(fX,array.fX,fNPoints*sizeof(Float_t));
66 memcpy(fY,array.fY,fNPoints*sizeof(Float_t));
67 memcpy(fZ,array.fZ,fNPoints*sizeof(Float_t));
68 memcpy(fVolumeID,array.fVolumeID,fNPoints*sizeof(UShort_t));
69 memcpy(fCov,array.fCov,fSize*sizeof(Float_t));
70}
71
72//_____________________________________________________________________________
73AliTrackPointArray &AliTrackPointArray::operator =(const AliTrackPointArray& array)
74{
75 // assignment operator
76 //
77 if(this==&array) return *this;
78 ((TObject *)this)->operator=(array);
79
80 fNPoints = array.fNPoints;
81 fSize = array.fSize;
82 fX = new Float_t[fNPoints];
83 fY = new Float_t[fNPoints];
84 fZ = new Float_t[fNPoints];
85 fVolumeID = new UShort_t[fNPoints];
86 fCov = new Float_t[fSize];
87 memcpy(fX,array.fX,fNPoints*sizeof(Float_t));
88 memcpy(fY,array.fY,fNPoints*sizeof(Float_t));
89 memcpy(fZ,array.fZ,fNPoints*sizeof(Float_t));
90 memcpy(fVolumeID,array.fVolumeID,fNPoints*sizeof(UShort_t));
91 memcpy(fCov,array.fCov,fSize*sizeof(Float_t));
92
93 return *this;
94}
95
96//______________________________________________________________________________
97AliTrackPointArray::~AliTrackPointArray()
98{
99 // Destructor
100 //
101 delete [] fX;
102 delete [] fY;
103 delete [] fZ;
104 delete [] fVolumeID;
105 delete [] fCov;
106}
107
108
109//______________________________________________________________________________
110Bool_t AliTrackPointArray::AddPoint(Int_t i, const AliTrackPoint *p)
111{
112 // Add a point to the array at position i
113 //
114 if (i >= fNPoints) return kFALSE;
115 fX[i] = p->GetX();
116 fY[i] = p->GetY();
117 fZ[i] = p->GetZ();
118 fVolumeID[i] = p->GetVolumeID();
119 memcpy(&fCov[6*i],p->GetCov(),6*sizeof(Float_t));
120 return kTRUE;
121}
122
123//______________________________________________________________________________
124Bool_t AliTrackPointArray::GetPoint(AliTrackPoint &p, Int_t i) const
125{
126 // Get the point at position i
127 //
128 if (i >= fNPoints) return kFALSE;
129 p.SetXYZ(fX[i],fY[i],fZ[i],&fCov[6*i]);
130 p.SetVolumeID(fVolumeID[i]);
131 return kTRUE;
132}
133
134//______________________________________________________________________________
135Bool_t AliTrackPointArray::HasVolumeID(UShort_t volid) const
136{
137 // This method checks if the array
138 // has at least one hit in the detector
139 // volume defined by volid
140 Bool_t check = kFALSE;
141 for (Int_t ipoint = 0; ipoint < fNPoints; ipoint++)
142 if (fVolumeID[ipoint] == volid) check = kTRUE;
143
144 return check;
145}
146
147ClassImp(AliTrackPoint)
148
149//______________________________________________________________________________
150AliTrackPoint::AliTrackPoint()
151{
152 // Default constructor
153 //
154 fX = fY = fZ = 0;
155 fVolumeID = 0;
156 memset(fCov,0,6*sizeof(Float_t));
157}
158
159
160//______________________________________________________________________________
161AliTrackPoint::AliTrackPoint(Float_t x, Float_t y, Float_t z, const Float_t *cov, UShort_t volid)
162{
163 // Constructor
164 //
165 SetXYZ(x,y,z,cov);
166 SetVolumeID(volid);
167}
168
169//______________________________________________________________________________
170AliTrackPoint::AliTrackPoint(const Float_t *xyz, const Float_t *cov, UShort_t volid)
171{
172 // Constructor
173 //
174 SetXYZ(xyz[0],xyz[1],xyz[2],cov);
175 SetVolumeID(volid);
176}
177
178//______________________________________________________________________________
179AliTrackPoint::AliTrackPoint(const AliTrackPoint &p):
180 TObject(p)
181{
182 // Copy constructor
183 //
184 SetXYZ(p.fX,p.fY,p.fZ,&(p.fCov[0]));
185 SetVolumeID(p.fVolumeID);
186}
187
188//_____________________________________________________________________________
189AliTrackPoint &AliTrackPoint::operator =(const AliTrackPoint& p)
190{
191 // assignment operator
192 //
193 if(this==&p) return *this;
194 ((TObject *)this)->operator=(p);
195
196 SetXYZ(p.fX,p.fY,p.fZ,&(p.fCov[0]));
197 SetVolumeID(p.fVolumeID);
198
199 return *this;
200}
201
202//______________________________________________________________________________
203void AliTrackPoint::SetXYZ(Float_t x, Float_t y, Float_t z, const Float_t *cov)
204{
205 // Set XYZ coordinates and their cov matrix
206 //
207 fX = x;
208 fY = y;
209 fZ = z;
210 if (cov)
211 memcpy(fCov,cov,6*sizeof(Float_t));
212}
213
214//______________________________________________________________________________
215void AliTrackPoint::SetXYZ(const Float_t *xyz, const Float_t *cov)
216{
217 // Set XYZ coordinates and their cov matrix
218 //
219 SetXYZ(xyz[0],xyz[1],xyz[2],cov);
220}
221
222//______________________________________________________________________________
223void AliTrackPoint::GetXYZ(Float_t *xyz, Float_t *cov) const
224{
225 xyz[0] = fX;
226 xyz[1] = fY;
227 xyz[2] = fZ;
228 if (cov)
229 memcpy(cov,fCov,6*sizeof(Float_t));
230}