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