1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////
20 // Handling of the attributes of a reconstructed particle track.
25 // Float_t a[4]={195.,1.2,-0.04,8.5};
27 // pmu.SetVector(a,"car");
29 // t1.Set4Momentum(pmu);
31 // Float_t b[3]={1.2,-0.04,8.5};
33 // p.SetVector(b,"car");
35 // t2.Set3Momentum(p);
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
47 // t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion
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
55 // AliSignal s1,s2,s3,s4;
57 // .... // Code (e.g. detector readout) to fill AliSignal data
59 // AliTrack trec; // Track which will be reconstructed from signals
60 // trec.AddSignal(s1);
61 // trec.AddSignal(s3);
62 // trec.AddSignal(s4);
67 // ... // Code which accesses signals from trec and reconstructs
68 // 3-momentum P, charge Q, mass M etc...
70 // trec.Set3Momentum(P);
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);
86 // Note : All quantities are in GeV, GeV/c or GeV/c**2
88 //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht
89 //- Modified: NvE $Date$ UU-SAP Utrecht
90 ///////////////////////////////////////////////////////////////////////////
94 ClassImp(AliTrack) // Class implementation to enable ROOT I/O
98 // Default constructor
99 // All variables initialised to 0
107 ///////////////////////////////////////////////////////////////////////////
108 AliTrack::~AliTrack()
110 // Destructor to delete memory allocated for decay tracks array
124 ///////////////////////////////////////////////////////////////////////////
125 void AliTrack::Reset()
127 // Reset all variables to 0 and delete all auto-generated decay tracks.
133 Double_t a[4]={0,0,0,0};
147 Double_t b[3]={0,0,0};
148 fBegin.SetPosition(b,"sph");
149 fEnd.SetPosition(b,"sph");
150 fImpactXY.SetPosition(b,"sph");
151 fImpactXZ.SetPosition(b,"sph");
152 fImpactYZ.SetPosition(b,"sph");
153 fClosest.SetPosition(b,"sph");
170 ///////////////////////////////////////////////////////////////////////////
171 void AliTrack::Set3Momentum(Ali3Vector& p)
173 // Set the track parameters according to the 3-momentum p
176 ///////////////////////////////////////////////////////////////////////////
177 void AliTrack::Set4Momentum(Ali4Vector& p)
179 // Set the track parameters according to the 4-momentum p
180 Double_t E=p.GetScalar();
181 Double_t dE=p.GetResultError();
182 Ali3Vector pv=p.Get3Vector();
186 ///////////////////////////////////////////////////////////////////////////
187 void AliTrack::SetMass(Double_t m,Double_t dm)
189 // Set the particle mass
190 // The default value for the error dm is 0.
191 Double_t inv=pow(m,2);
192 Double_t dinv=fabs(2.*m*dm);
193 SetInvariant(inv,dinv);
195 ///////////////////////////////////////////////////////////////////////////
196 void AliTrack::SetCharge(Float_t q)
198 // Set the particle charge
201 ///////////////////////////////////////////////////////////////////////////
202 void AliTrack::Info(TString f)
204 // Provide track information within the coordinate frame f
205 Double_t m=GetMass();
206 Double_t dm=GetResultError();
207 cout << " *AliTrack::Info* Id : " << fUserId << " Mass : " << m
208 << " error : " << dm << " Charge : " << fQ
209 << " Momentum : " << GetMomentum() << " Nmass hyp. : " << fNmasses
210 << " Ntracks : " << fNdec << " Nsignals : " << fNsig << endl;
211 for (Int_t i=0; i<fNmasses; i++)
213 cout << " Mass hypothesis " << (i+1) << " Mass : " << fMasses->At(i)
214 << " error : " << fDmasses->At(i) << " prob. : " << fPmasses->At(i)
219 ///////////////////////////////////////////////////////////////////////////
220 void AliTrack::List(TString f)
222 // Provide current track and decay level 1 information within coordinate frame f
224 Info(f); // Information of the current track
226 // Decay products of this track
228 for (Int_t id=1; id<=fNdec; id++)
230 td=GetDecayTrack(id);
233 cout << " ---Level 1 sec. track no. " << id << endl;
238 cout << " *AliTrack::List* Error : No decay track present." << endl;
242 ///////////////////////////////////////////////////////////////////////////
243 void AliTrack::ListAll(TString f)
245 // Provide complete track and decay information within the coordinate frame f
247 Info(f); // Information of the current track
248 cout << " Begin-point :"; fBegin.Info(f);
249 cout << " End-point :"; fEnd.Info(f);
250 for (Int_t is=1; is<=GetNsignals(); is++)
252 ((AliSignal*)GetSignal(is))->Info(f);
256 Dump(t,1,f); // Information of all decay products
258 //////////////////////////////////////////////////////////////////////////
259 void AliTrack::Dump(AliTrack* t,Int_t n,TString f)
261 // Recursively provide the info of all decay levels of this track
263 for (Int_t id=1; id<=t->GetNdecay(); id++)
265 td=t->GetDecayTrack(id);
268 cout << " ---Level " << n << " sec. track no. " << id << endl;
270 for (Int_t is=1; is<=td->GetNsignals(); is++)
272 ((AliSignal*)td->GetSignal(is))->Info(f);
275 // Go for next decay level of this decay track recursively
280 cout << " *AliTrack::Dump* Error : No decay track present." << endl;
284 //////////////////////////////////////////////////////////////////////////
285 Double_t AliTrack::GetMomentum()
287 // Provide the value of the track 3-momentum.
288 // The error can be obtained by invoking GetResultError() after
289 // invokation of GetMomentum().
290 Double_t norm=fV.GetNorm();
291 fDresult=fV.GetResultError();
294 ///////////////////////////////////////////////////////////////////////////
295 Ali3Vector AliTrack::Get3Momentum()
297 // Provide the track 3-momentum
298 return (Ali3Vector)Get3Vector();
300 ///////////////////////////////////////////////////////////////////////////
301 Double_t AliTrack::GetMass()
303 // Provide the particle mass.
304 // The error can be obtained by invoking GetResultError() after
305 // invokation of GetMass().
306 Double_t inv=GetInvariant();
307 Double_t dinv=GetResultError();
311 Double_t m=sqrt(inv);
312 if (m) dm=dinv/(2.*m);
318 cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl;
319 cout << " Value 0 will be returned." << endl;
324 ///////////////////////////////////////////////////////////////////////////
325 Float_t AliTrack::GetCharge()
327 // Provide the particle charge
330 ///////////////////////////////////////////////////////////////////////////
331 Double_t AliTrack::GetEnergy()
333 // Provide the particle's energy.
334 // The error can be obtained by invoking GetResultError() after
335 // invokation of GetEnergy().
336 Double_t E=GetScalar();
343 cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl;
344 cout << " Value 0 will be returned." << endl;
348 ///////////////////////////////////////////////////////////////////////////
349 void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms)
351 // Perform 2-body decay of current track
352 // m1 : mass of decay product 1
353 // m2 : mass of decay product 2
354 // thcms : cms theta decay angle (in rad.) of m1
355 // phicms : cms phi decay angle (in rad.) of m1
357 fNdec=2; // it's a 2-body decay
359 Double_t M=GetMass();
361 // Compute the 4-momenta of the decay products in the cms
362 // Note : p2=p1=pnorm for a 2-body decay
364 if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M);
366 if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M);
367 Double_t pnorm=(e1*e1)-(m1*m1);
382 p.SetVector(a,"sph");
385 pprim1.SetVector(e1,p);
386 pprim1.SetInvariant(m1*m1);
390 pprim2.SetVector(e2,p);
391 pprim2.SetInvariant(m2*m2);
393 // Determine boost parameters from the parent particle
394 Double_t E=GetEnergy();
402 Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1
403 Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2
405 // Enter the boosted data into the decay tracks array
411 fDecays=new TObjArray();
413 fDecays->Add(new AliTrack);
414 ((AliTrack*)fDecays->At(0))->Set4Momentum(p1);
415 ((AliTrack*)fDecays->At(0))->SetMass(m1);
416 fDecays->Add(new AliTrack);
417 ((AliTrack*)fDecays->At(1))->Set4Momentum(p2);
418 ((AliTrack*)fDecays->At(1))->SetMass(m2);
420 ///////////////////////////////////////////////////////////////////////////
421 Int_t AliTrack::GetNdecay()
423 // Provide the number of decay produced tracks
426 ///////////////////////////////////////////////////////////////////////////
427 AliTrack* AliTrack::GetDecayTrack(Int_t j)
429 // Provide decay produced track number j
430 // Note : j=1 denotes the first decay track
431 if ((j >= 1) && (j <= fNdec))
433 return (AliTrack*)fDecays->At(j-1);
437 cout << " *AliTrack* decay track number : " << j << " out of range." << endl;
438 cout << " -- Decay track number 1 (if any) returned." << endl;
439 return (AliTrack*)fDecays->At(0);
442 ///////////////////////////////////////////////////////////////////////////
443 void AliTrack::AddSignal(AliSignal& s)
445 // Relate an AliSignal object to this track.
446 if (!fSignals) fSignals=new TObjArray();
450 ///////////////////////////////////////////////////////////////////////////
451 void AliTrack::RemoveSignal(AliSignal& s)
453 // Remove related AliSignal object to this track.
456 AliSignal* test=(AliSignal*)fSignals->Remove(&s);
460 fSignals->Compress();
464 ///////////////////////////////////////////////////////////////////////////
465 Int_t AliTrack::GetNsignals()
467 // Provide the number of related AliSignals.
470 ///////////////////////////////////////////////////////////////////////////
471 AliSignal* AliTrack::GetSignal(Int_t j)
473 // Provide the related AliSignal number j.
474 // Note : j=1 denotes the first signal.
475 if ((j >= 1) && (j <= fNsig))
477 return (AliSignal*)fSignals->At(j-1);
481 cout << " *AliTrack* signal number : " << j << " out of range." << endl;
482 cout << " -- Signal number 1 (if any) returned." << endl;
483 return (AliSignal*)fDecays->At(0);
486 ///////////////////////////////////////////////////////////////////////////
487 void AliTrack::SetBeginPoint(AliPosition p)
489 // Store the position of the track begin-point.
492 ///////////////////////////////////////////////////////////////////////////
493 AliPosition AliTrack::GetBeginPoint()
495 // Provide the position of the track begin-point.
498 ///////////////////////////////////////////////////////////////////////////
499 void AliTrack::SetEndPoint(AliPosition p)
501 // Store the position of the track end-point.
504 ///////////////////////////////////////////////////////////////////////////
505 AliPosition AliTrack::GetEndPoint()
507 // Provide the position of the track end-point.
510 ///////////////////////////////////////////////////////////////////////////
511 void AliTrack::AddMassHypothesis(Double_t prob,Double_t m,Double_t dm)
513 // Add a mass hypothesis for this current track.
514 // prob=probalility m=mass value dm=error on the mass value.
515 // The default value for the mass error dm is 0.
516 if (!fMasses) fMasses=new TArrayD();
517 if (!fDmasses) fDmasses=new TArrayD();
518 if (!fPmasses) fPmasses=new TArrayD();
521 fMasses->Set(fNmasses);
522 fDmasses->Set(fNmasses);
523 fPmasses->Set(fNmasses);
525 fMasses->AddAt(m,fNmasses-1);
526 fDmasses->AddAt(dm,fNmasses-1);
527 fPmasses->AddAt(prob,fNmasses-1);
529 ///////////////////////////////////////////////////////////////////////////
530 Int_t AliTrack::GetNMassHypotheses()
532 // Provide the number of mass hypotheses for this track.
535 ///////////////////////////////////////////////////////////////////////////
536 Double_t AliTrack::GetMassHypothesis(Int_t j)
538 // Provide the mass of the jth hypothesis for this track.
539 // Note : the first hypothesis is indicated by j=1.
540 // Default : j=0 ==> Hypothesis with highest probability.
541 // The error on the mass can be obtained by invoking GetResultError()
542 // after invokation of GetMassHypothesis(j).
544 Double_t m=0,dm=0,prob=0;
546 // Check validity of index j
547 if (j<0 || j>fNmasses)
549 cout << " *AliTrack::GetMassHypothesis* Invalid index j : " << j
550 << " Number of mass hypotheses : " << fNmasses << endl;
555 // Select mass hypothesis with highest probability
562 prob=fPmasses->At(0);
563 for (Int_t i=1; i<fNmasses; i++)
565 if (fPmasses->At(i)>prob)
576 // Provide data of requested mass hypothesis
578 fDresult=fDmasses->At(j-1);
581 ///////////////////////////////////////////////////////////////////////////
582 Double_t AliTrack::GetMassHypothesisProb(Int_t j)
584 // Provide the probability of the jth hypothesis for this track.
585 // Note : the first hypothesis is indicated by j=1.
586 // Default : j=0 ==> Hypothesis with highest probability.
590 // Check validity of index j
591 if (j<0 || j>fNmasses)
593 cout << " *AliTrack::GetMassHypothesisProb* Invalid index j : " << j
594 << " Number of mass hypotheses : " << fNmasses << endl;
598 // Select mass hypothesis with highest probability
603 prob=fPmasses->At(0);
604 for (Int_t i=1; i<fNmasses; i++)
606 if (fPmasses->At(i)>prob) prob=fPmasses->At(i);
612 // Provide probability of requested mass hypothesis
613 prob=fPmasses->At(j-1);
616 ///////////////////////////////////////////////////////////////////////////
617 void AliTrack::SetMass()
619 // Set the mass and error to the value of the hypothesis with highest prob.
621 Double_t m=0,dm=0,prob=0;
623 // Select mass hypothesis with highest probability
628 prob=fPmasses->At(0);
629 for (Int_t i=1; i<fNmasses; i++)
631 if (fPmasses->At(i)>prob)
641 cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl;
644 ///////////////////////////////////////////////////////////////////////////
645 void AliTrack::RemoveMassHypothesis(Int_t j)
647 // Remove the jth mass hypothesis for this track.
648 // Note : the first hypothesis is indicated by j=1.
650 if (j<=0 || j>fNmasses) // Check validity of index j
652 cout << " *AliTrack::RemoveMassHypothesis* Invalid index j : " << j
653 << " Number of mass hypotheses : " << fNmasses << endl;
659 fMasses->AddAt(fMasses->At(fNmasses-1),j-1);
660 fDmasses->AddAt(fDmasses->At(fNmasses-1),j-1);
661 fPmasses->AddAt(fPmasses->At(fNmasses-1),j-1);
663 fMasses->AddAt(0,fNmasses-1);
664 fDmasses->AddAt(0,fNmasses-1);
665 fPmasses->AddAt(0,fNmasses-1);
667 fMasses->Set(fNmasses);
668 fDmasses->Set(fNmasses);
669 fPmasses->Set(fNmasses);
672 ///////////////////////////////////////////////////////////////////////////
673 Double_t AliTrack::GetPt()
675 // Provide trans. momentum value w.r.t. z-axis.
676 // The error on the value can be obtained by GetResultError()
677 // after invokation of GetPt().
680 Double_t norm=v.GetNorm();
681 fDresult=v.GetResultError();
685 ///////////////////////////////////////////////////////////////////////////
686 Double_t AliTrack::GetPl()
688 // Provide long. momentum value w.r.t. z-axis.
689 // Note : the returned value can also be negative.
690 // The error on the value can be obtained by GetResultError()
691 // after invokation of GetPl().
695 Double_t pl=v.GetNorm();
696 fDresult=v.GetResultError();
699 v.GetVector(a,"sph");
700 if (cos(a[1])<0) pl=-pl;
704 ///////////////////////////////////////////////////////////////////////////
705 Double_t AliTrack::GetEt()
707 // Provide trans. energy value w.r.t. z-axis.
708 // The error on the value can be obtained by GetResultError()
709 // after invokation of GetEt().
710 Double_t et=GetScaTrans();
714 ///////////////////////////////////////////////////////////////////////////
715 Double_t AliTrack::GetEl()
717 // Provide long. energy value w.r.t. z-axis.
718 // Note : the returned value can also be negative.
719 // The error on the value can be obtained by GetResultError()
720 // after invokation of GetEl().
721 Double_t el=GetScaLong();
725 ///////////////////////////////////////////////////////////////////////////
726 Double_t AliTrack::GetMt()
728 // Provide transverse mass value w.r.t. z-axis.
729 // The error on the value can be obtained by GetResultError()
730 // after invokation of GetMt().
732 Double_t dpt=GetResultError();
733 Double_t m=GetMass();
734 Double_t dm=GetResultError();
736 Double_t mt=sqrt(pt*pt+m*m);
738 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
743 ///////////////////////////////////////////////////////////////////////////
744 Double_t AliTrack::GetMt(Int_t j)
746 // Provide transverse mass value w.r.t. z-axis and jth mass hypothesis.
747 // Note : the first hypothesis is indicated by j=1.
748 // j=0 ==> Hypothesis with highest probability.
749 // The error on the value can be obtained by GetResultError()
750 // after invokation of GetMt(j).
752 Double_t dpt=GetResultError();
753 Double_t m=GetMassHypothesis(j);
754 Double_t dm=GetResultError();
756 Double_t mt=sqrt(pt*pt+m*m);
758 if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt);
763 ///////////////////////////////////////////////////////////////////////////
764 Double_t AliTrack::GetRapidity()
766 // Provide rapidity value w.r.t. z-axis.
767 // The error on the value can be obtained by GetResultError()
768 // after invokation of GetRapidity().
769 // Note : Also GetPseudoRapidity() is available since this class is
770 // derived from Ali4Vector.
771 Double_t e=GetEnergy();
772 Double_t de=GetResultError();
774 Double_t dpl=GetResultError();
778 Double_t y=9999,dy2=0;
779 if (sum && dif) y=0.5*log(sum/dif);
781 if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2));
786 ///////////////////////////////////////////////////////////////////////////
787 void AliTrack::SetImpactPoint(AliPosition p,TString q)
789 // Store the position of the impact-point in the plane "q=0".
790 // Here q denotes one of the axes X, Y or Z.
791 // Note : The character to denote the axis may be entered in lower or
794 if (q=="x" || q=="X") axis=1;
795 if (q=="y" || q=="Y") axis=2;
796 if (q=="z" || q=="Z") axis=3;
800 case 1: // Impact-point in the plane X=0
804 case 2: // Impact-point in the plane Y=0
808 case 3: // Impact-point in the plane Z=0
812 default: // Unsupported axis
813 cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl
814 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
818 ///////////////////////////////////////////////////////////////////////////
819 AliPosition AliTrack::GetImpactPoint(TString q)
821 // Provide the position of the impact-point in the plane "q=0".
822 // Here q denotes one of the axes X, Y or Z.
823 // Note : The character to denote the axis may be entered in lower or
827 if (q=="x" || q=="X") axis=1;
828 if (q=="y" || q=="Y") axis=2;
829 if (q=="z" || q=="Z") axis=3;
833 case 1: // Impact-point in the plane X=0
836 case 2: // Impact-point in the plane Y=0
839 case 3: // Impact-point in the plane Z=0
842 default: // Unsupported axis
843 cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl
844 << " Possible axes are 'X', 'Y' and 'Z'." << endl;
848 ///////////////////////////////////////////////////////////////////////////
849 void AliTrack::SetId(Int_t id)
851 // Set a user defined identifier for this track.
854 ///////////////////////////////////////////////////////////////////////////
855 Int_t AliTrack::GetId()
857 // Provide the user defined identifier of this track.
860 ///////////////////////////////////////////////////////////////////////////
861 void AliTrack::SetClosestPoint(AliPosition p)
863 // Set position p as the point of closest approach w.r.t. some reference
866 ///////////////////////////////////////////////////////////////////////////
867 AliPosition AliTrack::GetClosestPoint()
869 // Provide the point of closest approach w.r.t. some reference
872 ///////////////////////////////////////////////////////////////////////////