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