24-jul-2001 NvE Support for Chi2 and NDF information of track fit introduced in AliTrack.
[u/mrichter/AliRoot.git] / RALICE / AliTrack.cxx
CommitLineData
4c039060 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
f531a546 16// $Id$
4c039060 17
959fbac5 18///////////////////////////////////////////////////////////////////////////
19// Class AliTrack
20// Handling of the attributes of a reconstructed particle track.
21//
22// Coding example :
23// ----------------
24//
25// Float_t a[4]={195.,1.2,-0.04,8.5};
26// Ali4Vector pmu;
27// pmu.SetVector(a,"car");
28// AliTrack t1;
29// t1.Set4Momentum(pmu);
30//
31// Float_t b[3]={1.2,-0.04,8.5};
32// Ali3Vector p;
33// p.SetVector(b,"car");
34// AliTrack t2;
35// t2.Set3Momentum(p);
36// t2.SetCharge(0);
37// t2.SetMass(1.115);
38//
39// t1.Info();
40// t2.Info();
41//
42// Float_t pi=acos(-1.);
43// Float_t thcms=0.2*pi; // decay theta angle in cms
44// Float_t phicms=pi/4.; // decay theta angle in cms
45// Float_t m1=0.938;
46// Float_t m2=0.140;
47// t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
48//
49// t2.List();
50//
51// Int_t ndec=t2.GetNdecay();
52// AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1
53// AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2
54//
55// AliSignal s1,s2,s3,s4;
56//
57// .... // Code (e.g. detector readout) to fill AliSignal data
58//
59// AliTrack trec; // Track which will be reconstructed from signals
60// trec.AddSignal(s1);
61// trec.AddSignal(s3);
62// trec.AddSignal(s4);
63//
64// Ali3Vector P;
65// Float_t Q,M;
66//
67// ... // Code which accesses signals from trec and reconstructs
68// 3-momentum P, charge Q, mass M etc...
69//
70// trec.Set3Momentum(P);
71// trec.SetCharge(Q);
72// trec.SetMass(M);
73//
74// Float_t r1[3]={1.6,-3.8,25.7};
75// Float_t er1[3]={0.2,0.5,1.8};
76// Float_t r2[3]={8.6,23.8,-6.7};
77// Float_t er2[3]={0.93,1.78,0.8};
78// AliPosition begin,end;
79// begin.SetPosition(r1,"car");
80// begin.SetPositionErrors(er1,"car");
81// end.SetPosition(r2,"car");
82// end.SetPositionErrors(er2,"car");
83// trec.SetBeginPoint(begin);
84// trec.SetEndPoint(end);
85//
86// Note : All quantities are in GeV, GeV/c or GeV/c**2
87//
88//--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
f531a546 89//- Modified: NvE $Date$ UU-SAP Utrecht
959fbac5 90///////////////////////////////////////////////////////////////////////////
91
d88f97cc 92#include "AliTrack.h"
93
94ClassImp(AliTrack) // Class implementation to enable ROOT I/O
95
96AliTrack::AliTrack()
97{
98// Default constructor
99// All variables initialised to 0
100 fDecays=0;
959fbac5 101 fSignals=0;
f531a546 102 fMasses=0;
103 fDmasses=0;
104 fPmasses=0;
d88f97cc 105 Reset();
106}
107///////////////////////////////////////////////////////////////////////////
108AliTrack::~AliTrack()
109{
110// Destructor to delete memory allocated for decay tracks array
111 if (fDecays)
112 {
113 fDecays->Delete();
114 delete fDecays;
115 fDecays=0;
116 }
959fbac5 117 if (fSignals)
118 {
119 fSignals->Clear();
120 delete fSignals;
121 fSignals=0;
122 }
d88f97cc 123}
124///////////////////////////////////////////////////////////////////////////
125void AliTrack::Reset()
126{
35044448 127// Reset all variables to 0 and delete all auto-generated decay tracks.
d88f97cc 128 fQ=0;
2693cb4e 129 fChi2=0;
130 fNdf=0;
43bfa5be 131 fUserId=0;
d88f97cc 132 fNdec=0;
959fbac5 133 fNsig=0;
f531a546 134 fNmasses=0;
d88f97cc 135 Double_t a[4]={0,0,0,0};
136 SetVector(a,"sph");
137 if (fDecays)
138 {
139 fDecays->Delete();
140 delete fDecays;
141 fDecays=0;
142 }
959fbac5 143 if (fSignals)
144 {
145 fSignals->Clear();
146 delete fSignals;
147 fSignals=0;
148 }
149 Double_t b[3]={0,0,0};
150 fBegin.SetPosition(b,"sph");
151 fEnd.SetPosition(b,"sph");
43bfa5be 152 fImpactXY.SetPosition(b,"sph");
153 fImpactXZ.SetPosition(b,"sph");
154 fImpactYZ.SetPosition(b,"sph");
155 fClosest.SetPosition(b,"sph");
f531a546 156 if (fMasses)
157 {
158 delete fMasses;
159 fMasses=0;
160 }
161 if (fDmasses)
162 {
163 delete fDmasses;
164 fDmasses=0;
165 }
166 if (fPmasses)
167 {
168 delete fPmasses;
169 fPmasses=0;
170 }
d88f97cc 171}
172///////////////////////////////////////////////////////////////////////////
173void AliTrack::Set3Momentum(Ali3Vector& p)
174{
175// Set the track parameters according to the 3-momentum p
959fbac5 176 Set3Vector(p);
d88f97cc 177}
178///////////////////////////////////////////////////////////////////////////
179void AliTrack::Set4Momentum(Ali4Vector& p)
180{
181// Set the track parameters according to the 4-momentum p
182 Double_t E=p.GetScalar();
959fbac5 183 Double_t dE=p.GetResultError();
d88f97cc 184 Ali3Vector pv=p.Get3Vector();
185 SetVector(E,pv);
959fbac5 186 SetScalarError(dE);
d88f97cc 187}
188///////////////////////////////////////////////////////////////////////////
959fbac5 189void AliTrack::SetMass(Double_t m,Double_t dm)
d88f97cc 190{
191// Set the particle mass
959fbac5 192// The default value for the error dm is 0.
193 Double_t inv=pow(m,2);
194 Double_t dinv=fabs(2.*m*dm);
195 SetInvariant(inv,dinv);
d88f97cc 196}
197///////////////////////////////////////////////////////////////////////////
198void AliTrack::SetCharge(Float_t q)
199{
200// Set the particle charge
201 fQ=q;
202}
203///////////////////////////////////////////////////////////////////////////
204void AliTrack::Info(TString f)
205{
206// Provide track information within the coordinate frame f
959fbac5 207 Double_t m=GetMass();
208 Double_t dm=GetResultError();
43bfa5be 209 cout << " *AliTrack::Info* Id : " << fUserId << " Mass : " << m
959fbac5 210 << " error : " << dm << " Charge : " << fQ
f531a546 211 << " Momentum : " << GetMomentum() << " Nmass hyp. : " << fNmasses
212 << " Ntracks : " << fNdec << " Nsignals : " << fNsig << endl;
213 for (Int_t i=0; i<fNmasses; i++)
214 {
215 cout << " Mass hypothesis " << (i+1) << " Mass : " << fMasses->At(i)
216 << " error : " << fDmasses->At(i) << " prob. : " << fPmasses->At(i)
217 << endl;
218 }
d88f97cc 219 Ali4Vector::Info(f);
220}
221///////////////////////////////////////////////////////////////////////////
222void AliTrack::List(TString f)
223{
224// Provide current track and decay level 1 information within coordinate frame f
225
226 Info(f); // Information of the current track
227
228 // Decay products of this track
229 AliTrack* td;
230 for (Int_t id=1; id<=fNdec; id++)
231 {
232 td=GetDecayTrack(id);
233 if (td)
234 {
235 cout << " ---Level 1 sec. track no. " << id << endl;
d88f97cc 236 td->Info(f);
237 }
238 else
239 {
240 cout << " *AliTrack::List* Error : No decay track present." << endl;
241 }
242 }
243}
244///////////////////////////////////////////////////////////////////////////
245void AliTrack::ListAll(TString f)
246{
247// Provide complete track and decay information within the coordinate frame f
248
249 Info(f); // Information of the current track
959fbac5 250 cout << " Begin-point :"; fBegin.Info(f);
251 cout << " End-point :"; fEnd.Info(f);
252 for (Int_t is=1; is<=GetNsignals(); is++)
253 {
254 ((AliSignal*)GetSignal(is))->Info(f);
255 }
d88f97cc 256
257 AliTrack* t=this;
258 Dump(t,1,f); // Information of all decay products
259}
260//////////////////////////////////////////////////////////////////////////
261void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
262{
263// Recursively provide the info of all decay levels of this track
264 AliTrack* td;
265 for (Int_t id=1; id<=t->GetNdecay(); id++)
266 {
267 td=t->GetDecayTrack(id);
268 if (td)
269 {
270 cout << " ---Level " << n << " sec. track no. " << id << endl;
d88f97cc 271 td->Info(f);
959fbac5 272 for (Int_t is=1; is<=td->GetNsignals(); is++)
273 {
274 ((AliSignal*)td->GetSignal(is))->Info(f);
275 }
d88f97cc 276
277 // Go for next decay level of this decay track recursively
278 Dump(td,n+1,f);
279 }
280 else
281 {
282 cout << " *AliTrack::Dump* Error : No decay track present." << endl;
283 }
284 }
285}
286//////////////////////////////////////////////////////////////////////////
287Double_t AliTrack::GetMomentum()
288{
959fbac5 289// Provide the value of the track 3-momentum.
290// The error can be obtained by invoking GetResultError() after
291// invokation of GetMomentum().
959fbac5 292 Double_t norm=fV.GetNorm();
d071d629 293 fDresult=fV.GetResultError();
959fbac5 294 return norm;
d88f97cc 295}
296///////////////////////////////////////////////////////////////////////////
297Ali3Vector AliTrack::Get3Momentum()
298{
299// Provide the track 3-momentum
300 return (Ali3Vector)Get3Vector();
301}
302///////////////////////////////////////////////////////////////////////////
303Double_t AliTrack::GetMass()
304{
959fbac5 305// Provide the particle mass.
306// The error can be obtained by invoking GetResultError() after
307// invokation of GetMass().
308 Double_t inv=GetInvariant();
309 Double_t dinv=GetResultError();
310 Double_t dm=0;
311 if (inv >= 0)
312 {
313 Double_t m=sqrt(inv);
314 if (m) dm=dinv/(2.*m);
315 fDresult=dm;
316 return m;
317 }
318 else
319 {
320 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
321 cout << " Value 0 will be returned." << endl;
322 fDresult=dm;
323 return 0;
324 }
d88f97cc 325}
326///////////////////////////////////////////////////////////////////////////
327Float_t AliTrack::GetCharge()
328{
329// Provide the particle charge
330 return fQ;
331}
332///////////////////////////////////////////////////////////////////////////
333Double_t AliTrack::GetEnergy()
334{
959fbac5 335// Provide the particle's energy.
336// The error can be obtained by invoking GetResultError() after
337// invokation of GetEnergy().
338 Double_t E=GetScalar();
339 if (E>0)
340 {
341 return E;
342 }
343 else
344 {
345 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
346 cout << " Value 0 will be returned." << endl;
347 return 0;
348 }
d88f97cc 349}
350///////////////////////////////////////////////////////////////////////////
351void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
352{
353// Perform 2-body decay of current track
354// m1 : mass of decay product 1
355// m2 : mass of decay product 2
356// thcms : cms theta decay angle (in rad.) of m1
357// phicms : cms phi decay angle (in rad.) of m1
358
359 fNdec=2; // it's a 2-body decay
959fbac5 360
361 Double_t M=GetMass();
d88f97cc 362
363// Compute the 4-momenta of the decay products in the cms
364// Note : p2=p1=pnorm for a 2-body decay
959fbac5 365 Double_t e1=0;
366 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
367 Double_t e2=0;
368 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
d88f97cc 369 Double_t pnorm=(e1*e1)-(m1*m1);
370 if (pnorm>0.)
371 {
372 pnorm=sqrt(pnorm);
373 }
374 else
375 {
376 pnorm=0;
377 }
378
379 Double_t a[3];
380 a[0]=pnorm;
381 a[1]=thcms;
382 a[2]=phicms;
383 Ali3Vector p;
384 p.SetVector(a,"sph");
385
386 Ali4Vector pprim1;
387 pprim1.SetVector(e1,p);
959fbac5 388 pprim1.SetInvariant(m1*m1);
d88f97cc 389
390 Ali4Vector pprim2;
391 p*=-1;
392 pprim2.SetVector(e2,p);
959fbac5 393 pprim2.SetInvariant(m2*m2);
d88f97cc 394
395 // Determine boost parameters from the parent particle
959fbac5 396 Double_t E=GetEnergy();
d88f97cc 397 p=Get3Vector();
398 Ali4Vector pmu;
399 pmu.SetVector(E,p);
400
401 AliBoost q;
402 q.Set4Momentum(pmu);
403
404 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
405 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
406
407 // Enter the boosted data into the decay tracks array
408 if (fDecays)
409 {
410 fDecays->Delete();
411 delete fDecays;
412 }
413 fDecays=new TObjArray();
414
415 fDecays->Add(new AliTrack);
416 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
959fbac5 417 ((AliTrack*)fDecays->At(0))->SetMass(m1);
d88f97cc 418 fDecays->Add(new AliTrack);
419 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
d88f97cc 420 ((AliTrack*)fDecays->At(1))->SetMass(m2);
421}
422///////////////////////////////////////////////////////////////////////////
423Int_t AliTrack::GetNdecay()
424{
425// Provide the number of decay produced tracks
426 return fNdec;
427}
428///////////////////////////////////////////////////////////////////////////
429AliTrack* AliTrack::GetDecayTrack(Int_t j)
430{
431// Provide decay produced track number j
432// Note : j=1 denotes the first decay track
433 if ((j >= 1) && (j <= fNdec))
434 {
435 return (AliTrack*)fDecays->At(j-1);
436 }
437 else
438 {
439 cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
440 cout << " -- Decay track number 1 (if any) returned." << endl;
441 return (AliTrack*)fDecays->At(0);
442 }
443}
444///////////////////////////////////////////////////////////////////////////
959fbac5 445void AliTrack::AddSignal(AliSignal& s)
446{
447// Relate an AliSignal object to this track.
448 if (!fSignals) fSignals=new TObjArray();
449 fNsig++;
450 fSignals->Add(&s);
451}
452///////////////////////////////////////////////////////////////////////////
453void AliTrack::RemoveSignal(AliSignal& s)
454{
455// Remove related AliSignal object to this track.
456 if (fSignals)
457 {
458 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
459 if (test)
460 {
461 fNsig--;
462 fSignals->Compress();
463 }
464 }
465}
466///////////////////////////////////////////////////////////////////////////
467Int_t AliTrack::GetNsignals()
468{
469// Provide the number of related AliSignals.
470 return fNsig;
471}
472///////////////////////////////////////////////////////////////////////////
473AliSignal* AliTrack::GetSignal(Int_t j)
474{
475// Provide the related AliSignal number j.
476// Note : j=1 denotes the first signal.
477 if ((j >= 1) && (j <= fNsig))
478 {
479 return (AliSignal*)fSignals->At(j-1);
480 }
481 else
482 {
483 cout << " *AliTrack* signal number : " << j << " out of range." << endl;
484 cout << " -- Signal number 1 (if any) returned." << endl;
485 return (AliSignal*)fDecays->At(0);
486 }
487}
488///////////////////////////////////////////////////////////////////////////
489void AliTrack::SetBeginPoint(AliPosition p)
490{
491// Store the position of the track begin-point.
492 fBegin=p;
493}
494///////////////////////////////////////////////////////////////////////////
495AliPosition AliTrack::GetBeginPoint()
496{
497// Provide the position of the track begin-point.
498 return fBegin;
499}
500///////////////////////////////////////////////////////////////////////////
501void AliTrack::SetEndPoint(AliPosition p)
502{
503// Store the position of the track end-point.
504 fEnd=p;
505}
506///////////////////////////////////////////////////////////////////////////
507AliPosition AliTrack::GetEndPoint()
508{
509// Provide the position of the track end-point.
510 return fEnd;
511}
512///////////////////////////////////////////////////////////////////////////
f531a546 513void AliTrack::AddMassHypothesis(Double_t prob,Double_t m,Double_t dm)
514{
515// Add a mass hypothesis for this current track.
516// prob=probalility m=mass value dm=error on the mass value.
517// The default value for the mass error dm is 0.
518 if (!fMasses) fMasses=new TArrayD();
519 if (!fDmasses) fDmasses=new TArrayD();
520 if (!fPmasses) fPmasses=new TArrayD();
521
522 fNmasses++;
523 fMasses->Set(fNmasses);
524 fDmasses->Set(fNmasses);
525 fPmasses->Set(fNmasses);
526
527 fMasses->AddAt(m,fNmasses-1);
528 fDmasses->AddAt(dm,fNmasses-1);
529 fPmasses->AddAt(prob,fNmasses-1);
530}
531///////////////////////////////////////////////////////////////////////////
532Int_t AliTrack::GetNMassHypotheses()
533{
534// Provide the number of mass hypotheses for this track.
535 return fNmasses;
536}
537///////////////////////////////////////////////////////////////////////////
538Double_t AliTrack::GetMassHypothesis(Int_t j)
539{
540// Provide the mass of the jth hypothesis for this track.
541// Note : the first hypothesis is indicated by j=1.
542// Default : j=0 ==> Hypothesis with highest probability.
543// The error on the mass can be obtained by invoking GetResultError()
544// after invokation of GetMassHypothesis(j).
545
546 Double_t m=0,dm=0,prob=0;
547
548 // Check validity of index j
549 if (j<0 || j>fNmasses)
550 {
551 cout << " *AliTrack::GetMassHypothesis* Invalid index j : " << j
552 << " Number of mass hypotheses : " << fNmasses << endl;
553 fDresult=0;
554 return 0;
555 }
556
557 // Select mass hypothesis with highest probability
558 if (j==0)
559 {
560 if (fNmasses)
561 {
562 m=fMasses->At(0);
563 dm=fDmasses->At(0);
564 prob=fPmasses->At(0);
565 for (Int_t i=1; i<fNmasses; i++)
566 {
567 if (fPmasses->At(i)>prob)
568 {
569 m=fMasses->At(i);
570 dm=fDmasses->At(i);
571 }
572 }
573 }
574 fDresult=dm;
575 return m;
576 }
577
578 // Provide data of requested mass hypothesis
579 m=fMasses->At(j-1);
580 fDresult=fDmasses->At(j-1);
581 return m;
582}
583///////////////////////////////////////////////////////////////////////////
584Double_t AliTrack::GetMassHypothesisProb(Int_t j)
585{
586// Provide the probability of the jth hypothesis for this track.
587// Note : the first hypothesis is indicated by j=1.
588// Default : j=0 ==> Hypothesis with highest probability.
589
590 Double_t prob=0;
591
592 // Check validity of index j
593 if (j<0 || j>fNmasses)
594 {
595 cout << " *AliTrack::GetMassHypothesisProb* Invalid index j : " << j
596 << " Number of mass hypotheses : " << fNmasses << endl;
597 return 0;
598 }
599
600 // Select mass hypothesis with highest probability
601 if (j==0)
602 {
603 if (fNmasses)
604 {
605 prob=fPmasses->At(0);
606 for (Int_t i=1; i<fNmasses; i++)
607 {
608 if (fPmasses->At(i)>prob) prob=fPmasses->At(i);
609 }
610 }
611 return prob;
612 }
613
614 // Provide probability of requested mass hypothesis
615 prob=fPmasses->At(j-1);
616 return prob;
617}
618///////////////////////////////////////////////////////////////////////////
619void AliTrack::SetMass()
620{
621// Set the mass and error to the value of the hypothesis with highest prob.
622
623 Double_t m=0,dm=0,prob=0;
624
625 // Select mass hypothesis with highest probability
626 if (fNmasses)
627 {
628 m=fMasses->At(0);
629 dm=fDmasses->At(0);
630 prob=fPmasses->At(0);
631 for (Int_t i=1; i<fNmasses; i++)
632 {
633 if (fPmasses->At(i)>prob)
634 {
635 m=fMasses->At(i);
636 dm=fDmasses->At(i);
637 }
638 }
639 SetMass(m,dm);
640 }
641 else
642 {
643 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
644 }
645}
646///////////////////////////////////////////////////////////////////////////
647void AliTrack::RemoveMassHypothesis(Int_t j)
648{
649// Remove the jth mass hypothesis for this track.
650// Note : the first hypothesis is indicated by j=1.
651
652 if (j<=0 || j>fNmasses) // Check validity of index j
653 {
654 cout << " *AliTrack::RemoveMassHypothesis* Invalid index j : " << j
655 << " Number of mass hypotheses : " << fNmasses << endl;
656 }
657 else
658 {
659 if (j != fNmasses)
660 {
661 fMasses->AddAt(fMasses->At(fNmasses-1),j-1);
662 fDmasses->AddAt(fDmasses->At(fNmasses-1),j-1);
663 fPmasses->AddAt(fPmasses->At(fNmasses-1),j-1);
664 }
665 fMasses->AddAt(0,fNmasses-1);
666 fDmasses->AddAt(0,fNmasses-1);
667 fPmasses->AddAt(0,fNmasses-1);
668 fNmasses--;
669 fMasses->Set(fNmasses);
670 fDmasses->Set(fNmasses);
671 fPmasses->Set(fNmasses);
672 }
673}
674///////////////////////////////////////////////////////////////////////////
d071d629 675Double_t AliTrack::GetPt()
676{
677// Provide trans. momentum value w.r.t. z-axis.
678// The error on the value can be obtained by GetResultError()
679// after invokation of GetPt().
680 Ali3Vector v;
681 v=GetVecTrans();
682 Double_t norm=v.GetNorm();
683 fDresult=v.GetResultError();
684
685 return norm;
686}
687///////////////////////////////////////////////////////////////////////////
688Double_t AliTrack::GetPl()
689{
690// Provide long. momentum value w.r.t. z-axis.
8adaf597 691// Note : the returned value can also be negative.
d071d629 692// The error on the value can be obtained by GetResultError()
693// after invokation of GetPl().
694 Ali3Vector v;
695 v=GetVecLong();
8adaf597 696
697 Double_t pl=v.GetNorm();
d071d629 698 fDresult=v.GetResultError();
699
8adaf597 700 Double_t a[3];
701 v.GetVector(a,"sph");
702 if (cos(a[1])<0) pl=-pl;
703
704 return pl;
d071d629 705}
706///////////////////////////////////////////////////////////////////////////
707Double_t AliTrack::GetEt()
708{
709// Provide trans. energy value w.r.t. z-axis.
710// The error on the value can be obtained by GetResultError()
711// after invokation of GetEt().
712 Double_t et=GetScaTrans();
713
714 return et;
715}
716///////////////////////////////////////////////////////////////////////////
717Double_t AliTrack::GetEl()
718{
719// Provide long. energy value w.r.t. z-axis.
8adaf597 720// Note : the returned value can also be negative.
d071d629 721// The error on the value can be obtained by GetResultError()
722// after invokation of GetEl().
723 Double_t el=GetScaLong();
724
725 return el;
726}
727///////////////////////////////////////////////////////////////////////////
728Double_t AliTrack::GetMt()
729{
730// Provide transverse mass value w.r.t. z-axis.
731// The error on the value can be obtained by GetResultError()
732// after invokation of GetMt().
733 Double_t pt=GetPt();
734 Double_t dpt=GetResultError();
735 Double_t m=GetMass();
736 Double_t dm=GetResultError();
737
738 Double_t mt=sqrt(pt*pt+m*m);
739 Double_t dmt2=0;
740 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
741
742 fDresult=sqrt(dmt2);
743 return mt;
744}
745///////////////////////////////////////////////////////////////////////////
746Double_t AliTrack::GetMt(Int_t j)
747{
748// Provide transverse mass value w.r.t. z-axis and jth mass hypothesis.
749// Note : the first hypothesis is indicated by j=1.
750// j=0 ==> Hypothesis with highest probability.
751// The error on the value can be obtained by GetResultError()
752// after invokation of GetMt(j).
753 Double_t pt=GetPt();
754 Double_t dpt=GetResultError();
755 Double_t m=GetMassHypothesis(j);
756 Double_t dm=GetResultError();
757
758 Double_t mt=sqrt(pt*pt+m*m);
759 Double_t dmt2=0;
760 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
761
762 fDresult=sqrt(dmt2);
763 return mt;
764}
765///////////////////////////////////////////////////////////////////////////
8adaf597 766Double_t AliTrack::GetRapidity()
767{
768// Provide rapidity value w.r.t. z-axis.
769// The error on the value can be obtained by GetResultError()
770// after invokation of GetRapidity().
771// Note : Also GetPseudoRapidity() is available since this class is
772// derived from Ali4Vector.
773 Double_t e=GetEnergy();
774 Double_t de=GetResultError();
775 Double_t pl=GetPl();
776 Double_t dpl=GetResultError();
777 Double_t sum=e+pl;
778 Double_t dif=e-pl;
779
780 Double_t y=9999,dy2=0;
781 if (sum && dif) y=0.5*log(sum/dif);
782
783 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
784
785 fDresult=sqrt(dy2);
786 return y;
787}
788///////////////////////////////////////////////////////////////////////////
43bfa5be 789void AliTrack::SetImpactPoint(AliPosition p,TString q)
790{
791// Store the position of the impact-point in the plane "q=0".
792// Here q denotes one of the axes X, Y or Z.
793// Note : The character to denote the axis may be entered in lower or
794// in uppercase.
795 Int_t axis=0;
796 if (q=="x" || q=="X") axis=1;
797 if (q=="y" || q=="Y") axis=2;
798 if (q=="z" || q=="Z") axis=3;
799
800 switch (axis)
801 {
802 case 1: // Impact-point in the plane X=0
803 fImpactYZ=p;
804 break;
805
806 case 2: // Impact-point in the plane Y=0
807 fImpactXZ=p;
808 break;
809
810 case 3: // Impact-point in the plane Z=0
811 fImpactXY=p;
812 break;
813
814 default: // Unsupported axis
815 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
816 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
817 break;
818 }
819}
820///////////////////////////////////////////////////////////////////////////
821AliPosition AliTrack::GetImpactPoint(TString q)
822{
823// Provide the position of the impact-point in the plane "q=0".
824// Here q denotes one of the axes X, Y or Z.
825// Note : The character to denote the axis may be entered in lower or
826// in uppercase.
827 AliPosition dummy;
828 Int_t axis=0;
829 if (q=="x" || q=="X") axis=1;
830 if (q=="y" || q=="Y") axis=2;
831 if (q=="z" || q=="Z") axis=3;
832
833 switch (axis)
834 {
835 case 1: // Impact-point in the plane X=0
836 return fImpactYZ;
837
838 case 2: // Impact-point in the plane Y=0
839 return fImpactXZ;
840
841 case 3: // Impact-point in the plane Z=0
842 return fImpactXY;
843
844 default: // Unsupported axis
845 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
846 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
847 return dummy;
848 }
849}
850///////////////////////////////////////////////////////////////////////////
851void AliTrack::SetId(Int_t id)
852{
853// Set a user defined identifier for this track.
854 fUserId=id;
855}
856///////////////////////////////////////////////////////////////////////////
857Int_t AliTrack::GetId()
858{
859// Provide the user defined identifier of this track.
860 return fUserId;
861}
862///////////////////////////////////////////////////////////////////////////
863void AliTrack::SetClosestPoint(AliPosition p)
864{
865// Set position p as the point of closest approach w.r.t. some reference
866 fClosest=p;
867}
868///////////////////////////////////////////////////////////////////////////
869AliPosition AliTrack::GetClosestPoint()
870{
871// Provide the point of closest approach w.r.t. some reference
872 return fClosest;
873}
874///////////////////////////////////////////////////////////////////////////
2693cb4e 875void AliTrack::SetChi2(Float_t chi2)
876{
877// Set the chi-squared value of the track fit.
878 if (chi2<0)
879 {
880 cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl;
881 }
882 else
883 {
884 fChi2=chi2;
885 }
886}
887///////////////////////////////////////////////////////////////////////////
888void AliTrack::SetNdf(Int_t ndf)
889{
890// Set the number of degrees of freedom for the track fit.
891 if (ndf<0)
892 {
893 cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl;
894 }
895 else
896 {
897 fNdf=ndf;
898 }
899}
900///////////////////////////////////////////////////////////////////////////
901Float_t AliTrack::GetChi2()
902{
903// Provide the chi-squared value of the track fit.
904 return fChi2;
905}
906///////////////////////////////////////////////////////////////////////////
907Int_t AliTrack::GetNdf()
908{
909// Provide the number of degrees of freedom for the track fit.
910 return fNdf;
911}
912///////////////////////////////////////////////////////////////////////////