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