]>
Commit | Line | Data |
---|---|---|
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 | ||
46ae650f | 25 | #include <TMath.h> |
4dcdc747 | 26 | #include <TMatrixD.h> |
46ae650f | 27 | #include <TMatrixDSym.h> |
082050e1 | 28 | #include <TGeoMatrix.h> |
29 | #include <TMatrixDSymEigen.h> | |
46ae650f | 30 | |
98937d93 | 31 | #include "AliTrackPointArray.h" |
32 | ||
33 | ClassImp(AliTrackPointArray) | |
34 | ||
35 | //______________________________________________________________________________ | |
fe12e09c | 36 | AliTrackPointArray::AliTrackPointArray() : |
37 | TObject(), | |
bead9796 | 38 | fSorted(kFALSE), |
fe12e09c | 39 | fNPoints(0), |
40 | fX(0), | |
41 | fY(0), | |
42 | fZ(0), | |
6d016ab4 | 43 | fCharge(0), |
cb0800cc | 44 | fDriftTime(0), |
b7bcc8ed | 45 | fChargeRatio(0), |
e3901fd8 | 46 | fClusterType(0), |
eb2d90b9 | 47 | fIsExtra(0), |
fe12e09c | 48 | fSize(0), |
49 | fCov(0), | |
50 | fVolumeID(0) | |
98937d93 | 51 | { |
98937d93 | 52 | } |
53 | ||
54 | //______________________________________________________________________________ | |
55 | AliTrackPointArray::AliTrackPointArray(Int_t npoints): | |
fe12e09c | 56 | TObject(), |
bead9796 | 57 | fSorted(kFALSE), |
fe12e09c | 58 | fNPoints(npoints), |
59 | fX(new Float_t[npoints]), | |
60 | fY(new Float_t[npoints]), | |
61 | fZ(new Float_t[npoints]), | |
6d016ab4 | 62 | fCharge(new Float_t[npoints]), |
cb0800cc | 63 | fDriftTime(new Float_t[npoints]), |
b7bcc8ed | 64 | fChargeRatio(new Float_t[npoints]), |
e3901fd8 | 65 | fClusterType(new Int_t[npoints]), |
eb2d90b9 | 66 | fIsExtra(new Bool_t[npoints]), |
fe12e09c | 67 | fSize(6*npoints), |
68 | fCov(new Float_t[fSize]), | |
69 | fVolumeID(new UShort_t[npoints]) | |
98937d93 | 70 | { |
71 | // Constructor | |
72 | // | |
a090c665 | 73 | for (Int_t ip=0; ip<npoints;ip++){ |
74 | fX[ip]=0; | |
75 | fY[ip]=0; | |
76 | fZ[ip]=0; | |
6d016ab4 | 77 | fCharge[ip]=0; |
cb0800cc | 78 | fDriftTime[ip]=0; |
b7bcc8ed | 79 | fChargeRatio[ip]=0; |
e3901fd8 | 80 | fClusterType[ip]=0; |
eb2d90b9 | 81 | fIsExtra[ip]=kFALSE; |
a090c665 | 82 | fVolumeID[ip]=0; |
83 | for (Int_t icov=0;icov<6; icov++) | |
84 | fCov[6*ip+icov]=0; | |
85 | } | |
98937d93 | 86 | } |
87 | ||
88 | //______________________________________________________________________________ | |
89 | AliTrackPointArray::AliTrackPointArray(const AliTrackPointArray &array): | |
fe12e09c | 90 | TObject(array), |
bead9796 | 91 | fSorted(array.fSorted), |
fe12e09c | 92 | fNPoints(array.fNPoints), |
93 | fX(new Float_t[fNPoints]), | |
94 | fY(new Float_t[fNPoints]), | |
95 | fZ(new Float_t[fNPoints]), | |
6d016ab4 | 96 | fCharge(new Float_t[fNPoints]), |
cb0800cc | 97 | fDriftTime(new Float_t[fNPoints]), |
b7bcc8ed | 98 | fChargeRatio(new Float_t[fNPoints]), |
e3901fd8 | 99 | fClusterType(new Int_t[fNPoints]), |
eb2d90b9 | 100 | fIsExtra(new Bool_t[fNPoints]), |
fe12e09c | 101 | fSize(array.fSize), |
102 | fCov(new Float_t[fSize]), | |
103 | fVolumeID(new UShort_t[fNPoints]) | |
98937d93 | 104 | { |
105 | // Copy constructor | |
106 | // | |
98937d93 | 107 | memcpy(fX,array.fX,fNPoints*sizeof(Float_t)); |
108 | memcpy(fY,array.fY,fNPoints*sizeof(Float_t)); | |
109 | memcpy(fZ,array.fZ,fNPoints*sizeof(Float_t)); | |
b7a370ef | 110 | if (array.fCharge) { |
111 | memcpy(fCharge,array.fCharge,fNPoints*sizeof(Float_t)); | |
112 | } else { | |
113 | memset(fCharge, 0, fNPoints*sizeof(Float_t)); | |
114 | } | |
cb0800cc | 115 | if (array.fDriftTime) { |
116 | memcpy(fDriftTime,array.fDriftTime,fNPoints*sizeof(Float_t)); | |
117 | } else { | |
118 | memset(fDriftTime, 0, fNPoints*sizeof(Float_t)); | |
119 | } | |
b7bcc8ed | 120 | if (array.fChargeRatio) { |
121 | memcpy(fChargeRatio,array.fChargeRatio,fNPoints*sizeof(Float_t)); | |
122 | } else { | |
123 | memset(fChargeRatio, 0, fNPoints*sizeof(Float_t)); | |
124 | } | |
e3901fd8 | 125 | if (array.fClusterType) { |
126 | memcpy(fClusterType,array.fClusterType,fNPoints*sizeof(Int_t)); | |
127 | } else { | |
128 | memset(fClusterType, 0, fNPoints*sizeof(Int_t)); | |
129 | } | |
eb2d90b9 | 130 | if (array.fIsExtra) { |
131 | memcpy(fIsExtra,array.fIsExtra,fNPoints*sizeof(Bool_t)); | |
132 | } else { | |
133 | memset(fIsExtra, 0, fNPoints*sizeof(Bool_t)); | |
134 | } | |
98937d93 | 135 | memcpy(fVolumeID,array.fVolumeID,fNPoints*sizeof(UShort_t)); |
136 | memcpy(fCov,array.fCov,fSize*sizeof(Float_t)); | |
137 | } | |
138 | ||
139 | //_____________________________________________________________________________ | |
140 | AliTrackPointArray &AliTrackPointArray::operator =(const AliTrackPointArray& array) | |
141 | { | |
142 | // assignment operator | |
143 | // | |
144 | if(this==&array) return *this; | |
145 | ((TObject *)this)->operator=(array); | |
146 | ||
bead9796 | 147 | fSorted = array.fSorted; |
98937d93 | 148 | fNPoints = array.fNPoints; |
149 | fSize = array.fSize; | |
6989bff3 | 150 | delete [] fX; |
98937d93 | 151 | fX = new Float_t[fNPoints]; |
6989bff3 | 152 | delete [] fY; |
98937d93 | 153 | fY = new Float_t[fNPoints]; |
6989bff3 | 154 | delete [] fZ; |
98937d93 | 155 | fZ = new Float_t[fNPoints]; |
6d016ab4 | 156 | delete [] fCharge; |
157 | fCharge = new Float_t[fNPoints]; | |
cb0800cc | 158 | delete [] fDriftTime; |
159 | fDriftTime = new Float_t[fNPoints]; | |
b7bcc8ed | 160 | delete [] fChargeRatio; |
161 | fChargeRatio = new Float_t[fNPoints]; | |
e3901fd8 | 162 | delete [] fClusterType; |
163 | fClusterType = new Int_t[fNPoints]; | |
eb2d90b9 | 164 | delete [] fIsExtra; |
165 | fIsExtra = new Bool_t[fNPoints]; | |
6989bff3 | 166 | delete [] fVolumeID; |
98937d93 | 167 | fVolumeID = new UShort_t[fNPoints]; |
6989bff3 | 168 | delete [] fCov; |
98937d93 | 169 | fCov = new Float_t[fSize]; |
170 | memcpy(fX,array.fX,fNPoints*sizeof(Float_t)); | |
171 | memcpy(fY,array.fY,fNPoints*sizeof(Float_t)); | |
172 | memcpy(fZ,array.fZ,fNPoints*sizeof(Float_t)); | |
6d016ab4 | 173 | memcpy(fCharge,array.fCharge,fNPoints*sizeof(Float_t)); |
cb0800cc | 174 | memcpy(fDriftTime,array.fDriftTime,fNPoints*sizeof(Float_t)); |
b7bcc8ed | 175 | memcpy(fChargeRatio,array.fChargeRatio,fNPoints*sizeof(Float_t)); |
e3901fd8 | 176 | memcpy(fClusterType,array.fClusterType,fNPoints*sizeof(Int_t)); |
eb2d90b9 | 177 | memcpy(fIsExtra,array.fIsExtra,fNPoints*sizeof(Bool_t)); |
98937d93 | 178 | memcpy(fVolumeID,array.fVolumeID,fNPoints*sizeof(UShort_t)); |
179 | memcpy(fCov,array.fCov,fSize*sizeof(Float_t)); | |
180 | ||
181 | return *this; | |
182 | } | |
183 | ||
184 | //______________________________________________________________________________ | |
185 | AliTrackPointArray::~AliTrackPointArray() | |
186 | { | |
187 | // Destructor | |
188 | // | |
189 | delete [] fX; | |
190 | delete [] fY; | |
191 | delete [] fZ; | |
6d016ab4 | 192 | delete [] fCharge; |
cb0800cc | 193 | delete [] fDriftTime; |
b7bcc8ed | 194 | delete [] fChargeRatio; |
e3901fd8 | 195 | delete [] fClusterType; |
eb2d90b9 | 196 | delete [] fIsExtra; |
98937d93 | 197 | delete [] fVolumeID; |
198 | delete [] fCov; | |
199 | } | |
200 | ||
201 | ||
202 | //______________________________________________________________________________ | |
203 | Bool_t AliTrackPointArray::AddPoint(Int_t i, const AliTrackPoint *p) | |
204 | { | |
205 | // Add a point to the array at position i | |
206 | // | |
207 | if (i >= fNPoints) return kFALSE; | |
208 | fX[i] = p->GetX(); | |
209 | fY[i] = p->GetY(); | |
210 | fZ[i] = p->GetZ(); | |
6d016ab4 | 211 | fCharge[i] = p->GetCharge(); |
cb0800cc | 212 | fDriftTime[i] = p->GetDriftTime(); |
b7bcc8ed | 213 | fChargeRatio[i]=p->GetChargeRatio(); |
e3901fd8 | 214 | fClusterType[i]=p->GetClusterType(); |
eb2d90b9 | 215 | fIsExtra[i] = p->IsExtra(); |
98937d93 | 216 | fVolumeID[i] = p->GetVolumeID(); |
217 | memcpy(&fCov[6*i],p->GetCov(),6*sizeof(Float_t)); | |
218 | return kTRUE; | |
219 | } | |
220 | ||
ec9e17f9 | 221 | |
98937d93 | 222 | //______________________________________________________________________________ |
223 | Bool_t AliTrackPointArray::GetPoint(AliTrackPoint &p, Int_t i) const | |
224 | { | |
225 | // Get the point at position i | |
226 | // | |
227 | if (i >= fNPoints) return kFALSE; | |
228 | p.SetXYZ(fX[i],fY[i],fZ[i],&fCov[6*i]); | |
229 | p.SetVolumeID(fVolumeID[i]); | |
d58b83a7 | 230 | p.SetCharge(fCharge ? fCharge[i] : 0); |
231 | p.SetDriftTime(fDriftTime ? fDriftTime[i] : 0); | |
232 | p.SetChargeRatio(fChargeRatio ? fChargeRatio[i] : 0); | |
e3901fd8 | 233 | p.SetClusterType(fClusterType ? fClusterType[i] : 0); |
f7a1cc68 | 234 | p.SetExtra(fIsExtra ? fIsExtra[i] : kFALSE); |
98937d93 | 235 | return kTRUE; |
236 | } | |
237 | ||
238 | //______________________________________________________________________________ | |
239 | Bool_t AliTrackPointArray::HasVolumeID(UShort_t volid) const | |
240 | { | |
241 | // This method checks if the array | |
242 | // has at least one hit in the detector | |
243 | // volume defined by volid | |
244 | Bool_t check = kFALSE; | |
245 | for (Int_t ipoint = 0; ipoint < fNPoints; ipoint++) | |
246 | if (fVolumeID[ipoint] == volid) check = kTRUE; | |
247 | ||
248 | return check; | |
249 | } | |
250 | ||
bead9796 | 251 | //______________________________________________________________________________ |
252 | void AliTrackPointArray::Sort(Bool_t down) | |
253 | { | |
254 | // Sort the array by the values of Y-coordinate of the track points. | |
255 | // The order is given by "down". | |
256 | // Optimized more for maintenance rather than for speed. | |
257 | ||
258 | if (fSorted) return; | |
259 | ||
260 | Int_t *index=new Int_t[fNPoints]; | |
261 | AliTrackPointArray a(*this); | |
262 | TMath::Sort(fNPoints,a.GetY(),index,down); | |
263 | ||
264 | AliTrackPoint p; | |
265 | for (Int_t i = 0; i < fNPoints; i++) { | |
266 | a.GetPoint(p,index[i]); | |
267 | AddPoint(i,&p); | |
268 | } | |
269 | ||
270 | delete[] index; | |
271 | fSorted=kTRUE; | |
272 | } | |
273 | ||
98937d93 | 274 | ClassImp(AliTrackPoint) |
275 | ||
276 | //______________________________________________________________________________ | |
fe12e09c | 277 | AliTrackPoint::AliTrackPoint() : |
278 | TObject(), | |
279 | fX(0), | |
280 | fY(0), | |
281 | fZ(0), | |
6d016ab4 | 282 | fCharge(0), |
cb0800cc | 283 | fDriftTime(0), |
b7bcc8ed | 284 | fChargeRatio(0), |
e3901fd8 | 285 | fClusterType(0), |
eb2d90b9 | 286 | fIsExtra(kFALSE), |
fe12e09c | 287 | fVolumeID(0) |
98937d93 | 288 | { |
289 | // Default constructor | |
290 | // | |
98937d93 | 291 | memset(fCov,0,6*sizeof(Float_t)); |
292 | } | |
293 | ||
294 | ||
295 | //______________________________________________________________________________ | |
e3901fd8 | 296 | AliTrackPoint::AliTrackPoint(Float_t x, Float_t y, Float_t z, const Float_t *cov, UShort_t volid, Float_t charge, Float_t drifttime,Float_t chargeratio, Int_t clutyp) : |
fe12e09c | 297 | TObject(), |
298 | fX(0), | |
299 | fY(0), | |
300 | fZ(0), | |
6d016ab4 | 301 | fCharge(0), |
cb0800cc | 302 | fDriftTime(0), |
b7bcc8ed | 303 | fChargeRatio(0), |
e3901fd8 | 304 | fClusterType(0), |
eb2d90b9 | 305 | fIsExtra(kFALSE), |
fe12e09c | 306 | fVolumeID(0) |
98937d93 | 307 | { |
308 | // Constructor | |
309 | // | |
310 | SetXYZ(x,y,z,cov); | |
6d016ab4 | 311 | SetCharge(charge); |
cb0800cc | 312 | SetDriftTime(drifttime); |
b7bcc8ed | 313 | SetChargeRatio(chargeratio); |
e3901fd8 | 314 | SetClusterType(clutyp); |
98937d93 | 315 | SetVolumeID(volid); |
316 | } | |
317 | ||
318 | //______________________________________________________________________________ | |
e3901fd8 | 319 | AliTrackPoint::AliTrackPoint(const Float_t *xyz, const Float_t *cov, UShort_t volid, Float_t charge, Float_t drifttime,Float_t chargeratio, Int_t clutyp) : |
fe12e09c | 320 | TObject(), |
321 | fX(0), | |
322 | fY(0), | |
323 | fZ(0), | |
6d016ab4 | 324 | fCharge(0), |
cb0800cc | 325 | fDriftTime(0), |
b7bcc8ed | 326 | fChargeRatio(0), |
e3901fd8 | 327 | fClusterType(0), |
eb2d90b9 | 328 | fIsExtra(kFALSE), |
fe12e09c | 329 | fVolumeID(0) |
98937d93 | 330 | { |
331 | // Constructor | |
332 | // | |
333 | SetXYZ(xyz[0],xyz[1],xyz[2],cov); | |
6d016ab4 | 334 | SetCharge(charge); |
cb0800cc | 335 | SetDriftTime(drifttime); |
b7bcc8ed | 336 | SetChargeRatio(chargeratio); |
98937d93 | 337 | SetVolumeID(volid); |
e3901fd8 | 338 | SetClusterType(clutyp); |
98937d93 | 339 | } |
340 | ||
341 | //______________________________________________________________________________ | |
342 | AliTrackPoint::AliTrackPoint(const AliTrackPoint &p): | |
fe12e09c | 343 | TObject(p), |
344 | fX(0), | |
345 | fY(0), | |
346 | fZ(0), | |
6d016ab4 | 347 | fCharge(0), |
cb0800cc | 348 | fDriftTime(0), |
b7bcc8ed | 349 | fChargeRatio(0), |
e3901fd8 | 350 | fClusterType(0), |
eb2d90b9 | 351 | fIsExtra(kFALSE), |
fe12e09c | 352 | fVolumeID(0) |
98937d93 | 353 | { |
354 | // Copy constructor | |
355 | // | |
356 | SetXYZ(p.fX,p.fY,p.fZ,&(p.fCov[0])); | |
6d016ab4 | 357 | SetCharge(p.fCharge); |
cb0800cc | 358 | SetDriftTime(p.fDriftTime); |
b7bcc8ed | 359 | SetChargeRatio(p.fChargeRatio); |
e3901fd8 | 360 | SetClusterType(p.fClusterType); |
eb2d90b9 | 361 | SetExtra(p.fIsExtra); |
98937d93 | 362 | SetVolumeID(p.fVolumeID); |
363 | } | |
364 | ||
365 | //_____________________________________________________________________________ | |
366 | AliTrackPoint &AliTrackPoint::operator =(const AliTrackPoint& p) | |
367 | { | |
368 | // assignment operator | |
369 | // | |
370 | if(this==&p) return *this; | |
371 | ((TObject *)this)->operator=(p); | |
372 | ||
373 | SetXYZ(p.fX,p.fY,p.fZ,&(p.fCov[0])); | |
6d016ab4 | 374 | SetCharge(p.fCharge); |
cb0800cc | 375 | SetDriftTime(p.fDriftTime); |
b7bcc8ed | 376 | SetChargeRatio(p.fChargeRatio); |
e3901fd8 | 377 | SetClusterType(p.fClusterType); |
eb2d90b9 | 378 | SetExtra(p.fIsExtra); |
98937d93 | 379 | SetVolumeID(p.fVolumeID); |
380 | ||
381 | return *this; | |
382 | } | |
383 | ||
384 | //______________________________________________________________________________ | |
385 | void AliTrackPoint::SetXYZ(Float_t x, Float_t y, Float_t z, const Float_t *cov) | |
386 | { | |
387 | // Set XYZ coordinates and their cov matrix | |
388 | // | |
389 | fX = x; | |
390 | fY = y; | |
391 | fZ = z; | |
392 | if (cov) | |
393 | memcpy(fCov,cov,6*sizeof(Float_t)); | |
394 | } | |
395 | ||
396 | //______________________________________________________________________________ | |
397 | void AliTrackPoint::SetXYZ(const Float_t *xyz, const Float_t *cov) | |
398 | { | |
399 | // Set XYZ coordinates and their cov matrix | |
400 | // | |
401 | SetXYZ(xyz[0],xyz[1],xyz[2],cov); | |
402 | } | |
403 | ||
90a845c7 | 404 | //______________________________________________________________________________ |
405 | void AliTrackPoint::SetCov(const Float_t *cov) | |
406 | { | |
407 | // Set XYZ cov matrix | |
408 | // | |
409 | if (cov) | |
410 | memcpy(fCov,cov,6*sizeof(Float_t)); | |
411 | } | |
412 | ||
98937d93 | 413 | //______________________________________________________________________________ |
414 | void AliTrackPoint::GetXYZ(Float_t *xyz, Float_t *cov) const | |
415 | { | |
416 | xyz[0] = fX; | |
417 | xyz[1] = fY; | |
418 | xyz[2] = fZ; | |
419 | if (cov) | |
420 | memcpy(cov,fCov,6*sizeof(Float_t)); | |
421 | } | |
46ae650f | 422 | |
423 | //______________________________________________________________________________ | |
424 | Float_t AliTrackPoint::GetResidual(const AliTrackPoint &p, Bool_t weighted) const | |
425 | { | |
426 | // This method calculates the track to space-point residuals. The track | |
427 | // interpolation is also stored as AliTrackPoint. Using the option | |
428 | // 'weighted' one can calculate the residual either with or without | |
429 | // taking into account the covariance matrix of the space-point and | |
430 | // track interpolation. The second case the residual becomes a pull. | |
431 | ||
432 | Float_t res = 0; | |
433 | ||
434 | if (!weighted) { | |
435 | Float_t xyz[3],xyzp[3]; | |
436 | GetXYZ(xyz); | |
437 | p.GetXYZ(xyzp); | |
438 | res = (xyz[0]-xyzp[0])*(xyz[0]-xyzp[0])+ | |
439 | (xyz[1]-xyzp[1])*(xyz[1]-xyzp[1])+ | |
440 | (xyz[2]-xyzp[2])*(xyz[2]-xyzp[2]); | |
441 | } | |
442 | else { | |
443 | Float_t xyz[3],xyzp[3]; | |
444 | Float_t cov[6],covp[6]; | |
445 | GetXYZ(xyz,cov); | |
446 | TMatrixDSym mcov(3); | |
447 | mcov(0,0) = cov[0]; mcov(0,1) = cov[1]; mcov(0,2) = cov[2]; | |
448 | mcov(1,0) = cov[1]; mcov(1,1) = cov[3]; mcov(1,2) = cov[4]; | |
449 | mcov(2,0) = cov[2]; mcov(2,1) = cov[4]; mcov(2,2) = cov[5]; | |
450 | p.GetXYZ(xyzp,covp); | |
451 | TMatrixDSym mcovp(3); | |
452 | mcovp(0,0) = covp[0]; mcovp(0,1) = covp[1]; mcovp(0,2) = covp[2]; | |
453 | mcovp(1,0) = covp[1]; mcovp(1,1) = covp[3]; mcovp(1,2) = covp[4]; | |
454 | mcovp(2,0) = covp[2]; mcovp(2,1) = covp[4]; mcovp(2,2) = covp[5]; | |
455 | TMatrixDSym msum = mcov + mcovp; | |
456 | msum.Invert(); | |
cc345ce3 | 457 | // mcov.Print(); mcovp.Print(); msum.Print(); |
46ae650f | 458 | if (msum.IsValid()) { |
459 | for (Int_t i = 0; i < 3; i++) | |
460 | for (Int_t j = 0; j < 3; j++) | |
461 | res += (xyz[i]-xyzp[i])*(xyz[j]-xyzp[j])*msum(i,j); | |
462 | } | |
463 | } | |
464 | ||
465 | return res; | |
466 | } | |
467 | ||
4dcdc747 | 468 | //_____________________________________________________________________________ |
469 | Bool_t AliTrackPoint::GetPCA(const AliTrackPoint &p, AliTrackPoint &out) const | |
470 | { | |
471 | // | |
472 | // Get the intersection point between this point and | |
473 | // the point "p" belongs to. | |
474 | // The result is stored as a point 'out' | |
475 | // return kFALSE in case of failure. | |
476 | out.SetXYZ(0,0,0); | |
477 | ||
478 | TMatrixD t(3,1); | |
479 | t(0,0)=GetX(); | |
480 | t(1,0)=GetY(); | |
481 | t(2,0)=GetZ(); | |
482 | ||
483 | TMatrixDSym tC(3); | |
484 | { | |
485 | const Float_t *cv=GetCov(); | |
486 | tC(0,0)=cv[0]; tC(0,1)=cv[1]; tC(0,2)=cv[2]; | |
487 | tC(1,0)=cv[1]; tC(1,1)=cv[3]; tC(1,2)=cv[4]; | |
488 | tC(2,0)=cv[2]; tC(2,1)=cv[4]; tC(2,2)=cv[5]; | |
489 | } | |
490 | ||
491 | TMatrixD m(3,1); | |
492 | m(0,0)=p.GetX(); | |
493 | m(1,0)=p.GetY(); | |
494 | m(2,0)=p.GetZ(); | |
495 | ||
496 | TMatrixDSym mC(3); | |
497 | { | |
498 | const Float_t *cv=p.GetCov(); | |
499 | mC(0,0)=cv[0]; mC(0,1)=cv[1]; mC(0,2)=cv[2]; | |
500 | mC(1,0)=cv[1]; mC(1,1)=cv[3]; mC(1,2)=cv[4]; | |
501 | mC(2,0)=cv[2]; mC(2,1)=cv[4]; mC(2,2)=cv[5]; | |
502 | } | |
503 | ||
504 | TMatrixDSym tmW(tC); | |
505 | tmW+=mC; | |
506 | tmW.Invert(); | |
507 | if (!tmW.IsValid()) return kFALSE; | |
508 | ||
509 | TMatrixD mW(tC,TMatrixD::kMult,tmW); | |
510 | TMatrixD tW(mC,TMatrixD::kMult,tmW); | |
511 | ||
512 | TMatrixD mi(mW,TMatrixD::kMult,m); | |
513 | TMatrixD ti(tW,TMatrixD::kMult,t); | |
514 | ti+=mi; | |
515 | ||
516 | TMatrixD iC(tC,TMatrixD::kMult,tmW); | |
517 | iC*=mC; | |
518 | ||
519 | out.SetXYZ(ti(0,0),ti(1,0),ti(2,0)); | |
520 | UShort_t id=p.GetVolumeID(); | |
521 | out.SetVolumeID(id); | |
522 | ||
523 | return kTRUE; | |
524 | } | |
525 | ||
46ae650f | 526 | //______________________________________________________________________________ |
527 | Float_t AliTrackPoint::GetAngle() const | |
528 | { | |
529 | // The method uses the covariance matrix of | |
530 | // the space-point in order to extract the | |
531 | // orientation of the detector plane. | |
532 | // The rotation in XY plane only is calculated. | |
533 | ||
8e52c1a8 | 534 | Float_t phi= TMath::ATan2(TMath::Sqrt(fCov[0]),TMath::Sqrt(fCov[3])); |
535 | if (fCov[1] > 0) { | |
536 | phi = TMath::Pi() - phi; | |
537 | if ((fY-fX) < 0) phi += TMath::Pi(); | |
538 | } | |
46ae650f | 539 | else { |
8e52c1a8 | 540 | if ((fX+fY) < 0) phi += TMath::Pi(); |
541 | } | |
542 | ||
543 | return phi; | |
544 | ||
46ae650f | 545 | } |
546 | ||
082050e1 | 547 | //______________________________________________________________________________ |
548 | Bool_t AliTrackPoint::GetRotMatrix(TGeoRotation& rot) const | |
549 | { | |
550 | // Returns the orientation of the | |
551 | // sensitive layer (using cluster | |
552 | // covariance matrix). | |
553 | // Assumes that cluster has errors only in the layer's plane. | |
554 | // Return value is kTRUE in case of success. | |
555 | ||
556 | TMatrixDSym mcov(3); | |
557 | { | |
558 | const Float_t *cov=GetCov(); | |
559 | mcov(0,0)=cov[0]; mcov(0,1)=cov[1]; mcov(0,2)=cov[2]; | |
560 | mcov(1,0)=cov[1]; mcov(1,1)=cov[3]; mcov(1,2)=cov[4]; | |
561 | mcov(2,0)=cov[2]; mcov(2,1)=cov[4]; mcov(2,2)=cov[5]; | |
562 | } | |
563 | ||
564 | TMatrixDSymEigen eigen(mcov); | |
565 | TMatrixD eigenMatrix = eigen.GetEigenVectors(); | |
566 | ||
567 | rot.SetMatrix(eigenMatrix.GetMatrixArray()); | |
568 | ||
569 | return kTRUE; | |
570 | } | |
571 | ||
572 | ||
46ae650f | 573 | //_____________________________________________________________________________ |
574 | AliTrackPoint& AliTrackPoint::Rotate(Float_t alpha) const | |
575 | { | |
576 | // Transform the space-point coordinates | |
577 | // and covariance matrix from global to | |
578 | // local (detector plane) coordinate system | |
579 | // XY plane rotation only | |
580 | ||
581 | static AliTrackPoint p; | |
582 | p = *this; | |
583 | ||
584 | Float_t xyz[3],cov[6]; | |
585 | GetXYZ(xyz,cov); | |
586 | ||
587 | Float_t sin = TMath::Sin(alpha), cos = TMath::Cos(alpha); | |
588 | ||
589 | Float_t newxyz[3],newcov[6]; | |
590 | newxyz[0] = cos*xyz[0] + sin*xyz[1]; | |
591 | newxyz[1] = cos*xyz[1] - sin*xyz[0]; | |
592 | newxyz[2] = xyz[2]; | |
593 | ||
594 | newcov[0] = cov[0]*cos*cos+ | |
595 | 2*cov[1]*sin*cos+ | |
596 | cov[3]*sin*sin; | |
597 | newcov[1] = cov[1]*(cos*cos-sin*sin)+ | |
598 | (cov[3]-cov[0])*sin*cos; | |
599 | newcov[2] = cov[2]*cos+ | |
600 | cov[4]*sin; | |
601 | newcov[3] = cov[0]*sin*sin- | |
602 | 2*cov[1]*sin*cos+ | |
603 | cov[3]*cos*cos; | |
604 | newcov[4] = cov[4]*cos- | |
605 | cov[2]*sin; | |
606 | newcov[5] = cov[5]; | |
607 | ||
608 | p.SetXYZ(newxyz,newcov); | |
609 | p.SetVolumeID(GetVolumeID()); | |
610 | ||
611 | return p; | |
612 | } | |
613 | ||
614 | //_____________________________________________________________________________ | |
615 | AliTrackPoint& AliTrackPoint::MasterToLocal() const | |
616 | { | |
617 | // Transform the space-point coordinates | |
618 | // and the covariance matrix from the | |
619 | // (master) to the local (tracking) | |
620 | // coordinate system | |
621 | ||
622 | Float_t alpha = GetAngle(); | |
623 | return Rotate(alpha); | |
624 | } | |
625 | ||
626 | //_____________________________________________________________________________ | |
627 | void AliTrackPoint::Print(Option_t *) const | |
628 | { | |
629 | // Print the space-point coordinates and | |
630 | // covariance matrix | |
631 | ||
632 | printf("VolumeID=%d\n", GetVolumeID()); | |
633 | printf("X = %12.6f Tx = %12.6f%12.6f%12.6f\n", fX, fCov[0], fCov[1], fCov[2]); | |
634 | printf("Y = %12.6f Ty = %12.6f%12.6f%12.6f\n", fY, fCov[1], fCov[3], fCov[4]); | |
635 | printf("Z = %12.6f Tz = %12.6f%12.6f%12.6f\n", fZ, fCov[2], fCov[4], fCov[5]); | |
6d016ab4 | 636 | printf("Charge = %f\n", fCharge); |
cb0800cc | 637 | printf("Drift Time = %f\n", fDriftTime); |
b7bcc8ed | 638 | printf("Charge Ratio = %f\n", fChargeRatio); |
e3901fd8 | 639 | printf("Cluster Type = %d\n", fClusterType); |
eb2d90b9 | 640 | if(fIsExtra) printf("This is an extra point\n"); |
46ae650f | 641 | |
642 | } | |
ec9e17f9 | 643 | |
644 | ||
645 | //________________________________ | |
e04e816f | 646 | void AliTrackPoint::SetAlignCovMatrix(const TMatrixDSym& alignparmtrx){ |
ec9e17f9 | 647 | // Add the uncertainty on the cluster position due to alignment |
648 | // (using the 6x6 AliAlignObj Cov. Matrix alignparmtrx) to the already | |
649 | // present Cov. Matrix | |
650 | ||
651 | TMatrixDSym cov(3); | |
652 | TMatrixD coval(3,3); | |
653 | TMatrixD jacob(3,6); | |
654 | Float_t newcov[6]; | |
655 | ||
656 | cov(0,0)=fCov[0]; | |
657 | cov(1,0)=cov(0,1)=fCov[1]; | |
658 | cov(2,0)=cov(0,2)=fCov[2]; | |
659 | cov(1,1)=fCov[3]; | |
660 | cov(2,1)=cov(1,2)=fCov[4]; | |
661 | cov(2,2)=fCov[5]; | |
662 | ||
663 | jacob(0,0) = 1; jacob(1,0) = 0; jacob(2,0) = 0; | |
664 | jacob(0,1) = 0; jacob(1,1) = 1; jacob(2,1) = 0; | |
665 | jacob(0,2) = 0; jacob(1,2) = 0; jacob(2,2) = 1; | |
666 | jacob(0,3) = 0; jacob(1,3) =-fZ; jacob(2,3) = fY; | |
667 | jacob(0,4) = fZ; jacob(1,4) = 0; jacob(2,4) =-fX; | |
347c4515 | 668 | jacob(0,5) = -fY; jacob(1,5) = fX; jacob(2,5) = 0; |
ec9e17f9 | 669 | |
670 | TMatrixD jacobT=jacob.T();jacob.T(); | |
671 | ||
672 | coval=jacob*alignparmtrx*jacobT+cov; | |
673 | ||
674 | ||
675 | newcov[0]=coval(0,0); | |
676 | newcov[1]=coval(1,0); | |
677 | newcov[2]=coval(2,0); | |
678 | newcov[3]=coval(1,1); | |
679 | newcov[4]=coval(2,1); | |
680 | newcov[5]=coval(2,2); | |
681 | ||
682 | SetXYZ(fX,fY,fZ,newcov); | |
683 | ||
684 | } | |
bead9796 | 685 | |
eb2d90b9 | 686 |